You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2007/03/27 11:31:13 UTC

svn commit: r522840 - in /harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32: Ia32Inst.cpp Ia32Inst.h

Author: varlax
Date: Tue Mar 27 02:31:13 2007
New Revision: 522840

URL: http://svn.apache.org/viewvc?view=rev&rev=522840
Log:
HARMONY-3480 [drlvm][jit]Minor code quality improvements:
Complex memory addressing is 'normalized'

Modified:
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp
    harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h

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?view=diff&rev=522840&r1=522839&r2=522840
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.cpp Tue Mar 27 02:31:13 2007
@@ -16,7 +16,6 @@
  */
 /**
  * @author Vyacheslav P. Shakin
- * @version $Revision: 1.14.12.1.4.4 $
  */
 
 #include "Ia32Inst.h"
@@ -101,11 +100,15 @@
     bool replaced = false;
     if (memOpndKind != MemOpndKind_Null){
         assert(isPlacedIn(OpndKind_Mem));
-        for (uint32 i=0; i<MemOpndSubOpndKind_Count; i++)
+        for (uint32 i=0; i<MemOpndSubOpndKind_Count; i++) {
             if (memOpndSubOpnds[i]!=NULL && memOpndSubOpnds[i]==opndOld) {
                 setMemOpndSubOpnd((MemOpndSubOpndKind)i, opndNew);
                 replaced = true;
             }
+        }
+        if (replaced) {
+            normalizeMemSubOpnds();
+        }
     }
     return replaced;
 }
@@ -116,15 +119,34 @@
     bool replaced = false;
     if (memOpndKind != MemOpndKind_Null){
         assert(isPlacedIn(OpndKind_Mem));
-        for (uint32 i=0; i<MemOpndSubOpndKind_Count; i++)
+        for (uint32 i=0; i<MemOpndSubOpndKind_Count; i++) {
             if (memOpndSubOpnds[i]!=NULL && opndMap[memOpndSubOpnds[i]->id]!=NULL){
                 setMemOpndSubOpnd((MemOpndSubOpndKind)i, opndMap[memOpndSubOpnds[i]->id]);
                 replaced = true;
             }
+        }
+        if (replaced) {
+            normalizeMemSubOpnds();
+        }
     }
     return replaced;
 }
 
+
+void Opnd::normalizeMemSubOpnds(void)
+{
+    if (!isPlacedIn(OpndKind_Mem)) {
+        return;
+    }
+    Opnd* base = getMemOpndSubOpnd(MemOpndSubOpndKind_Base);
+    Opnd* disp = getMemOpndSubOpnd(MemOpndSubOpndKind_Displacement);
+    if (base != NULL && base->isPlacedIn(OpndKind_Imm)) {
+        assert(disp == NULL || !disp->isPlacedIn(OpndKind_Imm));
+        // can't call setMemOpndSubOpnd() as it fights against zero opnd.
+        memOpndSubOpnds[MemOpndSubOpndKind_Displacement] = base;//== setMemOpndSubOpnd(MemOpndSubOpndKind_Displacement, base);
+        memOpndSubOpnds[MemOpndSubOpndKind_Base] = disp; //==setMemOpndSubOpnd(MemOpndSubOpndKind_Base, disp);
+    }
+}
 
 #ifdef _DEBUG
 //_________________________________________________________________________________________________

Modified: harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h?view=diff&rev=522840&r1=522839&r2=522840
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/jitrino/src/codegenerator/ia32/Ia32Inst.h Tue Mar 27 02:31:13 2007
@@ -16,7 +16,6 @@
  */
 /**
  * @author Vyacheslav P. Shakin
- * @version $Revision: 1.18.12.2.4.3 $
  */
 
 #ifndef _IA32_INST_H_
@@ -325,6 +324,11 @@
 protected:
     bool replaceMemOpndSubOpnd(Opnd * opndOld, Opnd * opndNew);
     bool replaceMemOpndSubOpnds(Opnd * const * opndMap);
+    /**
+     * 'Normalizes' memory sub opnds. That is ensures that an immediate is 
+     * placed at the displacement, and a register gets placed ad the base.
+     */
+    void normalizeMemSubOpnds(void);
 
     void addRefCount(uint32& index, uint32 blockExecCount);