src/cpu/x86/vm/x86_32.ad

changeset 3049
95134e034042
parent 3047
f1c12354c3f7
child 3052
1af104d6cf99
     1.1 --- a/src/cpu/x86/vm/x86_32.ad	Wed Aug 10 14:06:57 2011 -0700
     1.2 +++ b/src/cpu/x86/vm/x86_32.ad	Thu Aug 11 12:08:11 2011 -0700
     1.3 @@ -1369,7 +1369,12 @@
     1.4  //
     1.5  // NOTE: If the platform does not provide any short branch variants, then
     1.6  //       this method should return false for offset 0.
     1.7 -bool Matcher::is_short_branch_offset(int rule, int offset) {
     1.8 +bool Matcher::is_short_branch_offset(int rule, int br_size, int offset) {
     1.9 +  // The passed offset is relative to address of the branch.
    1.10 +  // On 86 a branch displacement is calculated relative to address
    1.11 +  // of a next instruction.
    1.12 +  offset -= br_size;
    1.13 +
    1.14    // the short version of jmpConUCF2 contains multiple branches,
    1.15    // making the reach slightly less
    1.16    if (rule == jmpConUCF2_rule)
    1.17 @@ -1713,18 +1718,6 @@
    1.18      else                               emit_d32(cbuf,con);
    1.19    %}
    1.20  
    1.21 -  enc_class Lbl (label labl) %{ // GOTO
    1.22 -    Label *l = $labl$$label;
    1.23 -    emit_d32(cbuf, (l->loc_pos() - (cbuf.insts_size()+4)));
    1.24 -  %}
    1.25 -
    1.26 -  enc_class LblShort (label labl) %{ // GOTO
    1.27 -    Label *l = $labl$$label;
    1.28 -    int disp = l->loc_pos() - (cbuf.insts_size()+1);
    1.29 -    assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
    1.30 -    emit_d8(cbuf, disp);
    1.31 -  %}
    1.32 -
    1.33    enc_class OpcSReg (eRegI dst) %{    // BSWAP
    1.34      emit_cc(cbuf, $secondary, $dst$$reg );
    1.35    %}
    1.36 @@ -1747,21 +1740,6 @@
    1.37      emit_rm(cbuf, 0x3, $secondary, $div$$reg );
    1.38    %}
    1.39  
    1.40 -  enc_class Jcc (cmpOp cop, label labl) %{    // JCC
    1.41 -    Label *l = $labl$$label;
    1.42 -    $$$emit8$primary;
    1.43 -    emit_cc(cbuf, $secondary, $cop$$cmpcode);
    1.44 -    emit_d32(cbuf, (l->loc_pos() - (cbuf.insts_size()+4)));
    1.45 -  %}
    1.46 -
    1.47 -  enc_class JccShort (cmpOp cop, label labl) %{    // JCC
    1.48 -    Label *l = $labl$$label;
    1.49 -    emit_cc(cbuf, $primary, $cop$$cmpcode);
    1.50 -    int disp = l->loc_pos() - (cbuf.insts_size()+1);
    1.51 -    assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
    1.52 -    emit_d8(cbuf, disp);
    1.53 -  %}
    1.54 -
    1.55    enc_class enc_cmov(cmpOp cop ) %{ // CMOV
    1.56      $$$emit8$primary;
    1.57      emit_cc(cbuf, $secondary, $cop$$cmpcode);
    1.58 @@ -13055,8 +13033,10 @@
    1.59    ins_cost(300);
    1.60    format %{ "JMP    $labl" %}
    1.61    size(5);
    1.62 -  opcode(0xE9);
    1.63 -  ins_encode( OpcP, Lbl( labl ) );
    1.64 +  ins_encode %{
    1.65 +    Label* L = $labl$$label;
    1.66 +    __ jmp(*L, false); // Always long jump
    1.67 +  %}
    1.68    ins_pipe( pipe_jmp );
    1.69  %}
    1.70  
    1.71 @@ -13068,8 +13048,10 @@
    1.72    ins_cost(300);
    1.73    format %{ "J$cop    $labl" %}
    1.74    size(6);
    1.75 -  opcode(0x0F, 0x80);
    1.76 -  ins_encode( Jcc( cop, labl) );
    1.77 +  ins_encode %{
    1.78 +    Label* L = $labl$$label;
    1.79 +    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
    1.80 +  %}
    1.81    ins_pipe( pipe_jcc );
    1.82  %}
    1.83  
    1.84 @@ -13081,8 +13063,10 @@
    1.85    ins_cost(300);
    1.86    format %{ "J$cop    $labl\t# Loop end" %}
    1.87    size(6);
    1.88 -  opcode(0x0F, 0x80);
    1.89 -  ins_encode( Jcc( cop, labl) );
    1.90 +  ins_encode %{
    1.91 +    Label* L = $labl$$label;
    1.92 +    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
    1.93 +  %}
    1.94    ins_pipe( pipe_jcc );
    1.95  %}
    1.96  
    1.97 @@ -13094,8 +13078,10 @@
    1.98    ins_cost(300);
    1.99    format %{ "J$cop,u  $labl\t# Loop end" %}
   1.100    size(6);
   1.101 -  opcode(0x0F, 0x80);
   1.102 -  ins_encode( Jcc( cop, labl) );
   1.103 +  ins_encode %{
   1.104 +    Label* L = $labl$$label;
   1.105 +    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
   1.106 +  %}
   1.107    ins_pipe( pipe_jcc );
   1.108  %}
   1.109  
   1.110 @@ -13106,8 +13092,10 @@
   1.111    ins_cost(200);
   1.112    format %{ "J$cop,u  $labl\t# Loop end" %}
   1.113    size(6);
   1.114 -  opcode(0x0F, 0x80);
   1.115 -  ins_encode( Jcc( cop, labl) );
   1.116 +  ins_encode %{
   1.117 +    Label* L = $labl$$label;
   1.118 +    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
   1.119 +  %}
   1.120    ins_pipe( pipe_jcc );
   1.121  %}
   1.122  
   1.123 @@ -13119,8 +13107,10 @@
   1.124    ins_cost(300);
   1.125    format %{ "J$cop,u  $labl" %}
   1.126    size(6);
   1.127 -  opcode(0x0F, 0x80);
   1.128 -  ins_encode(Jcc(cop, labl));
   1.129 +  ins_encode %{
   1.130 +    Label* L = $labl$$label;
   1.131 +    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
   1.132 +  %}
   1.133    ins_pipe(pipe_jcc);
   1.134  %}
   1.135  
   1.136 @@ -13131,8 +13121,10 @@
   1.137    ins_cost(200);
   1.138    format %{ "J$cop,u  $labl" %}
   1.139    size(6);
   1.140 -  opcode(0x0F, 0x80);
   1.141 -  ins_encode(Jcc(cop, labl));
   1.142 +  ins_encode %{
   1.143 +    Label* L = $labl$$label;
   1.144 +    __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump
   1.145 +  %}
   1.146    ins_pipe(pipe_jcc);
   1.147  %}
   1.148  
   1.149 @@ -13151,28 +13143,19 @@
   1.150        $$emit$$"done:"
   1.151      }
   1.152    %}
   1.153 -  size(12);
   1.154 -  opcode(0x0F, 0x80);
   1.155    ins_encode %{
   1.156      Label* l = $labl$$label;
   1.157 -    $$$emit8$primary;
   1.158 -    emit_cc(cbuf, $secondary, Assembler::parity);
   1.159 -    int parity_disp = -1;
   1.160 -    bool ok = false;
   1.161      if ($cop$$cmpcode == Assembler::notEqual) {
   1.162 -       // the two jumps 6 bytes apart so the jump distances are too
   1.163 -       parity_disp = l->loc_pos() - (cbuf.insts_size() + 4);
   1.164 +      __ jcc(Assembler::parity, *l, false);
   1.165 +      __ jcc(Assembler::notEqual, *l, false);
   1.166      } else if ($cop$$cmpcode == Assembler::equal) {
   1.167 -       parity_disp = 6;
   1.168 -       ok = true;
   1.169 +      Label done;
   1.170 +      __ jccb(Assembler::parity, done);
   1.171 +      __ jcc(Assembler::equal, *l, false);
   1.172 +      __ bind(done);
   1.173      } else {
   1.174         ShouldNotReachHere();
   1.175      }
   1.176 -    emit_d32(cbuf, parity_disp);
   1.177 -    $$$emit8$primary;
   1.178 -    emit_cc(cbuf, $secondary, $cop$$cmpcode);
   1.179 -    int disp = l->loc_pos() - (cbuf.insts_size() + 4);
   1.180 -    emit_d32(cbuf, disp);
   1.181    %}
   1.182    ins_pipe(pipe_jcc);
   1.183  %}
   1.184 @@ -13239,8 +13222,10 @@
   1.185    ins_cost(300);
   1.186    format %{ "JMP,s  $labl" %}
   1.187    size(2);
   1.188 -  opcode(0xEB);
   1.189 -  ins_encode( OpcP, LblShort( labl ) );
   1.190 +  ins_encode %{
   1.191 +    Label* L = $labl$$label;
   1.192 +    __ jmpb(*L);
   1.193 +  %}
   1.194    ins_pipe( pipe_jmp );
   1.195    ins_short_branch(1);
   1.196  %}
   1.197 @@ -13253,8 +13238,10 @@
   1.198    ins_cost(300);
   1.199    format %{ "J$cop,s  $labl" %}
   1.200    size(2);
   1.201 -  opcode(0x70);
   1.202 -  ins_encode( JccShort( cop, labl) );
   1.203 +  ins_encode %{
   1.204 +    Label* L = $labl$$label;
   1.205 +    __ jccb((Assembler::Condition)($cop$$cmpcode), *L);
   1.206 +  %}
   1.207    ins_pipe( pipe_jcc );
   1.208    ins_short_branch(1);
   1.209  %}
   1.210 @@ -13267,8 +13254,10 @@
   1.211    ins_cost(300);
   1.212    format %{ "J$cop,s  $labl\t# Loop end" %}
   1.213    size(2);
   1.214 -  opcode(0x70);
   1.215 -  ins_encode( JccShort( cop, labl) );
   1.216 +  ins_encode %{
   1.217 +    Label* L = $labl$$label;
   1.218 +    __ jccb((Assembler::Condition)($cop$$cmpcode), *L);
   1.219 +  %}
   1.220    ins_pipe( pipe_jcc );
   1.221    ins_short_branch(1);
   1.222  %}
   1.223 @@ -13281,8 +13270,10 @@
   1.224    ins_cost(300);
   1.225    format %{ "J$cop,us $labl\t# Loop end" %}
   1.226    size(2);
   1.227 -  opcode(0x70);
   1.228 -  ins_encode( JccShort( cop, labl) );
   1.229 +  ins_encode %{
   1.230 +    Label* L = $labl$$label;
   1.231 +    __ jccb((Assembler::Condition)($cop$$cmpcode), *L);
   1.232 +  %}
   1.233    ins_pipe( pipe_jcc );
   1.234    ins_short_branch(1);
   1.235  %}
   1.236 @@ -13294,8 +13285,10 @@
   1.237    ins_cost(300);
   1.238    format %{ "J$cop,us $labl\t# Loop end" %}
   1.239    size(2);
   1.240 -  opcode(0x70);
   1.241 -  ins_encode( JccShort( cop, labl) );
   1.242 +  ins_encode %{
   1.243 +    Label* L = $labl$$label;
   1.244 +    __ jccb((Assembler::Condition)($cop$$cmpcode), *L);
   1.245 +  %}
   1.246    ins_pipe( pipe_jcc );
   1.247    ins_short_branch(1);
   1.248  %}
   1.249 @@ -13308,8 +13301,10 @@
   1.250    ins_cost(300);
   1.251    format %{ "J$cop,us $labl" %}
   1.252    size(2);
   1.253 -  opcode(0x70);
   1.254 -  ins_encode( JccShort( cop, labl) );
   1.255 +  ins_encode %{
   1.256 +    Label* L = $labl$$label;
   1.257 +    __ jccb((Assembler::Condition)($cop$$cmpcode), *L);
   1.258 +  %}
   1.259    ins_pipe( pipe_jcc );
   1.260    ins_short_branch(1);
   1.261  %}
   1.262 @@ -13321,8 +13316,10 @@
   1.263    ins_cost(300);
   1.264    format %{ "J$cop,us $labl" %}
   1.265    size(2);
   1.266 -  opcode(0x70);
   1.267 -  ins_encode( JccShort( cop, labl) );
   1.268 +  ins_encode %{
   1.269 +    Label* L = $labl$$label;
   1.270 +    __ jccb((Assembler::Condition)($cop$$cmpcode), *L);
   1.271 +  %}
   1.272    ins_pipe( pipe_jcc );
   1.273    ins_short_branch(1);
   1.274  %}
   1.275 @@ -13343,24 +13340,19 @@
   1.276      }
   1.277    %}
   1.278    size(4);
   1.279 -  opcode(0x70);
   1.280    ins_encode %{
   1.281      Label* l = $labl$$label;
   1.282 -    emit_cc(cbuf, $primary, Assembler::parity);
   1.283 -    int parity_disp = -1;
   1.284      if ($cop$$cmpcode == Assembler::notEqual) {
   1.285 -      parity_disp = l->loc_pos() - (cbuf.insts_size() + 1);
   1.286 +      __ jccb(Assembler::parity, *l);
   1.287 +      __ jccb(Assembler::notEqual, *l);
   1.288      } else if ($cop$$cmpcode == Assembler::equal) {
   1.289 -      parity_disp = 2;
   1.290 +      Label done;
   1.291 +      __ jccb(Assembler::parity, done);
   1.292 +      __ jccb(Assembler::equal, *l);
   1.293 +      __ bind(done);
   1.294      } else {
   1.295 -      ShouldNotReachHere();
   1.296 -    }
   1.297 -    emit_d8(cbuf, parity_disp);
   1.298 -    emit_cc(cbuf, $primary, $cop$$cmpcode);
   1.299 -    int disp = l->loc_pos() - (cbuf.insts_size() + 1);
   1.300 -    emit_d8(cbuf, disp);
   1.301 -    assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
   1.302 -    assert(-128 <= parity_disp && parity_disp <= 127, "Displacement too large for short jmp");
   1.303 +       ShouldNotReachHere();
   1.304 +    }
   1.305    %}
   1.306    ins_pipe(pipe_jcc);
   1.307    ins_short_branch(1);

mercurial