2426 } |
2426 } |
2427 %} |
2427 %} |
2428 |
2428 |
2429 enc_class Lbl(label labl) |
2429 enc_class Lbl(label labl) |
2430 %{ |
2430 %{ |
2431 // JMP, CALL |
2431 // GOTO |
2432 Label* l = $labl$$label; |
2432 Label* l = $labl$$label; |
2433 emit_d32(cbuf, l ? (l->loc_pos() - (cbuf.insts_size() + 4)) : 0); |
2433 emit_d32(cbuf, (l->loc_pos() - (cbuf.insts_size() + 4))); |
2434 %} |
2434 %} |
2435 |
2435 |
2436 enc_class LblShort(label labl) |
2436 enc_class LblShort(label labl) |
2437 %{ |
2437 %{ |
2438 // JMP, CALL |
2438 // GOTO |
2439 Label* l = $labl$$label; |
2439 Label* l = $labl$$label; |
2440 int disp = l ? (l->loc_pos() - (cbuf.insts_size() + 1)) : 0; |
2440 int disp = l->loc_pos() - (cbuf.insts_size() + 1); |
2441 assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp"); |
2441 assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp"); |
2442 emit_d8(cbuf, disp); |
2442 emit_d8(cbuf, disp); |
2443 %} |
2443 %} |
2444 |
2444 |
2445 enc_class opc2_reg(rRegI dst) |
2445 enc_class opc2_reg(rRegI dst) |
2464 %{ |
2464 %{ |
2465 // JCC |
2465 // JCC |
2466 Label* l = $labl$$label; |
2466 Label* l = $labl$$label; |
2467 $$$emit8$primary; |
2467 $$$emit8$primary; |
2468 emit_cc(cbuf, $secondary, $cop$$cmpcode); |
2468 emit_cc(cbuf, $secondary, $cop$$cmpcode); |
2469 emit_d32(cbuf, l ? (l->loc_pos() - (cbuf.insts_size() + 4)) : 0); |
2469 emit_d32(cbuf, (l->loc_pos() - (cbuf.insts_size() + 4))); |
2470 %} |
2470 %} |
2471 |
2471 |
2472 enc_class JccShort (cmpOp cop, label labl) |
2472 enc_class JccShort (cmpOp cop, label labl) |
2473 %{ |
2473 %{ |
2474 // JCC |
2474 // JCC |
2475 Label *l = $labl$$label; |
2475 Label *l = $labl$$label; |
2476 emit_cc(cbuf, $primary, $cop$$cmpcode); |
2476 emit_cc(cbuf, $primary, $cop$$cmpcode); |
2477 int disp = l ? (l->loc_pos() - (cbuf.insts_size() + 1)) : 0; |
2477 int disp = l->loc_pos() - (cbuf.insts_size() + 1); |
2478 assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp"); |
2478 assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp"); |
2479 emit_d8(cbuf, disp); |
2479 emit_d8(cbuf, disp); |
2480 %} |
2480 %} |
2481 |
2481 |
2482 enc_class enc_cmov(cmpOp cop) |
2482 enc_class enc_cmov(cmpOp cop) |
12129 $$$emit8$primary; |
12129 $$$emit8$primary; |
12130 emit_cc(cbuf, $secondary, Assembler::parity); |
12130 emit_cc(cbuf, $secondary, Assembler::parity); |
12131 int parity_disp = -1; |
12131 int parity_disp = -1; |
12132 if ($cop$$cmpcode == Assembler::notEqual) { |
12132 if ($cop$$cmpcode == Assembler::notEqual) { |
12133 // the two jumps 6 bytes apart so the jump distances are too |
12133 // the two jumps 6 bytes apart so the jump distances are too |
12134 parity_disp = l ? (l->loc_pos() - (cbuf.insts_size() + 4)) : 0; |
12134 parity_disp = l->loc_pos() - (cbuf.insts_size() + 4); |
12135 } else if ($cop$$cmpcode == Assembler::equal) { |
12135 } else if ($cop$$cmpcode == Assembler::equal) { |
12136 parity_disp = 6; |
12136 parity_disp = 6; |
12137 } else { |
12137 } else { |
12138 ShouldNotReachHere(); |
12138 ShouldNotReachHere(); |
12139 } |
12139 } |
12140 emit_d32(cbuf, parity_disp); |
12140 emit_d32(cbuf, parity_disp); |
12141 $$$emit8$primary; |
12141 $$$emit8$primary; |
12142 emit_cc(cbuf, $secondary, $cop$$cmpcode); |
12142 emit_cc(cbuf, $secondary, $cop$$cmpcode); |
12143 int disp = l ? (l->loc_pos() - (cbuf.insts_size() + 4)) : 0; |
12143 int disp = l->loc_pos() - (cbuf.insts_size() + 4); |
12144 emit_d32(cbuf, disp); |
12144 emit_d32(cbuf, disp); |
12145 %} |
12145 %} |
12146 ins_pipe(pipe_jcc); |
12146 ins_pipe(pipe_jcc); |
12147 ins_pc_relative(1); |
12147 ins_pc_relative(1); |
12148 %} |
12148 %} |
12333 ins_encode %{ |
12333 ins_encode %{ |
12334 Label* l = $labl$$label; |
12334 Label* l = $labl$$label; |
12335 emit_cc(cbuf, $primary, Assembler::parity); |
12335 emit_cc(cbuf, $primary, Assembler::parity); |
12336 int parity_disp = -1; |
12336 int parity_disp = -1; |
12337 if ($cop$$cmpcode == Assembler::notEqual) { |
12337 if ($cop$$cmpcode == Assembler::notEqual) { |
12338 parity_disp = l ? (l->loc_pos() - (cbuf.insts_size() + 1)) : 0; |
12338 parity_disp = l->loc_pos() - (cbuf.insts_size() + 1); |
12339 } else if ($cop$$cmpcode == Assembler::equal) { |
12339 } else if ($cop$$cmpcode == Assembler::equal) { |
12340 parity_disp = 2; |
12340 parity_disp = 2; |
12341 } else { |
12341 } else { |
12342 ShouldNotReachHere(); |
12342 ShouldNotReachHere(); |
12343 } |
12343 } |
12344 emit_d8(cbuf, parity_disp); |
12344 emit_d8(cbuf, parity_disp); |
12345 emit_cc(cbuf, $primary, $cop$$cmpcode); |
12345 emit_cc(cbuf, $primary, $cop$$cmpcode); |
12346 int disp = l ? (l->loc_pos() - (cbuf.insts_size() + 1)) : 0; |
12346 int disp = l->loc_pos() - (cbuf.insts_size() + 1); |
12347 emit_d8(cbuf, disp); |
12347 emit_d8(cbuf, disp); |
12348 assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp"); |
12348 assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp"); |
12349 assert(-128 <= parity_disp && parity_disp <= 127, "Displacement too large for short jmp"); |
12349 assert(-128 <= parity_disp && parity_disp <= 127, "Displacement too large for short jmp"); |
12350 %} |
12350 %} |
12351 ins_pipe(pipe_jcc); |
12351 ins_pipe(pipe_jcc); |