[pypy-svn] r65646 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend: llvm test
arigo at codespeak.net
arigo at codespeak.net
Sun Jun 7 17:50:58 CEST 2009
Author: arigo
Date: Sun Jun 7 17:50:57 2009
New Revision: 65646
Modified:
pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
Log:
Test and implement BOOL_NOT. Improve INT_IS_TRUE.
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/runner.py Sun Jun 7 17:50:57 2009
@@ -509,11 +509,37 @@
"")
def generate_INT_IS_TRUE(self, op):
- self.vars[op.result] = llvm_rffi.LLVMBuildICmp(self.builder,
- llvm_rffi.Predicate.NE,
- self.getintarg(op.args[0]),
- self.cpu.const_zero,
- "")
+ v = op.args[0]
+ try:
+ value_ref = self.vars[v]
+ if llvm_rffi.LLVMTypeOf(value_ref) != self.cpu.ty_bit:
+ raise KeyError
+ except KeyError:
+ res = llvm_rffi.LLVMBuildICmp(self.builder,
+ llvm_rffi.Predicate.NE,
+ self.getintarg(op.args[0]),
+ self.cpu.const_zero,
+ "")
+ else:
+ res = value_ref # value_ref: ty_bit. this is a no-op
+ self.vars[op.result] = res
+
+ def generate_BOOL_NOT(self, op):
+ v = op.args[0]
+ try:
+ value_ref = self.vars[v]
+ if llvm_rffi.LLVMTypeOf(value_ref) != self.cpu.ty_bit:
+ raise KeyError
+ except KeyError:
+ res = llvm_rffi.LLVMBuildICmp(self.builder,
+ llvm_rffi.Predicate.EQ,
+ self.getintarg(op.args[0]),
+ self.cpu.const_zero,
+ "")
+ else:
+ # value_ref: ty_int
+ res = LLVMBuildNot(self.builder, value_ref, "")
+ self.vars[op.result] = res
def generate_INT_ADD_OVF(self, op):
self._generate_ovf_op(op, self.cpu.f_add_ovf)
Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py (original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/test/runner_test.py Sun Jun 7 17:50:57 2009
@@ -189,6 +189,7 @@
(rop.INT_IS_TRUE, [(0, 0), (1, 1), (2, 1), (-1, 1), (minint, 1)]),
(rop.INT_NEG, [(0, 0), (123, -123), (-23127, 23127)]),
(rop.INT_INVERT, [(0, ~0), (-1, ~(-1)), (123, ~123)]),
+ (rop.BOOL_NOT, [(0, 1), (1, 0)]),
]:
for x, y in testcases:
res = self.execute_operation(opnum, [BoxInt(x)],
More information about the Pypy-commit
mailing list