hotspot/src/cpu/ppc/vm/ppc.ad
changeset 30303 c703c89fddbf
parent 29581 b8d83fef0c8e
child 30758 97072ce7c6fe
equal deleted inserted replaced
30302:ecca632210ef 30303:c703c89fddbf
   445   R24,
   445   R24,
   446   R25,
   446   R25,
   447   R26,
   447   R26,
   448   R27,
   448   R27,
   449   R28,
   449   R28,
   450 /*R29*/             // global TOC
   450 /*R29,*/             // global TOC
   451 /*R30*/             // Narrow Oop Base
   451   R30,
   452   R31
   452   R31
   453 );
   453 );
   454 
   454 
   455 // 32 bit registers that can only be read i.e. these registers can
   455 // 32 bit registers that can only be read i.e. these registers can
   456 // only be src of all instructions.
   456 // only be src of all instructions.
   482   R24,
   482   R24,
   483   R25,
   483   R25,
   484   R26,
   484   R26,
   485   R27,
   485   R27,
   486   R28,
   486   R28,
   487 /*R29*/
   487 /*R29,*/
   488 /*R30*/             // Narrow Oop Base
   488   R30,
   489   R31
   489   R31
   490 );
       
   491 
       
   492 // Complement-required-in-pipeline operands for narrow oops.
       
   493 reg_class bits32_reg_ro_not_complement (
       
   494 /*R0*/     // R0
       
   495   R1,      // SP
       
   496   R2,      // TOC
       
   497   R3,
       
   498   R4,
       
   499   R5,
       
   500   R6,
       
   501   R7,
       
   502   R8,
       
   503   R9,
       
   504   R10,
       
   505   R11,
       
   506   R12,
       
   507 /*R13,*/   // system thread id
       
   508   R14,
       
   509   R15,
       
   510   R16,    // R16_thread
       
   511   R17,
       
   512   R18,
       
   513   R19,
       
   514   R20,
       
   515   R21,
       
   516   R22,
       
   517 /*R23,
       
   518   R24,
       
   519   R25,
       
   520   R26,
       
   521   R27,
       
   522   R28,*/
       
   523 /*R29,*/ // TODO: let allocator handle TOC!!
       
   524 /*R30,*/
       
   525   R31
       
   526 );
       
   527 
       
   528 // Complement-required-in-pipeline operands for narrow oops.
       
   529 // See 64-bit declaration.
       
   530 reg_class bits32_reg_ro_complement (
       
   531   R23,
       
   532   R24,
       
   533   R25,
       
   534   R26,
       
   535   R27,
       
   536   R28
       
   537 );
   490 );
   538 
   491 
   539 reg_class rscratch1_bits32_reg(R11);
   492 reg_class rscratch1_bits32_reg(R11);
   540 reg_class rscratch2_bits32_reg(R12);
   493 reg_class rscratch2_bits32_reg(R12);
   541 reg_class rarg1_bits32_reg(R3);
   494 reg_class rarg1_bits32_reg(R3);
   589   R24_H, R24,
   542   R24_H, R24,
   590   R25_H, R25,
   543   R25_H, R25,
   591   R26_H, R26,
   544   R26_H, R26,
   592   R27_H, R27,
   545   R27_H, R27,
   593   R28_H, R28,
   546   R28_H, R28,
   594 /*R29_H, R29*/
   547 /*R29_H, R29,*/
   595 /*R30_H, R30*/
   548   R30_H, R30,
   596   R31_H, R31
   549   R31_H, R31
   597 );
   550 );
   598 
   551 
   599 // 64 bit registers used excluding r2, r11 and r12
   552 // 64 bit registers used excluding r2, r11 and r12
   600 // Used to hold the TOC to avoid collisions with expanded LeafCall which uses
   553 // Used to hold the TOC to avoid collisions with expanded LeafCall which uses
   627   R24_H, R24,
   580   R24_H, R24,
   628   R25_H, R25,
   581   R25_H, R25,
   629   R26_H, R26,
   582   R26_H, R26,
   630   R27_H, R27,
   583   R27_H, R27,
   631   R28_H, R28,
   584   R28_H, R28,
   632 /*R29_H, R29*/
   585 /*R29_H, R29,*/
   633 /*R30_H, R30*/
   586   R30_H, R30,
   634   R31_H, R31
   587   R31_H, R31
   635 );
   588 );
   636 
   589 
   637 // Used to hold the TOC to avoid collisions with expanded DynamicCall
   590 // Used to hold the TOC to avoid collisions with expanded DynamicCall
   638 // which uses r19 as inline cache internally and expanded LeafCall which uses
   591 // which uses r19 as inline cache internally and expanded LeafCall which uses
   665   R24_H, R24,
   618   R24_H, R24,
   666   R25_H, R25,
   619   R25_H, R25,
   667   R26_H, R26,
   620   R26_H, R26,
   668   R27_H, R27,
   621   R27_H, R27,
   669   R28_H, R28,
   622   R28_H, R28,
   670 /*R29_H, R29*/
   623 /*R29_H, R29,*/
   671 /*R30_H, R30*/
   624   R30_H, R30,
   672   R31_H, R31
   625   R31_H, R31
   673 );
   626 );
   674 
   627 
   675 // 64 bit registers that can only be read i.e. these registers can
   628 // 64 bit registers that can only be read i.e. these registers can
   676 // only be src of all instructions.
   629 // only be src of all instructions.
   702   R24_H, R24,
   655   R24_H, R24,
   703   R25_H, R25,
   656   R25_H, R25,
   704   R26_H, R26,
   657   R26_H, R26,
   705   R27_H, R27,
   658   R27_H, R27,
   706   R28_H, R28,
   659   R28_H, R28,
   707 /*R29_H, R29*/ // TODO: let allocator handle TOC!!
   660 /*R29_H, R29,*/ // TODO: let allocator handle TOC!!
   708 /*R30_H, R30,*/
   661   R30_H, R30,
   709   R31_H, R31
   662   R31_H, R31
   710 );
       
   711 
       
   712 // Complement-required-in-pipeline operands.
       
   713 reg_class bits64_reg_ro_not_complement (
       
   714 /*R0_H,  R0*/     // R0
       
   715   R1_H,  R1,      // SP
       
   716   R2_H,  R2,      // TOC
       
   717   R3_H,  R3,
       
   718   R4_H,  R4,
       
   719   R5_H,  R5,
       
   720   R6_H,  R6,
       
   721   R7_H,  R7,
       
   722   R8_H,  R8,
       
   723   R9_H,  R9,
       
   724   R10_H, R10,
       
   725   R11_H, R11,
       
   726   R12_H, R12,
       
   727 /*R13_H, R13*/   // system thread id
       
   728   R14_H, R14,
       
   729   R15_H, R15,
       
   730   R16_H, R16,    // R16_thread
       
   731   R17_H, R17,
       
   732   R18_H, R18,
       
   733   R19_H, R19,
       
   734   R20_H, R20,
       
   735   R21_H, R21,
       
   736   R22_H, R22,
       
   737 /*R23_H, R23,
       
   738   R24_H, R24,
       
   739   R25_H, R25,
       
   740   R26_H, R26,
       
   741   R27_H, R27,
       
   742   R28_H, R28,*/
       
   743 /*R29_H, R29*/ // TODO: let allocator handle TOC!!
       
   744 /*R30_H, R30,*/
       
   745   R31_H, R31
       
   746 );
       
   747 
       
   748 // Complement-required-in-pipeline operands.
       
   749 // This register mask is used for the trap instructions that implement
       
   750 // the null checks on AIX. The trap instruction first computes the
       
   751 // complement of the value it shall trap on. Because of this, the
       
   752 // instruction can not be scheduled in the same cycle as an other
       
   753 // instruction reading the normal value of the same register. So we
       
   754 // force the value to check into 'bits64_reg_ro_not_complement'
       
   755 // and then copy it to 'bits64_reg_ro_complement' for the trap.
       
   756 reg_class bits64_reg_ro_complement (
       
   757   R23_H, R23,
       
   758   R24_H, R24,
       
   759   R25_H, R25,
       
   760   R26_H, R26,
       
   761   R27_H, R27,
       
   762   R28_H, R28
       
   763 );
   663 );
   764 
   664 
   765 
   665 
   766 // ----------------------------
   666 // ----------------------------
   767 // Special Class for Condition Code Flags Register
   667 // Special Class for Condition Code Flags Register
   770 /*CCR0*/             // scratch
   670 /*CCR0*/             // scratch
   771 /*CCR1*/             // scratch
   671 /*CCR1*/             // scratch
   772 /*CCR2*/             // nv!
   672 /*CCR2*/             // nv!
   773 /*CCR3*/             // nv!
   673 /*CCR3*/             // nv!
   774 /*CCR4*/             // nv!
   674 /*CCR4*/             // nv!
       
   675   CCR5,
       
   676   CCR6,
       
   677   CCR7
       
   678 );
       
   679 
       
   680 reg_class int_flags_ro(
       
   681   CCR0,
       
   682   CCR1,
       
   683   CCR2,
       
   684   CCR3,
       
   685   CCR4,
   775   CCR5,
   686   CCR5,
   776   CCR6,
   687   CCR6,
   777   CCR7
   688   CCR7
   778 );
   689 );
   779 
   690 
  2874     __ stfd($src$$FloatRegister, Idisp, $mem$$base$$Register);
  2785     __ stfd($src$$FloatRegister, Idisp, $mem$$base$$Register);
  2875   %}
  2786   %}
  2876 
  2787 
  2877   // Use release_store for card-marking to ensure that previous
  2788   // Use release_store for card-marking to ensure that previous
  2878   // oop-stores are visible before the card-mark change.
  2789   // oop-stores are visible before the card-mark change.
  2879   enc_class enc_cms_card_mark(memory mem, iRegLdst releaseFieldAddr) %{
  2790   enc_class enc_cms_card_mark(memory mem, iRegLdst releaseFieldAddr, flagsReg crx) %{
  2880     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  2791     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  2881     // FIXME: Implement this as a cmove and use a fixed condition code
  2792     // FIXME: Implement this as a cmove and use a fixed condition code
  2882     // register which is written on every transition to compiled code,
  2793     // register which is written on every transition to compiled code,
  2883     // e.g. in call-stub and when returning from runtime stubs.
  2794     // e.g. in call-stub and when returning from runtime stubs.
  2884     //
  2795     //
  2895 
  2806 
  2896 #if 0 // TODO: PPC port
  2807 #if 0 // TODO: PPC port
  2897     // Check CMSCollectorCardTableModRefBSExt::_requires_release and do the
  2808     // Check CMSCollectorCardTableModRefBSExt::_requires_release and do the
  2898     // StoreStore barrier conditionally.
  2809     // StoreStore barrier conditionally.
  2899     __ lwz(R0, 0, $releaseFieldAddr$$Register);
  2810     __ lwz(R0, 0, $releaseFieldAddr$$Register);
  2900     __ cmpwi(CCR0, R0, 0);
  2811     __ cmpwi($crx$$CondRegister, R0, 0);
  2901     __ beq_predict_taken(CCR0, skip_storestore);
  2812     __ beq_predict_taken($crx$$CondRegister, skip_storestore);
  2902 #endif
  2813 #endif
  2903     __ li(R0, 0);
  2814     __ li(R0, 0);
  2904     __ membar(Assembler::StoreStore);
  2815     __ membar(Assembler::StoreStore);
  2905 #if 0 // TODO: PPC port
  2816 #if 0 // TODO: PPC port
  2906     __ bind(skip_storestore);
  2817     __ bind(skip_storestore);
  3106 
  3017 
  3107     nodes->push(n1);
  3018     nodes->push(n1);
  3108     nodes->push(n2);
  3019     nodes->push(n2);
  3109   %}
  3020   %}
  3110 
  3021 
  3111   enc_class enc_cmove_reg(iRegIdst dst, flagsReg crx, iRegIsrc src, cmpOp cmp) %{
  3022   enc_class enc_cmove_reg(iRegIdst dst, flagsRegSrc crx, iRegIsrc src, cmpOp cmp) %{
  3112     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
  3023     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
  3113 
  3024 
  3114     MacroAssembler _masm(&cbuf);
  3025     MacroAssembler _masm(&cbuf);
  3115     int cc        = $cmp$$cmpcode;
  3026     int cc        = $cmp$$cmpcode;
  3116     int flags_reg = $crx$$reg;
  3027     int flags_reg = $crx$$reg;
  3121     __ mr($dst$$Register, $src$$Register);
  3032     __ mr($dst$$Register, $src$$Register);
  3122     // TODO PPC port __ endgroup_if_needed(_size == 12);
  3033     // TODO PPC port __ endgroup_if_needed(_size == 12);
  3123     __ bind(done);
  3034     __ bind(done);
  3124   %}
  3035   %}
  3125 
  3036 
  3126   enc_class enc_cmove_imm(iRegIdst dst, flagsReg crx, immI16 src, cmpOp cmp) %{
  3037   enc_class enc_cmove_imm(iRegIdst dst, flagsRegSrc crx, immI16 src, cmpOp cmp) %{
  3127     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
  3038     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
  3128 
  3039 
  3129     MacroAssembler _masm(&cbuf);
  3040     MacroAssembler _masm(&cbuf);
  3130     Label done;
  3041     Label done;
  3131     assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding");
  3042     assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding");
  3267     __ beq($crx$$CondRegister, done);
  3178     __ beq($crx$$CondRegister, done);
  3268     __ li($dst$$Register, $notzero$$constant);
  3179     __ li($dst$$Register, $notzero$$constant);
  3269     __ bind(done);
  3180     __ bind(done);
  3270   %}
  3181   %}
  3271 
  3182 
  3272   enc_class enc_cmove_bso_stackSlotL(iRegLdst dst, flagsReg crx, stackSlotL mem ) %{
  3183   enc_class enc_cmove_bso_stackSlotL(iRegLdst dst, flagsRegSrc crx, stackSlotL mem ) %{
  3273     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
  3184     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
  3274 
  3185 
  3275     MacroAssembler _masm(&cbuf);
  3186     MacroAssembler _masm(&cbuf);
  3276     int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_);
  3187     int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_);
  3277     Label done;
  3188     Label done;
  3279     __ ld($dst$$Register, Idisp, $mem$$base$$Register);
  3190     __ ld($dst$$Register, Idisp, $mem$$base$$Register);
  3280     // TODO PPC port __ endgroup_if_needed(_size == 12);
  3191     // TODO PPC port __ endgroup_if_needed(_size == 12);
  3281     __ bind(done);
  3192     __ bind(done);
  3282   %}
  3193   %}
  3283 
  3194 
  3284   enc_class enc_bc(flagsReg crx, cmpOp cmp, Label lbl) %{
  3195   enc_class enc_bc(flagsRegSrc crx, cmpOp cmp, Label lbl) %{
  3285     // TODO: PPC port $archOpcode(ppc64Opcode_bc);
  3196     // TODO: PPC port $archOpcode(ppc64Opcode_bc);
  3286 
  3197 
  3287     MacroAssembler _masm(&cbuf);
  3198     MacroAssembler _masm(&cbuf);
  3288     Label d;   // dummy
  3199     Label d;   // dummy
  3289     __ bind(d);
  3200     __ bind(d);
  3307     __ bc(Assembler::add_bhint_to_boint(bhint, cc_to_boint(cc)),
  3218     __ bc(Assembler::add_bhint_to_boint(bhint, cc_to_boint(cc)),
  3308           cc_to_biint(cc, flags_reg),
  3219           cc_to_biint(cc, flags_reg),
  3309           l);
  3220           l);
  3310   %}
  3221   %}
  3311 
  3222 
  3312   enc_class enc_bc_far(flagsReg crx, cmpOp cmp, Label lbl) %{
  3223   enc_class enc_bc_far(flagsRegSrc crx, cmpOp cmp, Label lbl) %{
  3313     // The scheduler doesn't know about branch shortening, so we set the opcode
  3224     // The scheduler doesn't know about branch shortening, so we set the opcode
  3314     // to ppc64Opcode_bc in order to hide this detail from the scheduler.
  3225     // to ppc64Opcode_bc in order to hide this detail from the scheduler.
  3315     // TODO: PPC port $archOpcode(ppc64Opcode_bc);
  3226     // TODO: PPC port $archOpcode(ppc64Opcode_bc);
  3316 
  3227 
  3317     MacroAssembler _masm(&cbuf);
  3228     MacroAssembler _masm(&cbuf);
  3339                   l,
  3250                   l,
  3340                   MacroAssembler::bc_far_optimize_on_relocate);
  3251                   MacroAssembler::bc_far_optimize_on_relocate);
  3341   %}
  3252   %}
  3342 
  3253 
  3343   // Branch used with Power6 scheduling (can be shortened without changing the node).
  3254   // Branch used with Power6 scheduling (can be shortened without changing the node).
  3344   enc_class enc_bc_short_far(flagsReg crx, cmpOp cmp, Label lbl) %{
  3255   enc_class enc_bc_short_far(flagsRegSrc crx, cmpOp cmp, Label lbl) %{
  3345     // The scheduler doesn't know about branch shortening, so we set the opcode
  3256     // The scheduler doesn't know about branch shortening, so we set the opcode
  3346     // to ppc64Opcode_bc in order to hide this detail from the scheduler.
  3257     // to ppc64Opcode_bc in order to hide this detail from the scheduler.
  3347     // TODO: PPC port $archOpcode(ppc64Opcode_bc);
  3258     // TODO: PPC port $archOpcode(ppc64Opcode_bc);
  3348 
  3259 
  3349     MacroAssembler _masm(&cbuf);
  3260     MacroAssembler _masm(&cbuf);
  4698   match(RegFlags);
  4609   match(RegFlags);
  4699   format %{ %}
  4610   format %{ %}
  4700   interface(REG_INTER);
  4611   interface(REG_INTER);
  4701 %}
  4612 %}
  4702 
  4613 
       
  4614 operand flagsRegSrc() %{
       
  4615   constraint(ALLOC_IN_RC(int_flags_ro));
       
  4616   match(RegFlags);
       
  4617   match(flagsReg);
       
  4618   match(flagsRegCR0);
       
  4619   format %{ %}
       
  4620   interface(REG_INTER);
       
  4621 %}
       
  4622 
  4703 // Condition Code Flag Register CR0
  4623 // Condition Code Flag Register CR0
  4704 operand flagsRegCR0() %{
  4624 operand flagsRegCR0() %{
  4705   constraint(ALLOC_IN_RC(int_flags_CR0));
  4625   constraint(ALLOC_IN_RC(int_flags_CR0));
  4706   match(RegFlags);
  4626   match(RegFlags);
  4707   format %{ "CR0" %}
  4627   format %{ "CR0" %}
  4781 
  4701 
  4782 operand iRegN2P(iRegNsrc reg) %{
  4702 operand iRegN2P(iRegNsrc reg) %{
  4783   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4703   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4784   constraint(ALLOC_IN_RC(bits32_reg_ro));
  4704   constraint(ALLOC_IN_RC(bits32_reg_ro));
  4785   match(DecodeN reg);
  4705   match(DecodeN reg);
       
  4706   format %{ "$reg" %}
       
  4707   interface(REG_INTER)
       
  4708 %}
       
  4709 
       
  4710 operand iRegN2P_klass(iRegNsrc reg) %{
       
  4711   predicate(Universe::narrow_klass_base() == NULL && Universe::narrow_klass_shift() == 0);
       
  4712   constraint(ALLOC_IN_RC(bits32_reg_ro));
  4786   match(DecodeNKlass reg);
  4713   match(DecodeNKlass reg);
  4787   format %{ "$reg" %}
  4714   format %{ "$reg" %}
  4788   interface(REG_INTER)
  4715   interface(REG_INTER)
  4789 %}
  4716 %}
  4790 
  4717 
  4837 // Indirect Memory Reference, compressed OOP
  4764 // Indirect Memory Reference, compressed OOP
  4838 operand indirectNarrow(iRegNsrc reg) %{
  4765 operand indirectNarrow(iRegNsrc reg) %{
  4839   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4766   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4840   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4767   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4841   match(DecodeN reg);
  4768   match(DecodeN reg);
       
  4769   op_cost(100);
       
  4770   format %{ "[$reg]" %}
       
  4771   interface(MEMORY_INTER) %{
       
  4772     base($reg);
       
  4773     index(0x0);
       
  4774     scale(0x0);
       
  4775     disp(0x0);
       
  4776   %}
       
  4777 %}
       
  4778 
       
  4779 operand indirectNarrow_klass(iRegNsrc reg) %{
       
  4780   predicate(Universe::narrow_klass_base() == NULL && Universe::narrow_klass_shift() == 0);
       
  4781   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4842   match(DecodeNKlass reg);
  4782   match(DecodeNKlass reg);
  4843   op_cost(100);
  4783   op_cost(100);
  4844   format %{ "[$reg]" %}
  4784   format %{ "[$reg]" %}
  4845   interface(MEMORY_INTER) %{
  4785   interface(MEMORY_INTER) %{
  4846     base($reg);
  4786     base($reg);
  4853 // Indirect with Offset, compressed OOP
  4793 // Indirect with Offset, compressed OOP
  4854 operand indOffset16Narrow(iRegNsrc reg, immL16 offset) %{
  4794 operand indOffset16Narrow(iRegNsrc reg, immL16 offset) %{
  4855   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4795   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4856   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4796   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4857   match(AddP (DecodeN reg) offset);
  4797   match(AddP (DecodeN reg) offset);
       
  4798   op_cost(100);
       
  4799   format %{ "[$reg + $offset]" %}
       
  4800   interface(MEMORY_INTER) %{
       
  4801     base($reg);
       
  4802     index(0x0);
       
  4803     scale(0x0);
       
  4804     disp($offset);
       
  4805   %}
       
  4806 %}
       
  4807 
       
  4808 operand indOffset16Narrow_klass(iRegNsrc reg, immL16 offset) %{
       
  4809   predicate(Universe::narrow_klass_base() == NULL && Universe::narrow_klass_shift() == 0);
       
  4810   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4858   match(AddP (DecodeNKlass reg) offset);
  4811   match(AddP (DecodeNKlass reg) offset);
  4859   op_cost(100);
  4812   op_cost(100);
  4860   format %{ "[$reg + $offset]" %}
  4813   format %{ "[$reg + $offset]" %}
  4861   interface(MEMORY_INTER) %{
  4814   interface(MEMORY_INTER) %{
  4862     base($reg);
  4815     base($reg);
  4869 // Indirect with 4-aligned Offset, compressed OOP
  4822 // Indirect with 4-aligned Offset, compressed OOP
  4870 operand indOffset16NarrowAlg4(iRegNsrc reg, immL16Alg4 offset) %{
  4823 operand indOffset16NarrowAlg4(iRegNsrc reg, immL16Alg4 offset) %{
  4871   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4824   predicate(false /* TODO: PPC port MatchDecodeNodes*/);
  4872   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4825   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4873   match(AddP (DecodeN reg) offset);
  4826   match(AddP (DecodeN reg) offset);
       
  4827   op_cost(100);
       
  4828   format %{ "[$reg + $offset]" %}
       
  4829   interface(MEMORY_INTER) %{
       
  4830     base($reg);
       
  4831     index(0x0);
       
  4832     scale(0x0);
       
  4833     disp($offset);
       
  4834   %}
       
  4835 %}
       
  4836 
       
  4837 operand indOffset16NarrowAlg4_klass(iRegNsrc reg, immL16Alg4 offset) %{
       
  4838   predicate(Universe::narrow_klass_base() == NULL && Universe::narrow_klass_shift() == 0);
       
  4839   constraint(ALLOC_IN_RC(bits64_reg_ro));
  4874   match(AddP (DecodeNKlass reg) offset);
  4840   match(AddP (DecodeNKlass reg) offset);
  4875   op_cost(100);
  4841   op_cost(100);
  4876   format %{ "[$reg + $offset]" %}
  4842   format %{ "[$reg + $offset]" %}
  4877   interface(MEMORY_INTER) %{
  4843   interface(MEMORY_INTER) %{
  4878     base($reg);
  4844     base($reg);
  4996 // seperate instructions for every form of operand when the
  4962 // seperate instructions for every form of operand when the
  4997 // instruction accepts multiple operand types with the same basic
  4963 // instruction accepts multiple operand types with the same basic
  4998 // encoding and format. The classic case of this is memory operands.
  4964 // encoding and format. The classic case of this is memory operands.
  4999 // Indirect is not included since its use is limited to Compare & Swap.
  4965 // Indirect is not included since its use is limited to Compare & Swap.
  5000 
  4966 
  5001 opclass memory(indirect, indOffset16 /*, indIndex, tlsReference*/, indirectNarrow, indOffset16Narrow);
  4967 opclass memory(indirect, indOffset16 /*, indIndex, tlsReference*/, indirectNarrow, indirectNarrow_klass, indOffset16Narrow, indOffset16Narrow_klass);
  5002 // Memory operand where offsets are 4-aligned. Required for ld, std.
  4968 // Memory operand where offsets are 4-aligned. Required for ld, std.
  5003 opclass memoryAlg4(indirect, indOffset16Alg4, indirectNarrow, indOffset16NarrowAlg4);
  4969 opclass memoryAlg4(indirect, indOffset16Alg4, indirectNarrow, indOffset16NarrowAlg4, indOffset16NarrowAlg4_klass);
  5004 opclass indirectMemory(indirect, indirectNarrow);
  4970 opclass indirectMemory(indirect, indirectNarrow);
  5005 
  4971 
  5006 // Special opclass for I and ConvL2I.
  4972 // Special opclass for I and ConvL2I.
  5007 opclass iRegIsrc_iRegL2Isrc(iRegIsrc, iRegL2Isrc);
  4973 opclass iRegIsrc_iRegL2Isrc(iRegIsrc, iRegL2Isrc);
  5008 
  4974 
  5009 // Operand classes to match encode and decode. iRegN_P2N is only used
  4975 // Operand classes to match encode and decode. iRegN_P2N is only used
  5010 // for storeN. I have never seen an encode node elsewhere.
  4976 // for storeN. I have never seen an encode node elsewhere.
  5011 opclass iRegN_P2N(iRegNsrc, iRegP2N);
  4977 opclass iRegN_P2N(iRegNsrc, iRegP2N);
  5012 opclass iRegP_N2P(iRegPsrc, iRegN2P);
  4978 opclass iRegP_N2P(iRegPsrc, iRegN2P, iRegN2P_klass);
  5013 
  4979 
  5014 //----------PIPELINE-----------------------------------------------------------
  4980 //----------PIPELINE-----------------------------------------------------------
  5015 
  4981 
  5016 pipeline %{
  4982 pipeline %{
  5017 
  4983 
  5591   size(4);
  5557   size(4);
  5592   ins_encode( enc_lwz(dst, mem) );
  5558   ins_encode( enc_lwz(dst, mem) );
  5593   ins_pipe(pipe_class_memory);
  5559   ins_pipe(pipe_class_memory);
  5594 %}
  5560 %}
  5595 
  5561 
       
  5562 instruct loadN2P_klass_unscaled(iRegPdst dst, memory mem) %{
       
  5563   match(Set dst (DecodeNKlass (LoadNKlass mem)));
       
  5564   // SAPJVM GL 2014-05-21 Differs.
       
  5565   predicate(Universe::narrow_klass_base() == NULL && Universe::narrow_klass_shift() == 0 &&
       
  5566             _kids[0]->_leaf->as_Load()->is_unordered());
       
  5567   ins_cost(MEMORY_REF_COST);
       
  5568 
       
  5569   format %{ "LWZ     $dst, $mem \t// DecodeN (unscaled)" %}
       
  5570   size(4);
       
  5571   ins_encode( enc_lwz(dst, mem) );
       
  5572   ins_pipe(pipe_class_memory);
       
  5573 %}
       
  5574 
  5596 // Load Pointer
  5575 // Load Pointer
  5597 instruct loadP(iRegPdst dst, memoryAlg4 mem) %{
  5576 instruct loadP(iRegPdst dst, memoryAlg4 mem) %{
  5598   match(Set dst (LoadP mem));
  5577   match(Set dst (LoadP mem));
  5599   predicate(n->as_Load()->is_unordered() || followed_by_acquire(n));
  5578   predicate(n->as_Load()->is_unordered() || followed_by_acquire(n));
  5600   ins_cost(MEMORY_REF_COST);
  5579   ins_cost(MEMORY_REF_COST);
  5667   %}
  5646   %}
  5668   ins_pipe(pipe_class_memory);
  5647   ins_pipe(pipe_class_memory);
  5669 %}
  5648 %}
  5670 
  5649 
  5671 // Load Float acquire.
  5650 // Load Float acquire.
  5672 instruct loadF_ac(regF dst, memory mem) %{
  5651 instruct loadF_ac(regF dst, memory mem, flagsRegCR0 cr0) %{
  5673   match(Set dst (LoadF mem));
  5652   match(Set dst (LoadF mem));
       
  5653   effect(TEMP cr0);
  5674   ins_cost(3*MEMORY_REF_COST);
  5654   ins_cost(3*MEMORY_REF_COST);
  5675 
  5655 
  5676   format %{ "LFS     $dst, $mem \t// acquire\n\t"
  5656   format %{ "LFS     $dst, $mem \t// acquire\n\t"
  5677             "FCMPU   cr0, $dst, $dst\n\t"
  5657             "FCMPU   cr0, $dst, $dst\n\t"
  5678             "BNE     cr0, next\n"
  5658             "BNE     cr0, next\n"
  5703   ins_encode( enc_lfd(dst, mem) );
  5683   ins_encode( enc_lfd(dst, mem) );
  5704   ins_pipe(pipe_class_memory);
  5684   ins_pipe(pipe_class_memory);
  5705 %}
  5685 %}
  5706 
  5686 
  5707 // Load Double - aligned acquire.
  5687 // Load Double - aligned acquire.
  5708 instruct loadD_ac(regD dst, memory mem) %{
  5688 instruct loadD_ac(regD dst, memory mem, flagsRegCR0 cr0) %{
  5709   match(Set dst (LoadD mem));
  5689   match(Set dst (LoadD mem));
       
  5690   effect(TEMP cr0);
  5710   ins_cost(3*MEMORY_REF_COST);
  5691   ins_cost(3*MEMORY_REF_COST);
  5711 
  5692 
  5712   format %{ "LFD     $dst, $mem \t// acquire\n\t"
  5693   format %{ "LFD     $dst, $mem \t// acquire\n\t"
  5713             "FCMPU   cr0, $dst, $dst\n\t"
  5694             "FCMPU   cr0, $dst, $dst\n\t"
  5714             "BNE     cr0, next\n"
  5695             "BNE     cr0, next\n"
  6032 // Optimize DecodeN for disjoint base.
  6013 // Optimize DecodeN for disjoint base.
  6033 // Load base of compressed oops into a register
  6014 // Load base of compressed oops into a register
  6034 instruct loadBase(iRegLdst dst) %{
  6015 instruct loadBase(iRegLdst dst) %{
  6035   effect(DEF dst);
  6016   effect(DEF dst);
  6036 
  6017 
  6037   format %{ "MR      $dst, r30_heapbase" %}
  6018   format %{ "LoadConst $dst, heapbase" %}
  6038   size(4);
  6019   ins_encode %{
  6039   ins_encode %{
  6020     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  6040     // TODO: PPC port $archOpcode(ppc64Opcode_or);
  6021     __ load_const_optimized($dst$$Register, Universe::narrow_oop_base(), R0);
  6041     __ mr($dst$$Register, R30);
       
  6042   %}
  6022   %}
  6043   ins_pipe(pipe_class_default);
  6023   ins_pipe(pipe_class_default);
  6044 %}
  6024 %}
  6045 
  6025 
  6046 // Loading ConN must be postalloc expanded so that edges between
  6026 // Loading ConN must be postalloc expanded so that edges between
  6112 instruct loadConNKlass_lo(iRegNdst dst, immNKlass_NM src1, iRegNsrc src2) %{
  6092 instruct loadConNKlass_lo(iRegNdst dst, immNKlass_NM src1, iRegNsrc src2) %{
  6113   match(Set dst src1);
  6093   match(Set dst src1);
  6114   effect(TEMP src2);
  6094   effect(TEMP src2);
  6115   ins_cost(DEFAULT_COST);
  6095   ins_cost(DEFAULT_COST);
  6116 
  6096 
  6117   format %{ "ORI    $dst, $src1, $src2 \t// narrow klass lo" %}
  6097   format %{ "ORI     $dst, $src1, $src2 \t// narrow klass lo" %}
  6118   size(4);
  6098   size(4);
  6119   ins_encode %{
  6099   ins_encode %{
  6120     // TODO: PPC port $archOpcode(ppc64Opcode_ori);
  6100     // TODO: PPC port $archOpcode(ppc64Opcode_ori);
  6121     intptr_t Csrc = Klass::encode_klass((Klass *)$src1$$constant);
  6101     intptr_t Csrc = Klass::encode_klass((Klass *)$src1$$constant);
  6122     assert(__ oop_recorder() != NULL, "this assembler needs an OopRecorder");
  6102     assert(__ oop_recorder() != NULL, "this assembler needs an OopRecorder");
  6561 // Card-mark for CMS garbage collection.
  6541 // Card-mark for CMS garbage collection.
  6562 // This cardmark does an optimization so that it must not always
  6542 // This cardmark does an optimization so that it must not always
  6563 // do a releasing store. For this, it gets the address of
  6543 // do a releasing store. For this, it gets the address of
  6564 // CMSCollectorCardTableModRefBSExt::_requires_release as input.
  6544 // CMSCollectorCardTableModRefBSExt::_requires_release as input.
  6565 // (Using releaseFieldAddr in the match rule is a hack.)
  6545 // (Using releaseFieldAddr in the match rule is a hack.)
  6566 instruct storeCM_CMS(memory mem, iRegLdst releaseFieldAddr) %{
  6546 instruct storeCM_CMS(memory mem, iRegLdst releaseFieldAddr, flagsReg crx) %{
  6567   match(Set mem (StoreCM mem releaseFieldAddr));
  6547   match(Set mem (StoreCM mem releaseFieldAddr));
       
  6548   effect(TEMP crx);
  6568   predicate(false);
  6549   predicate(false);
  6569   ins_cost(MEMORY_REF_COST);
  6550   ins_cost(MEMORY_REF_COST);
  6570 
  6551 
  6571   // See loadConP.
  6552   // See loadConP.
  6572   ins_cannot_rematerialize(true);
  6553   ins_cannot_rematerialize(true);
  6573 
  6554 
  6574   format %{ "STB     #0, $mem \t// CMS card-mark byte (must be 0!), checking requires_release in [$releaseFieldAddr]" %}
  6555   format %{ "STB     #0, $mem \t// CMS card-mark byte (must be 0!), checking requires_release in [$releaseFieldAddr]" %}
  6575   ins_encode( enc_cms_card_mark(mem, releaseFieldAddr) );
  6556   ins_encode( enc_cms_card_mark(mem, releaseFieldAddr, crx) );
  6576   ins_pipe(pipe_class_memory);
  6557   ins_pipe(pipe_class_memory);
  6577 %}
  6558 %}
  6578 
  6559 
  6579 // Card-mark for CMS garbage collection.
  6560 // Card-mark for CMS garbage collection.
  6580 // This cardmark does an optimization so that it must not always
  6561 // This cardmark does an optimization so that it must not always
  6587   predicate(UseConcMarkSweepGC);
  6568   predicate(UseConcMarkSweepGC);
  6588 
  6569 
  6589   expand %{
  6570   expand %{
  6590     immL baseImm %{ 0 /* TODO: PPC port (jlong)CMSCollectorCardTableModRefBSExt::requires_release_address() */ %}
  6571     immL baseImm %{ 0 /* TODO: PPC port (jlong)CMSCollectorCardTableModRefBSExt::requires_release_address() */ %}
  6591     iRegLdst releaseFieldAddress;
  6572     iRegLdst releaseFieldAddress;
       
  6573     flagsReg crx;
  6592     loadConL_Ex(releaseFieldAddress, baseImm);
  6574     loadConL_Ex(releaseFieldAddress, baseImm);
  6593     storeCM_CMS(mem, releaseFieldAddress);
  6575     storeCM_CMS(mem, releaseFieldAddress, crx);
  6594   %}
  6576   %}
  6595 %}
  6577 %}
  6596 
  6578 
  6597 instruct storeCM_G1(memory mem, immI_0 zero) %{
  6579 instruct storeCM_G1(memory mem, immI_0 zero) %{
  6598   match(Set mem (StoreCM mem zero));
  6580   match(Set mem (StoreCM mem zero));
  6637   // The match rule is needed to make it a 'MachTypeNode'!
  6619   // The match rule is needed to make it a 'MachTypeNode'!
  6638   match(Set dst (EncodeP src));
  6620   match(Set dst (EncodeP src));
  6639   predicate(false);
  6621   predicate(false);
  6640 
  6622 
  6641   format %{ "SUB     $dst, $src, oop_base \t// encode" %}
  6623   format %{ "SUB     $dst, $src, oop_base \t// encode" %}
  6642   size(4);
  6624   ins_encode %{
  6643   ins_encode %{
  6625     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  6644     // TODO: PPC port $archOpcode(ppc64Opcode_subf);
  6626     __ sub_const_optimized($dst$$Register, $src$$Register, Universe::narrow_oop_base(), R0);
  6645     __ subf($dst$$Register, R30, $src$$Register);
       
  6646   %}
  6627   %}
  6647   ins_pipe(pipe_class_default);
  6628   ins_pipe(pipe_class_default);
  6648 %}
  6629 %}
  6649 
  6630 
  6650 // Conditional sub base.
  6631 // Conditional sub base.
  6651 instruct cond_sub_base(iRegNdst dst, flagsReg crx, iRegPsrc src1) %{
  6632 instruct cond_sub_base(iRegNdst dst, flagsRegSrc crx, iRegPsrc src1) %{
  6652   // The match rule is needed to make it a 'MachTypeNode'!
  6633   // The match rule is needed to make it a 'MachTypeNode'!
  6653   match(Set dst (EncodeP (Binary crx src1)));
  6634   match(Set dst (EncodeP (Binary crx src1)));
  6654   predicate(false);
  6635   predicate(false);
  6655 
  6636 
  6656   ins_variable_size_depending_on_alignment(true);
       
  6657 
       
  6658   format %{ "BEQ     $crx, done\n\t"
  6637   format %{ "BEQ     $crx, done\n\t"
  6659             "SUB     $dst, $src1, R30 \t// encode: subtract base if != NULL\n"
  6638             "SUB     $dst, $src1, heapbase \t// encode: subtract base if != NULL\n"
  6660             "done:" %}
  6639             "done:" %}
  6661   size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8);
  6640   ins_encode %{
  6662   ins_encode %{
  6641     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  6663     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
       
  6664     Label done;
  6642     Label done;
  6665     __ beq($crx$$CondRegister, done);
  6643     __ beq($crx$$CondRegister, done);
  6666     __ subf($dst$$Register, R30, $src1$$Register);
  6644     __ sub_const_optimized($dst$$Register, $src1$$Register, Universe::narrow_oop_base(), R0);
  6667     // TODO PPC port __ endgroup_if_needed(_size == 12);
       
  6668     __ bind(done);
  6645     __ bind(done);
  6669   %}
  6646   %}
  6670   ins_pipe(pipe_class_default);
  6647   ins_pipe(pipe_class_default);
  6671 %}
  6648 %}
  6672 
  6649 
  6673 // Power 7 can use isel instruction
  6650 // Power 7 can use isel instruction
  6674 instruct cond_set_0_oop(iRegNdst dst, flagsReg crx, iRegPsrc src1) %{
  6651 instruct cond_set_0_oop(iRegNdst dst, flagsRegSrc crx, iRegPsrc src1) %{
  6675   // The match rule is needed to make it a 'MachTypeNode'!
  6652   // The match rule is needed to make it a 'MachTypeNode'!
  6676   match(Set dst (EncodeP (Binary crx src1)));
  6653   match(Set dst (EncodeP (Binary crx src1)));
  6677   predicate(false);
  6654   predicate(false);
  6678 
  6655 
  6679   format %{ "CMOVE   $dst, $crx eq, 0, $src1 \t// encode: preserve 0" %}
  6656   format %{ "CMOVE   $dst, $crx eq, 0, $src1 \t// encode: preserve 0" %}
  6775 instruct decodeN_add(iRegPdst dst, iRegPdst src) %{
  6752 instruct decodeN_add(iRegPdst dst, iRegPdst src) %{
  6776   // The match rule is needed to make it a 'MachTypeNode'!
  6753   // The match rule is needed to make it a 'MachTypeNode'!
  6777   match(Set dst (DecodeN src));
  6754   match(Set dst (DecodeN src));
  6778   predicate(false);
  6755   predicate(false);
  6779 
  6756 
  6780   format %{ "ADD     $dst, $src, R30 \t// DecodeN, add oop base" %}
  6757   format %{ "ADD     $dst, $src, heapbase \t// DecodeN, add oop base" %}
  6781   size(4);
  6758   ins_encode %{
  6782   ins_encode %{
  6759     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  6783     // TODO: PPC port $archOpcode(ppc64Opcode_add);
  6760     __ add_const_optimized($dst$$Register, $src$$Register, Universe::narrow_oop_base(), R0);
  6784     __ add($dst$$Register, $src$$Register, R30);
       
  6785   %}
  6761   %}
  6786   ins_pipe(pipe_class_default);
  6762   ins_pipe(pipe_class_default);
  6787 %}
  6763 %}
  6788 
  6764 
  6789 // conditianal add base for expand
  6765 // conditianal add base for expand
  6790 instruct cond_add_base(iRegPdst dst, flagsReg crx, iRegPsrc src1) %{
  6766 instruct cond_add_base(iRegPdst dst, flagsRegSrc crx, iRegPsrc src) %{
  6791   // The match rule is needed to make it a 'MachTypeNode'!
  6767   // The match rule is needed to make it a 'MachTypeNode'!
  6792   // NOTICE that the rule is nonsense - we just have to make sure that:
  6768   // NOTICE that the rule is nonsense - we just have to make sure that:
  6793   //  - _matrule->_rChild->_opType == "DecodeN" (see InstructForm::captures_bottom_type() in formssel.cpp)
  6769   //  - _matrule->_rChild->_opType == "DecodeN" (see InstructForm::captures_bottom_type() in formssel.cpp)
  6794   //  - we have to match 'crx' to avoid an "illegal USE of non-input: flagsReg crx" error in ADLC.
  6770   //  - we have to match 'crx' to avoid an "illegal USE of non-input: flagsReg crx" error in ADLC.
  6795   match(Set dst (DecodeN (Binary crx src1)));
  6771   match(Set dst (DecodeN (Binary crx src)));
  6796   predicate(false);
  6772   predicate(false);
  6797 
  6773 
  6798   ins_variable_size_depending_on_alignment(true);
       
  6799 
       
  6800   format %{ "BEQ     $crx, done\n\t"
  6774   format %{ "BEQ     $crx, done\n\t"
  6801             "ADD     $dst, $src1, R30 \t// DecodeN: add oop base if $src1 != NULL\n"
  6775             "ADD     $dst, $src, heapbase \t// DecodeN: add oop base if $src != NULL\n"
  6802             "done:" %}
  6776             "done:" %}
  6803   size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling()) */? 12 : 8);
  6777   ins_encode %{
  6804   ins_encode %{
  6778     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  6805     // TODO: PPC port $archOpcode(ppc64Opcode_cmove);
       
  6806     Label done;
  6779     Label done;
  6807     __ beq($crx$$CondRegister, done);
  6780     __ beq($crx$$CondRegister, done);
  6808     __ add($dst$$Register, $src1$$Register, R30);
  6781     __ add_const_optimized($dst$$Register, $src$$Register, Universe::narrow_oop_base(), R0);
  6809     // TODO PPC port  __ endgroup_if_needed(_size == 12);
       
  6810     __ bind(done);
  6782     __ bind(done);
  6811   %}
  6783   %}
  6812   ins_pipe(pipe_class_default);
  6784   ins_pipe(pipe_class_default);
  6813 %}
  6785 %}
  6814 
  6786 
  6815 instruct cond_set_0_ptr(iRegPdst dst, flagsReg crx, iRegPsrc src1) %{
  6787 instruct cond_set_0_ptr(iRegPdst dst, flagsRegSrc crx, iRegPsrc src1) %{
  6816   // The match rule is needed to make it a 'MachTypeNode'!
  6788   // The match rule is needed to make it a 'MachTypeNode'!
  6817   // NOTICE that the rule is nonsense - we just have to make sure that:
  6789   // NOTICE that the rule is nonsense - we just have to make sure that:
  6818   //  - _matrule->_rChild->_opType == "DecodeN" (see InstructForm::captures_bottom_type() in formssel.cpp)
  6790   //  - _matrule->_rChild->_opType == "DecodeN" (see InstructForm::captures_bottom_type() in formssel.cpp)
  6819   //  - we have to match 'crx' to avoid an "illegal USE of non-input: flagsReg crx" error in ADLC.
  6791   //  - we have to match 'crx' to avoid an "illegal USE of non-input: flagsReg crx" error in ADLC.
  6820   match(Set dst (DecodeN (Binary crx src1)));
  6792   match(Set dst (DecodeN (Binary crx src1)));
  6886   predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull ||
  6858   predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull ||
  6887              n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
  6859              n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
  6888             Universe::narrow_oop_base_disjoint());
  6860             Universe::narrow_oop_base_disjoint());
  6889   ins_cost(DEFAULT_COST);
  6861   ins_cost(DEFAULT_COST);
  6890 
  6862 
  6891   format %{ "MOV     $dst, R30 \t\n"
  6863   format %{ "MOV     $dst, heapbase \t\n"
  6892             "RLDIMI  $dst, $src, shift, 32-shift \t// decode with disjoint base" %}
  6864             "RLDIMI  $dst, $src, shift, 32-shift \t// decode with disjoint base" %}
  6893   postalloc_expand %{
  6865   postalloc_expand %{
  6894     loadBaseNode *n1 = new loadBaseNode();
  6866     loadBaseNode *n1 = new loadBaseNode();
  6895     n1->add_req(NULL);
  6867     n1->add_req(NULL);
  6896     n1->_opnds[0] = op_dst;
  6868     n1->_opnds[0] = op_dst;
  6944     n_cond_set->_opnds[2] = op_dst;
  6916     n_cond_set->_opnds[2] = op_dst;
  6945     n_cond_set->_bottom_type = _bottom_type;
  6917     n_cond_set->_bottom_type = _bottom_type;
  6946 
  6918 
  6947     assert(ra_->is_oop(this) == true, "A decodeN node must produce an oop!");
  6919     assert(ra_->is_oop(this) == true, "A decodeN node must produce an oop!");
  6948     ra_->set_oop(n_cond_set, true);
  6920     ra_->set_oop(n_cond_set, true);
  6949     
  6921 
  6950     ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
  6922     ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
  6951     ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx));
  6923     ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx));
  6952     ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
  6924     ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
  6953     ra_->set_pair(n_cond_set->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
  6925     ra_->set_pair(n_cond_set->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this));
  6954 
  6926 
  7301 %}
  7273 %}
  7302 
  7274 
  7303 //----------Conditional Move---------------------------------------------------
  7275 //----------Conditional Move---------------------------------------------------
  7304 
  7276 
  7305 // Cmove using isel.
  7277 // Cmove using isel.
  7306 instruct cmovI_reg_isel(cmpOp cmp, flagsReg crx, iRegIdst dst, iRegIsrc src) %{
  7278 instruct cmovI_reg_isel(cmpOp cmp, flagsRegSrc crx, iRegIdst dst, iRegIsrc src) %{
  7307   match(Set dst (CMoveI (Binary cmp crx) (Binary dst src)));
  7279   match(Set dst (CMoveI (Binary cmp crx) (Binary dst src)));
  7308   predicate(VM_Version::has_isel());
  7280   predicate(VM_Version::has_isel());
  7309   ins_cost(DEFAULT_COST);
  7281   ins_cost(DEFAULT_COST);
  7310 
  7282 
  7311   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7283   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7319             (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register);
  7291             (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register);
  7320   %}
  7292   %}
  7321   ins_pipe(pipe_class_default);
  7293   ins_pipe(pipe_class_default);
  7322 %}
  7294 %}
  7323 
  7295 
  7324 instruct cmovI_reg(cmpOp cmp, flagsReg crx, iRegIdst dst, iRegIsrc src) %{
  7296 instruct cmovI_reg(cmpOp cmp, flagsRegSrc crx, iRegIdst dst, iRegIsrc src) %{
  7325   match(Set dst (CMoveI (Binary cmp crx) (Binary dst src)));
  7297   match(Set dst (CMoveI (Binary cmp crx) (Binary dst src)));
  7326   predicate(!VM_Version::has_isel());
  7298   predicate(!VM_Version::has_isel());
  7327   ins_cost(DEFAULT_COST+BRANCH_COST);
  7299   ins_cost(DEFAULT_COST+BRANCH_COST);
  7328 
  7300 
  7329   ins_variable_size_depending_on_alignment(true);
  7301   ins_variable_size_depending_on_alignment(true);
  7333   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7305   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7334   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7306   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7335   ins_pipe(pipe_class_default);
  7307   ins_pipe(pipe_class_default);
  7336 %}
  7308 %}
  7337 
  7309 
  7338 instruct cmovI_imm(cmpOp cmp, flagsReg crx, iRegIdst dst, immI16 src) %{
  7310 instruct cmovI_imm(cmpOp cmp, flagsRegSrc crx, iRegIdst dst, immI16 src) %{
  7339   match(Set dst (CMoveI (Binary cmp crx) (Binary dst src)));
  7311   match(Set dst (CMoveI (Binary cmp crx) (Binary dst src)));
  7340   ins_cost(DEFAULT_COST+BRANCH_COST);
  7312   ins_cost(DEFAULT_COST+BRANCH_COST);
  7341 
  7313 
  7342   ins_variable_size_depending_on_alignment(true);
  7314   ins_variable_size_depending_on_alignment(true);
  7343 
  7315 
  7347   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7319   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7348   ins_pipe(pipe_class_default);
  7320   ins_pipe(pipe_class_default);
  7349 %}
  7321 %}
  7350 
  7322 
  7351 // Cmove using isel.
  7323 // Cmove using isel.
  7352 instruct cmovL_reg_isel(cmpOp cmp, flagsReg crx, iRegLdst dst, iRegLsrc src) %{
  7324 instruct cmovL_reg_isel(cmpOp cmp, flagsRegSrc crx, iRegLdst dst, iRegLsrc src) %{
  7353   match(Set dst (CMoveL (Binary cmp crx) (Binary dst src)));
  7325   match(Set dst (CMoveL (Binary cmp crx) (Binary dst src)));
  7354   predicate(VM_Version::has_isel());
  7326   predicate(VM_Version::has_isel());
  7355   ins_cost(DEFAULT_COST);
  7327   ins_cost(DEFAULT_COST);
  7356 
  7328 
  7357   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7329   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7365             (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register);
  7337             (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register);
  7366   %}
  7338   %}
  7367   ins_pipe(pipe_class_default);
  7339   ins_pipe(pipe_class_default);
  7368 %}
  7340 %}
  7369 
  7341 
  7370 instruct cmovL_reg(cmpOp cmp, flagsReg crx, iRegLdst dst, iRegLsrc src) %{
  7342 instruct cmovL_reg(cmpOp cmp, flagsRegSrc crx, iRegLdst dst, iRegLsrc src) %{
  7371   match(Set dst (CMoveL (Binary cmp crx) (Binary dst src)));
  7343   match(Set dst (CMoveL (Binary cmp crx) (Binary dst src)));
  7372   predicate(!VM_Version::has_isel());
  7344   predicate(!VM_Version::has_isel());
  7373   ins_cost(DEFAULT_COST+BRANCH_COST);
  7345   ins_cost(DEFAULT_COST+BRANCH_COST);
  7374 
  7346 
  7375   ins_variable_size_depending_on_alignment(true);
  7347   ins_variable_size_depending_on_alignment(true);
  7379   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7351   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7380   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7352   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7381   ins_pipe(pipe_class_default);
  7353   ins_pipe(pipe_class_default);
  7382 %}
  7354 %}
  7383 
  7355 
  7384 instruct cmovL_imm(cmpOp cmp, flagsReg crx, iRegLdst dst, immL16 src) %{
  7356 instruct cmovL_imm(cmpOp cmp, flagsRegSrc crx, iRegLdst dst, immL16 src) %{
  7385   match(Set dst (CMoveL (Binary cmp crx) (Binary dst src)));
  7357   match(Set dst (CMoveL (Binary cmp crx) (Binary dst src)));
  7386   ins_cost(DEFAULT_COST+BRANCH_COST);
  7358   ins_cost(DEFAULT_COST+BRANCH_COST);
  7387 
  7359 
  7388   ins_variable_size_depending_on_alignment(true);
  7360   ins_variable_size_depending_on_alignment(true);
  7389 
  7361 
  7393   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7365   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7394   ins_pipe(pipe_class_default);
  7366   ins_pipe(pipe_class_default);
  7395 %}
  7367 %}
  7396 
  7368 
  7397 // Cmove using isel.
  7369 // Cmove using isel.
  7398 instruct cmovN_reg_isel(cmpOp cmp, flagsReg crx, iRegNdst dst, iRegNsrc src) %{
  7370 instruct cmovN_reg_isel(cmpOp cmp, flagsRegSrc crx, iRegNdst dst, iRegNsrc src) %{
  7399   match(Set dst (CMoveN (Binary cmp crx) (Binary dst src)));
  7371   match(Set dst (CMoveN (Binary cmp crx) (Binary dst src)));
  7400   predicate(VM_Version::has_isel());
  7372   predicate(VM_Version::has_isel());
  7401   ins_cost(DEFAULT_COST);
  7373   ins_cost(DEFAULT_COST);
  7402 
  7374 
  7403   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7375   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7412   %}
  7384   %}
  7413   ins_pipe(pipe_class_default);
  7385   ins_pipe(pipe_class_default);
  7414 %}
  7386 %}
  7415 
  7387 
  7416 // Conditional move for RegN. Only cmov(reg, reg).
  7388 // Conditional move for RegN. Only cmov(reg, reg).
  7417 instruct cmovN_reg(cmpOp cmp, flagsReg crx, iRegNdst dst, iRegNsrc src) %{
  7389 instruct cmovN_reg(cmpOp cmp, flagsRegSrc crx, iRegNdst dst, iRegNsrc src) %{
  7418   match(Set dst (CMoveN (Binary cmp crx) (Binary dst src)));
  7390   match(Set dst (CMoveN (Binary cmp crx) (Binary dst src)));
  7419   predicate(!VM_Version::has_isel());
  7391   predicate(!VM_Version::has_isel());
  7420   ins_cost(DEFAULT_COST+BRANCH_COST);
  7392   ins_cost(DEFAULT_COST+BRANCH_COST);
  7421 
  7393 
  7422   ins_variable_size_depending_on_alignment(true);
  7394   ins_variable_size_depending_on_alignment(true);
  7426   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7398   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7427   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7399   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7428   ins_pipe(pipe_class_default);
  7400   ins_pipe(pipe_class_default);
  7429 %}
  7401 %}
  7430 
  7402 
  7431 instruct cmovN_imm(cmpOp cmp, flagsReg crx, iRegNdst dst, immN_0 src) %{
  7403 instruct cmovN_imm(cmpOp cmp, flagsRegSrc crx, iRegNdst dst, immN_0 src) %{
  7432   match(Set dst (CMoveN (Binary cmp crx) (Binary dst src)));
  7404   match(Set dst (CMoveN (Binary cmp crx) (Binary dst src)));
  7433   ins_cost(DEFAULT_COST+BRANCH_COST);
  7405   ins_cost(DEFAULT_COST+BRANCH_COST);
  7434 
  7406 
  7435   ins_variable_size_depending_on_alignment(true);
  7407   ins_variable_size_depending_on_alignment(true);
  7436 
  7408 
  7440   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7412   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7441   ins_pipe(pipe_class_default);
  7413   ins_pipe(pipe_class_default);
  7442 %}
  7414 %}
  7443 
  7415 
  7444 // Cmove using isel.
  7416 // Cmove using isel.
  7445 instruct cmovP_reg_isel(cmpOp cmp, flagsReg crx, iRegPdst dst, iRegPsrc src) %{
  7417 instruct cmovP_reg_isel(cmpOp cmp, flagsRegSrc crx, iRegPdst dst, iRegPsrc src) %{
  7446   match(Set dst (CMoveP (Binary cmp crx) (Binary dst src)));
  7418   match(Set dst (CMoveP (Binary cmp crx) (Binary dst src)));
  7447   predicate(VM_Version::has_isel());
  7419   predicate(VM_Version::has_isel());
  7448   ins_cost(DEFAULT_COST);
  7420   ins_cost(DEFAULT_COST);
  7449 
  7421 
  7450   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7422   format %{ "CMOVE   $cmp, $crx, $dst, $src\n\t" %}
  7458             (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register);
  7430             (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register);
  7459   %}
  7431   %}
  7460   ins_pipe(pipe_class_default);
  7432   ins_pipe(pipe_class_default);
  7461 %}
  7433 %}
  7462 
  7434 
  7463 instruct cmovP_reg(cmpOp cmp, flagsReg crx, iRegPdst dst, iRegP_N2P src) %{
  7435 instruct cmovP_reg(cmpOp cmp, flagsRegSrc crx, iRegPdst dst, iRegP_N2P src) %{
  7464   match(Set dst (CMoveP (Binary cmp crx) (Binary dst src)));
  7436   match(Set dst (CMoveP (Binary cmp crx) (Binary dst src)));
  7465   predicate(!VM_Version::has_isel());
  7437   predicate(!VM_Version::has_isel());
  7466   ins_cost(DEFAULT_COST+BRANCH_COST);
  7438   ins_cost(DEFAULT_COST+BRANCH_COST);
  7467 
  7439 
  7468   ins_variable_size_depending_on_alignment(true);
  7440   ins_variable_size_depending_on_alignment(true);
  7472   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7444   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7473   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7445   ins_encode( enc_cmove_reg(dst, crx, src, cmp) );
  7474   ins_pipe(pipe_class_default);
  7446   ins_pipe(pipe_class_default);
  7475 %}
  7447 %}
  7476 
  7448 
  7477 instruct cmovP_imm(cmpOp cmp, flagsReg crx, iRegPdst dst, immP_0 src) %{
  7449 instruct cmovP_imm(cmpOp cmp, flagsRegSrc crx, iRegPdst dst, immP_0 src) %{
  7478   match(Set dst (CMoveP (Binary cmp crx) (Binary dst src)));
  7450   match(Set dst (CMoveP (Binary cmp crx) (Binary dst src)));
  7479   ins_cost(DEFAULT_COST+BRANCH_COST);
  7451   ins_cost(DEFAULT_COST+BRANCH_COST);
  7480 
  7452 
  7481   ins_variable_size_depending_on_alignment(true);
  7453   ins_variable_size_depending_on_alignment(true);
  7482 
  7454 
  7485   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7457   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  7486   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7458   ins_encode( enc_cmove_imm(dst, crx, src, cmp) );
  7487   ins_pipe(pipe_class_default);
  7459   ins_pipe(pipe_class_default);
  7488 %}
  7460 %}
  7489 
  7461 
  7490 instruct cmovF_reg(cmpOp cmp, flagsReg crx, regF dst, regF src) %{
  7462 instruct cmovF_reg(cmpOp cmp, flagsRegSrc crx, regF dst, regF src) %{
  7491   match(Set dst (CMoveF (Binary cmp crx) (Binary dst src)));
  7463   match(Set dst (CMoveF (Binary cmp crx) (Binary dst src)));
  7492   ins_cost(DEFAULT_COST+BRANCH_COST);
  7464   ins_cost(DEFAULT_COST+BRANCH_COST);
  7493 
  7465 
  7494   ins_variable_size_depending_on_alignment(true);
  7466   ins_variable_size_depending_on_alignment(true);
  7495 
  7467 
  7507     __ bind(done);
  7479     __ bind(done);
  7508   %}
  7480   %}
  7509   ins_pipe(pipe_class_default);
  7481   ins_pipe(pipe_class_default);
  7510 %}
  7482 %}
  7511 
  7483 
  7512 instruct cmovD_reg(cmpOp cmp, flagsReg crx, regD dst, regD src) %{
  7484 instruct cmovD_reg(cmpOp cmp, flagsRegSrc crx, regD dst, regD src) %{
  7513   match(Set dst (CMoveD (Binary cmp crx) (Binary dst src)));
  7485   match(Set dst (CMoveD (Binary cmp crx) (Binary dst src)));
  7514   ins_cost(DEFAULT_COST+BRANCH_COST);
  7486   ins_cost(DEFAULT_COST+BRANCH_COST);
  7515 
  7487 
  7516   ins_variable_size_depending_on_alignment(true);
  7488   ins_variable_size_depending_on_alignment(true);
  7517 
  7489 
  7540 // int register.
  7512 // int register.
  7541 // Used by sun/misc/AtomicLongCSImpl.java.
  7513 // Used by sun/misc/AtomicLongCSImpl.java.
  7542 // Mem_ptr must be a memory operand, else this node does not get
  7514 // Mem_ptr must be a memory operand, else this node does not get
  7543 // Flag_needs_anti_dependence_check set by adlc. If this is not set this node
  7515 // Flag_needs_anti_dependence_check set by adlc. If this is not set this node
  7544 // can be rematerialized which leads to errors.
  7516 // can be rematerialized which leads to errors.
  7545 instruct storeLConditional_regP_regL_regL(flagsReg crx, indirect mem_ptr, iRegLsrc oldVal, iRegLsrc newVal) %{
  7517 instruct storeLConditional_regP_regL_regL(flagsReg crx, indirect mem_ptr, iRegLsrc oldVal, iRegLsrc newVal, flagsRegCR0 cr0) %{
  7546   match(Set crx (StoreLConditional mem_ptr (Binary oldVal newVal)));
  7518   match(Set crx (StoreLConditional mem_ptr (Binary oldVal newVal)));
       
  7519   effect(TEMP cr0);
  7547   format %{ "CMPXCHGD if ($crx = ($oldVal == *$mem_ptr)) *mem_ptr = $newVal; as bool" %}
  7520   format %{ "CMPXCHGD if ($crx = ($oldVal == *$mem_ptr)) *mem_ptr = $newVal; as bool" %}
  7548   ins_encode %{
  7521   ins_encode %{
  7549     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7522     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7550     __ cmpxchgd($crx$$CondRegister, R0, $oldVal$$Register, $newVal$$Register, $mem_ptr$$Register,
  7523     __ cmpxchgd($crx$$CondRegister, R0, $oldVal$$Register, $newVal$$Register, $mem_ptr$$Register,
  7551                 MacroAssembler::MemBarAcq, MacroAssembler::cmpxchgx_hint_atomic_update(),
  7524                 MacroAssembler::MemBarAcq, MacroAssembler::cmpxchgx_hint_atomic_update(),
  7558 // int register.
  7531 // int register.
  7559 // This instruction is matched if UseTLAB is off.
  7532 // This instruction is matched if UseTLAB is off.
  7560 // Mem_ptr must be a memory operand, else this node does not get
  7533 // Mem_ptr must be a memory operand, else this node does not get
  7561 // Flag_needs_anti_dependence_check set by adlc. If this is not set this node
  7534 // Flag_needs_anti_dependence_check set by adlc. If this is not set this node
  7562 // can be rematerialized which leads to errors.
  7535 // can be rematerialized which leads to errors.
  7563 instruct storePConditional_regP_regP_regP(flagsReg crx, indirect mem_ptr, iRegPsrc oldVal, iRegPsrc newVal) %{
  7536 instruct storePConditional_regP_regP_regP(flagsRegCR0 cr0, indirect mem_ptr, iRegPsrc oldVal, iRegPsrc newVal) %{
  7564   match(Set crx (StorePConditional mem_ptr (Binary oldVal newVal)));
  7537   match(Set cr0 (StorePConditional mem_ptr (Binary oldVal newVal)));
  7565   format %{ "CMPXCHGD if ($crx = ($oldVal == *$mem_ptr)) *mem_ptr = $newVal; as bool" %}
  7538   ins_cost(2*MEMORY_REF_COST);
  7566   ins_encode %{
  7539 
  7567     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7540   format %{ "STDCX_  if ($cr0 = ($oldVal == *$mem_ptr)) *mem_ptr = $newVal; as bool" %}
  7568     __ cmpxchgd($crx$$CondRegister, R0, $oldVal$$Register, $newVal$$Register, $mem_ptr$$Register,
  7541   ins_encode %{
  7569                 MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(),
  7542     // TODO: PPC port $archOpcode(ppc64Opcode_stdcx_);
  7570                 noreg, NULL, true);
  7543     __ stdcx_($newVal$$Register, $mem_ptr$$Register);
  7571   %}
  7544   %}
  7572   ins_pipe(pipe_class_default);
  7545   ins_pipe(pipe_class_memory);
  7573 %}
  7546 %}
  7574 
  7547 
  7575 // Implement LoadPLocked. Must be ordered against changes of the memory location
  7548 // Implement LoadPLocked. Must be ordered against changes of the memory location
  7576 // by storePConditional.
  7549 // by storePConditional.
  7577 // Don't know whether this is ever used.
  7550 // Don't know whether this is ever used.
  7578 instruct loadPLocked(iRegPdst dst, memory mem) %{
  7551 instruct loadPLocked(iRegPdst dst, memory mem) %{
  7579   match(Set dst (LoadPLocked mem));
  7552   match(Set dst (LoadPLocked mem));
  7580   ins_cost(MEMORY_REF_COST);
  7553   ins_cost(2*MEMORY_REF_COST);
  7581 
  7554 
  7582   format %{ "LD      $dst, $mem \t// loadPLocked\n\t"
  7555   format %{ "LDARX   $dst, $mem \t// loadPLocked\n\t" %}
  7583             "TWI     $dst\n\t"
  7556   size(4);
  7584             "ISYNC" %}
  7557   ins_encode %{
  7585   size(12);
  7558     // TODO: PPC port $archOpcode(ppc64Opcode_ldarx);
  7586   ins_encode( enc_ld_ac(dst, mem) );
  7559     __ ldarx($dst$$Register, $mem$$Register, MacroAssembler::cmpxchgx_hint_atomic_update());
       
  7560   %}
  7587   ins_pipe(pipe_class_memory);
  7561   ins_pipe(pipe_class_memory);
  7588 %}
  7562 %}
  7589 
  7563 
  7590 //----------Compare-And-Swap---------------------------------------------------
  7564 //----------Compare-And-Swap---------------------------------------------------
  7591 
  7565 
  7592 // CompareAndSwap{P,I,L} have more than one output, therefore "CmpI
  7566 // CompareAndSwap{P,I,L} have more than one output, therefore "CmpI
  7593 // (CompareAndSwap ...)" or "If (CmpI (CompareAndSwap ..))"  cannot be
  7567 // (CompareAndSwap ...)" or "If (CmpI (CompareAndSwap ..))"  cannot be
  7594 // matched.
  7568 // matched.
  7595 
  7569 
  7596 instruct compareAndSwapI_regP_regI_regI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src1, iRegIsrc src2) %{
  7570 instruct compareAndSwapI_regP_regI_regI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src1, iRegIsrc src2, flagsRegCR0 cr0) %{
  7597   match(Set res (CompareAndSwapI mem_ptr (Binary src1 src2)));
  7571   match(Set res (CompareAndSwapI mem_ptr (Binary src1 src2)));
       
  7572   effect(TEMP cr0);
  7598   format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %}
  7573   format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %}
  7599   // Variable size: instruction count smaller if regs are disjoint.
  7574   // Variable size: instruction count smaller if regs are disjoint.
  7600   ins_encode %{
  7575   ins_encode %{
  7601     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7576     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7602     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7577     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7605                 $res$$Register, true);
  7580                 $res$$Register, true);
  7606   %}
  7581   %}
  7607   ins_pipe(pipe_class_default);
  7582   ins_pipe(pipe_class_default);
  7608 %}
  7583 %}
  7609 
  7584 
  7610 instruct compareAndSwapN_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2) %{
  7585 instruct compareAndSwapN_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2, flagsRegCR0 cr0) %{
  7611   match(Set res (CompareAndSwapN mem_ptr (Binary src1 src2)));
  7586   match(Set res (CompareAndSwapN mem_ptr (Binary src1 src2)));
       
  7587   effect(TEMP cr0);
  7612   format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %}
  7588   format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %}
  7613   // Variable size: instruction count smaller if regs are disjoint.
  7589   // Variable size: instruction count smaller if regs are disjoint.
  7614   ins_encode %{
  7590   ins_encode %{
  7615     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7591     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7616     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7592     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7619                 $res$$Register, true);
  7595                 $res$$Register, true);
  7620   %}
  7596   %}
  7621   ins_pipe(pipe_class_default);
  7597   ins_pipe(pipe_class_default);
  7622 %}
  7598 %}
  7623 
  7599 
  7624 instruct compareAndSwapL_regP_regL_regL(iRegIdst res, iRegPdst mem_ptr, iRegLsrc src1, iRegLsrc src2) %{
  7600 instruct compareAndSwapL_regP_regL_regL(iRegIdst res, iRegPdst mem_ptr, iRegLsrc src1, iRegLsrc src2, flagsRegCR0 cr0) %{
  7625   match(Set res (CompareAndSwapL mem_ptr (Binary src1 src2)));
  7601   match(Set res (CompareAndSwapL mem_ptr (Binary src1 src2)));
       
  7602   effect(TEMP cr0);
  7626   format %{ "CMPXCHGD $res, $mem_ptr, $src1, $src2; as bool" %}
  7603   format %{ "CMPXCHGD $res, $mem_ptr, $src1, $src2; as bool" %}
  7627   // Variable size: instruction count smaller if regs are disjoint.
  7604   // Variable size: instruction count smaller if regs are disjoint.
  7628   ins_encode %{
  7605   ins_encode %{
  7629     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7606     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7630     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7607     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7633                 $res$$Register, NULL, true);
  7610                 $res$$Register, NULL, true);
  7634   %}
  7611   %}
  7635   ins_pipe(pipe_class_default);
  7612   ins_pipe(pipe_class_default);
  7636 %}
  7613 %}
  7637 
  7614 
  7638 instruct compareAndSwapP_regP_regP_regP(iRegIdst res, iRegPdst mem_ptr, iRegPsrc src1, iRegPsrc src2) %{
  7615 instruct compareAndSwapP_regP_regP_regP(iRegIdst res, iRegPdst mem_ptr, iRegPsrc src1, iRegPsrc src2, flagsRegCR0 cr0) %{
  7639   match(Set res (CompareAndSwapP mem_ptr (Binary src1 src2)));
  7616   match(Set res (CompareAndSwapP mem_ptr (Binary src1 src2)));
       
  7617   effect(TEMP cr0);
  7640   format %{ "CMPXCHGD $res, $mem_ptr, $src1, $src2; as bool; ptr" %}
  7618   format %{ "CMPXCHGD $res, $mem_ptr, $src1, $src2; as bool; ptr" %}
  7641   // Variable size: instruction count smaller if regs are disjoint.
  7619   // Variable size: instruction count smaller if regs are disjoint.
  7642   ins_encode %{
  7620   ins_encode %{
  7643     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7621     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
  7644     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7622     // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'.
  7647                 $res$$Register, NULL, true);
  7625                 $res$$Register, NULL, true);
  7648   %}
  7626   %}
  7649   ins_pipe(pipe_class_default);
  7627   ins_pipe(pipe_class_default);
  7650 %}
  7628 %}
  7651 
  7629 
  7652 instruct getAndAddI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src) %{
  7630 instruct getAndAddI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src, flagsRegCR0 cr0) %{
  7653   match(Set res (GetAndAddI mem_ptr src));
  7631   match(Set res (GetAndAddI mem_ptr src));
       
  7632   effect(TEMP cr0);
  7654   format %{ "GetAndAddI $res, $mem_ptr, $src" %}
  7633   format %{ "GetAndAddI $res, $mem_ptr, $src" %}
  7655   // Variable size: instruction count smaller if regs are disjoint.
  7634   // Variable size: instruction count smaller if regs are disjoint.
  7656   ins_encode( enc_GetAndAddI(res, mem_ptr, src) );
  7635   ins_encode( enc_GetAndAddI(res, mem_ptr, src) );
  7657   ins_pipe(pipe_class_default);
  7636   ins_pipe(pipe_class_default);
  7658 %}
  7637 %}
  7659 
  7638 
  7660 instruct getAndAddL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src) %{
  7639 instruct getAndAddL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src, flagsRegCR0 cr0) %{
  7661   match(Set res (GetAndAddL mem_ptr src));
  7640   match(Set res (GetAndAddL mem_ptr src));
       
  7641   effect(TEMP cr0);
  7662   format %{ "GetAndAddL $res, $mem_ptr, $src" %}
  7642   format %{ "GetAndAddL $res, $mem_ptr, $src" %}
  7663   // Variable size: instruction count smaller if regs are disjoint.
  7643   // Variable size: instruction count smaller if regs are disjoint.
  7664   ins_encode( enc_GetAndAddL(res, mem_ptr, src) );
  7644   ins_encode( enc_GetAndAddL(res, mem_ptr, src) );
  7665   ins_pipe(pipe_class_default);
  7645   ins_pipe(pipe_class_default);
  7666 %}
  7646 %}
  7667 
  7647 
  7668 instruct getAndSetI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src) %{
  7648 instruct getAndSetI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src, flagsRegCR0 cr0) %{
  7669   match(Set res (GetAndSetI mem_ptr src));
  7649   match(Set res (GetAndSetI mem_ptr src));
       
  7650   effect(TEMP cr0);
  7670   format %{ "GetAndSetI $res, $mem_ptr, $src" %}
  7651   format %{ "GetAndSetI $res, $mem_ptr, $src" %}
  7671   // Variable size: instruction count smaller if regs are disjoint.
  7652   // Variable size: instruction count smaller if regs are disjoint.
  7672   ins_encode( enc_GetAndSetI(res, mem_ptr, src) );
  7653   ins_encode( enc_GetAndSetI(res, mem_ptr, src) );
  7673   ins_pipe(pipe_class_default);
  7654   ins_pipe(pipe_class_default);
  7674 %}
  7655 %}
  7675 
  7656 
  7676 instruct getAndSetL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src) %{
  7657 instruct getAndSetL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src, flagsRegCR0 cr0) %{
  7677   match(Set res (GetAndSetL mem_ptr src));
  7658   match(Set res (GetAndSetL mem_ptr src));
       
  7659   effect(TEMP cr0);
  7678   format %{ "GetAndSetL $res, $mem_ptr, $src" %}
  7660   format %{ "GetAndSetL $res, $mem_ptr, $src" %}
  7679   // Variable size: instruction count smaller if regs are disjoint.
  7661   // Variable size: instruction count smaller if regs are disjoint.
  7680   ins_encode( enc_GetAndSetL(res, mem_ptr, src) );
  7662   ins_encode( enc_GetAndSetL(res, mem_ptr, src) );
  7681   ins_pipe(pipe_class_default);
  7663   ins_pipe(pipe_class_default);
  7682 %}
  7664 %}
  7683 
  7665 
  7684 instruct getAndSetP(iRegPdst res, iRegPdst mem_ptr, iRegPsrc src) %{
  7666 instruct getAndSetP(iRegPdst res, iRegPdst mem_ptr, iRegPsrc src, flagsRegCR0 cr0) %{
  7685   match(Set res (GetAndSetP mem_ptr src));
  7667   match(Set res (GetAndSetP mem_ptr src));
       
  7668   effect(TEMP cr0);
  7686   format %{ "GetAndSetP $res, $mem_ptr, $src" %}
  7669   format %{ "GetAndSetP $res, $mem_ptr, $src" %}
  7687   // Variable size: instruction count smaller if regs are disjoint.
  7670   // Variable size: instruction count smaller if regs are disjoint.
  7688   ins_encode( enc_GetAndSetL(res, mem_ptr, src) );
  7671   ins_encode( enc_GetAndSetL(res, mem_ptr, src) );
  7689   ins_pipe(pipe_class_default);
  7672   ins_pipe(pipe_class_default);
  7690 %}
  7673 %}
  7691 
  7674 
  7692 instruct getAndSetN(iRegNdst res, iRegPdst mem_ptr, iRegNsrc src) %{
  7675 instruct getAndSetN(iRegNdst res, iRegPdst mem_ptr, iRegNsrc src, flagsRegCR0 cr0) %{
  7693   match(Set res (GetAndSetN mem_ptr src));
  7676   match(Set res (GetAndSetN mem_ptr src));
       
  7677   effect(TEMP cr0);
  7694   format %{ "GetAndSetN $res, $mem_ptr, $src" %}
  7678   format %{ "GetAndSetN $res, $mem_ptr, $src" %}
  7695   // Variable size: instruction count smaller if regs are disjoint.
  7679   // Variable size: instruction count smaller if regs are disjoint.
  7696   ins_encode( enc_GetAndSetI(res, mem_ptr, src) );
  7680   ins_encode( enc_GetAndSetI(res, mem_ptr, src) );
  7697   ins_pipe(pipe_class_default);
  7681   ins_pipe(pipe_class_default);
  7698 %}
  7682 %}
  7896   %}
  7880   %}
  7897   ins_pipe(pipe_class_default);
  7881   ins_pipe(pipe_class_default);
  7898 %}
  7882 %}
  7899 
  7883 
  7900 // Immediate Subtraction
  7884 // Immediate Subtraction
  7901 // The compiler converts "x-c0" into "x+ -c0" (see SubINode::Ideal),
  7885 // Immediate Subtraction: The compiler converts "x-c0" into "x+ -c0" (see SubLNode::Ideal),
  7902 // so this rule seems to be unused.
  7886 // Don't try to use addi with - $src2$$constant since it can overflow when $src2$$constant == minI16.
  7903 instruct subI_reg_imm16(iRegIdst dst, iRegIsrc src1, immI16 src2) %{
       
  7904   match(Set dst (SubI src1 src2));
       
  7905   format %{ "SUBI    $dst, $src1, $src2" %}
       
  7906   size(4);
       
  7907   ins_encode %{
       
  7908     // TODO: PPC port $archOpcode(ppc64Opcode_addi);
       
  7909     __ addi($dst$$Register, $src1$$Register, ($src2$$constant) * (-1));
       
  7910   %}
       
  7911   ins_pipe(pipe_class_default);
       
  7912 %}
       
  7913 
  7887 
  7914 // SubI from constant (using subfic).
  7888 // SubI from constant (using subfic).
  7915 instruct subI_imm16_reg(iRegIdst dst, immI16 src1, iRegIsrc src2) %{
  7889 instruct subI_imm16_reg(iRegIdst dst, immI16 src1, iRegIsrc src2) %{
  7916   match(Set dst (SubI src1 src2));
  7890   match(Set dst (SubI src1 src2));
  7917   format %{ "SUBI    $dst, $src1, $src2" %}
  7891   format %{ "SUBI    $dst, $src1, $src2" %}
  7983   format %{ "SUBF    $dst, $src2, $src1 \t// long + l2i" %}
  7957   format %{ "SUBF    $dst, $src2, $src1 \t// long + l2i" %}
  7984   size(4);
  7958   size(4);
  7985   ins_encode %{
  7959   ins_encode %{
  7986     // TODO: PPC port $archOpcode(ppc64Opcode_subf);
  7960     // TODO: PPC port $archOpcode(ppc64Opcode_subf);
  7987     __ subf($dst$$Register, $src2$$Register, $src1$$Register);
  7961     __ subf($dst$$Register, $src2$$Register, $src1$$Register);
  7988   %}
       
  7989   ins_pipe(pipe_class_default);
       
  7990 %}
       
  7991 
       
  7992 // Immediate Subtraction
       
  7993 // The compiler converts "x-c0" into "x+ -c0" (see SubLNode::Ideal),
       
  7994 // so this rule seems to be unused.
       
  7995 // No constant pool entries required.
       
  7996 instruct subL_reg_imm16(iRegLdst dst, iRegLsrc src1, immL16 src2) %{
       
  7997   match(Set dst (SubL src1 src2));
       
  7998 
       
  7999   format %{ "SUBI    $dst, $src1, $src2 \t// long" %}
       
  8000   size(4);
       
  8001   ins_encode %{
       
  8002     // TODO: PPC port $archOpcode(ppc64Opcode_addi);
       
  8003     __ addi($dst$$Register, $src1$$Register, ($src2$$constant) * (-1));
       
  8004   %}
  7962   %}
  8005   ins_pipe(pipe_class_default);
  7963   ins_pipe(pipe_class_default);
  8006 %}
  7964 %}
  8007 
  7965 
  8008 // Turn the sign-bit of a long into a 64-bit mask, 0x0...0 for
  7966 // Turn the sign-bit of a long into a 64-bit mask, 0x0...0 for
  8163     __ divw($dst$$Register, $src1$$Register, $src2$$Register);
  8121     __ divw($dst$$Register, $src1$$Register, $src2$$Register);
  8164   %}
  8122   %}
  8165   ins_pipe(pipe_class_default);
  8123   ins_pipe(pipe_class_default);
  8166 %}
  8124 %}
  8167 
  8125 
  8168 instruct cmovI_bne_negI_reg(iRegIdst dst, flagsReg crx, iRegIsrc src1) %{
  8126 instruct cmovI_bne_negI_reg(iRegIdst dst, flagsRegSrc crx, iRegIsrc src1) %{
  8169   effect(USE_DEF dst, USE src1, USE crx);
  8127   effect(USE_DEF dst, USE src1, USE crx);
  8170   predicate(false);
  8128   predicate(false);
  8171 
  8129 
  8172   ins_variable_size_depending_on_alignment(true);
  8130   ins_variable_size_depending_on_alignment(true);
  8173 
  8131 
  8226     __ divd($dst$$Register, $src1$$Register, $src2$$Register);
  8184     __ divd($dst$$Register, $src1$$Register, $src2$$Register);
  8227   %}
  8185   %}
  8228   ins_pipe(pipe_class_default);
  8186   ins_pipe(pipe_class_default);
  8229 %}
  8187 %}
  8230 
  8188 
  8231 instruct cmovL_bne_negL_reg(iRegLdst dst, flagsReg crx, iRegLsrc src1) %{
  8189 instruct cmovL_bne_negL_reg(iRegLdst dst, flagsRegSrc crx, iRegLsrc src1) %{
  8232   effect(USE_DEF dst, USE src1, USE crx);
  8190   effect(USE_DEF dst, USE src1, USE crx);
  8233   predicate(false);
  8191   predicate(false);
  8234 
  8192 
  8235   ins_variable_size_depending_on_alignment(true);
  8193   ins_variable_size_depending_on_alignment(true);
  8236 
  8194 
  8279     subI_reg_reg(dst, src1, tmp3);             // dst = src1 - tmp3
  8237     subI_reg_reg(dst, src1, tmp3);             // dst = src1 - tmp3
  8280   %}
  8238   %}
  8281 %}
  8239 %}
  8282 
  8240 
  8283 // Long Remainder with registers
  8241 // Long Remainder with registers
  8284 instruct modL_reg_reg_Ex(iRegLdst dst, iRegLsrc src1, iRegLsrc src2, flagsRegCR0 cr0) %{
  8242 instruct modL_reg_reg_Ex(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{
  8285   match(Set dst (ModL src1 src2));
  8243   match(Set dst (ModL src1 src2));
  8286   ins_cost(10*DEFAULT_COST);
  8244   ins_cost(10*DEFAULT_COST);
  8287 
  8245 
  8288   expand %{
  8246   expand %{
  8289     immL16 imm %{ (int)-1 %}
  8247     immL16 imm %{ (int)-1 %}
  9009 
  8967 
  9010 // Immediate And long
  8968 // Immediate And long
  9011 instruct andL_reg_uimm16(iRegLdst dst, iRegLsrc src1, uimmL16 src2, flagsRegCR0 cr0) %{
  8969 instruct andL_reg_uimm16(iRegLdst dst, iRegLsrc src1, uimmL16 src2, flagsRegCR0 cr0) %{
  9012   match(Set dst (AndL src1 src2));
  8970   match(Set dst (AndL src1 src2));
  9013   effect(KILL cr0);
  8971   effect(KILL cr0);
  9014   ins_cost(DEFAULT_COST);
       
  9015 
  8972 
  9016   format %{ "ANDI    $dst, $src1, $src2 \t// long" %}
  8973   format %{ "ANDI    $dst, $src1, $src2 \t// long" %}
  9017   size(4);
  8974   size(4);
  9018   ins_encode %{
  8975   ins_encode %{
  9019     // TODO: PPC port $archOpcode(ppc64Opcode_andi_);
  8976     // TODO: PPC port $archOpcode(ppc64Opcode_andi_);
  9801     __ fctiwz($dst$$FloatRegister, $src$$FloatRegister);
  9758     __ fctiwz($dst$$FloatRegister, $src$$FloatRegister);
  9802   %}
  9759   %}
  9803   ins_pipe(pipe_class_default);
  9760   ins_pipe(pipe_class_default);
  9804 %}
  9761 %}
  9805 
  9762 
  9806 instruct cmovI_bso_stackSlotL(iRegIdst dst, flagsReg crx, stackSlotL src) %{
  9763 instruct cmovI_bso_stackSlotL(iRegIdst dst, flagsRegSrc crx, stackSlotL src) %{
  9807   // no match-rule, false predicate
  9764   // no match-rule, false predicate
  9808   effect(DEF dst, USE crx, USE src);
  9765   effect(DEF dst, USE crx, USE src);
  9809   predicate(false);
  9766   predicate(false);
  9810 
  9767 
  9811   ins_variable_size_depending_on_alignment(true);
  9768   ins_variable_size_depending_on_alignment(true);
  9815   size(false /* TODO: PPC PORT(InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8);
  9772   size(false /* TODO: PPC PORT(InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8);
  9816   ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) );
  9773   ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) );
  9817   ins_pipe(pipe_class_default);
  9774   ins_pipe(pipe_class_default);
  9818 %}
  9775 %}
  9819 
  9776 
  9820 instruct cmovI_bso_stackSlotL_conLvalue0_Ex(iRegIdst dst, flagsReg crx, stackSlotL mem) %{
  9777 instruct cmovI_bso_stackSlotL_conLvalue0_Ex(iRegIdst dst, flagsRegSrc crx, stackSlotL mem) %{
  9821   // no match-rule, false predicate
  9778   // no match-rule, false predicate
  9822   effect(DEF dst, USE crx, USE mem);
  9779   effect(DEF dst, USE crx, USE mem);
  9823   predicate(false);
  9780   predicate(false);
  9824 
  9781 
  9825   format %{ "CmovI   $dst, $crx, $mem \t// postalloc expanded" %}
  9782   format %{ "CmovI   $dst, $crx, $mem \t// postalloc expanded" %}
  9970     __ fctidz($dst$$FloatRegister, $src$$FloatRegister);
  9927     __ fctidz($dst$$FloatRegister, $src$$FloatRegister);
  9971   %}
  9928   %}
  9972   ins_pipe(pipe_class_default);
  9929   ins_pipe(pipe_class_default);
  9973 %}
  9930 %}
  9974 
  9931 
  9975 instruct cmovL_bso_stackSlotL(iRegLdst dst, flagsReg crx, stackSlotL src) %{
  9932 instruct cmovL_bso_stackSlotL(iRegLdst dst, flagsRegSrc crx, stackSlotL src) %{
  9976   // no match-rule, false predicate
  9933   // no match-rule, false predicate
  9977   effect(DEF dst, USE crx, USE src);
  9934   effect(DEF dst, USE crx, USE src);
  9978   predicate(false);
  9935   predicate(false);
  9979 
  9936 
  9980   ins_variable_size_depending_on_alignment(true);
  9937   ins_variable_size_depending_on_alignment(true);
  9984   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  9941   size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8);
  9985   ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) );
  9942   ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) );
  9986   ins_pipe(pipe_class_default);
  9943   ins_pipe(pipe_class_default);
  9987 %}
  9944 %}
  9988 
  9945 
  9989 instruct cmovL_bso_stackSlotL_conLvalue0_Ex(iRegLdst dst, flagsReg crx, stackSlotL mem) %{
  9946 instruct cmovL_bso_stackSlotL_conLvalue0_Ex(iRegLdst dst, flagsRegSrc crx, stackSlotL mem) %{
  9990   // no match-rule, false predicate
  9947   // no match-rule, false predicate
  9991   effect(DEF dst, USE crx, USE mem);
  9948   effect(DEF dst, USE crx, USE mem);
  9992   predicate(false);
  9949   predicate(false);
  9993 
  9950 
  9994   format %{ "CmovL   $dst, $crx, $mem \t// postalloc expanded" %}
  9951   format %{ "CmovL   $dst, $crx, $mem \t// postalloc expanded" %}
 10253   // r0 is killed
 10210   // r0 is killed
 10254   format %{ "ANDI    R0, $src1, $src2 \t// BTST int" %}
 10211   format %{ "ANDI    R0, $src1, $src2 \t// BTST int" %}
 10255   size(4);
 10212   size(4);
 10256   ins_encode %{
 10213   ins_encode %{
 10257     // TODO: PPC port $archOpcode(ppc64Opcode_andi_);
 10214     // TODO: PPC port $archOpcode(ppc64Opcode_andi_);
 10258     // FIXME: avoid andi_ ?
       
 10259     __ andi_(R0, $src1$$Register, $src2$$constant);
 10215     __ andi_(R0, $src1$$Register, $src2$$constant);
 10260   %}
 10216   %}
 10261   ins_pipe(pipe_class_compare);
 10217   ins_pipe(pipe_class_compare);
 10262 %}
 10218 %}
 10263 
 10219 
 10300   // r0 is killed
 10256   // r0 is killed
 10301   format %{ "ANDI    R0, $src1, $src2 \t// BTST long" %}
 10257   format %{ "ANDI    R0, $src1, $src2 \t// BTST long" %}
 10302   size(4);
 10258   size(4);
 10303   ins_encode %{
 10259   ins_encode %{
 10304     // TODO: PPC port $archOpcode(ppc64Opcode_andi_);
 10260     // TODO: PPC port $archOpcode(ppc64Opcode_andi_);
 10305     // FIXME: avoid andi_ ?
       
 10306     __ andi_(R0, $src1$$Register, $src2$$constant);
 10261     __ andi_(R0, $src1$$Register, $src2$$constant);
 10307   %}
 10262   %}
 10308   ins_pipe(pipe_class_compare);
 10263   ins_pipe(pipe_class_compare);
 10309 %}
 10264 %}
 10310 
 10265 
 10311 instruct cmovI_conIvalueMinus1_conIvalue1(iRegIdst dst, flagsReg crx) %{
 10266 instruct cmovI_conIvalueMinus1_conIvalue1(iRegIdst dst, flagsRegSrc crx) %{
 10312   // no match-rule, false predicate
 10267   // no match-rule, false predicate
 10313   effect(DEF dst, USE crx);
 10268   effect(DEF dst, USE crx);
 10314   predicate(false);
 10269   predicate(false);
 10315 
 10270 
 10316   ins_variable_size_depending_on_alignment(true);
 10271   ins_variable_size_depending_on_alignment(true);
 10330     __ bind(done);
 10285     __ bind(done);
 10331   %}
 10286   %}
 10332   ins_pipe(pipe_class_compare);
 10287   ins_pipe(pipe_class_compare);
 10333 %}
 10288 %}
 10334 
 10289 
 10335 instruct cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(iRegIdst dst, flagsReg crx) %{
 10290 instruct cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(iRegIdst dst, flagsRegSrc crx) %{
 10336   // no match-rule, false predicate
 10291   // no match-rule, false predicate
 10337   effect(DEF dst, USE crx);
 10292   effect(DEF dst, USE crx);
 10338   predicate(false);
 10293   predicate(false);
 10339 
 10294 
 10340   format %{ "CmovI    $crx, $dst, -1, 0, +1 \t// postalloc expanded" %}
 10295   format %{ "CmovI    $crx, $dst, -1, 0, +1 \t// postalloc expanded" %}
 10620 %}
 10575 %}
 10621 
 10576 
 10622 //----------Float Compares----------------------------------------------------
 10577 //----------Float Compares----------------------------------------------------
 10623 
 10578 
 10624 instruct cmpFUnordered_reg_reg(flagsReg crx, regF src1, regF src2) %{
 10579 instruct cmpFUnordered_reg_reg(flagsReg crx, regF src1, regF src2) %{
       
 10580   // Needs matchrule, see cmpDUnordered.
       
 10581   match(Set crx (CmpF src1 src2)); 
 10625   // no match-rule, false predicate
 10582   // no match-rule, false predicate
 10626   effect(DEF crx, USE src1, USE src2);
       
 10627   predicate(false);
 10583   predicate(false);
 10628 
 10584 
 10629   format %{ "cmpFUrd $crx, $src1, $src2" %}
 10585   format %{ "cmpFUrd $crx, $src1, $src2" %}
 10630   size(4);
 10586   size(4);
 10631   ins_encode %{
 10587   ins_encode %{
 10729     cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(dst, tmp1);
 10685     cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(dst, tmp1);
 10730   %}
 10686   %}
 10731 %}
 10687 %}
 10732 
 10688 
 10733 instruct cmpDUnordered_reg_reg(flagsReg crx, regD src1, regD src2) %{
 10689 instruct cmpDUnordered_reg_reg(flagsReg crx, regD src1, regD src2) %{
 10734   // no match-rule, false predicate
 10690   // Needs matchrule so that ideal opcode is Cmp. This causes that gcm places the 
 10735   effect(DEF crx, USE src1, USE src2);
 10691   // node right before the conditional move using it. 
       
 10692   // In jck test api/java_awt/geom/QuadCurve2DFloat/index.html#SetCurveTesttestCase7,
       
 10693   // compilation of java.awt.geom.RectangularShape::getBounds()Ljava/awt/Rectangle
       
 10694   // crashed in register allocation where the flags Reg between cmpDUnoredered and a
       
 10695   // conditional move was supposed to be spilled.
       
 10696   match(Set crx (CmpD src1 src2)); 
       
 10697   // False predicate, shall not be matched.
 10736   predicate(false);
 10698   predicate(false);
 10737 
 10699 
 10738   format %{ "cmpFUrd $crx, $src1, $src2" %}
 10700   format %{ "cmpFUrd $crx, $src1, $src2" %}
 10739   size(4);
 10701   size(4);
 10740   ins_encode %{
 10702   ins_encode %{
 10828   %}
 10790   %}
 10829   ins_pipe(pipe_class_default);
 10791   ins_pipe(pipe_class_default);
 10830 %}
 10792 %}
 10831 
 10793 
 10832 // Conditional Near Branch
 10794 // Conditional Near Branch
 10833 instruct branchCon(cmpOp cmp, flagsReg crx, label lbl) %{
 10795 instruct branchCon(cmpOp cmp, flagsRegSrc crx, label lbl) %{
 10834   // Same match rule as `branchConFar'.
 10796   // Same match rule as `branchConFar'.
 10835   match(If cmp crx);
 10797   match(If cmp crx);
 10836   effect(USE lbl);
 10798   effect(USE lbl);
 10837   ins_cost(BRANCH_COST);
 10799   ins_cost(BRANCH_COST);
 10838 
 10800 
 10851 // This is for cases when the ppc64 `bc' instruction does not
 10813 // This is for cases when the ppc64 `bc' instruction does not
 10852 // reach far enough. So we emit a far branch here, which is more
 10814 // reach far enough. So we emit a far branch here, which is more
 10853 // expensive.
 10815 // expensive.
 10854 //
 10816 //
 10855 // Conditional Far Branch
 10817 // Conditional Far Branch
 10856 instruct branchConFar(cmpOp cmp, flagsReg crx, label lbl) %{
 10818 instruct branchConFar(cmpOp cmp, flagsRegSrc crx, label lbl) %{
 10857   // Same match rule as `branchCon'.
 10819   // Same match rule as `branchCon'.
 10858   match(If cmp crx);
 10820   match(If cmp crx);
 10859   effect(USE crx, USE lbl);
 10821   effect(USE crx, USE lbl);
 10860   predicate(!false /* TODO: PPC port HB_Schedule*/);
 10822   predicate(!false /* TODO: PPC port HB_Schedule*/);
 10861   // Higher cost than `branchCon'.
 10823   // Higher cost than `branchCon'.
 10869   ins_encode( enc_bc_far(crx, cmp, lbl) );
 10831   ins_encode( enc_bc_far(crx, cmp, lbl) );
 10870   ins_pipe(pipe_class_default);
 10832   ins_pipe(pipe_class_default);
 10871 %}
 10833 %}
 10872 
 10834 
 10873 // Conditional Branch used with Power6 scheduler (can be far or short).
 10835 // Conditional Branch used with Power6 scheduler (can be far or short).
 10874 instruct branchConSched(cmpOp cmp, flagsReg crx, label lbl) %{
 10836 instruct branchConSched(cmpOp cmp, flagsRegSrc crx, label lbl) %{
 10875   // Same match rule as `branchCon'.
 10837   // Same match rule as `branchCon'.
 10876   match(If cmp crx);
 10838   match(If cmp crx);
 10877   effect(USE crx, USE lbl);
 10839   effect(USE crx, USE lbl);
 10878   predicate(false /* TODO: PPC port HB_Schedule*/);
 10840   predicate(false /* TODO: PPC port HB_Schedule*/);
 10879   // Higher cost than `branchCon'.
 10841   // Higher cost than `branchCon'.
 10888   size(8); // worst case
 10850   size(8); // worst case
 10889   ins_encode( enc_bc_short_far(crx, cmp, lbl) );
 10851   ins_encode( enc_bc_short_far(crx, cmp, lbl) );
 10890   ins_pipe(pipe_class_default);
 10852   ins_pipe(pipe_class_default);
 10891 %}
 10853 %}
 10892 
 10854 
 10893 instruct branchLoopEnd(cmpOp cmp, flagsReg crx, label labl) %{
 10855 instruct branchLoopEnd(cmpOp cmp, flagsRegSrc crx, label labl) %{
 10894   match(CountedLoopEnd cmp crx);
 10856   match(CountedLoopEnd cmp crx);
 10895   effect(USE labl);
 10857   effect(USE labl);
 10896   ins_cost(BRANCH_COST);
 10858   ins_cost(BRANCH_COST);
 10897 
 10859 
 10898   // short variant.
 10860   // short variant.
 10902   size(4);
 10864   size(4);
 10903   ins_encode( enc_bc(crx, cmp, labl) );
 10865   ins_encode( enc_bc(crx, cmp, labl) );
 10904   ins_pipe(pipe_class_default);
 10866   ins_pipe(pipe_class_default);
 10905 %}
 10867 %}
 10906 
 10868 
 10907 instruct branchLoopEndFar(cmpOp cmp, flagsReg crx, label labl) %{
 10869 instruct branchLoopEndFar(cmpOp cmp, flagsRegSrc crx, label labl) %{
 10908   match(CountedLoopEnd cmp crx);
 10870   match(CountedLoopEnd cmp crx);
 10909   effect(USE labl);
 10871   effect(USE labl);
 10910   predicate(!false /* TODO: PPC port HB_Schedule */);
 10872   predicate(!false /* TODO: PPC port HB_Schedule */);
 10911   ins_cost(BRANCH_COST);
 10873   ins_cost(BRANCH_COST);
 10912 
 10874 
 10918   ins_encode( enc_bc_far(crx, cmp, labl) );
 10880   ins_encode( enc_bc_far(crx, cmp, labl) );
 10919   ins_pipe(pipe_class_default);
 10881   ins_pipe(pipe_class_default);
 10920 %}
 10882 %}
 10921 
 10883 
 10922 // Conditional Branch used with Power6 scheduler (can be far or short).
 10884 // Conditional Branch used with Power6 scheduler (can be far or short).
 10923 instruct branchLoopEndSched(cmpOp cmp, flagsReg crx, label labl) %{
 10885 instruct branchLoopEndSched(cmpOp cmp, flagsRegSrc crx, label labl) %{
 10924   match(CountedLoopEnd cmp crx);
 10886   match(CountedLoopEnd cmp crx);
 10925   effect(USE labl);
 10887   effect(USE labl);
 10926   predicate(false /* TODO: PPC port HB_Schedule */);
 10888   predicate(false /* TODO: PPC port HB_Schedule */);
 10927   // Higher cost than `branchCon'.
 10889   // Higher cost than `branchCon'.
 10928   ins_cost(5*BRANCH_COST);
 10890   ins_cost(5*BRANCH_COST);
 10967 // inlined locking and unlocking
 10929 // inlined locking and unlocking
 10968 
 10930 
 10969 instruct cmpFastLock(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{
 10931 instruct cmpFastLock(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{
 10970   match(Set crx (FastLock oop box));
 10932   match(Set crx (FastLock oop box));
 10971   effect(TEMP tmp1, TEMP tmp2, TEMP tmp3);
 10933   effect(TEMP tmp1, TEMP tmp2, TEMP tmp3);
 10972   // TODO PPC port predicate(!UseNewFastLockPPC64 || UseBiasedLocking);
 10934   predicate(/*(!UseNewFastLockPPC64 || UseBiasedLocking) &&*/ !Compile::current()->use_rtm());
 10973 
 10935 
 10974   format %{ "FASTLOCK  $oop, $box, $tmp1, $tmp2, $tmp3" %}
 10936   format %{ "FASTLOCK  $oop, $box, $tmp1, $tmp2, $tmp3" %}
 10975   ins_encode %{
 10937   ins_encode %{
 10976     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
 10938     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
 10977     __ compiler_fast_lock_object($crx$$CondRegister, $oop$$Register, $box$$Register,
 10939     __ compiler_fast_lock_object($crx$$CondRegister, $oop$$Register, $box$$Register,
 10978                                  $tmp3$$Register, $tmp1$$Register, $tmp2$$Register);
 10940                                  $tmp3$$Register, $tmp1$$Register, $tmp2$$Register,
       
 10941                                  UseBiasedLocking && !UseOptoBiasInlining); // SAPJVM MD 2014-11-06 UseOptoBiasInlining
 10979     // If locking was successfull, crx should indicate 'EQ'.
 10942     // If locking was successfull, crx should indicate 'EQ'.
 10980     // The compiler generates a branch to the runtime call to
 10943     // The compiler generates a branch to the runtime call to
 10981     // _complete_monitor_locking_Java for the case where crx is 'NE'.
 10944     // _complete_monitor_locking_Java for the case where crx is 'NE'.
 10982   %}
 10945   %}
 10983   ins_pipe(pipe_class_compare);
 10946   ins_pipe(pipe_class_compare);
 10984 %}
 10947 %}
 10985 
 10948 
       
 10949 // Separate version for TM. Use bound register for box to enable USE_KILL.
       
 10950 instruct cmpFastLock_tm(flagsReg crx, iRegPdst oop, rarg2RegP box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{
       
 10951   match(Set crx (FastLock oop box));
       
 10952   effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, USE_KILL box);
       
 10953   predicate(Compile::current()->use_rtm());
       
 10954 
       
 10955   format %{ "FASTLOCK  $oop, $box, $tmp1, $tmp2, $tmp3 (TM)" %}
       
 10956   ins_encode %{
       
 10957     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
       
 10958     __ compiler_fast_lock_object($crx$$CondRegister, $oop$$Register, $box$$Register,
       
 10959                                  $tmp3$$Register, $tmp1$$Register, $tmp2$$Register,
       
 10960                                  /*Biased Locking*/ false,
       
 10961                                  _rtm_counters, _stack_rtm_counters,
       
 10962                                  ((Method*)(ra_->C->method()->constant_encoding()))->method_data(),
       
 10963                                  /*TM*/ true, ra_->C->profile_rtm());
       
 10964     // If locking was successfull, crx should indicate 'EQ'.
       
 10965     // The compiler generates a branch to the runtime call to
       
 10966     // _complete_monitor_locking_Java for the case where crx is 'NE'.
       
 10967   %}
       
 10968   ins_pipe(pipe_class_compare);
       
 10969 %}
       
 10970 
 10986 instruct cmpFastUnlock(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{
 10971 instruct cmpFastUnlock(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{
 10987   match(Set crx (FastUnlock oop box));
 10972   match(Set crx (FastUnlock oop box));
 10988   effect(TEMP tmp1, TEMP tmp2, TEMP tmp3);
 10973   effect(TEMP tmp1, TEMP tmp2, TEMP tmp3);
       
 10974   predicate(!Compile::current()->use_rtm());
 10989 
 10975 
 10990   format %{ "FASTUNLOCK  $oop, $box, $tmp1, $tmp2" %}
 10976   format %{ "FASTUNLOCK  $oop, $box, $tmp1, $tmp2" %}
 10991   ins_encode %{
 10977   ins_encode %{
 10992     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
 10978     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
 10993     __ compiler_fast_unlock_object($crx$$CondRegister, $oop$$Register, $box$$Register,
 10979     __ compiler_fast_unlock_object($crx$$CondRegister, $oop$$Register, $box$$Register,
 10994                                    $tmp3$$Register, $tmp1$$Register, $tmp2$$Register);
 10980                                    $tmp3$$Register, $tmp1$$Register, $tmp2$$Register,
       
 10981                                    UseBiasedLocking && !UseOptoBiasInlining,
       
 10982                                    false);
       
 10983     // If unlocking was successfull, crx should indicate 'EQ'.
       
 10984     // The compiler generates a branch to the runtime call to
       
 10985     // _complete_monitor_unlocking_Java for the case where crx is 'NE'.
       
 10986   %}
       
 10987   ins_pipe(pipe_class_compare);
       
 10988 %}
       
 10989 
       
 10990 instruct cmpFastUnlock_tm(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{
       
 10991   match(Set crx (FastUnlock oop box));
       
 10992   effect(TEMP tmp1, TEMP tmp2, TEMP tmp3);
       
 10993   predicate(Compile::current()->use_rtm());
       
 10994 
       
 10995   format %{ "FASTUNLOCK  $oop, $box, $tmp1, $tmp2 (TM)" %}
       
 10996   ins_encode %{
       
 10997     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
       
 10998     __ compiler_fast_unlock_object($crx$$CondRegister, $oop$$Register, $box$$Register,
       
 10999                                    $tmp3$$Register, $tmp1$$Register, $tmp2$$Register,
       
 11000                                    /*Biased Locking*/ false, /*TM*/ true);
 10995     // If unlocking was successfull, crx should indicate 'EQ'.
 11001     // If unlocking was successfull, crx should indicate 'EQ'.
 10996     // The compiler generates a branch to the runtime call to
 11002     // The compiler generates a branch to the runtime call to
 10997     // _complete_monitor_unlocking_Java for the case where crx is 'NE'.
 11003     // _complete_monitor_unlocking_Java for the case where crx is 'NE'.
 10998   %}
 11004   %}
 10999   ins_pipe(pipe_class_compare);
 11005   ins_pipe(pipe_class_compare);
 11655     // TODO: PPC port $archOpcode(ppc64Opcode_addi);
 11661     // TODO: PPC port $archOpcode(ppc64Opcode_addi);
 11656     __ li($dst$$Register, 0x0);
 11662     __ li($dst$$Register, 0x0);
 11657   %}
 11663   %}
 11658   ins_pipe(pipe_class_default);
 11664   ins_pipe(pipe_class_default);
 11659 %}
 11665 %}
       
 11666 
       
 11667 
       
 11668 //----------Overflow Math Instructions-----------------------------------------
       
 11669 
       
 11670 // Note that we have to make sure that XER.SO is reset before using overflow instructions.
       
 11671 // Simple Overflow operations can be matched by very few instructions (e.g. addExact: xor, and_, bc).
       
 11672 // Seems like only Long intrinsincs have an advantage. (The only expensive one is OverflowMulL.)
       
 11673 
       
 11674 instruct overflowAddL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{
       
 11675   match(Set cr0 (OverflowAddL op1 op2));
       
 11676 
       
 11677   format %{ "add_    $op1, $op2\t# overflow check long" %}
       
 11678   ins_encode %{
       
 11679     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
       
 11680     __ li(R0, 0);
       
 11681     __ mtxer(R0); // clear XER.SO
       
 11682     __ addo_(R0, $op1$$Register, $op2$$Register);
       
 11683   %}
       
 11684   ins_pipe(pipe_class_default);
       
 11685 %}
       
 11686 
       
 11687 instruct overflowSubL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{
       
 11688   match(Set cr0 (OverflowSubL op1 op2));
       
 11689 
       
 11690   format %{ "subfo_  R0, $op2, $op1\t# overflow check long" %}
       
 11691   ins_encode %{
       
 11692     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
       
 11693     __ li(R0, 0);
       
 11694     __ mtxer(R0); // clear XER.SO
       
 11695     __ subfo_(R0, $op2$$Register, $op1$$Register);
       
 11696   %}
       
 11697   ins_pipe(pipe_class_default);
       
 11698 %}
       
 11699 
       
 11700 instruct overflowNegL_reg(flagsRegCR0 cr0, immL_0 zero, iRegLsrc op2) %{
       
 11701   match(Set cr0 (OverflowSubL zero op2));
       
 11702 
       
 11703   format %{ "nego_   R0, $op2\t# overflow check long" %}
       
 11704   ins_encode %{
       
 11705     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
       
 11706     __ li(R0, 0);
       
 11707     __ mtxer(R0); // clear XER.SO
       
 11708     __ nego_(R0, $op2$$Register);
       
 11709   %}
       
 11710   ins_pipe(pipe_class_default);
       
 11711 %}
       
 11712 
       
 11713 instruct overflowMulL_reg_reg(flagsRegCR0 cr0, iRegLsrc op1, iRegLsrc op2) %{
       
 11714   match(Set cr0 (OverflowMulL op1 op2));
       
 11715 
       
 11716   format %{ "mulldo_ R0, $op1, $op2\t# overflow check long" %}
       
 11717   ins_encode %{
       
 11718     // TODO: PPC port $archOpcode(ppc64Opcode_compound);
       
 11719     __ li(R0, 0);
       
 11720     __ mtxer(R0); // clear XER.SO
       
 11721     __ mulldo_(R0, $op1$$Register, $op2$$Register);
       
 11722   %}
       
 11723   ins_pipe(pipe_class_default);
       
 11724 %}
       
 11725 
 11660 
 11726 
 11661 // ============================================================================
 11727 // ============================================================================
 11662 // Safepoint Instruction
 11728 // Safepoint Instruction
 11663 
 11729 
 11664 instruct safePoint_poll(iRegPdst poll) %{
 11730 instruct safePoint_poll(iRegPdst poll) %{