467 // Introduced with Power 8:
468 // Data Stream Control Register
469 inline void Assembler::mtdscr(Register s1) { emit_int32(MTDSCR_OPCODE | rs(s1)); }
470 inline void Assembler::mfdscr(Register d ) { emit_int32(MFDSCR_OPCODE | rt(d)); }
471
472 // PPC 1, section 2.4.1 Branch Instructions
473 inline void Assembler::b( address a, relocInfo::relocType rt) { emit_data(BXX_OPCODE| li(disp( intptr_t(a), intptr_t(pc()))) |aa(0)|lk(0), rt); }
474 inline void Assembler::b( Label& L) { b( target(L)); }
475 inline void Assembler::bl(address a, relocInfo::relocType rt) { emit_data(BXX_OPCODE| li(disp( intptr_t(a), intptr_t(pc()))) |aa(0)|lk(1), rt); }
476 inline void Assembler::bl(Label& L) { bl(target(L)); }
477 inline void Assembler::bc( int boint, int biint, address a, relocInfo::relocType rt) { emit_data(BCXX_OPCODE| bo(boint) | bi(biint) | bd(disp( intptr_t(a), intptr_t(pc()))) | aa(0) | lk(0), rt); }
478 inline void Assembler::bc( int boint, int biint, Label& L) { bc(boint, biint, target(L)); }
479 inline void Assembler::bcl(int boint, int biint, address a, relocInfo::relocType rt) { emit_data(BCXX_OPCODE| bo(boint) | bi(biint) | bd(disp( intptr_t(a), intptr_t(pc()))) | aa(0)|lk(1)); }
480 inline void Assembler::bcl(int boint, int biint, Label& L) { bcl(boint, biint, target(L)); }
481
482 inline void Assembler::bclr( int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCLR_OPCODE | bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(0), rt); }
483 inline void Assembler::bclrl( int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCLR_OPCODE | bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(1), rt); }
484 inline void Assembler::bcctr( int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCCTR_OPCODE| bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(0), rt); }
485 inline void Assembler::bcctrl(int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCCTR_OPCODE| bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(1), rt); }
486
487 // helper function for b
488 inline bool Assembler::is_within_range_of_b(address a, address pc) {
489 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
490 if ((((uint64_t)a) & 0x3) != 0) return false;
491
492 const int range = 1 << (29-6); // li field is from bit 6 to bit 29.
493 int value = disp(intptr_t(a), intptr_t(pc));
494 bool result = -range <= value && value < range-1;
495 #ifdef ASSERT
496 if (result) li(value); // Assert that value is in correct range.
497 #endif
498 return result;
499 }
500
501 // helper functions for bcxx.
502 inline bool Assembler::is_within_range_of_bcxx(address a, address pc) {
503 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
504 if ((((uint64_t)a) & 0x3) != 0) return false;
505
506 const int range = 1 << (29-16); // bd field is from bit 16 to bit 29.
|
467 // Introduced with Power 8:
468 // Data Stream Control Register
469 inline void Assembler::mtdscr(Register s1) { emit_int32(MTDSCR_OPCODE | rs(s1)); }
470 inline void Assembler::mfdscr(Register d ) { emit_int32(MFDSCR_OPCODE | rt(d)); }
471
472 // PPC 1, section 2.4.1 Branch Instructions
473 inline void Assembler::b( address a, relocInfo::relocType rt) { emit_data(BXX_OPCODE| li(disp( intptr_t(a), intptr_t(pc()))) |aa(0)|lk(0), rt); }
474 inline void Assembler::b( Label& L) { b( target(L)); }
475 inline void Assembler::bl(address a, relocInfo::relocType rt) { emit_data(BXX_OPCODE| li(disp( intptr_t(a), intptr_t(pc()))) |aa(0)|lk(1), rt); }
476 inline void Assembler::bl(Label& L) { bl(target(L)); }
477 inline void Assembler::bc( int boint, int biint, address a, relocInfo::relocType rt) { emit_data(BCXX_OPCODE| bo(boint) | bi(biint) | bd(disp( intptr_t(a), intptr_t(pc()))) | aa(0) | lk(0), rt); }
478 inline void Assembler::bc( int boint, int biint, Label& L) { bc(boint, biint, target(L)); }
479 inline void Assembler::bcl(int boint, int biint, address a, relocInfo::relocType rt) { emit_data(BCXX_OPCODE| bo(boint) | bi(biint) | bd(disp( intptr_t(a), intptr_t(pc()))) | aa(0)|lk(1)); }
480 inline void Assembler::bcl(int boint, int biint, Label& L) { bcl(boint, biint, target(L)); }
481
482 inline void Assembler::bclr( int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCLR_OPCODE | bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(0), rt); }
483 inline void Assembler::bclrl( int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCLR_OPCODE | bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(1), rt); }
484 inline void Assembler::bcctr( int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCCTR_OPCODE| bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(0), rt); }
485 inline void Assembler::bcctrl(int boint, int biint, int bhint, relocInfo::relocType rt) { emit_data(BCCTR_OPCODE| bo(boint) | bi(biint) | bh(bhint) | aa(0) | lk(1), rt); }
486
487 inline bool Assembler::is_branch(address a) {
488 int32_t instr = *(int32_t*) a;
489 int op = inv_op_ppc(instr);
490 return op == b_op || op == bc_op;
491 }
492
493 // helper function for b
494 inline bool Assembler::is_within_range_of_b(address a, address pc) {
495 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
496 if ((((uint64_t)a) & 0x3) != 0) return false;
497
498 const int range = 1 << (29-6); // li field is from bit 6 to bit 29.
499 int value = disp(intptr_t(a), intptr_t(pc));
500 bool result = -range <= value && value < range-1;
501 #ifdef ASSERT
502 if (result) li(value); // Assert that value is in correct range.
503 #endif
504 return result;
505 }
506
507 // helper functions for bcxx.
508 inline bool Assembler::is_within_range_of_bcxx(address a, address pc) {
509 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
510 if ((((uint64_t)a) & 0x3) != 0) return false;
511
512 const int range = 1 << (29-16); // bd field is from bit 16 to bit 29.
|