437 // Introduced with Power 8:
438 // Data Stream Control Register
439 inline void Assembler::mtdscr(Register s1) { emit_int32(MTDSCR_OPCODE | rs(s1)); }
440 inline void Assembler::mfdscr(Register d ) { emit_int32(MFDSCR_OPCODE | rt(d)); }
441
442 // PPC 1, section 2.4.1 Branch Instructions
443 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); }
444 inline void Assembler::b( Label& L) { b( target(L)); }
445 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); }
446 inline void Assembler::bl(Label& L) { bl(target(L)); }
447 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); }
448 inline void Assembler::bc( int boint, int biint, Label& L) { bc(boint, biint, target(L)); }
449 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)); }
450 inline void Assembler::bcl(int boint, int biint, Label& L) { bcl(boint, biint, target(L)); }
451
452 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); }
453 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); }
454 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); }
455 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); }
456
457 // helper function for b
458 inline bool Assembler::is_within_range_of_b(address a, address pc) {
459 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
460 if ((((uint64_t)a) & 0x3) != 0) return false;
461
462 const int range = 1 << (29-6); // li field is from bit 6 to bit 29.
463 int value = disp(intptr_t(a), intptr_t(pc));
464 bool result = -range <= value && value < range-1;
465 #ifdef ASSERT
466 if (result) li(value); // Assert that value is in correct range.
467 #endif
468 return result;
469 }
470
471 // helper functions for bcxx.
472 inline bool Assembler::is_within_range_of_bcxx(address a, address pc) {
473 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
474 if ((((uint64_t)a) & 0x3) != 0) return false;
475
476 const int range = 1 << (29-16); // bd field is from bit 16 to bit 29.
|
437 // Introduced with Power 8:
438 // Data Stream Control Register
439 inline void Assembler::mtdscr(Register s1) { emit_int32(MTDSCR_OPCODE | rs(s1)); }
440 inline void Assembler::mfdscr(Register d ) { emit_int32(MFDSCR_OPCODE | rt(d)); }
441
442 // PPC 1, section 2.4.1 Branch Instructions
443 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); }
444 inline void Assembler::b( Label& L) { b( target(L)); }
445 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); }
446 inline void Assembler::bl(Label& L) { bl(target(L)); }
447 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); }
448 inline void Assembler::bc( int boint, int biint, Label& L) { bc(boint, biint, target(L)); }
449 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)); }
450 inline void Assembler::bcl(int boint, int biint, Label& L) { bcl(boint, biint, target(L)); }
451
452 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); }
453 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); }
454 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); }
455 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); }
456
457 inline bool Assembler::is_branch(address a) {
458 int32_t instr = *(int32_t*) a;
459 int op = inv_op_ppc(instr);
460 return op == b_op || op == bc_op;
461 }
462
463 // helper function for b
464 inline bool Assembler::is_within_range_of_b(address a, address pc) {
465 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
466 if ((((uint64_t)a) & 0x3) != 0) return false;
467
468 const int range = 1 << (29-6); // li field is from bit 6 to bit 29.
469 int value = disp(intptr_t(a), intptr_t(pc));
470 bool result = -range <= value && value < range-1;
471 #ifdef ASSERT
472 if (result) li(value); // Assert that value is in correct range.
473 #endif
474 return result;
475 }
476
477 // helper functions for bcxx.
478 inline bool Assembler::is_within_range_of_bcxx(address a, address pc) {
479 // Guard against illegal branch targets, e.g. -1 (see CompiledDirectCall and ad-file).
480 if ((((uint64_t)a) & 0x3) != 0) return false;
481
482 const int range = 1 << (29-16); // bd field is from bit 16 to bit 29.
|