[pypy-svn] r31680 - pypy/dist/pypy/jit/codegen/i386

arigo at codespeak.net arigo at codespeak.net
Sat Aug 26 14:53:29 CEST 2006


Author: arigo
Date: Sat Aug 26 14:53:27 2006
New Revision: 31680

Modified:
   pypy/dist/pypy/jit/codegen/i386/i386.py
   pypy/dist/pypy/jit/codegen/i386/ri386genop.py
   pypy/dist/pypy/jit/codegen/i386/ri386setup.py
Log:
(michael, arigo)

Added some more instructions to the 386 back-end.


Modified: pypy/dist/pypy/jit/codegen/i386/i386.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/i386.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/i386.py	Sat Aug 26 14:53:27 2006
@@ -402,6 +402,13 @@
 IMUL.mode2(REG, IMM32, ['\x69', register(1,9), '\xC0', immediate(2)])
 IMUL.mode2(REG, MODRM, ['\x0F\xAF', register(1,8), modrm(2)])
 
+IDIV = Instruction()
+IDIV.mode1(MODRM,  ['\xF7', orbyte(7<<3), modrm(1)])
+IDIV.mode1(MODRM8, ['\xF6', orbyte(7<<3), modrm(1)])
+
+CDQ = Instruction()
+CDQ.mode0(['\x99'])
+
 MOVSX = Instruction()
 MOVSX.mode2(REG, MODRM8, ['\x0F\xBE', register(1,8), modrm(2,'b')])
 MOVSX.as_all_suffixes = 1

Modified: pypy/dist/pypy/jit/codegen/i386/ri386genop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/ri386genop.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/ri386genop.py	Sat Aug 26 14:53:27 2006
@@ -106,6 +106,7 @@
     def close2(self, gv_condition):
         false_block = self.rgenop.newblock()
         false_block.stackdepth = self.stackdepth
+        # XXX what if gv_condition is a Const?
         self.mc.CMP(gv_condition.operand(self), imm8(0))
         self.mc.JE(rel32(false_block.startaddr))
         return Link(false_block), Link(self)
@@ -129,6 +130,61 @@
         self.mc.SUB(eax, gv_y.operand(self))
         return self.push(eax)
 
+    def op_int_mul(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.IMUL(eax, gv_y.operand(self))
+        return self.push(eax)
+
+    def op_int_floordiv(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.CDQ()
+        self.mc.MOV(ecx, gv_y.operand(self))
+        self.mc.IDIV(ecx)
+        return self.push(eax)
+
+    def op_int_and(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.AND(eax, gv_y.operand(self))
+        return self.push(eax)
+
+    def op_int_or(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.OR(eax, gv_y.operand(self))
+        return self.push(eax)
+
+    def op_int_xor(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.XOR(eax, gv_y.operand(self))
+        return self.push(eax)
+
+    def op_int_lt(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.CMP(eax, gv_y.operand(self))
+        self.mc.SETL(al)
+        self.mc.MOVZX(eax, al)
+        return self.push(eax)
+
+    def op_int_le(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.CMP(eax, gv_y.operand(self))
+        self.mc.SETLE(al)
+        self.mc.MOVZX(eax, al)
+        return self.push(eax)
+
+    def op_int_eq(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.CMP(eax, gv_y.operand(self))
+        self.mc.SETE(al)
+        self.mc.MOVZX(eax, al)
+        return self.push(eax)
+
+    def op_int_ne(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.CMP(eax, gv_y.operand(self))
+        self.mc.SETNE(al)
+        self.mc.MOVZX(eax, al)
+        return self.push(eax)
+
     def op_int_gt(self, (gv_x, gv_y), gv_RESTYPE):
         self.mc.MOV(eax, gv_x.operand(self))
         self.mc.CMP(eax, gv_y.operand(self))
@@ -136,6 +192,37 @@
         self.mc.MOVZX(eax, al)
         return self.push(eax)
 
+    def op_int_ge(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.CMP(eax, gv_y.operand(self))
+        self.mc.SETGE(al)
+        self.mc.MOVZX(eax, al)
+        return self.push(eax)
+
+    def op_int_neg(self, (gv_x,), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.NEG(eax)
+        return self.push(eax)
+
+    def op_int_lshift(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.MOV(ecx, gv_y.operand(self))
+        self.mc.SHL(eax, cl)
+        return self.push(eax)
+
+    def op_int_rshift(self, (gv_x, gv_y), gv_RESTYPE):
+        self.mc.MOV(eax, gv_x.operand(self))
+        self.mc.MOV(ecx, gv_y.operand(self))
+        self.mc.SHR(eax, cl)
+        return self.push(eax)
+
+    def op_bool_not(self, (gv_x,), gv_RESTYPE):
+        # XXX what if gv_x is a Const?
+        self.mc.CMP(gv_x.operand(self), imm8(0))
+        self.mc.SETE(al)
+        self.mc.MOVZX(eax, al)
+        return self.push(eax)
+
 
 class Link(CodeGenLink):
 

Modified: pypy/dist/pypy/jit/codegen/i386/ri386setup.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/i386/ri386setup.py	(original)
+++ pypy/dist/pypy/jit/codegen/i386/ri386setup.py	Sat Aug 26 14:53:27 2006
@@ -324,6 +324,13 @@
 IMUL.mode2(REG, IMM32, ['\x69', register(1,9), '\xC0', immediate(2)])
 IMUL.mode2(REG, MODRM, ['\x0F\xAF', register(1,8), modrm(2)])
 
+IDIV = Instruction()
+IDIV.mode1(MODRM,  ['\xF7', orbyte(7<<3), modrm(1)])
+IDIV.mode1(MODRM8, ['\xF6', orbyte(7<<3), modrm(1)])
+
+CDQ = Instruction()
+CDQ.mode0(['\x99'])
+
 MOVSX = Instruction()
 MOVSX.mode2(REG, MODRM8, ['\x0F\xBE', register(1,8), modrm(2,'b')])
 MOVSX.as_all_suffixes = 1



More information about the Pypy-commit mailing list