harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r672239 [1/2] - in /harmony/enhanced/drlvm/trunk/vm: jitrino/config/em64t/ jitrino/config/ia32/ jitrino/src/codegenerator/ia32/ jitrino/src/jet/ jitrino/src/optimizer/ jitrino/src/shared/ port/src/encoder/ia32_em64t/ vmcore/src/lil/em64t/ v...
Date Fri, 27 Jun 2008 11:01:51 GMT
Author: varlax
Date: Fri Jun 27 04:01:50 2008
New Revision: 672239

URL: http://svn.apache.org/viewvc?rev=672239&view=rev
Log:
Applied HARMONY-5037 [drlvm][jit][opt] improper opcode group lookup

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/client.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/opt.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/server.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/opt.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc2.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc3.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32SpillGen.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jdefs.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_base.cpp
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_base.h
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_defs.h
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_prvt.h
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_tabl.cpp
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.h
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/encoder.inl
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/lil/em64t/lil_code_generator_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/lil/em64t/m2n_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/lil/ia32/lil_code_generator_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/lil/ia32/m2n_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/lil/ia32/stack_iterator_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/em64t/base/compile_em64t.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/client.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/client.emconf?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/client.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/client.emconf Fri Jun 27 04:01:50 2008
@@ -56,7 +56,7 @@
 -XX:jit.CD_OPT.path=opt_init,lock_method,translator,optimizer,hir2lir,codegen,unlock_method
 
 -XX:jit.CD_OPT.path.optimizer=ssa,devirt,inline,purge,simplify,dce,uce,memopt,simplify,dce,uce,lower,dessa,statprof
--XX:jit.CD_OPT.path.codegen=bbp,gcpoints,cafl,dce1,i8l-,api_magic,light_jni-,early_prop-,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info
+-XX:jit.CD_OPT.path.codegen=bbp,gcpoints,cafl,dce1,i8l-,api_magic,light_jni-,early_prop-,itrace-,native,constraints,dce2,regalloc-,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info
 -XX:jit.CD_OPT.path.dce1=cg_dce
 -XX:jit.CD_OPT.path.dce2=cg_dce
 -XX:jit.CD_OPT.path.regalloc=bp_regalloc1,bp_regalloc2

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/opt.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/opt.emconf?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/opt.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/opt.emconf Fri Jun 27 04:01:50 2008
@@ -27,7 +27,7 @@
 -XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,simplify,dce,uce,osr_path-,escape_path,dce,uce,memopt,simplify,dce,uce,lower,dessa,statprof
 -XX:jit.CS_OPT.path.osr_path=gcm,osr,simplify,dce,uce
 -XX:jit.CS_OPT.path.escape_path=hvn,simplify,dce,uce,escape
--XX:jit.CS_OPT.path.codegen=bbp,gcpoints,cafl,dce1,i8l-,api_magic,light_jni-,early_prop-,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info
+-XX:jit.CS_OPT.path.codegen=bbp,gcpoints,cafl,dce1,i8l-,api_magic,light_jni-,early_prop-,itrace-,native,constraints,dce2,regalloc-,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info
 -XX:jit.CS_OPT.path.dce1=cg_dce
 -XX:jit.CS_OPT.path.dce2=cg_dce
 -XX:jit.CS_OPT.path.regalloc=bp_regalloc1,bp_regalloc2

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/server.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/server.emconf?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/em64t/server.emconf Fri Jun 27 04:01:50 2008
@@ -67,7 +67,7 @@
 
 -XX:jit.SD1_OPT.path.optimizer=ssa,simplify,dce,uce,vp_instrument,devirt_virtual,edge_instrument,dessa,statprof
 -XX:jit.SD1_OPT.path.devirt_virtual=devirt
--XX:jit.SD1_OPT.path.codegen=bbp,gcpoints,cafl,dce1,i8l-,light_jni-,early_prop-,itrace-,native,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info
+-XX:jit.SD1_OPT.path.codegen=bbp,gcpoints,cafl,dce1,i8l-,light_jni-,early_prop-,itrace-,native,constraints,dce2,regalloc-,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info
 -XX:jit.SD1_OPT.path.dce1=cg_dce
 -XX:jit.SD1_OPT.path.dce2=cg_dce
 
@@ -82,7 +82,7 @@
 -XX:jit.SD2_OPT.path.osr_path=gcm,osr,simplify,dce,uce
 -XX:jit.SD2_OPT.path.escape_path=hvn,simplify,dce,uce,escape
 -XX:jit.SD2_OPT.path.abce=classic_abcd,dce,uce,dessa,statprof,peel,ssa,hvn,simplify,dce,uce,memopt,dce,uce,dessa,fastArrayFill,ssa,statprof,dabce,dce,uce
--XX:jit.SD2_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l-,api_magic,light_jni-,early_prop-,itrace-,native,cg_fastArrayFill,constraints,dce2,regalloc,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method
+-XX:jit.SD2_OPT.path.codegen=lock_method,bbp,gcpoints,cafl,dce1,i8l-,api_magic,light_jni-,early_prop-,itrace-,native,cg_fastArrayFill,constraints,dce2,regalloc-,spillgen,layout,copy,rce-,stack,break-,iprof-,emitter!,si_insts,gcmap,info,unlock_method
 -XX:jit.SD2_OPT.path.dce1=cg_dce
 -XX:jit.SD2_OPT.path.dce2=cg_dce
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/opt.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/opt.emconf?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/opt.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/opt.emconf Fri Jun 27 04:01:50 2008
@@ -27,7 +27,7 @@
 -XX:jit.CS_OPT.path.optimizer=ssa,devirt,hlo_api_magic,inline,purge,simplify,dce,uce,osr_path-,lazyexc,throwopt,escape_path,dce,uce,memopt,simplify,dce,uce,lower,statprof,unroll,ssa,simplify,dce,uce,dessa,statprof
 -XX:jit.CS_OPT.path.osr_path=gcm,osr,simplify,dce,uce
 -XX:jit.CS_OPT.path.escape_path=hvn,simplify,dce,uce,escape
--XX:jit.CS_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic,light_jni-,early_prop,peephole,itrace-,native,constraints,dce2,regalloc,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info
+-XX:jit.CS_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic,light_jni-,early_prop,peephole,itrace-,native,constraints,dce2,regalloc-,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info
 -XX:jit.CS_OPT.path.dce1=cg_dce
 -XX:jit.CS_OPT.path.dce2=cg_dce
 -XX:jit.CS_OPT.path.regalloc=bp_regalloc1,bp_regalloc2

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/config/ia32/server.emconf Fri Jun 27 04:01:50 2008
@@ -67,7 +67,7 @@
 
 -XX:jit.SD1_OPT.path.optimizer=ssa,simplify,dce,uce,vp_instrument,devirt_virtual,edge_instrument,dessa,statprof
 -XX:jit.SD1_OPT.path.devirt_virtual=devirt
--XX:jit.SD1_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic,light_jni-,early_prop,peephole,itrace-,native,constraints,dce2,regalloc,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info
+-XX:jit.SD1_OPT.path.codegen=bbp,btr,gcpoints,cafl,dce1,i8l,api_magic,light_jni-,early_prop,peephole,itrace-,native,constraints,dce2,regalloc-,spillgen,copy,i586,layout,rce+,stack,break-,iprof-,peephole,emitter!,si_insts,gcmap,info
 -XX:jit.SD1_OPT.path.dce1=cg_dce
 -XX:jit.SD1_OPT.path.dce2=cg_dce
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32APIMagics.cpp Fri Jun 27 04:01:50 2008
@@ -939,7 +939,9 @@
 
     if(srcType != dstType) {
 #ifdef _EM64T_
-        node->appendInst(irm->newInstEx(Mnemonic_MOVZX, 1, dst, src));
+        Opnd* aux = irm->newOpnd(irm->getTypeManager().getUInt32Type());
+        node->appendInst(irm->newCopyPseudoInst(Mnemonic_MOV, aux, src));
+        node->appendInst(irm->newInstEx(Mnemonic_MOVZX, 1, dst, aux));
 #else
         node->appendInst(irm->newCopyPseudoInst(Mnemonic_MOV, dst, src));
 #endif

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.cpp Fri Jun 27 04:01:50 2008
@@ -102,6 +102,7 @@
 Constraint Constraint::getAliasConstraint(OpndSize s, U_32 offset)const
 {
     OpndSize sz=(OpndSize)size;
+    OpndExt e = (OpndExt)ext;
     if (s==OpndSize_Default){
         s=getDefaultSize(kind);
         if (s==OpndSize_Any)
@@ -134,7 +135,7 @@
         newMask=mask;
     }
     if (newMask==0) newKind&=~OpndKind_Reg;
-    return newKind==OpndKind_Null?Constraint():Constraint( (OpndKind)newKind, s, newMask);
+    return newKind==OpndKind_Null?Constraint():Constraint( (OpndKind)newKind, s, e, newMask);
 }
 
 //_________________________________________________________________________________________________
@@ -181,7 +182,7 @@
 RegName Constraint::getAliasRegName(RegName regName, U_32 offset)const
 {
     RegName rn=getAliasRegName(regName, (OpndSize)size, offset);
-    return contains(rn)?rn:RegName_Null;
+    return contains(Constraint(rn,(OpndExt)ext))?rn:RegName_Null;
 }
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.h?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Constraint.h Fri Jun 27 04:01:50 2008
@@ -72,7 +72,7 @@
     For OpndKind_Reg and sub-kinds initializes the mask field to 0xffff
     */
     Constraint(OpndKind k)
-        :mask(OpndKind_Reg&k?0xffff:0), size(OpndSize_Any), kind(k)
+        :mask(OpndKind_Reg&k?0xffff:0), size(OpndSize_Any), ext(OpndExt_Any), kind(k)
     { assert(k!=OpndKind_Null); }
 
     /** Creates a constraint of the specified OpndKind k and OpndSize s
@@ -82,17 +82,27 @@
     If k contains OpndKind_Reg the constructor initializes the mask field to 0xffff
     */
     Constraint(OpndKind k, OpndSize s)
-        :mask(OpndKind_Reg&k?0xffff:0), size(s), kind(k)
+        :mask(OpndKind_Reg&k?0xffff:0), size(s), ext(OpndExt_Any), kind(k)
     { assert(k!=OpndKind_Null && size!=OpndSize_Null); }
 
-    /** Creates a constraint of the specified OpndKind, OpndSize, and register mask m
+    /** Creates a constraint of the specified OpndKind k, OpndSize s and OpndExt e
+
+    Both k and s cannot be _Null.
+
+    If k contains OpndKind_Reg the constructor initializes the mask field to 0xffff
+    */
+    Constraint(OpndKind k, OpndSize s, OpndExt e)
+        :mask(OpndKind_Reg&k?0xffff:0), size(s), ext(e), kind(k)
+    { assert(k!=OpndKind_Null && size!=OpndSize_Null); }
+
+    /** Creates a constraint of the specified OpndKind, OpndSize, OpndExt and register mask m
 
     Both k and s cannot be _Null, and k must contain be OpndKind_Reg if mask is not null
 
     For OpndKind_Reg and sub-kinds initializes the mask field to 0xffff
     */
-    Constraint(OpndKind k, OpndSize s, U_32 m)
-        :mask(m), size(s), kind(k)
+    Constraint(OpndKind k, OpndSize s, OpndExt e, U_32 m)
+        :mask(m), size(s), ext(e), kind(k)
     {   assert(k!=OpndKind_Null && size!=OpndSize_Null); assert(mask==0||(OpndKind_Reg&k)!=0);  }
 
     /** Creates a constraint corresponding to the specified physical register RegName
@@ -103,8 +113,8 @@
 
     The mask field of the constraint is initialized to the mask corresponding to the specified register
     */
-    Constraint(RegName reg)
-        :mask(getRegMask(reg)), size(getRegSize(reg)), kind(getRegKind(reg)) {}
+    Constraint(RegName reg, OpndExt e = OpndExt_Any)
+        :mask(getRegMask(reg)), size(getRegSize(reg)), ext(e), kind(getRegKind(reg)) {}
 
     
     Constraint(const char * str){ fullValue = 0; str=parse(str); assert(str!=NULL); }
@@ -119,6 +129,12 @@
     /** returns the mask field of the constraint */
     U_32 getMask()const{ return mask; }
 
+    /** returns the ext field of the constraint */
+    OpndExt getExt()const {return (OpndExt)ext; }
+    
+    /** sets the ext field of the constraint */
+    void setExt(U_32 e){ext=e; }
+    
     /** sets the mask field of the constraint */
     void setMask(U_32 m){ mask=m; }
 
@@ -217,7 +233,8 @@
     union{
         struct {
             U_32  mask:16;
-            U_32  size:8;
+            U_32  size:6;
+            U_32  ext:2;
             U_32  kind:8;
         };
         U_32  fullValue;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32CopyExpansion.cpp Fri Jun 27 04:01:50 2008
@@ -409,7 +409,7 @@
                         if (toOpnd == fromOpnd){
                             continue;
                         } else if (toOpnd->isPlacedIn(OpndKind_Reg) && fromOpnd->isPlacedIn(OpndKind_Reg)){
-                            if (toOpnd->getRegName()==fromOpnd->getRegName())
+                            if ( equals(toOpnd->getRegName(),fromOpnd->getRegName()) )
                                 continue;
                         }else{
 #ifdef _EM64T_

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32EarlyPropagation.cpp Fri Jun 27 04:01:50 2008
@@ -62,6 +62,9 @@
 static bool isTypeConversionAllowed(Opnd* fromOpnd, Opnd* toOpnd) {
     Type * fromType = fromOpnd->getType();
     Type * toType = toOpnd->getType();
+    if (fromType->isFloatingPoint() != toType->isFloatingPoint()) {
+        return false;
+    }
     bool fromIsGCType = fromType->isObject() || fromType->isManagedPtr();
     bool toIsGCType = toType->isObject() || toType->isManagedPtr();
     return fromIsGCType == toIsGCType;
@@ -153,8 +156,17 @@
                     U_32 defOpndId = defOpnd->getId();
                     OpndInfo * opndInfo = opndInfos + defOpndId;
                     bool instHandled=false;
-                    bool typeConvOk = isTypeConversionAllowed(srcOpnd, defOpnd);
-                    if (typeConvOk && opndInfo->defCount == 1 && ! srcOpnd->isPlacedIn(OpndKind_Reg)){
+                    bool typeConvOk = srcOpnd->getSize() == defOpnd->getSize() && isTypeConversionAllowed(srcOpnd, defOpnd);
+                    bool kindsAreOk = true;
+                    // this is caused by the fact that FPReg and XMMReg can not be merged in the same Constraint
+                    // there might be a problem with replacing operads of different reg kinds
+                    // if src and def has different reg kinds the inst must be skipped
+                    if(srcOpnd->canBePlacedIn(OpndKind_FPReg) || defOpnd->canBePlacedIn(OpndKind_FPReg)) {
+                        Constraint srcConstr = srcOpnd->getConstraint(Opnd::ConstraintKind_Calculated);
+                        Constraint defConstr = defOpnd->getConstraint(Opnd::ConstraintKind_Calculated);
+                        kindsAreOk = ! (srcConstr&defConstr).isNull();
+                    }
+                    if (typeConvOk && kindsAreOk && opndInfo->defCount == 1 && ! srcOpnd->isPlacedIn(OpndKind_Reg)){
                         if (!defOpnd->hasAssignedPhysicalLocation()){
                             opndInfo->sourceInst = inst;
                             opndInfo->sourceOpndId = srcOpnd->getId();

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.cpp Fri Jun 27 04:01:50 2008
@@ -99,16 +99,16 @@
     switch(regKind) {
     case OpndKind_GPReg:
         return Constraint(OpndKind_GPReg, 
-                          Constraint::getDefaultSize(OpndKind_GPReg), 0xff);
+                          Constraint::getDefaultSize(OpndKind_GPReg), OpndExt_None, 0xff);
     case OpndKind_XMMReg:
         return Constraint(OpndKind_XMMReg,
-                          Constraint::getDefaultSize(OpndKind_XMMReg), 0xff);
+                          Constraint::getDefaultSize(OpndKind_XMMReg), OpndExt_None, 0xff);
     case OpndKind_FPReg:
         return Constraint(OpndKind_FPReg,
-                          Constraint::getDefaultSize(OpndKind_FPReg), 0x1);
+                          Constraint::getDefaultSize(OpndKind_FPReg), OpndExt_None, 0x1);
     case OpndKind_StatusReg:
         return Constraint(OpndKind_StatusReg,
-                        Constraint::getDefaultSize(OpndKind_StatusReg), 0x1);
+                        Constraint::getDefaultSize(OpndKind_StatusReg), OpndExt_None, 0x1);
     default: 
         break;
     }
@@ -129,14 +129,6 @@
 };
 
 //_________________________________________________________________________________________________
-bool Encoder::matches(Constraint co, Constraint ci, U_32 opndRoles,
-                      bool allowAliases)
-{
-    return co.isNull() || !(ci&co).isNull() || 
-        (allowAliases && !(ci.getAliasConstraint(co.getSize())&co).isNull());
-}
-
-//_________________________________________________________________________________________________
 const Encoder::OpcodeGroup * 
 Encoder::findOpcodeGroup(const FindInfo& fi)
 {
@@ -177,11 +169,7 @@
         }
     }
     for (U_32 i = 0, n = fi.opndCount; i < n; i++) {
-        U_32 idx = fi.isExtended ? og->extendedToNativeMap[i] : i;
-        Constraint co=fi.opndConstraints[idx];
-        if (any) {
-            co = Constraint(OpndKind_Any, co.getSize());
-        }
+        Constraint co = fi.opndConstraints[i];
         if (!isOpndAllowed(og, i, co, fi.isExtended, any))
             return false;
     }
@@ -189,6 +177,29 @@
 }
 
 //_________________________________________________________________________________________________
+bool Encoder::matches(Constraint co, Constraint ci)
+{
+    Constraint cc = ci&co;   
+    return  co.isNull() || ( !cc.isNull() && EncoderBase::extAllowed(co.getExt(),ci.getExt()) );
+}
+
+Constraint
+Encoder::expandImmediate(Constraint co) {
+    assert(co.getKind() == OpndKind_Imm);
+    OpndSize newSize = OpndSize_Null; 
+    switch (co.getSize()) {
+    case OpndSize_8:
+        newSize = OpndSize_16;
+        break;
+    case OpndSize_16:
+        newSize = OpndSize_32;
+        break;
+    default:;
+    }
+    return newSize == OpndSize_Null ? Constraint() :
+        Constraint((OpndKind)co.getKind(), newSize, co.getExt(), co.getMask());
+}
+//_________________________________________________________________________________________________
 bool 
 Encoder::isOpndAllowed(const Encoder::OpcodeGroup * og, U_32 i, Constraint co, bool isExtended, bool any)
 {
@@ -197,10 +208,22 @@
 
         Constraint ci=og->opndConstraints[idx];
 
-        if (!matches(co, ci, Encoder::getOpndRoles(og->opndRoles,idx), any && (!(Encoder::getOpndRoles(og->opndRoles,idx)&Inst::OpndRole_Def) || getBaseConditionMnemonic(og->mnemonic) == Mnemonic_SETcc))) {
-            return false;
+        assert(!ci.isNull());
+        
+        // Strict matching
+        if (matches(co, ci)) {
+            return true;
+        }
+        
+        // Try to match with extended immediate.
+        if (any && co.getKind() == OpndKind_Imm) {
+            while (!(co = expandImmediate(co)).isNull()) {
+                if (matches(co, ci)) {
+                    return true;
+                }
+            }
         }
-        return true;
+        return false;
 }
 
 //_________________________________________________________________________________________________
@@ -219,11 +242,12 @@
         const Opnd * p = opnds[idx];
         Constraint c = p->getConstraint(Opnd::ConstraintKind_Location);
 
+        OpndExt ext = p->getConstraint(Opnd::ConstraintKind_Calculated).getExt();
         OpndSize sz = inst->opcodeGroup->opndConstraints[args.count()].getSize();
     
         switch( c.getKind() ) {
         case OpndKind_Imm:
-            args.add(EncoderBase::Operand(sz, p->getImmValue()));
+            args.add(EncoderBase::Operand(sz, p->getImmValue(), ext));
             break;
         case OpndKind_Mem:
             {
@@ -262,7 +286,8 @@
                     baseReg,
                     indexReg,
                     NULL == pscale ? 0 : (unsigned char)pscale->getImmValue(),
-                    disp);
+                    disp,
+                    ext);
                 args.add( o );
                 // Emit prefix here - so it relates to the real instruction
                 // emitted alter, rather that to the hidden MOV inserted above
@@ -280,7 +305,7 @@
             // with different size
             RegName reg = Constraint::getAliasRegName(opndReg, sz);
             assert(reg != RegName_Null);
-            args.add(EncoderBase::Operand(reg));
+            args.add(EncoderBase::Operand(reg,ext));
             }
             break;
         }
@@ -329,8 +354,8 @@
         if(!((Constraint)og.opndConstraints[j]).canBeMergedWith(od.opndConstraints[j]))
             return false;
 
-        Constraint ogConstr = ((Constraint)og.opndConstraints[j]).intersectWith(Constraint((OpndKind)(OpndKind_Reg|OpndKind_Imm),OpndSize_Any,0xFFFF));
-        Constraint odConstr = ((Constraint)od.opndConstraints[j]).intersectWith(Constraint((OpndKind)(OpndKind_Reg|OpndKind_Imm),OpndSize_Any,0xFFFF));
+        Constraint ogConstr = ((Constraint)og.opndConstraints[j]).intersectWith(Constraint((OpndKind)(OpndKind_Reg|OpndKind_Imm), OpndSize_Any, OpndExt_Any, 0xFFFF));
+        Constraint odConstr = ((Constraint)od.opndConstraints[j]).intersectWith(Constraint((OpndKind)(OpndKind_Reg|OpndKind_Imm), OpndSize_Any, OpndExt_Any, 0xFFFF));
 
         Constraint::CompareResult compareResult = ogConstr.compare(odConstr);
 
@@ -419,12 +444,14 @@
     for (unsigned k=0; k<od.opndRoles.count; k++) {
         if (opcode->opnds[k].reg != RegName_Null) {
             // exact Register specified
-            od.opndConstraints[k] = Constraint(opcode->opnds[k].reg);
+            od.opndConstraints[k] = Constraint(opcode->opnds[k].reg, opcode->opnds[k].ext);
         }
         else {
-            od.opndConstraints[k] = Constraint(opcode->opnds[k].kind, 
-                opcode->opnds[k].size == OpndSize_Null ? 
-                                        OpndSize_Any : opcode->opnds[k].size);
+            od.opndConstraints[k] = Constraint(
+                opcode->opnds[k].kind, 
+                opcode->opnds[k].size == OpndSize_Null ? OpndSize_Any : opcode->opnds[k].size,
+                opcode->opnds[k].ext
+            );
         }
     }
 }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.h?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Encoder.h Fri Jun 27 04:01:50 2008
@@ -68,7 +68,8 @@
         const OpcodeGroup * opcodeGroup;
     };
 
-    static bool matches(Constraint co, Constraint ci, U_32 opndRoles, bool allowAliases);
+    static bool matches(Constraint co, Constraint ci);
+    static Constraint expandImmediate(Constraint co);
     static const OpcodeGroup* findOpcodeGroup(const FindInfo& fi);
     static bool matches(const OpcodeGroup* og, const FindInfo& fi, bool any);
     static bool isOpndAllowed(const Encoder::OpcodeGroup * og, U_32 i, Constraint co, bool isExtended, bool any);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32GCSafePoints.cpp Fri Jun 27 04:01:50 2008
@@ -338,7 +338,7 @@
 }
 
 I_32 GCSafePointsInfo::getOffsetFromImmediate(Opnd* offsetOpnd) const {
-    if (offsetOpnd->isPlacedIn(OpndKind_Immediate)) {
+    if (offsetOpnd->isPlacedIn(OpndKind_Imm)) {
         if (offsetOpnd->getImmValue() == 0 && offsetOpnd->getRuntimeInfo()!=NULL) {
             irm.resolveRuntimeInfo(offsetOpnd);
         }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32I8Lowerer.cpp Fri Jun 27 04:01:50 2008
@@ -1122,6 +1122,7 @@
     Opnd* temp_hi = irManager->newOpnd(int32type);
     Opnd* zero = irManager->newImmOpnd(int32type, 0);
     Opnd* one = irManager->newImmOpnd(int32type, 1);
+    Opnd* one8 = irManager->newImmOpnd(tm.getInt8Type(), 1);
     //
 
     newSubGFG();
@@ -1282,10 +1283,10 @@
                             // ^^^divisor now in edi:ebx and ecx:esi
 
                             // shift both divisor and dividend right on 1 bit
-    /* shr edx, 1       */  newInst(Mnemonic_SHR, edx, one);
-    /* rcr eax, 1       */  newInst(Mnemonic_RCR, eax, one);
-    /* ror edi, 1       */  newInst(Mnemonic_ROR, edi, one);
-    /* rcr ebx, 1       */  newInst(Mnemonic_RCR, ebx, one);
+    /* shr edx, 1       */  newInst(Mnemonic_SHR, edx, one8);
+    /* rcr eax, 1       */  newInst(Mnemonic_RCR, eax, one8);
+    /* ror edi, 1       */  newInst(Mnemonic_ROR, edi, one8);
+    /* rcr ebx, 1       */  newInst(Mnemonic_RCR, ebx, one8);
 
     //
     // FIXME: workarounding WebMaker problem, which does not like 
@@ -1313,14 +1314,18 @@
     /* shrd eax, edx, CL*/  newInst(Mnemonic_SHRD, eax, edx, ecx);
     /* shr  edx, CL   */    newInst(Mnemonic_SHR, edx, ecx);
 #else
-    Opnd* trueECX = irManager->getRegOpnd(RegName_ECX);
+//    Opnd* trueECX = irManager->getRegOpnd(RegName_ECX);
+    Opnd* trueECX   = irManager->newOpnd(tm.getInt32Type()/*, Constraint(RegName_ECX)*/);
     newInst(Mnemonic_MOV, trueECX, ecx);
+//    Opnd* ecxCL   = irManager->getRegOpnd(RegName_CL);
+    Opnd* ecxCL   = irManager->newOpnd(tm.getInt8Type(), Constraint(RegName_CL));
+    newInst(Mnemonic_MOV, ecxCL, trueECX);
     //~FIXME
-    /* shrd ebx, edi, CL*/  newInst(Mnemonic_SHRD, ebx, edi, trueECX);
-    /* shrd eax, edx, CL*/  newInst(Mnemonic_SHRD, eax, edx, trueECX);
-    /* shr  edx, CL   */    newInst(Mnemonic_SHR, edx, trueECX);
+    /* shrd ebx, edi, CL*/  newInst(Mnemonic_SHRD, ebx, edi, ecxCL);
+    /* shrd eax, edx, CL*/  newInst(Mnemonic_SHRD, eax, edx, ecxCL);
+    /* shr  edx, CL   */    newInst(Mnemonic_SHR, edx, ecxCL);
 #endif
-    /* rol  edi, 1    */    newInst(Mnemonic_ROL, edi, one);
+    /* rol  edi, 1    */    newInst(Mnemonic_ROL, edi, one8);
                             // get quotient
     /* div    ebx     */    newInst(Mnemonic_DIV, 2, edx, eax, edx, eax, ebx, NULL);
     /* mov ebx, temp_lo*/   newInst(Mnemonic_MOV, ebx, temp_lo);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.cpp Fri Jun 27 04:01:50 2008
@@ -96,7 +96,7 @@
 //_____________________________________________________________________________________________
 Opnd * IRManager::newOpnd(Type * type, Constraint c)
 {
-    c.intersectWith(Constraint(OpndKind_Any, getTypeSize(type)));
+    c.intersectWith(Constraint(OpndKind_Any, getTypeSize(type), extByType(type->tag)));
     assert(!c.isNull());
     Opnd * opnd=new(memoryManager) Opnd(opndId++, type, c);
     addOpnd(opnd);
@@ -234,7 +234,7 @@
 //_____________________________________________________________________________________________
 Opnd * IRManager::newRegOpnd(Type * type, RegName reg)
 {
-    Opnd * opnd = newOpnd(type, Constraint(getRegKind(reg)));
+    Opnd * opnd = newOpnd(type, Constraint(getRegKind(reg), OpndSize_Any, extByType(type->tag)));
     opnd->assignRegName(reg);
     return opnd;
 }
@@ -297,14 +297,16 @@
 //_____________________________________________________________________________________________
 Constraint IRManager::createInitialConstraint(Type::Tag t)const
 {
-    OpndSize sz=getTypeSize(t);
+    OpndSize sz = getTypeSize(t);
+    OpndExt ext = extByType(t); 
+    
     if (t==Type::Single||t==Type::Double||t==Type::Float)
-        return Constraint(OpndKind_XMMReg, sz)|Constraint(OpndKind_Mem, sz);
+        return Constraint(OpndKind_XMMReg, sz, ext)|Constraint(OpndKind_Mem, sz, ext);
     if (sz<=Constraint::getDefaultSize(OpndKind_GPReg))
-        return Constraint(OpndKind_GPReg, sz)|Constraint(OpndKind_Mem, sz)|Constraint(OpndKind_Imm, sz);
+        return Constraint(OpndKind_GPReg, sz, ext)|Constraint(OpndKind_Mem, sz, ext)|Constraint(OpndKind_Imm, sz, ext);
     if (sz==OpndSize_64)
-        return Constraint(OpndKind_Mem, sz)|Constraint(OpndKind_Imm, sz); // imm before lowering
-    return Constraint(OpndKind_Memory, sz);
+        return Constraint(OpndKind_Mem, sz, ext)|Constraint(OpndKind_Imm, sz, ext); // imm before lowering
+    return Constraint(OpndKind_Memory, sz, ext);
 }
 
 //_____________________________________________________________________________________________
@@ -1017,10 +1019,25 @@
 
     assert(tmpRegName!=RegName_Null);
     Opnd * tmp=getRegOpnd(tmpRegName);
+
+    if(sourceOpnd->getSize() != targetOpnd->getSize()) {
+        assert(sourceOpnd->getSize() > targetOpnd->getSize());
+        tmpRegName = getAliasReg(tmpRegName,targetOpnd->getSize());
+        assert(tmpRegName!=RegName_Null);
+        Opnd* shortSrc = newMemOpnd(targetOpnd->getType(),
+                                    sourceOpnd->getMemOpndKind(),
+                                    sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Base),
+                                    sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Index),
+                                    sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Scale),
+                                    sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Displacement),
+                                    sourceOpnd->getSegReg());
+        appendToInstList(instList, newCopyPseudoInst(Mnemonic_MOV, shortSrc, sourceOpnd));
+        sourceOpnd = shortSrc;
+    }
+
     Opnd * tmpAdjusted=newRegOpnd(targetOpnd->getType(), tmpRegName);
     Opnd * tmpRegStackOpnd = newMemOpnd(tmp->getType(), MemOpndKind_StackAutoLayout, getRegOpnd(STACK_REG), 0); 
 
-
     if (unusedTmpRegName==RegName_Null)
         appendToInstList(instList, newInst(Mnemonic_MOV, tmpRegStackOpnd, tmp));
 
@@ -1050,21 +1067,23 @@
     }
 
     OpndSize sourceSize=sourceConstraint.getSize();
+    OpndSize targetSize=targetConstraint.getSize();
     U_32 sourceByteSize=getByteSize(sourceSize);
-    OpndKind targetKind=(OpndKind)targetConstraint.getKind();
-    OpndKind sourceKind=(OpndKind)sourceConstraint.getKind();
 
 #if defined(_DEBUG) || !defined(_EM64T_)
-    OpndSize targetSize=targetConstraint.getSize();
     assert(targetSize<=sourceSize); // only same size or truncating conversions are allowed
 #endif
 
-    if (targetKind&OpndKind_Reg) {
-        if(sourceOpnd->isPlacedIn(OpndKind_Imm) && sourceOpnd->getImmValue()==0 && targetKind==OpndKind_GPReg && 
-            !sourceOpnd->getRuntimeInfo() && !(getRegMask(RegName_EFLAGS)&flagsRegUsageMask)) {
-            return newInst(Mnemonic_XOR,targetOpnd, targetOpnd);
+    if (targetOpnd->isPlacedIn(OpndKind_Reg)) {
+        if(sourceOpnd->isPlacedIn(OpndKind_Imm)
+            && sourceOpnd->getImmValue()==0
+            && targetOpnd->isPlacedIn(OpndKind_GPReg)
+            && !sourceOpnd->getRuntimeInfo()
+            && !(getRegMask(RegName_EFLAGS)&flagsRegUsageMask)) {
+                return newInst(Mnemonic_XOR,targetOpnd, targetOpnd);
         }
-        else if (targetKind==OpndKind_XMMReg && sourceOpnd->getMemOpndKind()==MemOpndKind_ConstantArea) {
+        else if (targetOpnd->isPlacedIn(OpndKind_XMMReg)
+            && sourceOpnd->getMemOpndKind()==MemOpndKind_ConstantArea) {
 #ifdef _EM64T_
             Opnd * addr = NULL;
             Opnd * base = sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Base);
@@ -1105,10 +1124,10 @@
         }
     }
 
-    if ( (targetKind==OpndKind_GPReg||targetKind==OpndKind_Mem) && 
-         (sourceKind==OpndKind_GPReg||sourceKind==OpndKind_Mem||sourceKind==OpndKind_Imm)
+    if ( targetOpnd->isPlacedIn(OpndKind_GPReg_Mem) && 
+         (sourceOpnd->isPlacedIn(OpndKind_GPReg_Mem) || sourceOpnd->isPlacedIn(OpndKind_Imm))
     ){
-        if (sourceKind==OpndKind_Mem && targetKind==OpndKind_Mem){
+        if (sourceOpnd->isPlacedIn(OpndKind_Mem) && targetOpnd->isPlacedIn(OpndKind_Mem)){
             Inst * instList=NULL;
 #ifndef _EM64T_
             U_32 targetByteSize=getByteSize(targetSize);
@@ -1136,47 +1155,88 @@
             return instList;
         }else{
 #ifdef _EM64T_
-            if((targetOpnd->getMemOpndKind() == MemOpndKind_StackAutoLayout) && (sourceKind==OpndKind_Imm) && (sourceOpnd->getSize() == OpndSize_64)) 
+            if((targetOpnd->getMemOpndKind() == MemOpndKind_StackAutoLayout)
+                && (sourceOpnd->isPlacedIn(OpndKind_Imm)) && (sourceOpnd->getSize() == OpndSize_64)) 
                 return newMemMovSequence(targetOpnd, sourceOpnd, regUsageMask, false);
             else 
 #else
             assert(sourceByteSize<=4);
 #endif
-                return newInst(Mnemonic_MOV, targetOpnd, sourceOpnd); // must satisfy constraints
+            if (sourceSize != targetSize) {
+                if (sourceOpnd->isPlacedIn(OpndKind_Imm)) {
+                    sourceOpnd = newImmOpnd(targetOpnd->getType(),sourceOpnd->getImmValue());
+                } else if (sourceOpnd->isPlacedIn(OpndKind_Reg)) {
+                    if (/*sourceSize == OpndSize_32 && */sourceOpnd->getType()->isInteger() 
+                        //&& targetOpnd->getType()->isInteger()
+#ifdef _EM64T_
+                        || sourceSize == OpndSize_64 
+                        && sourceOpnd->getType()->isObject() 
+                        && targetOpnd->getType()->isCompressedReference() 
+                        //TODO verify if types match exactly?
+#endif
+                        ) {
+                        RegName regName = getAliasReg(sourceOpnd->getRegName(), targetSize);
+                        assert(regName != RegName_Null);
+                        Opnd* reg = newOpnd(typeManager.getSignedIntegerType(getByteSize(targetSize)), Constraint(regName));
+                        reg->assignRegName(regName);
+                        Inst * instList=NULL;
+                        appendToInstList(instList, newCopyPseudoInst(Mnemonic_MOV, reg, sourceOpnd));
+                        appendToInstList(instList, newInst(Mnemonic_MOV, targetOpnd, reg));
+                        return instList;
+                    } else {
+                        assert(0);
+                        return NULL;
+                    }
+                } else if (sourceOpnd->isPlacedIn(OpndKind_Mem)) {
+                    assert(sourceOpnd->getType()->isInteger() && targetOpnd->getType()->isInteger());
+                    assert(targetOpnd->isPlacedIn(OpndKind_GPReg));
+                    Opnd* shortSrc = newMemOpnd(targetOpnd->getType(),
+                                                sourceOpnd->getMemOpndKind(),
+                                                sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Base),
+                                                sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Index),
+                                                sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Scale),
+                                                sourceOpnd->getMemOpndSubOpnd(MemOpndSubOpndKind_Displacement),
+                                                sourceOpnd->getSegReg());
+                    Inst * instList=NULL;
+                    appendToInstList(instList, newCopyPseudoInst(Mnemonic_MOV, shortSrc, sourceOpnd));
+                    appendToInstList(instList, newInst(Mnemonic_MOV, targetOpnd, shortSrc));
+                    return instList;
+                }
+            }
+            assert(targetOpnd->getSize() == sourceOpnd->getSize());
+            return newInst(Mnemonic_MOV, targetOpnd, sourceOpnd); // must satisfy constraints
         }
-    }else if ( 
-        (targetKind==OpndKind_XMMReg||targetKind==OpndKind_Mem) && 
-        (sourceKind==OpndKind_XMMReg||sourceKind==OpndKind_Mem)
-    ){
+    }else if (targetOpnd->isPlacedIn(OpndKind_XMMReg_Mem)
+            && sourceOpnd->isPlacedIn(OpndKind_XMMReg_Mem)){
         targetOpnd->setMemOpndAlignment(Opnd::MemOpndAlignment_16);
         sourceOpnd->setMemOpndAlignment(Opnd::MemOpndAlignment_16);
         if (sourceByteSize==4){
             return newInst(Mnemonic_MOVSS,targetOpnd, sourceOpnd);
         }else if (sourceByteSize==8){
-            bool regsOnly = targetKind==OpndKind_XMMReg && sourceKind==OpndKind_XMMReg;
+            bool regsOnly = targetOpnd->isPlacedIn(OpndKind_XMMReg) && sourceOpnd->isPlacedIn(OpndKind_XMMReg);
             if (regsOnly && CPUID::isSSE2Supported()) {
                 return newInst(Mnemonic_MOVAPD, targetOpnd, sourceOpnd);
             } else  {
                 return newInst(Mnemonic_MOVSD, targetOpnd, sourceOpnd);
             }
         }
-    }else if (targetKind==OpndKind_FPReg && sourceKind==OpndKind_Mem){
+    }else if (targetOpnd->isPlacedIn(OpndKind_FPReg) && sourceOpnd->isPlacedIn(OpndKind_Mem)){
         sourceOpnd->setMemOpndAlignment(Opnd::MemOpndAlignment_16);
         return newInst(Mnemonic_FLD, targetOpnd, sourceOpnd);
-    }else if (targetKind==OpndKind_Mem && sourceKind==OpndKind_FPReg){
+    }else if (targetOpnd->isPlacedIn(OpndKind_Mem) && sourceOpnd->isPlacedIn(OpndKind_FPReg)){
         targetOpnd->setMemOpndAlignment(Opnd::MemOpndAlignment_16);
         return newInst(Mnemonic_FSTP, targetOpnd, sourceOpnd);
-    }else if (targetKind==OpndKind_XMMReg && (sourceKind==OpndKind_Mem || sourceKind==OpndKind_GPReg)){
-        if (sourceKind==OpndKind_Mem)
+    }else if (targetOpnd->isPlacedIn(OpndKind_XMMReg) && sourceOpnd->isPlacedIn(OpndKind_GPReg_Mem)){
+        if (sourceOpnd->isPlacedIn(OpndKind_Mem))
             sourceOpnd->setMemOpndAlignment(Opnd::MemOpndAlignment_16);
         return newInst(Mnemonic_MOVD, targetOpnd, sourceOpnd);
-    }else if ((targetKind==OpndKind_Mem || targetKind==OpndKind_GPReg) && sourceKind==OpndKind_XMMReg){
-        if (targetKind==OpndKind_Mem)
+    }else if (targetOpnd->isPlacedIn(OpndKind_GPReg_Mem) && sourceOpnd->isPlacedIn(OpndKind_XMMReg)){
+        if (targetOpnd->isPlacedIn(OpndKind_Mem))
             targetOpnd->setMemOpndAlignment(Opnd::MemOpndAlignment_16);
         return newInst(Mnemonic_MOVD, targetOpnd, sourceOpnd);
     }else if (
-        (targetKind==OpndKind_FPReg && sourceKind==OpndKind_XMMReg)||
-        (targetKind==OpndKind_XMMReg && sourceKind==OpndKind_FPReg)
+        (targetOpnd->isPlacedIn(OpndKind_FPReg) && sourceOpnd->isPlacedIn(OpndKind_XMMReg))
+        || (targetOpnd->isPlacedIn(OpndKind_XMMReg) && sourceOpnd->isPlacedIn(OpndKind_FPReg))
     ){
         Inst * instList=NULL;
         Opnd * tmp = newMemOpnd(targetOpnd->getType(), MemOpndKind_StackAutoLayout, getRegOpnd(STACK_REG), 0);
@@ -1195,35 +1255,34 @@
 
 Inst * IRManager::newPushPopSequence(Mnemonic mn, Opnd * opnd, U_32 regUsageMask)
 {
-    assert(opnd!=NULL);
+    assert(opnd != NULL);
 
-    Constraint constraint = opnd->getConstraint(Opnd::ConstraintKind_Location);
-    if (constraint.isNull())
+    if (opnd->isPlacedIn(OpndKind_Null))
         return newCopyPseudoInst(mn, opnd);
 
-    OpndKind kind=(OpndKind)constraint.getKind();
-    OpndSize size=constraint.getSize();
+    OpndSize size = opnd->getConstraint(Opnd::ConstraintKind_Location).getSize();
 
-    Inst * instList=NULL;
+    Inst * instList = NULL;
 
 #ifdef _EM64T_
-    if ( ((kind==OpndKind_GPReg ||kind==OpndKind_Mem)&& size!=OpndSize_32)||(kind==OpndKind_Imm && size<OpndSize_32)){
+    if ( (opnd->isPlacedIn(OpndKind_GPReg_Mem) && size != OpndSize_32)
+        ||(opnd->isPlacedIn(OpndKind_Imm) && size < OpndSize_32)){
             return newInst(mn, opnd);
 #else
-    if ( kind==OpndKind_GPReg||kind==OpndKind_Mem||kind==OpndKind_Imm ){
-        if (size==OpndSize_32){
+    if (opnd->isPlacedIn(OpndKind_GPReg_Mem) || opnd->isPlacedIn(OpndKind_Imm)){
+        if (size == OpndSize_32){
             return newInst(mn, opnd);
-        }else if (size<OpndSize_32){ 
-        }else if (size==OpndSize_64){
+        }else if (size < OpndSize_32){ 
+        }else if (size == OpndSize_64){
             if (mn==Mnemonic_PUSH){
-                Opnd * opndLo=newOpnd(typeManager.getUInt32Type());
+                Opnd * opndLo = newOpnd(typeManager.getUInt32Type());
                 appendToInstList(instList, newAliasPseudoInst(opndLo, opnd, 0)); 
-                Opnd * opndHi=newOpnd(typeManager.getIntPtrType());
+                Opnd * opndHi = newOpnd(typeManager.getIntPtrType());
                 appendToInstList(instList, newAliasPseudoInst(opndHi, opnd, 4)); 
                 appendToInstList(instList, newInst(Mnemonic_PUSH, opndHi));
                 appendToInstList(instList, newInst(Mnemonic_PUSH, opndLo));
             }else{
-                Opnd * opnds[2]={ newOpnd(typeManager.getUInt32Type()), newOpnd(typeManager.getInt32Type()) };
+                Opnd * opnds[2] = { newOpnd(typeManager.getUInt32Type()), newOpnd(typeManager.getInt32Type()) };
                 appendToInstList(instList, newInst(Mnemonic_POP, opnds[0])); 
                 appendToInstList(instList, newInst(Mnemonic_POP, opnds[1]));
                 appendToInstList(instList, newAliasPseudoInst(opnd, 2, opnds));
@@ -1232,20 +1291,20 @@
         }
 #endif
     }
-    Opnd * espOpnd=getRegOpnd(STACK_REG);
-    Opnd * tmp=newMemOpnd(opnd->getType(), MemOpndKind_StackManualLayout, espOpnd, 0); 
+    Opnd * espOpnd = getRegOpnd(STACK_REG);
+    Opnd * tmp = newMemOpnd(opnd->getType(), MemOpndKind_StackManualLayout, espOpnd, 0); 
 #ifdef _EM64T_
-    Opnd * sizeOpnd=newImmOpnd(typeManager.getInt32Type(), sizeof(POINTER_SIZE_INT));
-    if(kind==OpndKind_Imm) {
-        assert(mn==Mnemonic_PUSH);
+    Opnd * sizeOpnd = newImmOpnd(typeManager.getInt32Type(), sizeof(POINTER_SIZE_INT));
+    if(opnd->isPlacedIn(OpndKind_Imm)) {
+        assert(mn == Mnemonic_PUSH);
         appendToInstList(instList, newInst(Mnemonic_SUB, espOpnd, sizeOpnd));
         appendToInstList(instList, newMemMovSequence(tmp, opnd, regUsageMask));
-    } else if (kind == OpndKind_GPReg){
-        assert(mn==Mnemonic_PUSH);
+    } else if (opnd->isPlacedIn(OpndKind_GPReg)){
+        assert(mn == Mnemonic_PUSH);
         appendToInstList(instList, newInst(Mnemonic_SUB, espOpnd, sizeOpnd));
         appendToInstList(instList, newInst(Mnemonic_MOV, tmp, opnd));
     } else {
-        if (mn==Mnemonic_PUSH){
+        if (mn == Mnemonic_PUSH){
             appendToInstList(instList, newInst(Mnemonic_SUB, espOpnd, sizeOpnd));
             appendToInstList(instList, newCopySequence(tmp, opnd, regUsageMask));
         }else{
@@ -1254,11 +1313,11 @@
         }
     }
 #else
-    U_32 cb=getByteSize(size);
-    U_32 slotSize=4; 
-    cb=(cb+slotSize-1)&~(slotSize-1);
-    Opnd * sizeOpnd=newImmOpnd(typeManager.getInt32Type(), cb);
-    if (mn==Mnemonic_PUSH){
+    U_32 cb = getByteSize(size);
+    U_32 slotSize = 4; 
+    cb = (cb+slotSize-1)&~(slotSize-1);
+    Opnd * sizeOpnd = newImmOpnd(typeManager.getInt32Type(), cb);
+    if (mn == Mnemonic_PUSH){
         appendToInstList(instList, newInst(Mnemonic_SUB, espOpnd, sizeOpnd));
         appendToInstList(instList, newCopySequence(tmp, opnd, regUsageMask));
     }else{
@@ -1324,8 +1383,9 @@
     U_32 opndCount=getOpndCount();
     for (U_32 i=0; i<opndCount; i++){
         Opnd * opnd=getOpnd(i);
-        if (opnd->isPlacedIn(regKind))
+        if (opnd->isPlacedIn(regKind)) {
             gpTotalRegUsage |= getRegMask(opnd->getRegName());
+        }
     }
 }
 //_________________________________________________________________________________________________
@@ -1361,6 +1421,7 @@
         case Type::Int64:   
         case Type::UInt8:   
         case Type::UInt16:  
+        case Type::Char:  
         case Type::UInt32:  
         case Type::UInt64:  
         case Type::Single:  
@@ -1906,9 +1967,9 @@
                     Node* dispatchNode= dispatchEdge->getTargetNode();
                     if ((dispatchNode!=fg->getUnwindNode()) ||(checkOpnds[opnd] == (POINTER_SIZE_INT)-1
 #ifdef _EM64T_
-                            ||!Type::isCompressedReference(opnd->getType()->tag)
+                          ||!Type::isCompressedReference(opnd->getType()->tag)
 #endif
-                            )){
+                       )){
                         Node* throwBasicBlock = fg->createBlockNode();
                         ObjectType* excType = compilationInterface.findClassUsingBootstrapClassloader(NULL_POINTER_EXCEPTION);
                         assert(lastInst->getBCOffset()!=ILLEGAL_BC_MAPPING_VALUE);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32IRManager.h Fri Jun 27 04:01:50 2008
@@ -344,6 +344,15 @@
         }
     }
 
+    static OpndExt extByType(Type::Tag t) {
+        if( t == Type::Char || t == Type::Boolean || Type::isUnsignedInteger(t) ) {
+            return OpndExt_Zero; 
+        } else if( Type::isSignedInteger(t) ) {
+            return OpndExt_Signed; 
+        }
+        return OpndExt_Any;
+    }
+
     //-----------------------------------------------------------------------------------------------
     bool isOnlyPrologSuccessor(Node * bb) ;
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp Fri Jun 27 04:01:50 2008
@@ -38,7 +38,7 @@
     assert(r!=RegName_Null);
     memOpndKind=MemOpndKind_Null;
     regName=r;
-    constraints[ConstraintKind_Location]=Constraint(r);
+    constraints[ConstraintKind_Location]=Constraint(r,constraints[ConstraintKind_Calculated].getExt());
     checkConstraints();
 }
 
@@ -49,7 +49,9 @@
     if (constraints[ConstraintKind_Location].getKind() != OpndKind_Imm)
         runtimeInfo=NULL;
     immValue=v;
-    constraints[ConstraintKind_Location]=Constraint(OpndKind_Imm, constraints[ConstraintKind_Initial].getSize());
+    constraints[ConstraintKind_Location]=Constraint(OpndKind_Imm,
+                                                    constraints[ConstraintKind_Initial].getSize(),
+                                                    constraints[ConstraintKind_Initial].getExt());
     checkConstraints();
 }
 
@@ -59,7 +61,9 @@
     assert(_base||_index||_displacement);
     assert(!_scale||_index);
 
-    constraints[ConstraintKind_Location]=Constraint(OpndKind_Mem, constraints[ConstraintKind_Initial].getSize());
+    constraints[ConstraintKind_Location]=Constraint(OpndKind_Mem,
+                                                    constraints[ConstraintKind_Initial].getSize(),
+                                                    constraints[ConstraintKind_Initial].getExt());
     memOpndKind=k;
 
     checkConstraints();
@@ -291,7 +295,7 @@
             }
         }
             if (removeMemory) 
-                c = Constraint((OpndKind)(c.getKind() &~ OpndKind_Mem), c.getSize(), c.getMask());
+                c = Constraint((OpndKind)(c.getKind() &~ OpndKind_Mem), c.getSize(), c.getExt(), c.getMask());
         }
     }else{
         c = opnds[(idx - opndCount) / 4]->getMemOpndSubOpndConstraint((MemOpndSubOpndKind)((idx - opndCount) & 3));

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32InstCodeSelector.cpp Fri Jun 27 04:01:50 2008
@@ -336,7 +336,14 @@
 
     OpndSize srcSize=irManager.getTypeSize(srcType);
     OpndSize dstSize=irManager.getTypeSize(dstType);
-    
+
+    if (dstSize!=srcSize && srcOpnd->isPlacedIn(OpndKind_Imm) && dstOpnd == NULL) {
+        int64 immValue = srcOpnd->getImmValue();
+        if (dstSize > srcSize || Type::constFits(immValue, dstType->tag)) {
+            return irManager.newImmOpnd(dstType, immValue);
+        }
+    }
+
     if (dstSize==srcSize){ // trivial conversion
         if (dstOpnd==NULL && dstType == srcType) {
             dstOpnd=srcOpnd;
@@ -354,7 +361,7 @@
         if (dstOpnd==NULL)
             dstOpnd=irManager.newOpnd(dstType);
 #ifdef _EM64T_
-            appendInsts(irManager.newInstEx(srcType->isSignedInteger() & !isZeroExtend ? Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
+        appendInsts(irManager.newInstEx(srcType->isSignedInteger() & !isZeroExtend ? Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
 #else
         if (dstSize<OpndSize_64){
             appendInsts(irManager.newInstEx(srcType->isSignedInteger() && !isZeroExtend ? Mnemonic_MOVSX:Mnemonic_MOVZX, 1, dstOpnd, srcOpnd));
@@ -405,7 +412,8 @@
 #endif
 
             //load float value to FP0
-            Opnd* fpResOpnd = irManager.newOpnd(irManager.getTypeManager().getDoubleType());
+            Type* dType = irManager.getTypeManager().getDoubleType();
+            Opnd* fpResOpnd = irManager.newRegOpnd(dType, RegName_FP0);
             Inst* convInst = irManager.newInst(Mnemonic_FILD, fpResOpnd, int64Opnd);            
             appendInsts(convInst);
 
@@ -545,6 +553,10 @@
     Opnd * srcOpnd=(Opnd*)oph;
 
     Type * srcType=srcOpnd->getType();
+    if (dstOpnd == NULL && dstType == srcType) {
+        dstOpnd = srcOpnd;
+        return dstOpnd;
+    }
     bool converted=false;
     if (isIntegerType(srcType)){
         if (isIntegerType(dstType)){
@@ -688,7 +700,11 @@
 Opnd * InstCodeSelector::fpOp(Mnemonic mn, Type * dstType, Opnd * src1, Opnd * src2)
 {
     Opnd * dst=irManager.newOpnd(dstType);
-    Opnd * srcOpnd1=(Opnd*)convert(src1, dstType), * srcOpnd2=(Opnd*)convert(src2, dstType);
+    Opnd * srcOpnd1 = src1->canBePlacedIn(OpndKind_XMMReg)? NULL : irManager.newOpnd(dstType);
+    srcOpnd1 = convert(src1, dstType, srcOpnd1);
+    Opnd * srcOpnd2 = src2->canBePlacedIn(OpndKind_XMMReg_Mem)? NULL : irManager.newOpnd(dstType);
+    srcOpnd2 = convert(src2, dstType, srcOpnd2);
+
     appendInsts(irManager.newInstEx(mn, 1, dst, srcOpnd1, srcOpnd2));
     return dst;
 }
@@ -983,15 +999,17 @@
         case NegOp::F:
         {
             Type * dstType=irManager.getTypeFromTag(Type::Double);
-            dst = irManager.newOpnd(dstType);
-            appendInsts(irManager.newInstEx(Mnemonic_FCHS,1,dst,(Opnd*)src));
+            dst = irManager.newOpnd(dstType, Constraint(OpndKind_FPReg, ((Opnd*)src)->getSize(), OpndExt_Any));
+            copyOpnd(dst,(Opnd*)src);
+            appendInsts(irManager.newInst(Mnemonic_FCHS,dst));
             break;
         }
         case NegOp::S:
         {
             Type * dstType=irManager.getTypeFromTag(Type::Single);
-            dst = irManager.newOpnd(dstType);
-            appendInsts(irManager.newInstEx(Mnemonic_FCHS,1,dst,(Opnd*)src));
+            dst = irManager.newOpnd(dstType, Constraint(OpndKind_FPReg, ((Opnd*)src)->getSize(), OpndExt_Any));
+            copyOpnd(dst,(Opnd*)src);
+            appendInsts(irManager.newInst(Mnemonic_FCHS,dst));
             break;
         }
         default:
@@ -1188,9 +1206,9 @@
             dstType=irManager.getTypeFromTag(Type::Int64);
             dst=irManager.newOpnd(dstType);
 #ifndef _EM64T_
-            appendInsts(irManager.newI8PseudoInst(mn,1,dst,(Opnd*)convert(value, dstType),(Opnd*)convert(shiftAmount, typeManager.getInt32Type())));
+            appendInsts(irManager.newI8PseudoInst(mn,1,dst,(Opnd*)convert(value, dstType),(Opnd*)convert(shiftAmount, typeManager.getInt8Type())));
 #else
-            appendInsts(irManager.newInstEx(mn,1,dst,(Opnd*)convert(value, dstType),(Opnd*)convert(shiftAmount, typeManager.getInt32Type())));
+            appendInsts(irManager.newInstEx(mn,1,dst,(Opnd*)convert(value, dstType),(Opnd*)convert(shiftAmount, typeManager.getInt8Type())));
 #endif
             return dst;
         default:
@@ -1268,13 +1286,15 @@
                                          CG_OpndHandle*       src1,
                                          CG_OpndHandle*       src2, int ifNaNResult) 
 {
+    Opnd * dst8=irManager.newOpnd(typeManager.getUInt8Type());
     Opnd * dst=irManager.newOpnd(typeManager.getInt32Type());
     bool swapped=cmpToEflags(cmpOp, opType, (Opnd*)src1, (Opnd*)src2);
     ConditionMnemonic cm=getConditionMnemonicFromCompareOperator(cmpOp, opType);
     if (swapped) 
         cm=swapConditionMnemonic(cm);
-    appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dst, irManager.newImmOpnd(typeManager.getInt32Type(), 0)));
-    appendInsts(irManager.newInstEx(getMnemonic(Mnemonic_SETcc, cm), 1, dst,dst));
+    appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dst8, irManager.newImmOpnd(typeManager.getUInt8Type(), 0)));
+    appendInsts(irManager.newInstEx(getMnemonic(Mnemonic_SETcc, cm), 1, dst8,dst8));
+    appendInsts(irManager.newInstEx(Mnemonic_MOVZX, 1, dst, dst8));
     if (ifNaNResult == 1 || (ifNaNResult ==0 && ((opType==CompareOp::F) ||(opType==CompareOp::S) ||(opType==CompareOp::D)) && ((cmpOp == CompareOp::Geu) || (cmpOp == CompareOp::Gtu) || (cmpOp == CompareOp::Ne) || (cmpOp == CompareOp::Eq)))) {
         appendInsts(irManager.newInstEx(Mnemonic_CMOVP,1,dst,dst,irManager.newImmOpnd(typeManager.getInt32Type(), ifNaNResult)));
     }
@@ -1359,26 +1379,40 @@
         case CompareOp::F:
         {
             Type * srcType=irManager.getTypeFromTag(Type::Double);
-            Opnd * srcOpnd1=(Opnd*)convert(src1, srcType);
+            Opnd * srcOpnd1 = src1->canBePlacedIn(OpndKind_XMMReg)? NULL : irManager.newOpnd(srcType);
+            srcOpnd1 = convert(src1, srcType, srcOpnd1);
+            Opnd * srcOpnd2;
+            if (src2) {
+                srcOpnd2 = src2->canBePlacedIn(OpndKind_XMMReg_Mem)? NULL : irManager.newOpnd(srcType);
+                srcOpnd2 = convert(src2, srcType, srcOpnd2);
+            } else {
 #ifdef _EM64T_
-            Opnd * baseOpnd = irManager.newOpnd(typeManager.getUnmanagedPtrType(srcType));
-            Opnd * srcOpnd2=src2?(Opnd*)convert(src2, srcType):irManager.newFPConstantMemOpnd((double)0.0, baseOpnd, (BasicBlock*)currentBasicBlock);
+                Opnd * baseOpnd = irManager.newOpnd(typeManager.getUnmanagedPtrType(srcType));
+                srcOpnd2 = irManager.newFPConstantMemOpnd((double)0.0, baseOpnd, (BasicBlock*)currentBasicBlock);
 #else
-            Opnd * srcOpnd2=src2?(Opnd*)convert(src2, srcType):irManager.newFPConstantMemOpnd((double)0.0);
+                srcOpnd2 = irManager.newFPConstantMemOpnd((double)0.0);
 #endif
+            }
             appendInsts(irManager.newInst(Mnemonic_UCOMISD, srcOpnd1, srcOpnd2));
             break;
         }
         case CompareOp::S:
         {
             Type * srcType=irManager.getTypeFromTag(Type::Single);
-            Opnd * srcOpnd1=(Opnd*)convert(src1, srcType);
+            Opnd * srcOpnd1 = src1->canBePlacedIn(OpndKind_XMMReg)? NULL : irManager.newOpnd(srcType);
+            srcOpnd1 = convert(src1, srcType, srcOpnd1);
+            Opnd * srcOpnd2;
+            if (src2) {
+                srcOpnd2 = src2->canBePlacedIn(OpndKind_XMMReg_Mem)? NULL : irManager.newOpnd(srcType);
+                srcOpnd2 = convert(src2, srcType, srcOpnd2);
+            } else {
 #ifdef _EM64T_
-            Opnd * baseOpnd = irManager.newOpnd(typeManager.getUnmanagedPtrType(srcType));
-            Opnd * srcOpnd2=src2?(Opnd*)convert(src2, srcType):irManager.newFPConstantMemOpnd((float)0.0, baseOpnd, (BasicBlock*)currentBasicBlock);
+                Opnd * baseOpnd = irManager.newOpnd(typeManager.getUnmanagedPtrType(srcType));
+                srcOpnd2 = irManager.newFPConstantMemOpnd((float)0.0, baseOpnd, (BasicBlock*)currentBasicBlock);
 #else
-            Opnd * srcOpnd2=src2?(Opnd*)convert(src2, srcType):irManager.newFPConstantMemOpnd((float)0.0);
+                srcOpnd2 = irManager.newFPConstantMemOpnd((float)0.0);
 #endif
+            }
             appendInsts(irManager.newInst(Mnemonic_UCOMISS, srcOpnd1, srcOpnd2));
             break;
         }
@@ -2098,7 +2132,7 @@
 {
 #ifdef _EM64T_
     if(irManager.refsAreCompressed() && memType > Type::Float && memType!=Type::UnmanagedPtr) {
-        Opnd * opnd = irManager.newMemOpndAutoKind(typeManager.getInt32Type(), addr);
+        Opnd * opnd = irManager.newMemOpndAutoKind(typeManager.getUInt32Type(), addr);
         Opnd * dst = irManager.newOpnd(typeManager.getInt64Type());
         // loading compressed 32-bit managed address, ensure zero-extention
         copyOpnd(dst, opnd, true);
@@ -2135,7 +2169,7 @@
     if(irManager.refsAreCompressed() && memType > Type::Float && !src->getType()->isUnmanagedPtr()) {
         Type * unmanagedPtrType = typeManager.getUnmanagedPtrType(typeManager.getInt8Type());
         Opnd * heap_base = heapBaseOpnd(unmanagedPtrType, (POINTER_SIZE_INT)VMInterface::getHeapBase());
-        Opnd * compressed_src = irManager.newOpnd(typeManager.compressType(src->getType()));
+        Opnd * compressed_src = irManager.newOpnd(src->getType());
         Opnd * opnd = irManager.newMemOpndAutoKind(typeManager.compressType(src->getType()), addr);
         appendInsts(irManager.newInstEx(Mnemonic_SUB, 1, compressed_src, src, heap_base));
         appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, opnd, compressed_src));
@@ -2455,7 +2489,7 @@
     Opnd* baseOpnd = irManager.newImmOpnd(typeManager.getUnmanagedPtrType(typeManager.getUIntPtrType()), (POINTER_SIZE_INT)ptr);
     Opnd* memOpnd = irManager.newMemOpnd(typeManager.getUIntPtrType(), MemOpndKind_Heap, baseOpnd, NULL, NULL, NULL);
     const Mnemonic mn = Mnemonic_ADD;
-    Inst* inst = irManager.newInst(mn, memOpnd,  irManager.newImmOpnd(typeManager.getUInt32Type(), 1));
+    Inst* inst = irManager.newInst(mn, memOpnd,  irManager.newImmOpnd(typeManager.getInt8Type(), 1));
     appendInsts(inst);
 }
 
@@ -2568,7 +2602,7 @@
 
     int64 heapBase = (int64) VMInterface::getVTableBase();
     Opnd * acc =  simpleOp_I8(Mnemonic_ADD, dstType, (Opnd *)base, irManager.newImmOpnd(dstType, Opnd::RuntimeInfo::Kind_VTableAddrOffset));
-    Opnd * sourceVTableAddr=irManager.newMemOpnd(typeManager.getInt32Type(), acc, 0, 0, irManager.newImmOpnd(typeManager.getUInt32Type(), 0));
+    Opnd * sourceVTableAddr=irManager.newMemOpnd(typeManager.getUInt32Type(), acc, 0, 0, irManager.newImmOpnd(typeManager.getUInt32Type(), 0));
     acc=irManager.newOpnd(dstType);
     appendInsts(irManager.newInstEx(Mnemonic_MOVZX, 1, acc, sourceVTableAddr));
     vtableAddr =  simpleOp_I8(Mnemonic_ADD, dstType, acc,  irManager.newImmOpnd(dstType, heapBase));
@@ -2798,8 +2832,8 @@
         assert(irManager.getTypeSize(opnds[1]->getType())==irManager.getTypeSize(opnds[2]->getType()));
         bool is64bit = irManager.getTypeSize(opnd1Type) == OpndSize_64;
 //        Type* opType = is64bit ? typeManager.getInt64Type():typeManager.getInt32Type();
-        Constraint ceax(OpndKind_GPReg, is64bit?OpndSize_64:OpndSize_32, 1<<getRegIndex(is64bit?RegName_RAX:RegName_EAX));
-        Constraint cecx(OpndKind_GPReg, is64bit?OpndSize_64:OpndSize_32, 1<<getRegIndex(is64bit?RegName_RCX:RegName_ECX));
+        Constraint ceax(OpndKind_GPReg, is64bit?OpndSize_64:OpndSize_32, OpndExt_Any, 1<<getRegIndex(is64bit?RegName_RAX:RegName_EAX));
+        Constraint cecx(OpndKind_GPReg, is64bit?OpndSize_64:OpndSize_32, OpndExt_Any, 1<<getRegIndex(is64bit?RegName_RCX:RegName_ECX));
         Opnd* eaxOpnd = irManager.newOpnd(opnds[1]->getType(), ceax);
         Opnd* ecxOpnd = irManager.newOpnd(opnds[2]->getType(), cecx);
 #else
@@ -2815,8 +2849,10 @@
         appendInsts(inst);
 
         //save the result
-        appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dstOpnd, irManager.newImmOpnd(typeManager.getInt32Type(), 0)));
-        appendInsts(irManager.newInst(Mnemonic_SETZ, dstOpnd));
+        Opnd * dst8=irManager.newOpnd(typeManager.getUInt8Type());
+        appendInsts(irManager.newCopyPseudoInst(Mnemonic_MOV, dst8, irManager.newImmOpnd(typeManager.getUInt8Type(), 0)));
+        appendInsts(irManager.newInst(Mnemonic_SETZ,dst8));
+        appendInsts(irManager.newInstEx(Mnemonic_MOVZX, 1, dstOpnd, dst8));
         break;
     }
     case AddValueProfileValue:
@@ -3193,11 +3229,7 @@
                                                  CG_OpndHandle* obj,
                                                  CG_OpndHandle* tauCheckedNull) 
 {
-#ifdef _EM64T_
-    Opnd * dst=irManager.newOpnd(typeManager.getInt64Type());
-#else
-    Opnd * dst=irManager.newOpnd(typeManager.getInt32Type());
-#endif
+    Opnd * dst=irManager.newOpnd(typeManager.getInt32Type()); // boolean is represented as int32
     Opnd * args[]={ (Opnd*)obj, irManager.newImmOpnd(getRuntimeIdType(), Opnd::RuntimeInfo::Kind_TypeRuntimeId, type) };
     CallInst * callInst=irManager.newRuntimeHelperCallInst(
         VM_RT_INSTANCEOF,

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32PeepHole.cpp Fri Jun 27 04:01:50 2008
@@ -279,8 +279,7 @@
     // 2. Assigned to FPU - convert to FPU operations, to 
     //    avoid long FPU->mem->XMM chain
     // 3. Assigned to XMM - see #1
-    const bool xmm_way = 
-        !(src->hasAssignedPhysicalLocation() && src->isPlacedIn(OpndKind_FPReg));
+    const bool xmm_way = src->canBePlacedIn(OpndKind_XMMReg);
 
     if (!xmm_way) {
         //TODO: will add FPU later if measurements show it worths trying
@@ -509,8 +508,9 @@
                 nextmovopnd2 = next->getOpnd(nextmovuses.begin());
             }
             if (movopnd1->getId() == nextmovopnd2->getId() && 
-                !isMem(movopnd2) && !isMem(nextmovopnd1) &&
-                !isMem(movopnd1)
+                !isMem(movopnd2) && !isMem(nextmovopnd1) && !isMem(movopnd1) &&
+                movopnd1->getSize() == movopnd2->getSize() &&
+                nextmovopnd1->getSize() == nextmovopnd2->getSize()
                 )
             {
                 BitSet ls(irManager->getMemoryManager(), irManager->getOpndCount());
@@ -522,7 +522,16 @@
                 bool dstNotUsed = !ls.getBit(movopnd1->getId());
                 if (dstNotUsed)
                 {
-                    irManager->newInst(Mnemonic_MOV, nextmovopnd1, movopnd2)->insertAfter(inst);
+                    Inst* merged;
+                    // peephole pass can be used in various positions in pipeline
+                    // thus avoid inserting pseudo instructions in late stages
+                    // still try to be useful in early stages
+                    if (inst->hasKind(Inst::Kind_PseudoInst) && next->hasKind(Inst::Kind_PseudoInst)) {
+                        merged = irManager->newCopyPseudoInst(Mnemonic_MOV, nextmovopnd1, movopnd2);
+                    } else {
+                        merged = irManager->newInst(Mnemonic_MOV, nextmovopnd1, movopnd2);
+                    }
+                    merged->insertAfter(inst);
                     inst->unlink();
                     next->unlink();
                     return Changed_Node;
@@ -667,8 +676,9 @@
             if (minBit == maxBit) {
                 assert(minBit>=2);
                 if (Log::isEnabled()) Log::out()<<"I"<<inst->getId()<<" -> MUL with 2^"<<minBit<<std::endl;
-                Type* int32Type = irManager->getTypeManager().getUInt32Type();
-                irManager->newInstEx(Mnemonic_SHL, 1, dst, src1, irManager->newImmOpnd(int32Type, minBit))->insertAfter(inst);
+                Type* immType = irManager->getTypeManager().getUInt8Type();
+                irManager->newCopyPseudoInst(Mnemonic_MOV, dst, src1)->insertBefore(inst);
+                irManager->newInst(Mnemonic_SHL, dst, irManager->newImmOpnd(immType, minBit))->insertBefore(inst);
                 inst->unlink();
                 return Changed_Inst;
             }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc2.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc2.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc2.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc2.cpp Fri Jun 27 04:01:50 2008
@@ -454,6 +454,7 @@
 
     OpndKind k = (OpndKind)constrs.getKind(); 
     OpndSize s = constrs.getSize();
+    OpndExt e = constrs.getExt();
 
     registers.clear();
     RegMask mask = constrs.getMask();
@@ -464,7 +465,7 @@
             Register* r = new (mm) Register(mm);
             r->regmask = m,
             r->regname = getRegName(k, s, x);
-            r->constraint = Constraint(k, s, m);
+            r->constraint = Constraint(k, s, e, m);
             r->length = 0;
             r->beg=(Instnb)UINT_MAX;
             r->end=(Instnb)0;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc3.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc3.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc3.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32RegAlloc3.cpp Fri Jun 27 04:01:50 2008
@@ -632,15 +632,25 @@
         opndx.ignore = false;
 
         int ridx;
-        Constraint loc = opnd->getConstraint(Opnd::ConstraintKind_Location, OpndSize_Default);
+        Constraint loc = opnd->getConstraint(Opnd::ConstraintKind_Location/*, OpndSize_Default*/);
         if (loc.isNull())
         {// this operand is not allocated yet
-            loc = opnd->getConstraint(Opnd::ConstraintKind_Calculated, OpndSize_Default);
+            loc = opnd->getConstraint(Opnd::ConstraintKind_Calculated/*, OpndSize_Default*/);
             if ((ridx = registers.index(loc)) != -1)
             {// operand should be assigned to register
                 opndx.ridx  = ridx;
                 opndx.alloc = 0;
                 opndx.avail = loc.getMask() & registers[ridx].getMask();
+#if !defined(_EM64T_)
+                if (loc.getSize() == OpndSize_8 && loc.getMask() == 0xffff) { 
+                    // FIXME better check for mask ?
+                    // allow only low-byte regs to workaround platform irregularity
+                    opndx.avail &= (getRegMask(RegName_AL)
+                        |getRegMask(RegName_BL)
+                        |getRegMask(RegName_CL)
+                        |getRegMask(RegName_DL));
+                }
+#endif
                 opndx.nbavails = bitCount(opndx.avail);
                 assert(opndx.nbavails != 0);
                 opndx.spillcost = 1;

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32SpillGen.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32SpillGen.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32SpillGen.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32SpillGen.cpp Fri Jun 27 04:01:50 2008
@@ -1015,7 +1015,7 @@
         return false;
 
     Constraint cx = c.getAliasConstraint(OpndSize_Default) & registers[opline.idx];
-    Constraint cr((OpndKind)cx.getKind(), c.getSize(), cx.getMask());
+    Constraint cr((OpndKind)cx.getKind(), c.getSize(), c.getExt(), cx.getMask());
 
 //  handle first instruction of the interval
 
@@ -1120,7 +1120,7 @@
         return false;
 
     Constraint cx = c.getAliasConstraint(OpndSize_Default) & registers[opline.idx];
-    Constraint cr((OpndKind)cx.getKind(), c.getSize(), cx.getMask());
+    Constraint cr((OpndKind)cx.getKind(), c.getSize(), c.getExt(), cx.getMask());
 
     Instx* begx = opline.instx;
     Instx* endx = begx;
@@ -1168,7 +1168,7 @@
         return false;
 
     Constraint ca = c.getAliasConstraint(OpndSize_Default) & registers[opline.idx];
-    Constraint cr((OpndKind)ca.getKind(), c.getSize(), ca.getMask());
+    Constraint cr((OpndKind)ca.getKind(), c.getSize(), c.getExt(), ca.getMask());
 
     Inst* inst = opline.instx->inst;
 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/cg_fld_arr.cpp Fri Jun 27 04:01:50 2008
@@ -386,7 +386,7 @@
             // store the resulting I_32
             Opnd where32(i32, where.base(), where.disp(), 
                           where.index(), where.scale());
-            mov(where32, Opnd(jobj, tmp)); //s0.as_opnd(i32));
+            mov(where32, Opnd(i32, tmp)); //s0.as_opnd(i32));
         }
         runlock(s0);
     }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc_ia32.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/enc_ia32.cpp Fri Jun 27 04:01:50 2008
@@ -114,38 +114,46 @@
     assert(!op0.is_imm());
 }
 
+static OpndExt default_arg_ext(jtype t) {
+    if (is_signed_int(t)) return OpndExt_Signed;
+    else if ( t == u16) return OpndExt_Zero;
+    else return OpndExt_None;
+}
+
 static void add_arg(EncoderBase::Operands& args, const Opnd& op, 
                     bool can_shrink = false)
 {
     OpndSize sz = to_size(op.jt());
+    OpndExt ext = default_arg_ext(op.jt());
     if (op.is_reg()) {
         RegName reg = devirt(op.reg(), op.jt());
         //::OpndKind kind = is_f(op.reg()) ? OpndKind_XMMReg : OpndKind_GPReg;
-        //args.add(EncoderBase::Operand(sz, kind, reg));
-        args.add(EncoderBase::Operand(reg));
+        //args.add(EncoderBase::Operand(sz, kind, reg, ext));
+        args.add(EncoderBase::Operand(reg, ext));
     }
     else if (op.is_mem()) {
         RegName base = op.base() != ar_x ? devirt(op.base()) : RegName_Null;
         RegName idx = op.index() == ar_x ? RegName_Null : devirt(op.index());
-        EncoderBase::Operand mem(sz, base, idx, op.scale(), op.disp());
+        EncoderBase::Operand mem(sz, base, idx, op.scale(), op.disp(), ext);
         args.add(mem);
     }
     else {
         assert(!is_f(op.jt()));
         if (op.jt() == i64) {
-            EncoderBase::Operand imm(sz, op.lval());
+            EncoderBase::Operand imm(sz, op.lval(), ext);
             args.add(imm);
         }
         else if (op.jt() == jobj) {
-            EncoderBase::Operand imm(sz, (int_ptr)(void*)op.lval());
+            EncoderBase::Operand imm(sz, (int_ptr)(void*)op.lval(), ext);
             args.add(imm);
         }
         else {
             assert(op.jt()<=i32);
             if (can_shrink && fits_i8(op.ival())) {
                 sz = OpndSize_8;
+                ext = OpndExt_Any;
             }
-            EncoderBase::Operand imm(sz, op.ival());
+            EncoderBase::Operand imm(sz, op.ival(), ext);
             args.add(imm);
         }
     }

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jdefs.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jdefs.h?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jdefs.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/jet/jdefs.h Fri Jun 27 04:01:50 2008
@@ -583,6 +583,14 @@
 extern JTypeDesc jtypes[num_jtypes];
 
 /**
+ *@brief Tests whether specified #jtype represents signed integer value.
+ */
+inline bool is_signed_int( jtype jt )
+{
+    return jt==i8 || jt==i16 || jt==i32 || jt==i64;
+}
+
+/**
  *@brief Tests whether specified #jtype represents floating point value.
  */
 inline bool is_f( jtype jt )

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/optimizer/IRBuilder.h Fri Jun 27 04:01:50 2008
@@ -381,7 +381,6 @@
     //
     Opnd*    propagateCopy(Opnd*);
     Inst*    appendInst(Inst*);
-    Type*    getOpndTypeFromLdType(Type* ldType);
     Opnd*    createOpnd(Type*);
     PiOpnd*  createPiOpnd(Opnd *org);
     Opnd*    createTypeOpnd(ObjectType* type);

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.cpp Fri Jun 27 04:01:50 2008
@@ -1321,5 +1321,17 @@
     return type_tag_names[t].name;
 }
 
+bool Type::constFits(int64 val, Tag tag) {
+    if (tag == Int8 || tag == UInt8) {
+        return (val & (int64)0x00000000000000FF) == val;
+    } else if (tag == Int16 || tag == UInt16 || tag == Char) {
+        return (val & (int64)0x000000000000FFFF) == val;
+    } else if (isIntegerOf4Bytes(tag)) {
+        return (val & (int64)0x00000000FFFFFFFF) == val;
+    } else {
+        assert(0); // implement if you need it
+    }
+    return false;
+}
 
 } //namespace Jitrino 

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/shared/Type.h Fri Jun 27 04:01:50 2008
@@ -59,15 +59,15 @@
         // (1) Value types
         // --------------------
         //   (1.1) Built-in value types
-        Tau,     // essentially a void type, used for 
+        Tau,    // essentially a void type, used for 
         Void,    
         Boolean,
-        Char,
-        IntPtr,  // ptr-sized integer
+        Char,   // unsigned 2-byte integer
+        IntPtr, // ptr-sized integer
         Int8,
         Int16,
-        Int32, // 4-byte integer
-        Int64, // 8-byte integer
+        Int32,  // 4-byte integer
+        Int64,  // 8-byte integer
         UIntPtr, // unsigned ptr-sized integer
         UInt8,
         UInt16,
@@ -383,7 +383,9 @@
 #endif
     static bool isIntegerOf4Bytes(Tag tag) { return isIntegerOf4Signed(tag) || isIntegerOf4Unsigned(tag); }
     static bool isIntegerOf8Bytes(Tag tag) { return isIntegerOf8Signed(tag) || isIntegerOf8Unsigned(tag); }
-    
+
+    // checks if a constant fits into type
+    static bool constFits(int64 val, Tag tag);
 
 protected:
     virtual bool    _isFinalClass()    {return false;}
@@ -791,6 +793,18 @@
     void setLazyResolutionMode(bool flag) {lazyResolutionMode = flag;}
     bool isLazyResolutionMode() const {return lazyResolutionMode;}
 
+    Type* getIntegerType(int size, bool isSigned) {
+        switch (size) {
+        case 1: return isSigned ? int8Type  : uint8Type;
+        case 2: return isSigned ? int16Type : uint16Type;
+        case 4: return isSigned ? int32Type : uint32Type;
+        case 8: return isSigned ? int64Type : uint64Type;
+        default: assert(0); return int32Type;
+        } 
+    }
+    Type* getSignedIntegerType(int size) { return getIntegerType(size, true); }
+    Type* getUnsignedIntegerType(int size) { return getIntegerType(size, false);}
+
 private:
     MemoryManager& memManager;
     // singletons for the built-in types

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_base.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_base.cpp?rev=672239&r1=672238&r2=672239&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_base.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/enc_base.cpp Fri Jun 27 04:01:50 2008
@@ -638,32 +638,41 @@
 /**
  *
  */
-static bool try_match(const EncoderBase::OpcodeDesc& odesc, 
-                      const EncoderBase::Operands& opnds, bool strict) {
+bool EncoderBase::extAllowed(OpndExt opndExt, OpndExt instExt) {
+    if (instExt == opndExt || instExt == OpndExt_Any || opndExt == OpndExt_Any) {
+            return true;
+    }
+//asm("int3");
+assert(0);
+    return false;
+}
+
+/**
+ *
+ */
+static bool match(const EncoderBase::OpcodeDesc& odesc, 
+                      const EncoderBase::Operands& opnds) {
                       
     assert(odesc.roles.count == opnds.count());
     
-    for(unsigned j=0; j<odesc.roles.count; j++) {
-        // - the location must match exactly
-        if ((odesc.opnds[j].kind & opnds[j].kind()) != opnds[j].kind()) {
+    for(unsigned j = 0; j < odesc.roles.count; j++) {
+        const EncoderBase::OpndDesc& desc = odesc.opnds[j];
+        const EncoderBase::Operand& op = opnds[j];  
+        // location must match exactly
+        if ((desc.kind & op.kind()) != op.kind()) {
+//assert(0);
             return false;
         }
-        if (strict) {
-            // the size must match exactly
-            if (odesc.opnds[j].size != opnds[j].size()) {
-                return false;
-            }
+        // size must match exactly
+        if (desc.size != op.size()) {
+//assert(0);
+            return false;
         }
-        else {
-            // must match only for def operands, and dont care about use ones
-            // situations like 'mov r8, imm32/mov r32, imm8' so the 
-            // destination operand defines the overall size
-            if (EncoderBase::getOpndRoles(odesc.roles, j) & OpndRole_Def) {
-                if (odesc.opnds[j].size != opnds[j].size()) {
-                    return false;
-                }
-            }
+        // extentions should be consistent
+        if (!EncoderBase::extAllowed(op.ext(), desc.ext)) {
+            return false;
         }
+        
     }
     return true;
 }
@@ -717,9 +726,7 @@
     if (opcodeIndex == NOHASH) {
         // fast-path did no work. try to lookup sequentially
         const OpcodeDesc * odesc = opcodes[mn];
-        int idx = -1;
-        bool found = false;
-        for (idx=0; !odesc[idx].last; idx++) {
+        for (int idx = 0; !odesc[idx].last; idx++) {
             const OpcodeDesc& opcode = odesc[idx];
             if (opcode.platf == OpcodeInfo::decoder) {
                 continue;
@@ -727,28 +734,11 @@
             if (opcode.roles.count != opnds.count()) {
                 continue;
             }
-            if (try_match(opcode, opnds, true)) {
-                found = true;
+            if (match(opcode, opnds)) {
+                opcodeIndex = idx;
                 break;
             }
         }
-        if (!found) {
-            for (idx=0; !odesc[idx].last; idx++) {
-                const OpcodeDesc& opcode = odesc[idx];
-                if (opcode.platf == OpcodeInfo::decoder) {
-                    continue;
-                }
-                if (opcode.roles.count != opnds.count()) {
-                    continue;
-                }
-                if (try_match(opcode, opnds, false)) {
-                    found = true;
-                    break;
-                }
-            }
-        }
-        assert(found);
-        opcodeIndex = idx;
 #ifdef ENCODER_USE_SUBHASH
         put(mn, hash, opcodeIndex);
 #endif
@@ -758,6 +748,7 @@
     assert(!odesc->last);
     assert(odesc->roles.count == opnds.count());
     assert(odesc->platf != OpcodeInfo::decoder);
+    assert(match(*odesc, opnds));
 #if !defined(_EM64T_)
     // tuning was done for IA32 only, so no size restriction on EM64T
     //assert(sizeof(OpcodeDesc)==128);



Mime
View raw message