1.1 --- a/src/cpu/x86/vm/x86_32.ad Thu Mar 12 10:37:46 2009 -0700 1.2 +++ b/src/cpu/x86/vm/x86_32.ad Fri Mar 13 11:35:17 2009 -0700 1.3 @@ -1483,16 +1483,20 @@ 1.4 // main source block for now. In future, we can generalize this by 1.5 // adding a syntax that specifies the sizes of fields in an order, 1.6 // so that the adlc can build the emit functions automagically 1.7 - enc_class OpcP %{ // Emit opcode 1.8 - emit_opcode(cbuf,$primary); 1.9 - %} 1.10 - 1.11 - enc_class OpcS %{ // Emit opcode 1.12 - emit_opcode(cbuf,$secondary); 1.13 - %} 1.14 - 1.15 - enc_class Opcode(immI d8 ) %{ // Emit opcode 1.16 - emit_opcode(cbuf,$d8$$constant); 1.17 + 1.18 + // Emit primary opcode 1.19 + enc_class OpcP %{ 1.20 + emit_opcode(cbuf, $primary); 1.21 + %} 1.22 + 1.23 + // Emit secondary opcode 1.24 + enc_class OpcS %{ 1.25 + emit_opcode(cbuf, $secondary); 1.26 + %} 1.27 + 1.28 + // Emit opcode directly 1.29 + enc_class Opcode(immI d8) %{ 1.30 + emit_opcode(cbuf, $d8$$constant); 1.31 %} 1.32 1.33 enc_class SizePrefix %{ 1.34 @@ -6387,6 +6391,67 @@ 1.35 %} 1.36 1.37 1.38 +//---------- Population Count Instructions ------------------------------------- 1.39 + 1.40 +instruct popCountI(eRegI dst, eRegI src) %{ 1.41 + predicate(UsePopCountInstruction); 1.42 + match(Set dst (PopCountI src)); 1.43 + 1.44 + format %{ "POPCNT $dst, $src" %} 1.45 + ins_encode %{ 1.46 + __ popcntl($dst$$Register, $src$$Register); 1.47 + %} 1.48 + ins_pipe(ialu_reg); 1.49 +%} 1.50 + 1.51 +instruct popCountI_mem(eRegI dst, memory mem) %{ 1.52 + predicate(UsePopCountInstruction); 1.53 + match(Set dst (PopCountI (LoadI mem))); 1.54 + 1.55 + format %{ "POPCNT $dst, $mem" %} 1.56 + ins_encode %{ 1.57 + __ popcntl($dst$$Register, $mem$$Address); 1.58 + %} 1.59 + ins_pipe(ialu_reg); 1.60 +%} 1.61 + 1.62 +// Note: Long.bitCount(long) returns an int. 1.63 +instruct popCountL(eRegI dst, eRegL src, eRegI tmp, eFlagsReg cr) %{ 1.64 + predicate(UsePopCountInstruction); 1.65 + match(Set dst (PopCountL src)); 1.66 + effect(KILL cr, TEMP tmp, TEMP dst); 1.67 + 1.68 + format %{ "POPCNT $dst, $src.lo\n\t" 1.69 + "POPCNT $tmp, $src.hi\n\t" 1.70 + "ADD $dst, $tmp" %} 1.71 + ins_encode %{ 1.72 + __ popcntl($dst$$Register, $src$$Register); 1.73 + __ popcntl($tmp$$Register, HIGH_FROM_LOW($src$$Register)); 1.74 + __ addl($dst$$Register, $tmp$$Register); 1.75 + %} 1.76 + ins_pipe(ialu_reg); 1.77 +%} 1.78 + 1.79 +// Note: Long.bitCount(long) returns an int. 1.80 +instruct popCountL_mem(eRegI dst, memory mem, eRegI tmp, eFlagsReg cr) %{ 1.81 + predicate(UsePopCountInstruction); 1.82 + match(Set dst (PopCountL (LoadL mem))); 1.83 + effect(KILL cr, TEMP tmp, TEMP dst); 1.84 + 1.85 + format %{ "POPCNT $dst, $mem\n\t" 1.86 + "POPCNT $tmp, $mem+4\n\t" 1.87 + "ADD $dst, $tmp" %} 1.88 + ins_encode %{ 1.89 + //__ popcntl($dst$$Register, $mem$$Address$$first); 1.90 + //__ popcntl($tmp$$Register, $mem$$Address$$second); 1.91 + __ popcntl($dst$$Register, Address::make_raw($mem$$base, $mem$$index, $mem$$scale, $mem$$disp, false)); 1.92 + __ popcntl($tmp$$Register, Address::make_raw($mem$$base, $mem$$index, $mem$$scale, $mem$$disp + 4, false)); 1.93 + __ addl($dst$$Register, $tmp$$Register); 1.94 + %} 1.95 + ins_pipe(ialu_reg); 1.96 +%} 1.97 + 1.98 + 1.99 //----------Load/Store/Move Instructions--------------------------------------- 1.100 //----------Load Instructions-------------------------------------------------- 1.101 // Load Byte (8bit signed)