src/cpu/x86/vm/x86_64.ad

changeset 1210
93c14e5562c4
parent 1116
fbde8ec322d0
child 1220
2056494941db
     1.1 --- a/src/cpu/x86/vm/x86_64.ad	Tue May 05 11:02:10 2009 -0700
     1.2 +++ b/src/cpu/x86/vm/x86_64.ad	Wed May 06 00:27:52 2009 -0700
     1.3 @@ -1980,6 +1980,13 @@
     1.4  }
     1.5  
     1.6  
     1.7 +const bool Matcher::match_rule_supported(int opcode) {
     1.8 +  if (!has_match_rule(opcode))
     1.9 +    return false;
    1.10 +
    1.11 +  return true;  // Per default match rules are supported.
    1.12 +}
    1.13 +
    1.14  int Matcher::regnum_to_fpu_offset(int regnum)
    1.15  {
    1.16    return regnum - 32; // The FP registers are in the second chunk
    1.17 @@ -7656,6 +7663,121 @@
    1.18  %}
    1.19  
    1.20  
    1.21 +//---------- Zeros Count Instructions ------------------------------------------
    1.22 +
    1.23 +instruct countLeadingZerosI(rRegI dst, rRegI src, rFlagsReg cr) %{
    1.24 +  predicate(UseCountLeadingZerosInstruction);
    1.25 +  match(Set dst (CountLeadingZerosI src));
    1.26 +  effect(KILL cr);
    1.27 +
    1.28 +  format %{ "lzcntl  $dst, $src\t# count leading zeros (int)" %}
    1.29 +  ins_encode %{
    1.30 +    __ lzcntl($dst$$Register, $src$$Register);
    1.31 +  %}
    1.32 +  ins_pipe(ialu_reg);
    1.33 +%}
    1.34 +
    1.35 +instruct countLeadingZerosI_bsr(rRegI dst, rRegI src, rFlagsReg cr) %{
    1.36 +  predicate(!UseCountLeadingZerosInstruction);
    1.37 +  match(Set dst (CountLeadingZerosI src));
    1.38 +  effect(KILL cr);
    1.39 +
    1.40 +  format %{ "bsrl    $dst, $src\t# count leading zeros (int)\n\t"
    1.41 +            "jnz     skip\n\t"
    1.42 +            "movl    $dst, -1\n"
    1.43 +      "skip:\n\t"
    1.44 +            "negl    $dst\n\t"
    1.45 +            "addl    $dst, 31" %}
    1.46 +  ins_encode %{
    1.47 +    Register Rdst = $dst$$Register;
    1.48 +    Register Rsrc = $src$$Register;
    1.49 +    Label skip;
    1.50 +    __ bsrl(Rdst, Rsrc);
    1.51 +    __ jccb(Assembler::notZero, skip);
    1.52 +    __ movl(Rdst, -1);
    1.53 +    __ bind(skip);
    1.54 +    __ negl(Rdst);
    1.55 +    __ addl(Rdst, BitsPerInt - 1);
    1.56 +  %}
    1.57 +  ins_pipe(ialu_reg);
    1.58 +%}
    1.59 +
    1.60 +instruct countLeadingZerosL(rRegI dst, rRegL src, rFlagsReg cr) %{
    1.61 +  predicate(UseCountLeadingZerosInstruction);
    1.62 +  match(Set dst (CountLeadingZerosL src));
    1.63 +  effect(KILL cr);
    1.64 +
    1.65 +  format %{ "lzcntq  $dst, $src\t# count leading zeros (long)" %}
    1.66 +  ins_encode %{
    1.67 +    __ lzcntq($dst$$Register, $src$$Register);
    1.68 +  %}
    1.69 +  ins_pipe(ialu_reg);
    1.70 +%}
    1.71 +
    1.72 +instruct countLeadingZerosL_bsr(rRegI dst, rRegL src, rFlagsReg cr) %{
    1.73 +  predicate(!UseCountLeadingZerosInstruction);
    1.74 +  match(Set dst (CountLeadingZerosL src));
    1.75 +  effect(KILL cr);
    1.76 +
    1.77 +  format %{ "bsrq    $dst, $src\t# count leading zeros (long)\n\t"
    1.78 +            "jnz     skip\n\t"
    1.79 +            "movl    $dst, -1\n"
    1.80 +      "skip:\n\t"
    1.81 +            "negl    $dst\n\t"
    1.82 +            "addl    $dst, 63" %}
    1.83 +  ins_encode %{
    1.84 +    Register Rdst = $dst$$Register;
    1.85 +    Register Rsrc = $src$$Register;
    1.86 +    Label skip;
    1.87 +    __ bsrq(Rdst, Rsrc);
    1.88 +    __ jccb(Assembler::notZero, skip);
    1.89 +    __ movl(Rdst, -1);
    1.90 +    __ bind(skip);
    1.91 +    __ negl(Rdst);
    1.92 +    __ addl(Rdst, BitsPerLong - 1);
    1.93 +  %}
    1.94 +  ins_pipe(ialu_reg);
    1.95 +%}
    1.96 +
    1.97 +instruct countTrailingZerosI(rRegI dst, rRegI src, rFlagsReg cr) %{
    1.98 +  match(Set dst (CountTrailingZerosI src));
    1.99 +  effect(KILL cr);
   1.100 +
   1.101 +  format %{ "bsfl    $dst, $src\t# count trailing zeros (int)\n\t"
   1.102 +            "jnz     done\n\t"
   1.103 +            "movl    $dst, 32\n"
   1.104 +      "done:" %}
   1.105 +  ins_encode %{
   1.106 +    Register Rdst = $dst$$Register;
   1.107 +    Label done;
   1.108 +    __ bsfl(Rdst, $src$$Register);
   1.109 +    __ jccb(Assembler::notZero, done);
   1.110 +    __ movl(Rdst, BitsPerInt);
   1.111 +    __ bind(done);
   1.112 +  %}
   1.113 +  ins_pipe(ialu_reg);
   1.114 +%}
   1.115 +
   1.116 +instruct countTrailingZerosL(rRegI dst, rRegL src, rFlagsReg cr) %{
   1.117 +  match(Set dst (CountTrailingZerosL src));
   1.118 +  effect(KILL cr);
   1.119 +
   1.120 +  format %{ "bsfq    $dst, $src\t# count trailing zeros (long)\n\t"
   1.121 +            "jnz     done\n\t"
   1.122 +            "movl    $dst, 64\n"
   1.123 +      "done:" %}
   1.124 +  ins_encode %{
   1.125 +    Register Rdst = $dst$$Register;
   1.126 +    Label done;
   1.127 +    __ bsfq(Rdst, $src$$Register);
   1.128 +    __ jccb(Assembler::notZero, done);
   1.129 +    __ movl(Rdst, BitsPerLong);
   1.130 +    __ bind(done);
   1.131 +  %}
   1.132 +  ins_pipe(ialu_reg);
   1.133 +%}
   1.134 +
   1.135 +
   1.136  //---------- Population Count Instructions -------------------------------------
   1.137  
   1.138  instruct popCountI(rRegI dst, rRegI src) %{

mercurial