[pypy-svn] r58735 - in pypy/branch/oo-jit/pypy/jit/codegen/x86_64: . test

witulski at codespeak.net witulski at codespeak.net
Tue Oct 7 14:23:35 CEST 2008


Author: witulski
Date: Tue Oct  7 14:23:35 2008
New Revision: 58735

Modified:
   pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py
   pypy/branch/oo-jit/pypy/jit/codegen/x86_64/rgenop.py
   pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_rgenop.py
Log:
IDIV sign extended(Test pass)


Modified: pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/x86_64/assembler.py	Tue Oct  7 14:23:35 2008
@@ -231,7 +231,11 @@
     def AND(self, op1, op2):
         method = getattr(self, "_AND"+op1.to_string()+op2.to_string())
         method(op1, op2)
-        
+     
+    def CDQ(self):
+        self.write("\x48")
+        self.write("\x99")
+    
     def CMP(self, op1, op2):
         #import pdb;pdb.set_trace()
         method = getattr(self, "_CMP"+op1.to_string()+op2.to_string())

Modified: pypy/branch/oo-jit/pypy/jit/codegen/x86_64/rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/x86_64/rgenop.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/x86_64/rgenop.py	Tue Oct  7 14:23:35 2008
@@ -137,12 +137,11 @@
         return gv_x
     
     # IDIV RDX:RAX with QWREG
-    # FIXME: supports only RAX with QWREG
+    # supports only RAX (64bit) with QWREG
     def op_int_div(self, gv_x, gv_y):
         gv_z = self.allocate_register("rax")
-        gv_w = self.allocate_register("rdx")
         self.mc.MOV(gv_z, gv_x)
-        self.mc.XOR(gv_w, gv_w)
+        self.mc.CDQ() #sign extention
         self.mc.IDIV(gv_y)
         return gv_z 
     

Modified: pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_rgenop.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_rgenop.py	Tue Oct  7 14:23:35 2008
@@ -34,7 +34,7 @@
     builder.start_writing() 
     gv_z = builder.genop2("int_gt", gv_x, gv_y)
     builder.mc.CMP(gv_z, rgenop.genconst(1)) 
-    builder.mc.JNE(6)
+    builder.mc.JNE(builder.mc.tell()+6+6) #length of the jne(6 byte) + length of tow incs(3 byte)
     builder.genop1("int_inc",gv_y)#not executed if x<=y
     builder.genop1("int_inc",gv_y)#not executed if x<=y
     builder.genop1("int_inc",gv_y)



More information about the Pypy-commit mailing list