src/cpu/x86/vm/x86_32.ad
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7069452 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/x86_32.ad

Print this page




4479   return_value %{
4480     assert( ideal_reg >= Op_RegI && ideal_reg <= Op_RegL, "only return normal values" );
4481     static int lo[Op_RegL+1] = { 0, 0, OptoReg::Bad, EAX_num,      EAX_num,      FPR1L_num,    FPR1L_num, EAX_num };
4482     static int hi[Op_RegL+1] = { 0, 0, OptoReg::Bad, OptoReg::Bad, OptoReg::Bad, OptoReg::Bad, FPR1H_num, EDX_num };
4483     if( ideal_reg == Op_RegD && UseSSE>=2 )
4484       return OptoRegPair(XMM0b_num,XMM0a_num);
4485     if( ideal_reg == Op_RegF && UseSSE>=1 )
4486       return OptoRegPair(OptoReg::Bad,XMM0a_num);
4487     return OptoRegPair(hi[ideal_reg],lo[ideal_reg]);
4488   %}
4489 
4490 %}
4491 
4492 //----------ATTRIBUTES---------------------------------------------------------
4493 //----------Operand Attributes-------------------------------------------------
4494 op_attrib op_cost(0);        // Required cost attribute
4495 
4496 //----------Instruction Attributes---------------------------------------------
4497 ins_attrib ins_cost(100);       // Required cost attribute
4498 ins_attrib ins_size(8);         // Required size attribute (in bits)
4499 ins_attrib ins_pc_relative(0);  // Required PC Relative flag
4500 ins_attrib ins_short_branch(0); // Required flag: is this instruction a
4501                                 // non-matching short branch variant of some
4502                                                             // long branch?
4503 ins_attrib ins_alignment(1);    // Required alignment attribute (must be a power of 2)
4504                                 // specifies the alignment that some part of the instruction (not
4505                                 // necessarily the start) requires.  If > 1, a compute_padding()
4506                                 // function must be provided for the instruction
4507 
4508 //----------OPERANDS-----------------------------------------------------------
4509 // Operand definitions must precede instruction definitions for correct parsing
4510 // in the ADLC because operands constitute user defined types which are used in
4511 // instruction definitions.
4512 
4513 //----------Simple Operands----------------------------------------------------
4514 // Immediate Operands
4515 // Integer Immediate
4516 operand immI() %{
4517   match(ConI);
4518 
4519   op_cost(10);


13030     // (EAX) * stride
13031     __ mull($tmp$$Register);
13032     // + init (ignore upper bits)
13033     __ addl($limit$$Register, $init$$Register);
13034   %}
13035   ins_pipe( pipe_slow );
13036 %}
13037 
13038 // ============================================================================
13039 // Branch Instructions
13040 // Jump Table
13041 instruct jumpXtnd(eRegI switch_val) %{
13042   match(Jump switch_val);
13043   ins_cost(350);
13044   format %{  "JMP    [$constantaddress](,$switch_val,1)\n\t" %}
13045   ins_encode %{
13046     // Jump to Address(table_base + switch_reg)
13047     Address index(noreg, $switch_val$$Register, Address::times_1);
13048     __ jump(ArrayAddress($constantaddress, index));
13049   %}
13050   ins_pc_relative(1);
13051   ins_pipe(pipe_jmp);
13052 %}
13053 
13054 // Jump Direct - Label defines a relative address from JMP+1
13055 instruct jmpDir(label labl) %{
13056   match(Goto);
13057   effect(USE labl);
13058 
13059   ins_cost(300);
13060   format %{ "JMP    $labl" %}
13061   size(5);
13062   opcode(0xE9);
13063   ins_encode( OpcP, Lbl( labl ) );
13064   ins_pipe( pipe_jmp );
13065   ins_pc_relative(1);
13066 %}
13067 
13068 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13069 instruct jmpCon(cmpOp cop, eFlagsReg cr, label labl) %{
13070   match(If cop cr);
13071   effect(USE labl);
13072 
13073   ins_cost(300);
13074   format %{ "J$cop    $labl" %}
13075   size(6);
13076   opcode(0x0F, 0x80);
13077   ins_encode( Jcc( cop, labl) );
13078   ins_pipe( pipe_jcc );
13079   ins_pc_relative(1);
13080 %}
13081 
13082 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13083 instruct jmpLoopEnd(cmpOp cop, eFlagsReg cr, label labl) %{
13084   match(CountedLoopEnd cop cr);
13085   effect(USE labl);
13086 
13087   ins_cost(300);
13088   format %{ "J$cop    $labl\t# Loop end" %}
13089   size(6);
13090   opcode(0x0F, 0x80);
13091   ins_encode( Jcc( cop, labl) );
13092   ins_pipe( pipe_jcc );
13093   ins_pc_relative(1);
13094 %}
13095 
13096 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13097 instruct jmpLoopEndU(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13098   match(CountedLoopEnd cop cmp);
13099   effect(USE labl);
13100 
13101   ins_cost(300);
13102   format %{ "J$cop,u  $labl\t# Loop end" %}
13103   size(6);
13104   opcode(0x0F, 0x80);
13105   ins_encode( Jcc( cop, labl) );
13106   ins_pipe( pipe_jcc );
13107   ins_pc_relative(1);
13108 %}
13109 
13110 instruct jmpLoopEndUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13111   match(CountedLoopEnd cop cmp);
13112   effect(USE labl);
13113 
13114   ins_cost(200);
13115   format %{ "J$cop,u  $labl\t# Loop end" %}
13116   size(6);
13117   opcode(0x0F, 0x80);
13118   ins_encode( Jcc( cop, labl) );
13119   ins_pipe( pipe_jcc );
13120   ins_pc_relative(1);
13121 %}
13122 
13123 // Jump Direct Conditional - using unsigned comparison
13124 instruct jmpConU(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13125   match(If cop cmp);
13126   effect(USE labl);
13127 
13128   ins_cost(300);
13129   format %{ "J$cop,u  $labl" %}
13130   size(6);
13131   opcode(0x0F, 0x80);
13132   ins_encode(Jcc(cop, labl));
13133   ins_pipe(pipe_jcc);
13134   ins_pc_relative(1);
13135 %}
13136 
13137 instruct jmpConUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13138   match(If cop cmp);
13139   effect(USE labl);
13140 
13141   ins_cost(200);
13142   format %{ "J$cop,u  $labl" %}
13143   size(6);
13144   opcode(0x0F, 0x80);
13145   ins_encode(Jcc(cop, labl));
13146   ins_pipe(pipe_jcc);
13147   ins_pc_relative(1);
13148 %}
13149 
13150 instruct jmpConUCF2(cmpOpUCF2 cop, eFlagsRegUCF cmp, label labl) %{
13151   match(If cop cmp);
13152   effect(USE labl);
13153 
13154   ins_cost(200);
13155   format %{ $$template
13156     if ($cop$$cmpcode == Assembler::notEqual) {
13157       $$emit$$"JP,u   $labl\n\t"
13158       $$emit$$"J$cop,u   $labl"
13159     } else {
13160       $$emit$$"JP,u   done\n\t"
13161       $$emit$$"J$cop,u   $labl\n\t"
13162       $$emit$$"done:"
13163     }
13164   %}
13165   size(12);
13166   opcode(0x0F, 0x80);
13167   ins_encode %{


13169     $$$emit8$primary;
13170     emit_cc(cbuf, $secondary, Assembler::parity);
13171     int parity_disp = -1;
13172     bool ok = false;
13173     if ($cop$$cmpcode == Assembler::notEqual) {
13174        // the two jumps 6 bytes apart so the jump distances are too
13175        parity_disp = l->loc_pos() - (cbuf.insts_size() + 4);
13176     } else if ($cop$$cmpcode == Assembler::equal) {
13177        parity_disp = 6;
13178        ok = true;
13179     } else {
13180        ShouldNotReachHere();
13181     }
13182     emit_d32(cbuf, parity_disp);
13183     $$$emit8$primary;
13184     emit_cc(cbuf, $secondary, $cop$$cmpcode);
13185     int disp = l->loc_pos() - (cbuf.insts_size() + 4);
13186     emit_d32(cbuf, disp);
13187   %}
13188   ins_pipe(pipe_jcc);
13189   ins_pc_relative(1);
13190 %}
13191 
13192 // ============================================================================
13193 // The 2nd slow-half of a subtype check.  Scan the subklass's 2ndary superklass
13194 // array for an instance of the superklass.  Set a hidden internal cache on a
13195 // hit (cache is checked with exposed code in gen_subtype_check()).  Return
13196 // NZ for a miss or zero for a hit.  The encoding ALSO sets flags.
13197 instruct partialSubtypeCheck( eDIRegP result, eSIRegP sub, eAXRegP super, eCXRegI rcx, eFlagsReg cr ) %{
13198   match(Set result (PartialSubtypeCheck sub super));
13199   effect( KILL rcx, KILL cr );
13200 
13201   ins_cost(1100);  // slightly larger than the next version
13202   format %{ "MOV    EDI,[$sub+Klass::secondary_supers]\n\t"
13203             "MOV    ECX,[EDI+arrayKlass::length]\t# length to scan\n\t"
13204             "ADD    EDI,arrayKlass::base_offset\t# Skip to start of data; set NZ in case count is zero\n\t"
13205             "REPNE SCASD\t# Scan *EDI++ for a match with EAX while CX-- != 0\n\t"
13206             "JNE,s  miss\t\t# Missed: EDI not-zero\n\t"
13207             "MOV    [$sub+Klass::secondary_super_cache],$super\t# Hit: update cache\n\t"
13208             "XOR    $result,$result\t\t Hit: EDI zero\n\t"
13209      "miss:\t" %}


13237 // These instructions are used to replace jumps of a long offset (the default
13238 // match) with jumps of a shorter offset.  These instructions are all tagged
13239 // with the ins_short_branch attribute, which causes the ADLC to suppress the
13240 // match rules in general matching.  Instead, the ADLC generates a conversion
13241 // method in the MachNode which can be used to do in-place replacement of the
13242 // long variant with the shorter variant.  The compiler will determine if a
13243 // branch can be taken by the is_short_branch_offset() predicate in the machine
13244 // specific code section of the file.
13245 
13246 // Jump Direct - Label defines a relative address from JMP+1
13247 instruct jmpDir_short(label labl) %{
13248   match(Goto);
13249   effect(USE labl);
13250 
13251   ins_cost(300);
13252   format %{ "JMP,s  $labl" %}
13253   size(2);
13254   opcode(0xEB);
13255   ins_encode( OpcP, LblShort( labl ) );
13256   ins_pipe( pipe_jmp );
13257   ins_pc_relative(1);
13258   ins_short_branch(1);
13259 %}
13260 
13261 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13262 instruct jmpCon_short(cmpOp cop, eFlagsReg cr, label labl) %{
13263   match(If cop cr);
13264   effect(USE labl);
13265 
13266   ins_cost(300);
13267   format %{ "J$cop,s  $labl" %}
13268   size(2);
13269   opcode(0x70);
13270   ins_encode( JccShort( cop, labl) );
13271   ins_pipe( pipe_jcc );
13272   ins_pc_relative(1);
13273   ins_short_branch(1);
13274 %}
13275 
13276 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13277 instruct jmpLoopEnd_short(cmpOp cop, eFlagsReg cr, label labl) %{
13278   match(CountedLoopEnd cop cr);
13279   effect(USE labl);
13280 
13281   ins_cost(300);
13282   format %{ "J$cop,s  $labl\t# Loop end" %}
13283   size(2);
13284   opcode(0x70);
13285   ins_encode( JccShort( cop, labl) );
13286   ins_pipe( pipe_jcc );
13287   ins_pc_relative(1);
13288   ins_short_branch(1);
13289 %}
13290 
13291 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13292 instruct jmpLoopEndU_short(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13293   match(CountedLoopEnd cop cmp);
13294   effect(USE labl);
13295 
13296   ins_cost(300);
13297   format %{ "J$cop,us $labl\t# Loop end" %}
13298   size(2);
13299   opcode(0x70);
13300   ins_encode( JccShort( cop, labl) );
13301   ins_pipe( pipe_jcc );
13302   ins_pc_relative(1);
13303   ins_short_branch(1);
13304 %}
13305 
13306 instruct jmpLoopEndUCF_short(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13307   match(CountedLoopEnd cop cmp);
13308   effect(USE labl);
13309 
13310   ins_cost(300);
13311   format %{ "J$cop,us $labl\t# Loop end" %}
13312   size(2);
13313   opcode(0x70);
13314   ins_encode( JccShort( cop, labl) );
13315   ins_pipe( pipe_jcc );
13316   ins_pc_relative(1);
13317   ins_short_branch(1);
13318 %}
13319 
13320 // Jump Direct Conditional - using unsigned comparison
13321 instruct jmpConU_short(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13322   match(If cop cmp);
13323   effect(USE labl);
13324 
13325   ins_cost(300);
13326   format %{ "J$cop,us $labl" %}
13327   size(2);
13328   opcode(0x70);
13329   ins_encode( JccShort( cop, labl) );
13330   ins_pipe( pipe_jcc );
13331   ins_pc_relative(1);
13332   ins_short_branch(1);
13333 %}
13334 
13335 instruct jmpConUCF_short(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13336   match(If cop cmp);
13337   effect(USE labl);
13338 
13339   ins_cost(300);
13340   format %{ "J$cop,us $labl" %}
13341   size(2);
13342   opcode(0x70);
13343   ins_encode( JccShort( cop, labl) );
13344   ins_pipe( pipe_jcc );
13345   ins_pc_relative(1);
13346   ins_short_branch(1);
13347 %}
13348 
13349 instruct jmpConUCF2_short(cmpOpUCF2 cop, eFlagsRegUCF cmp, label labl) %{
13350   match(If cop cmp);
13351   effect(USE labl);
13352 
13353   ins_cost(300);
13354   format %{ $$template
13355     if ($cop$$cmpcode == Assembler::notEqual) {
13356       $$emit$$"JP,u,s   $labl\n\t"
13357       $$emit$$"J$cop,u,s   $labl"
13358     } else {
13359       $$emit$$"JP,u,s   done\n\t"
13360       $$emit$$"J$cop,u,s  $labl\n\t"
13361       $$emit$$"done:"
13362     }
13363   %}
13364   size(4);
13365   opcode(0x70);
13366   ins_encode %{
13367     Label* l = $labl$$label;
13368     emit_cc(cbuf, $primary, Assembler::parity);
13369     int parity_disp = -1;
13370     if ($cop$$cmpcode == Assembler::notEqual) {
13371       parity_disp = l->loc_pos() - (cbuf.insts_size() + 1);
13372     } else if ($cop$$cmpcode == Assembler::equal) {
13373       parity_disp = 2;
13374     } else {
13375       ShouldNotReachHere();
13376     }
13377     emit_d8(cbuf, parity_disp);
13378     emit_cc(cbuf, $primary, $cop$$cmpcode);
13379     int disp = l->loc_pos() - (cbuf.insts_size() + 1);
13380     emit_d8(cbuf, disp);
13381     assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
13382     assert(-128 <= parity_disp && parity_disp <= 127, "Displacement too large for short jmp");
13383   %}
13384   ins_pipe(pipe_jcc);
13385   ins_pc_relative(1);
13386   ins_short_branch(1);
13387 %}
13388 
13389 // ============================================================================
13390 // Long Compare
13391 //
13392 // Currently we hold longs in 2 registers.  Comparing such values efficiently
13393 // is tricky.  The flavor of compare used depends on whether we are testing
13394 // for LT, LE, or EQ.  For a simple LT test we can check just the sign bit.
13395 // The GE test is the negated LT test.  The LE test can be had by commuting
13396 // the operands (yielding a GE test) and then negating; negate again for the
13397 // GT test.  The EQ test is done by ORcc'ing the high and low halves, and the
13398 // NE test is negated from that.
13399 
13400 // Due to a shortcoming in the ADLC, it mixes up expressions like:
13401 // (foo (CmpI (CmpL X Y) 0)) and (bar (CmpI (CmpL X 0L) 0)).  Note the
13402 // difference between 'Y' and '0L'.  The tree-matches for the CmpI sections
13403 // are collapsed internally in the ADLC's dfa-gen code.  The match for
13404 // (CmpI (CmpL X Y) 0) is silently replaced with (CmpI (CmpL X 0L) 0) and the
13405 // foo match ends up with the wrong leaf.  One fix is to not match both


13838 
13839 
13840 // ============================================================================
13841 // Procedure Call/Return Instructions
13842 // Call Java Static Instruction
13843 // Note: If this code changes, the corresponding ret_addr_offset() and
13844 //       compute_padding() functions will have to be adjusted.
13845 instruct CallStaticJavaDirect(method meth) %{
13846   match(CallStaticJava);
13847   predicate(! ((CallStaticJavaNode*)n)->is_method_handle_invoke());
13848   effect(USE meth);
13849 
13850   ins_cost(300);
13851   format %{ "CALL,static " %}
13852   opcode(0xE8); /* E8 cd */
13853   ins_encode( pre_call_FPU,
13854               Java_Static_Call( meth ),
13855               call_epilog,
13856               post_call_FPU );
13857   ins_pipe( pipe_slow );
13858   ins_pc_relative(1);
13859   ins_alignment(4);
13860 %}
13861 
13862 // Call Java Static Instruction (method handle version)
13863 // Note: If this code changes, the corresponding ret_addr_offset() and
13864 //       compute_padding() functions will have to be adjusted.
13865 instruct CallStaticJavaHandle(method meth, eBPRegP ebp_mh_SP_save) %{
13866   match(CallStaticJava);
13867   predicate(((CallStaticJavaNode*)n)->is_method_handle_invoke());
13868   effect(USE meth);
13869   // EBP is saved by all callees (for interpreter stack correction).
13870   // We use it here for a similar purpose, in {preserve,restore}_SP.
13871 
13872   ins_cost(300);
13873   format %{ "CALL,static/MethodHandle " %}
13874   opcode(0xE8); /* E8 cd */
13875   ins_encode( pre_call_FPU,
13876               preserve_SP,
13877               Java_Static_Call( meth ),
13878               restore_SP,
13879               call_epilog,
13880               post_call_FPU );
13881   ins_pipe( pipe_slow );
13882   ins_pc_relative(1);
13883   ins_alignment(4);
13884 %}
13885 
13886 // Call Java Dynamic Instruction
13887 // Note: If this code changes, the corresponding ret_addr_offset() and
13888 //       compute_padding() functions will have to be adjusted.
13889 instruct CallDynamicJavaDirect(method meth) %{
13890   match(CallDynamicJava);
13891   effect(USE meth);
13892 
13893   ins_cost(300);
13894   format %{ "MOV    EAX,(oop)-1\n\t"
13895             "CALL,dynamic" %}
13896   opcode(0xE8); /* E8 cd */
13897   ins_encode( pre_call_FPU,
13898               Java_Dynamic_Call( meth ),
13899               call_epilog,
13900               post_call_FPU );
13901   ins_pipe( pipe_slow );
13902   ins_pc_relative(1);
13903   ins_alignment(4);
13904 %}
13905 
13906 // Call Runtime Instruction
13907 instruct CallRuntimeDirect(method meth) %{
13908   match(CallRuntime );
13909   effect(USE meth);
13910 
13911   ins_cost(300);
13912   format %{ "CALL,runtime " %}
13913   opcode(0xE8); /* E8 cd */
13914   // Use FFREEs to clear entries in float stack
13915   ins_encode( pre_call_FPU,
13916               FFree_Float_Stack_All,
13917               Java_To_Runtime( meth ),
13918               post_call_FPU );
13919   ins_pipe( pipe_slow );
13920   ins_pc_relative(1);
13921 %}
13922 
13923 // Call runtime without safepoint
13924 instruct CallLeafDirect(method meth) %{
13925   match(CallLeaf);
13926   effect(USE meth);
13927 
13928   ins_cost(300);
13929   format %{ "CALL_LEAF,runtime " %}
13930   opcode(0xE8); /* E8 cd */
13931   ins_encode( pre_call_FPU,
13932               FFree_Float_Stack_All,
13933               Java_To_Runtime( meth ),
13934               Verify_FPU_For_Leaf, post_call_FPU );
13935   ins_pipe( pipe_slow );
13936   ins_pc_relative(1);
13937 %}
13938 
13939 instruct CallLeafNoFPDirect(method meth) %{
13940   match(CallLeafNoFP);
13941   effect(USE meth);
13942 
13943   ins_cost(300);
13944   format %{ "CALL_LEAF_NOFP,runtime " %}
13945   opcode(0xE8); /* E8 cd */
13946   ins_encode(Java_To_Runtime(meth));
13947   ins_pipe( pipe_slow );
13948   ins_pc_relative(1);
13949 %}
13950 
13951 
13952 // Return Instruction
13953 // Remove the return address & jump to it.
13954 instruct Ret() %{
13955   match(Return);
13956   format %{ "RET" %}
13957   opcode(0xC3);
13958   ins_encode(OpcP);
13959   ins_pipe( pipe_jmp );
13960 %}
13961 
13962 // Tail Call; Jump from runtime stub to Java code.
13963 // Also known as an 'interprocedural jump'.
13964 // Target of jump will eventually return to caller.
13965 // TailJump below removes the return address.
13966 instruct TailCalljmpInd(eRegP_no_EBP jump_target, eBXRegP method_oop) %{
13967   match(TailCall jump_target method_oop );
13968   ins_cost(300);


14007 instruct RethrowException()
14008 %{
14009   match(Rethrow);
14010 
14011   // use the following format syntax
14012   format %{ "JMP    rethrow_stub" %}
14013   ins_encode(enc_rethrow);
14014   ins_pipe( pipe_jmp );
14015 %}
14016 
14017 // inlined locking and unlocking
14018 
14019 
14020 instruct cmpFastLock( eFlagsReg cr, eRegP object, eRegP box, eAXRegI tmp, eRegP scr) %{
14021   match( Set cr (FastLock object box) );
14022   effect( TEMP tmp, TEMP scr );
14023   ins_cost(300);
14024   format %{ "FASTLOCK $object, $box KILLS $tmp,$scr" %}
14025   ins_encode( Fast_Lock(object,box,tmp,scr) );
14026   ins_pipe( pipe_slow );
14027   ins_pc_relative(1);
14028 %}
14029 
14030 instruct cmpFastUnlock( eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{
14031   match( Set cr (FastUnlock object box) );
14032   effect( TEMP tmp );
14033   ins_cost(300);
14034   format %{ "FASTUNLOCK $object, $box, $tmp" %}
14035   ins_encode( Fast_Unlock(object,box,tmp) );
14036   ins_pipe( pipe_slow );
14037   ins_pc_relative(1);
14038 %}
14039 
14040 
14041 
14042 // ============================================================================
14043 // Safepoint Instruction
14044 instruct safePoint_poll(eFlagsReg cr) %{
14045   match(SafePoint);
14046   effect(KILL cr);
14047 
14048   // TODO-FIXME: we currently poll at offset 0 of the safepoint polling page.
14049   // On SPARC that might be acceptable as we can generate the address with
14050   // just a sethi, saving an or.  By polling at offset 0 we can end up
14051   // putting additional pressure on the index-0 in the D$.  Because of
14052   // alignment (just like the situation at hand) the lower indices tend
14053   // to see more traffic.  It'd be better to change the polling address
14054   // to offset 0 of the last $line in the polling page.
14055 
14056   format %{ "TSTL   #polladdr,EAX\t! Safepoint: poll for GC" %}
14057   ins_cost(125);




4479   return_value %{
4480     assert( ideal_reg >= Op_RegI && ideal_reg <= Op_RegL, "only return normal values" );
4481     static int lo[Op_RegL+1] = { 0, 0, OptoReg::Bad, EAX_num,      EAX_num,      FPR1L_num,    FPR1L_num, EAX_num };
4482     static int hi[Op_RegL+1] = { 0, 0, OptoReg::Bad, OptoReg::Bad, OptoReg::Bad, OptoReg::Bad, FPR1H_num, EDX_num };
4483     if( ideal_reg == Op_RegD && UseSSE>=2 )
4484       return OptoRegPair(XMM0b_num,XMM0a_num);
4485     if( ideal_reg == Op_RegF && UseSSE>=1 )
4486       return OptoRegPair(OptoReg::Bad,XMM0a_num);
4487     return OptoRegPair(hi[ideal_reg],lo[ideal_reg]);
4488   %}
4489 
4490 %}
4491 
4492 //----------ATTRIBUTES---------------------------------------------------------
4493 //----------Operand Attributes-------------------------------------------------
4494 op_attrib op_cost(0);        // Required cost attribute
4495 
4496 //----------Instruction Attributes---------------------------------------------
4497 ins_attrib ins_cost(100);       // Required cost attribute
4498 ins_attrib ins_size(8);         // Required size attribute (in bits)

4499 ins_attrib ins_short_branch(0); // Required flag: is this instruction a
4500                                 // non-matching short branch variant of some
4501                                                             // long branch?
4502 ins_attrib ins_alignment(1);    // Required alignment attribute (must be a power of 2)
4503                                 // specifies the alignment that some part of the instruction (not
4504                                 // necessarily the start) requires.  If > 1, a compute_padding()
4505                                 // function must be provided for the instruction
4506 
4507 //----------OPERANDS-----------------------------------------------------------
4508 // Operand definitions must precede instruction definitions for correct parsing
4509 // in the ADLC because operands constitute user defined types which are used in
4510 // instruction definitions.
4511 
4512 //----------Simple Operands----------------------------------------------------
4513 // Immediate Operands
4514 // Integer Immediate
4515 operand immI() %{
4516   match(ConI);
4517 
4518   op_cost(10);


13029     // (EAX) * stride
13030     __ mull($tmp$$Register);
13031     // + init (ignore upper bits)
13032     __ addl($limit$$Register, $init$$Register);
13033   %}
13034   ins_pipe( pipe_slow );
13035 %}
13036 
13037 // ============================================================================
13038 // Branch Instructions
13039 // Jump Table
13040 instruct jumpXtnd(eRegI switch_val) %{
13041   match(Jump switch_val);
13042   ins_cost(350);
13043   format %{  "JMP    [$constantaddress](,$switch_val,1)\n\t" %}
13044   ins_encode %{
13045     // Jump to Address(table_base + switch_reg)
13046     Address index(noreg, $switch_val$$Register, Address::times_1);
13047     __ jump(ArrayAddress($constantaddress, index));
13048   %}

13049   ins_pipe(pipe_jmp);
13050 %}
13051 
13052 // Jump Direct - Label defines a relative address from JMP+1
13053 instruct jmpDir(label labl) %{
13054   match(Goto);
13055   effect(USE labl);
13056 
13057   ins_cost(300);
13058   format %{ "JMP    $labl" %}
13059   size(5);
13060   opcode(0xE9);
13061   ins_encode( OpcP, Lbl( labl ) );
13062   ins_pipe( pipe_jmp );

13063 %}
13064 
13065 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13066 instruct jmpCon(cmpOp cop, eFlagsReg cr, label labl) %{
13067   match(If cop cr);
13068   effect(USE labl);
13069 
13070   ins_cost(300);
13071   format %{ "J$cop    $labl" %}
13072   size(6);
13073   opcode(0x0F, 0x80);
13074   ins_encode( Jcc( cop, labl) );
13075   ins_pipe( pipe_jcc );

13076 %}
13077 
13078 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13079 instruct jmpLoopEnd(cmpOp cop, eFlagsReg cr, label labl) %{
13080   match(CountedLoopEnd cop cr);
13081   effect(USE labl);
13082 
13083   ins_cost(300);
13084   format %{ "J$cop    $labl\t# Loop end" %}
13085   size(6);
13086   opcode(0x0F, 0x80);
13087   ins_encode( Jcc( cop, labl) );
13088   ins_pipe( pipe_jcc );

13089 %}
13090 
13091 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13092 instruct jmpLoopEndU(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13093   match(CountedLoopEnd cop cmp);
13094   effect(USE labl);
13095 
13096   ins_cost(300);
13097   format %{ "J$cop,u  $labl\t# Loop end" %}
13098   size(6);
13099   opcode(0x0F, 0x80);
13100   ins_encode( Jcc( cop, labl) );
13101   ins_pipe( pipe_jcc );

13102 %}
13103 
13104 instruct jmpLoopEndUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13105   match(CountedLoopEnd cop cmp);
13106   effect(USE labl);
13107 
13108   ins_cost(200);
13109   format %{ "J$cop,u  $labl\t# Loop end" %}
13110   size(6);
13111   opcode(0x0F, 0x80);
13112   ins_encode( Jcc( cop, labl) );
13113   ins_pipe( pipe_jcc );

13114 %}
13115 
13116 // Jump Direct Conditional - using unsigned comparison
13117 instruct jmpConU(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13118   match(If cop cmp);
13119   effect(USE labl);
13120 
13121   ins_cost(300);
13122   format %{ "J$cop,u  $labl" %}
13123   size(6);
13124   opcode(0x0F, 0x80);
13125   ins_encode(Jcc(cop, labl));
13126   ins_pipe(pipe_jcc);

13127 %}
13128 
13129 instruct jmpConUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13130   match(If cop cmp);
13131   effect(USE labl);
13132 
13133   ins_cost(200);
13134   format %{ "J$cop,u  $labl" %}
13135   size(6);
13136   opcode(0x0F, 0x80);
13137   ins_encode(Jcc(cop, labl));
13138   ins_pipe(pipe_jcc);

13139 %}
13140 
13141 instruct jmpConUCF2(cmpOpUCF2 cop, eFlagsRegUCF cmp, label labl) %{
13142   match(If cop cmp);
13143   effect(USE labl);
13144 
13145   ins_cost(200);
13146   format %{ $$template
13147     if ($cop$$cmpcode == Assembler::notEqual) {
13148       $$emit$$"JP,u   $labl\n\t"
13149       $$emit$$"J$cop,u   $labl"
13150     } else {
13151       $$emit$$"JP,u   done\n\t"
13152       $$emit$$"J$cop,u   $labl\n\t"
13153       $$emit$$"done:"
13154     }
13155   %}
13156   size(12);
13157   opcode(0x0F, 0x80);
13158   ins_encode %{


13160     $$$emit8$primary;
13161     emit_cc(cbuf, $secondary, Assembler::parity);
13162     int parity_disp = -1;
13163     bool ok = false;
13164     if ($cop$$cmpcode == Assembler::notEqual) {
13165        // the two jumps 6 bytes apart so the jump distances are too
13166        parity_disp = l->loc_pos() - (cbuf.insts_size() + 4);
13167     } else if ($cop$$cmpcode == Assembler::equal) {
13168        parity_disp = 6;
13169        ok = true;
13170     } else {
13171        ShouldNotReachHere();
13172     }
13173     emit_d32(cbuf, parity_disp);
13174     $$$emit8$primary;
13175     emit_cc(cbuf, $secondary, $cop$$cmpcode);
13176     int disp = l->loc_pos() - (cbuf.insts_size() + 4);
13177     emit_d32(cbuf, disp);
13178   %}
13179   ins_pipe(pipe_jcc);

13180 %}
13181 
13182 // ============================================================================
13183 // The 2nd slow-half of a subtype check.  Scan the subklass's 2ndary superklass
13184 // array for an instance of the superklass.  Set a hidden internal cache on a
13185 // hit (cache is checked with exposed code in gen_subtype_check()).  Return
13186 // NZ for a miss or zero for a hit.  The encoding ALSO sets flags.
13187 instruct partialSubtypeCheck( eDIRegP result, eSIRegP sub, eAXRegP super, eCXRegI rcx, eFlagsReg cr ) %{
13188   match(Set result (PartialSubtypeCheck sub super));
13189   effect( KILL rcx, KILL cr );
13190 
13191   ins_cost(1100);  // slightly larger than the next version
13192   format %{ "MOV    EDI,[$sub+Klass::secondary_supers]\n\t"
13193             "MOV    ECX,[EDI+arrayKlass::length]\t# length to scan\n\t"
13194             "ADD    EDI,arrayKlass::base_offset\t# Skip to start of data; set NZ in case count is zero\n\t"
13195             "REPNE SCASD\t# Scan *EDI++ for a match with EAX while CX-- != 0\n\t"
13196             "JNE,s  miss\t\t# Missed: EDI not-zero\n\t"
13197             "MOV    [$sub+Klass::secondary_super_cache],$super\t# Hit: update cache\n\t"
13198             "XOR    $result,$result\t\t Hit: EDI zero\n\t"
13199      "miss:\t" %}


13227 // These instructions are used to replace jumps of a long offset (the default
13228 // match) with jumps of a shorter offset.  These instructions are all tagged
13229 // with the ins_short_branch attribute, which causes the ADLC to suppress the
13230 // match rules in general matching.  Instead, the ADLC generates a conversion
13231 // method in the MachNode which can be used to do in-place replacement of the
13232 // long variant with the shorter variant.  The compiler will determine if a
13233 // branch can be taken by the is_short_branch_offset() predicate in the machine
13234 // specific code section of the file.
13235 
13236 // Jump Direct - Label defines a relative address from JMP+1
13237 instruct jmpDir_short(label labl) %{
13238   match(Goto);
13239   effect(USE labl);
13240 
13241   ins_cost(300);
13242   format %{ "JMP,s  $labl" %}
13243   size(2);
13244   opcode(0xEB);
13245   ins_encode( OpcP, LblShort( labl ) );
13246   ins_pipe( pipe_jmp );

13247   ins_short_branch(1);
13248 %}
13249 
13250 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13251 instruct jmpCon_short(cmpOp cop, eFlagsReg cr, label labl) %{
13252   match(If cop cr);
13253   effect(USE labl);
13254 
13255   ins_cost(300);
13256   format %{ "J$cop,s  $labl" %}
13257   size(2);
13258   opcode(0x70);
13259   ins_encode( JccShort( cop, labl) );
13260   ins_pipe( pipe_jcc );

13261   ins_short_branch(1);
13262 %}
13263 
13264 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13265 instruct jmpLoopEnd_short(cmpOp cop, eFlagsReg cr, label labl) %{
13266   match(CountedLoopEnd cop cr);
13267   effect(USE labl);
13268 
13269   ins_cost(300);
13270   format %{ "J$cop,s  $labl\t# Loop end" %}
13271   size(2);
13272   opcode(0x70);
13273   ins_encode( JccShort( cop, labl) );
13274   ins_pipe( pipe_jcc );

13275   ins_short_branch(1);
13276 %}
13277 
13278 // Jump Direct Conditional - Label defines a relative address from Jcc+1
13279 instruct jmpLoopEndU_short(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13280   match(CountedLoopEnd cop cmp);
13281   effect(USE labl);
13282 
13283   ins_cost(300);
13284   format %{ "J$cop,us $labl\t# Loop end" %}
13285   size(2);
13286   opcode(0x70);
13287   ins_encode( JccShort( cop, labl) );
13288   ins_pipe( pipe_jcc );

13289   ins_short_branch(1);
13290 %}
13291 
13292 instruct jmpLoopEndUCF_short(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13293   match(CountedLoopEnd cop cmp);
13294   effect(USE labl);
13295 
13296   ins_cost(300);
13297   format %{ "J$cop,us $labl\t# Loop end" %}
13298   size(2);
13299   opcode(0x70);
13300   ins_encode( JccShort( cop, labl) );
13301   ins_pipe( pipe_jcc );

13302   ins_short_branch(1);
13303 %}
13304 
13305 // Jump Direct Conditional - using unsigned comparison
13306 instruct jmpConU_short(cmpOpU cop, eFlagsRegU cmp, label labl) %{
13307   match(If cop cmp);
13308   effect(USE labl);
13309 
13310   ins_cost(300);
13311   format %{ "J$cop,us $labl" %}
13312   size(2);
13313   opcode(0x70);
13314   ins_encode( JccShort( cop, labl) );
13315   ins_pipe( pipe_jcc );

13316   ins_short_branch(1);
13317 %}
13318 
13319 instruct jmpConUCF_short(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{
13320   match(If cop cmp);
13321   effect(USE labl);
13322 
13323   ins_cost(300);
13324   format %{ "J$cop,us $labl" %}
13325   size(2);
13326   opcode(0x70);
13327   ins_encode( JccShort( cop, labl) );
13328   ins_pipe( pipe_jcc );

13329   ins_short_branch(1);
13330 %}
13331 
13332 instruct jmpConUCF2_short(cmpOpUCF2 cop, eFlagsRegUCF cmp, label labl) %{
13333   match(If cop cmp);
13334   effect(USE labl);
13335 
13336   ins_cost(300);
13337   format %{ $$template
13338     if ($cop$$cmpcode == Assembler::notEqual) {
13339       $$emit$$"JP,u,s   $labl\n\t"
13340       $$emit$$"J$cop,u,s   $labl"
13341     } else {
13342       $$emit$$"JP,u,s   done\n\t"
13343       $$emit$$"J$cop,u,s  $labl\n\t"
13344       $$emit$$"done:"
13345     }
13346   %}
13347   size(4);
13348   opcode(0x70);
13349   ins_encode %{
13350     Label* l = $labl$$label;
13351     emit_cc(cbuf, $primary, Assembler::parity);
13352     int parity_disp = -1;
13353     if ($cop$$cmpcode == Assembler::notEqual) {
13354       parity_disp = l->loc_pos() - (cbuf.insts_size() + 1);
13355     } else if ($cop$$cmpcode == Assembler::equal) {
13356       parity_disp = 2;
13357     } else {
13358       ShouldNotReachHere();
13359     }
13360     emit_d8(cbuf, parity_disp);
13361     emit_cc(cbuf, $primary, $cop$$cmpcode);
13362     int disp = l->loc_pos() - (cbuf.insts_size() + 1);
13363     emit_d8(cbuf, disp);
13364     assert(-128 <= disp && disp <= 127, "Displacement too large for short jmp");
13365     assert(-128 <= parity_disp && parity_disp <= 127, "Displacement too large for short jmp");
13366   %}
13367   ins_pipe(pipe_jcc);

13368   ins_short_branch(1);
13369 %}
13370 
13371 // ============================================================================
13372 // Long Compare
13373 //
13374 // Currently we hold longs in 2 registers.  Comparing such values efficiently
13375 // is tricky.  The flavor of compare used depends on whether we are testing
13376 // for LT, LE, or EQ.  For a simple LT test we can check just the sign bit.
13377 // The GE test is the negated LT test.  The LE test can be had by commuting
13378 // the operands (yielding a GE test) and then negating; negate again for the
13379 // GT test.  The EQ test is done by ORcc'ing the high and low halves, and the
13380 // NE test is negated from that.
13381 
13382 // Due to a shortcoming in the ADLC, it mixes up expressions like:
13383 // (foo (CmpI (CmpL X Y) 0)) and (bar (CmpI (CmpL X 0L) 0)).  Note the
13384 // difference between 'Y' and '0L'.  The tree-matches for the CmpI sections
13385 // are collapsed internally in the ADLC's dfa-gen code.  The match for
13386 // (CmpI (CmpL X Y) 0) is silently replaced with (CmpI (CmpL X 0L) 0) and the
13387 // foo match ends up with the wrong leaf.  One fix is to not match both


13820 
13821 
13822 // ============================================================================
13823 // Procedure Call/Return Instructions
13824 // Call Java Static Instruction
13825 // Note: If this code changes, the corresponding ret_addr_offset() and
13826 //       compute_padding() functions will have to be adjusted.
13827 instruct CallStaticJavaDirect(method meth) %{
13828   match(CallStaticJava);
13829   predicate(! ((CallStaticJavaNode*)n)->is_method_handle_invoke());
13830   effect(USE meth);
13831 
13832   ins_cost(300);
13833   format %{ "CALL,static " %}
13834   opcode(0xE8); /* E8 cd */
13835   ins_encode( pre_call_FPU,
13836               Java_Static_Call( meth ),
13837               call_epilog,
13838               post_call_FPU );
13839   ins_pipe( pipe_slow );

13840   ins_alignment(4);
13841 %}
13842 
13843 // Call Java Static Instruction (method handle version)
13844 // Note: If this code changes, the corresponding ret_addr_offset() and
13845 //       compute_padding() functions will have to be adjusted.
13846 instruct CallStaticJavaHandle(method meth, eBPRegP ebp_mh_SP_save) %{
13847   match(CallStaticJava);
13848   predicate(((CallStaticJavaNode*)n)->is_method_handle_invoke());
13849   effect(USE meth);
13850   // EBP is saved by all callees (for interpreter stack correction).
13851   // We use it here for a similar purpose, in {preserve,restore}_SP.
13852 
13853   ins_cost(300);
13854   format %{ "CALL,static/MethodHandle " %}
13855   opcode(0xE8); /* E8 cd */
13856   ins_encode( pre_call_FPU,
13857               preserve_SP,
13858               Java_Static_Call( meth ),
13859               restore_SP,
13860               call_epilog,
13861               post_call_FPU );
13862   ins_pipe( pipe_slow );

13863   ins_alignment(4);
13864 %}
13865 
13866 // Call Java Dynamic Instruction
13867 // Note: If this code changes, the corresponding ret_addr_offset() and
13868 //       compute_padding() functions will have to be adjusted.
13869 instruct CallDynamicJavaDirect(method meth) %{
13870   match(CallDynamicJava);
13871   effect(USE meth);
13872 
13873   ins_cost(300);
13874   format %{ "MOV    EAX,(oop)-1\n\t"
13875             "CALL,dynamic" %}
13876   opcode(0xE8); /* E8 cd */
13877   ins_encode( pre_call_FPU,
13878               Java_Dynamic_Call( meth ),
13879               call_epilog,
13880               post_call_FPU );
13881   ins_pipe( pipe_slow );

13882   ins_alignment(4);
13883 %}
13884 
13885 // Call Runtime Instruction
13886 instruct CallRuntimeDirect(method meth) %{
13887   match(CallRuntime );
13888   effect(USE meth);
13889 
13890   ins_cost(300);
13891   format %{ "CALL,runtime " %}
13892   opcode(0xE8); /* E8 cd */
13893   // Use FFREEs to clear entries in float stack
13894   ins_encode( pre_call_FPU,
13895               FFree_Float_Stack_All,
13896               Java_To_Runtime( meth ),
13897               post_call_FPU );
13898   ins_pipe( pipe_slow );

13899 %}
13900 
13901 // Call runtime without safepoint
13902 instruct CallLeafDirect(method meth) %{
13903   match(CallLeaf);
13904   effect(USE meth);
13905 
13906   ins_cost(300);
13907   format %{ "CALL_LEAF,runtime " %}
13908   opcode(0xE8); /* E8 cd */
13909   ins_encode( pre_call_FPU,
13910               FFree_Float_Stack_All,
13911               Java_To_Runtime( meth ),
13912               Verify_FPU_For_Leaf, post_call_FPU );
13913   ins_pipe( pipe_slow );

13914 %}
13915 
13916 instruct CallLeafNoFPDirect(method meth) %{
13917   match(CallLeafNoFP);
13918   effect(USE meth);
13919 
13920   ins_cost(300);
13921   format %{ "CALL_LEAF_NOFP,runtime " %}
13922   opcode(0xE8); /* E8 cd */
13923   ins_encode(Java_To_Runtime(meth));
13924   ins_pipe( pipe_slow );

13925 %}
13926 
13927 
13928 // Return Instruction
13929 // Remove the return address & jump to it.
13930 instruct Ret() %{
13931   match(Return);
13932   format %{ "RET" %}
13933   opcode(0xC3);
13934   ins_encode(OpcP);
13935   ins_pipe( pipe_jmp );
13936 %}
13937 
13938 // Tail Call; Jump from runtime stub to Java code.
13939 // Also known as an 'interprocedural jump'.
13940 // Target of jump will eventually return to caller.
13941 // TailJump below removes the return address.
13942 instruct TailCalljmpInd(eRegP_no_EBP jump_target, eBXRegP method_oop) %{
13943   match(TailCall jump_target method_oop );
13944   ins_cost(300);


13983 instruct RethrowException()
13984 %{
13985   match(Rethrow);
13986 
13987   // use the following format syntax
13988   format %{ "JMP    rethrow_stub" %}
13989   ins_encode(enc_rethrow);
13990   ins_pipe( pipe_jmp );
13991 %}
13992 
13993 // inlined locking and unlocking
13994 
13995 
13996 instruct cmpFastLock( eFlagsReg cr, eRegP object, eRegP box, eAXRegI tmp, eRegP scr) %{
13997   match( Set cr (FastLock object box) );
13998   effect( TEMP tmp, TEMP scr );
13999   ins_cost(300);
14000   format %{ "FASTLOCK $object, $box KILLS $tmp,$scr" %}
14001   ins_encode( Fast_Lock(object,box,tmp,scr) );
14002   ins_pipe( pipe_slow );

14003 %}
14004 
14005 instruct cmpFastUnlock( eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{
14006   match( Set cr (FastUnlock object box) );
14007   effect( TEMP tmp );
14008   ins_cost(300);
14009   format %{ "FASTUNLOCK $object, $box, $tmp" %}
14010   ins_encode( Fast_Unlock(object,box,tmp) );
14011   ins_pipe( pipe_slow );

14012 %}
14013 
14014 
14015 
14016 // ============================================================================
14017 // Safepoint Instruction
14018 instruct safePoint_poll(eFlagsReg cr) %{
14019   match(SafePoint);
14020   effect(KILL cr);
14021 
14022   // TODO-FIXME: we currently poll at offset 0 of the safepoint polling page.
14023   // On SPARC that might be acceptable as we can generate the address with
14024   // just a sethi, saving an or.  By polling at offset 0 we can end up
14025   // putting additional pressure on the index-0 in the D$.  Because of
14026   // alignment (just like the situation at hand) the lower indices tend
14027   // to see more traffic.  It'd be better to change the polling address
14028   // to offset 0 of the last $line in the polling page.
14029 
14030   format %{ "TSTL   #polladdr,EAX\t! Safepoint: poll for GC" %}
14031   ins_cost(125);


src/cpu/x86/vm/x86_32.ad
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File