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

witulski at codespeak.net witulski at codespeak.net
Thu Jul 31 17:44:22 CEST 2008


Author: witulski
Date: Thu Jul 31 17:44:21 2008
New Revision: 56880

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_simple.py
Log:
(witulski) Added SUB instruction


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	Thu Jul 31 17:44:21 2008
@@ -43,6 +43,7 @@
     
     ADD = make_two_quadreg_instr("\x00")
     MOV = make_two_quadreg_instr("\x89")
+    SUB = make_two_quadreg_instr("\x28")
     
     def RET(self):
         self.write("\xC3")

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	Thu Jul 31 17:44:21 2008
@@ -42,6 +42,12 @@
         self.mc.ADD(gv_z.reg, gv_y.reg)
         return gv_z
     
+    def op_int_sub(self, gv_x, gv_y):
+        gv_z = self.allocate_register()
+        self.mc.MOV(gv_z.reg, gv_x.reg)
+        self.mc.SUB(gv_z.reg, gv_y.reg)
+        return gv_z
+    
     def finish_and_return(self, sigtoken, gv_returnvar):
         #self.mc.write("\xB8\x0F\x00\x00\x00")
         self.mc.MOV("rax", gv_returnvar.reg)

Modified: pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_simple.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_simple.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/x86_64/test/test_simple.py	Thu Jul 31 17:44:21 2008
@@ -29,4 +29,14 @@
     print repr("".join(builder.mc._all))
     four = fp(4, 17)
     assert four == 4
+    print four
+    
+def test_sub():
+    builder, fp, inputargs_gv, token = make_testbuilder()
+    genv0 = inputargs_gv[0] #the first argument "place"
+    genv1 = inputargs_gv[1] 
+    genv_result = builder.genop2("int_sub", genv0, genv1) #creates the addition and returns the place(register) of the result in genv_result
+    builder.finish_and_return(token, genv_result)
+    four = fp(10, 6)
+    assert four == 4
     print four
\ No newline at end of file



More information about the Pypy-commit mailing list