Author: Ronan Lamy <[email protected]>
Branch: llconst
Changeset: r80101:21621915e9f0
Date: 2015-10-10 04:20 +0100
http://bitbucket.org/pypy/pypy/changeset/21621915e9f0/

Log:    fix tests

diff --git a/rpython/jit/codewriter/flatten.py 
b/rpython/jit/codewriter/flatten.py
--- a/rpython/jit/codewriter/flatten.py
+++ b/rpython/jit/codewriter/flatten.py
@@ -1,4 +1,5 @@
 from rpython.flowspace.model import Variable, Constant, c_last_exception
+from rpython.rtyper.rmodel import ll_const
 from rpython.jit.metainterp.history import AbstractDescr, getkind
 from rpython.rtyper.lltypesystem import lltype
 
@@ -166,7 +167,7 @@
                 exc_data = self.cpu.rtyper.exceptiondata
                 ll_ovf = exc_data.get_standard_ll_exc_instance_by_class(
                     OverflowError)
-                c = Constant(ll_ovf, concretetype=lltype.typeOf(ll_ovf))
+                c = ll_const(ll_ovf)
                 self.emitline("raise", c)
             else:
                 self.emitline("reraise")
@@ -226,8 +227,7 @@
                     self.make_exception_link(link, False)
                     break
                 self.emitline('goto_if_exception_mismatch',
-                              Constant(link.llexitcase,
-                                       lltype.typeOf(link.llexitcase)),
+                              ll_const(link.llexitcase),
                               TLabel(link))
                 self.make_exception_link(link, False)
                 self.emitline(Label(link))
diff --git a/rpython/jit/codewriter/format.py b/rpython/jit/codewriter/format.py
--- a/rpython/jit/codewriter/format.py
+++ b/rpython/jit/codewriter/format.py
@@ -1,5 +1,5 @@
 import py
-from rpython.flowspace.model import Constant
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.rtyper.lltypesystem import lltype
 from rpython.jit.codewriter.flatten import SSARepr, Label, TLabel, Register
 from rpython.jit.codewriter.flatten import ListOfKind, IndirectCallTargets
@@ -14,7 +14,7 @@
     def repr(x):
         if isinstance(x, Register):
             return '%%%s%d' % (x.kind[0], x.index)    # e.g. %i1 or %r2 or %f3
-        elif isinstance(x, Constant):
+        elif isinstance(x, LLConstant):
             if (isinstance(x.concretetype, lltype.Ptr) and
                 isinstance(x.concretetype.TO, lltype.Struct)):
                 return '$<* struct %s>' % (x.concretetype.TO._name,)
@@ -117,7 +117,7 @@
                 return reg
         elif s[0] == '$':
             intvalue = int(s[1:])
-            return Constant(intvalue, lltype.Signed)
+            return ll_const(intvalue)
         elif s[0] == 'L':
             return TLabel(s)
         elif s[0] in 'IRF' and s[1] == '[' and s[-1] == ']':
diff --git a/rpython/jit/codewriter/jtransform.py 
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -8,11 +8,11 @@
 from rpython.jit.metainterp.history import getkind
 from rpython.jit.metainterp.typesystem import deref, arrayItem
 from rpython.jit.metainterp.blackhole import BlackholeInterpreter
-from rpython.flowspace.model import SpaceOperation, Variable, Constant,\
-     c_last_exception
+from rpython.flowspace.model import SpaceOperation, Variable, Constant
 from rpython.rlib import objectmodel
 from rpython.rlib.jit import _we_are_jitted
 from rpython.rlib.rgc import lltype_is_gc
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.rtyper.lltypesystem import lltype, llmemory, rstr, rffi
 from rpython.rtyper.lltypesystem import rbytearray
 from rpython.rtyper import rclass
@@ -44,7 +44,7 @@
                 constant_result = excmatch(*[a.value for a in op.args[1:]])
                 block.operations[i] = SpaceOperation(
                     'same_as',
-                    [Constant(constant_result, lltype.Bool)],
+                    [LLConstant(constant_result, lltype.Bool)],
                     op.result)
                 if block.exitswitch is op.result:
                     block.exitswitch = None
@@ -81,13 +81,13 @@
         #
         def do_rename(var, var_or_const):
             if var.concretetype is lltype.Void:
-                renamings[var] = Constant(None, lltype.Void)
+                renamings[var] = ll_const(None)
                 return
             renamings[var] = var_or_const
             if isinstance(var_or_const, Constant):
                 value = var_or_const.value
                 value = lltype._cast_whatever(var.concretetype, value)
-                renamings_constants[var] = Constant(value, var.concretetype)
+                renamings_constants[var] = LLConstant(value, var.concretetype)
         #
         for op in block.operations:
             if renamings_constants:
@@ -221,7 +221,7 @@
                 for link in block.exits:
                     while v in link.args:
                         index = link.args.index(v)
-                        link.args[index] = Constant(link.llexitcase,
+                        link.args[index] = LLConstant(link.llexitcase,
                                                     lltype.Bool)
                 return True
         return False
@@ -257,7 +257,7 @@
                 vtable = heaptracker.get_vtable_for_gcstruct(self.cpu, TO)
                 if vtable.subclassrange_max - vtable.subclassrange_min == 1:
                     # it's a precise class check
-                    const_vtable = Constant(vtable, lltype.typeOf(vtable))
+                    const_vtable = ll_const(vtable)
                     return [None, # hack, do the right renaming from 
op.args[0] to op.result
                             SpaceOperation("record_exact_class", [op.args[0], 
const_vtable], None)]
 
@@ -274,7 +274,7 @@
             # only for untranslated tests: get a real integer estimate
             arg = op.args[0].value
             arg = llmemory.raw_malloc_usage(arg)
-            return [Constant(arg, lltype.Signed)]
+            return [LLConstant(arg, lltype.Signed)]
 
     def rewrite_op_jit_record_exact_class(self, op):
         return SpaceOperation("record_exact_class", [op.args[0], op.args[1]], 
None)
@@ -471,7 +471,7 @@
         assert jitdriver_sd is not None
         ops = self.promote_greens(op.args[1:], jitdriver_sd.jitdriver)
         num_green_args = len(jitdriver_sd.jitdriver.greens)
-        args = ([Constant(jitdriver_sd.index, lltype.Signed)] +
+        args = ([LLConstant(jitdriver_sd.index, lltype.Signed)] +
                 self.make_three_lists(op.args[1:1+num_green_args]) +
                 self.make_three_lists(op.args[1+num_green_args:]))
         kind = getkind(op.result.concretetype)[0]
@@ -582,7 +582,7 @@
                 EffectInfo.OS_STREQ_NONNULL)
             # XXX this is fairly ugly way of creating a constant,
             #     however, callinfocollection has no better interface
-            c = Constant(p.adr.ptr, lltype.typeOf(p.adr.ptr))
+            c = ll_const(p.adr.ptr)
             op1 = SpaceOperation('str_guard_value', [op.args[0], c, descr],
                                  op.result)
             return [SpaceOperation('-live-', [], None), op1, None]
@@ -643,8 +643,8 @@
                     # substruct
                     self.zero_contents(ops, v, FIELD)
                 else:
-                    c_name = Constant(name, lltype.Void)
-                    c_null = Constant(FIELD._defl(), FIELD)
+                    c_name = LLConstant(name, lltype.Void)
+                    c_null = LLConstant(FIELD._defl(), FIELD)
                     op = SpaceOperation('setfield', [v, c_name, c_null],
                                         None)
                     self.extend_with(ops, self.rewrite_op_setfield(op,
@@ -851,7 +851,7 @@
             raise Exception("%r: only supported for gckind=raw" % (op,))
         ofs = llmemory.offsetof(STRUCT, op.args[1].value)
         return SpaceOperation('int_add',
-                              [op.args[0], Constant(ofs, lltype.Signed)],
+                              [op.args[0], LLConstant(ofs, lltype.Signed)],
                               op.result)
 
     def is_typeptr_getset(self, op):
@@ -909,7 +909,7 @@
     def handle_getfield_typeptr(self, op):
         if isinstance(op.args[0], Constant):
             cls = op.args[0].value.typeptr
-            return Constant(cls, concretetype=rclass.CLASSTYPE)
+            return LLConstant(cls, rclass.CLASSTYPE)
         op0 = SpaceOperation('-live-', [], None)
         op1 = SpaceOperation('guard_class', [op.args[0]], op.result)
         return [op0, op1]
@@ -1232,7 +1232,7 @@
         elif longlong_arg:
             if v_result.concretetype is lltype.Bool:
                 longlong_zero = rffi.cast(v_arg.concretetype, 0)
-                c_longlong_zero = Constant(longlong_zero, v_arg.concretetype)
+                c_longlong_zero = ll_const(longlong_zero)
                 if unsigned1:
                     name = 'ullong_ne'
                 else:
@@ -1295,11 +1295,11 @@
         if v_result.concretetype is lltype.Bool:
             result.append(SpaceOperation('int_is_true', [v_arg], v_result))
         elif min2:
-            c_bytes = Constant(size2, lltype.Signed)
+            c_bytes = LLConstant(size2, lltype.Signed)
             result.append(SpaceOperation('int_signext', [v_arg, c_bytes],
                                          v_result))
         else:
-            c_mask = Constant(int((1 << (8 * size2)) - 1), lltype.Signed)
+            c_mask = LLConstant(int((1 << (8 * size2)) - 1), lltype.Signed)
             result.append(SpaceOperation('int_and', [v_arg, c_mask], v_result))
         return result
 
@@ -1323,7 +1323,7 @@
         if op.args[0].concretetype != rffi.CCHARP:
             v_prod = varoftype(lltype.Signed)
             by = llmemory.sizeof(op.args[0].concretetype.TO.OF)
-            c_by = Constant(by, lltype.Signed)
+            c_by = LLConstant(by, lltype.Signed)
             ops.append(SpaceOperation('int_mul', [v_shift, c_by], v_prod))
             v_shift = v_prod
         #
@@ -1407,9 +1407,7 @@
 
     def rewrite_op_llong_neg(self, op):
         v = varoftype(lltype.SignedLongLong)
-        op0 = SpaceOperation('cast_int_to_longlong',
-                             [Constant(0, lltype.Signed)],
-                             v)
+        op0 = SpaceOperation('cast_int_to_longlong', [ll_const(0)], v)
         args = [v, op.args[0]]
         op1 = SpaceOperation('llong_sub', args, op.result)
         return (self._normalize(self.rewrite_operation(op0)) +
@@ -1417,9 +1415,7 @@
 
     def rewrite_op_llong_is_true(self, op):
         v = varoftype(op.args[0].concretetype)
-        op0 = SpaceOperation('cast_primitive',
-                             [Constant(0, lltype.Signed)],
-                             v)
+        op0 = SpaceOperation('cast_primitive', [ll_const(0)], v)
         args = [op.args[0], v]
         op1 = SpaceOperation('llong_ne', args, op.result)
         return (self._normalize(self.rewrite_operation(op0)) +
@@ -1471,14 +1467,12 @@
 
     def rewrite_op_int_neg_ovf(self, op):
         op1 = SpaceOperation('int_sub_ovf',
-                             [Constant(0, lltype.Signed), op.args[0]],
-                             op.result)
+                             [ll_const(0), op.args[0]], op.result)
         return self.rewrite_operation(op1)
 
     def rewrite_op_float_is_true(self, op):
         op1 = SpaceOperation('float_ne',
-                             [op.args[0], Constant(0.0, lltype.Float)],
-                             op.result)
+                             [op.args[0], ll_const(0.0)], op.result)
         return self.rewrite_operation(op1)
 
     def rewrite_op_int_is_true(self, op):
@@ -1491,7 +1485,7 @@
             else:
                 raise AssertionError("don't know the truth value of %r"
                                      % (value,))
-            return Constant(value, lltype.Bool)
+            return LLConstant(value, lltype.Bool)
         return op
 
     def promote_greens(self, args, jitdriver):
@@ -1545,7 +1539,7 @@
                     "Constant specified red in jit_merge_point()")
             assert len(dict.fromkeys(redlist)) == len(list(redlist)), (
                 "duplicate red variable on jit_merge_point()")
-        args = ([Constant(self.portal_jd.index, lltype.Signed)] +
+        args = ([LLConstant(self.portal_jd.index, lltype.Signed)] +
                 self.make_three_lists(op.args[2:2+num_green_args]) +
                 redlists)
         op1 = SpaceOperation('jit_merge_point', args, None)
@@ -1558,7 +1552,7 @@
     def handle_jit_marker__loop_header(self, op, jitdriver):
         jd = self.callcontrol.jitdriver_sd_from_jitdriver(jitdriver)
         assert jd is not None
-        c_index = Constant(jd.index, lltype.Signed)
+        c_index = LLConstant(jd.index, lltype.Signed)
         return SpaceOperation('loop_header', [c_index], None)
 
     # a 'can_enter_jit' in the source graph becomes a 'loop_header'
@@ -1683,7 +1677,7 @@
             assert v_length.concretetype is lltype.Signed
             return v_length
         else:
-            return Constant(0, lltype.Signed)     # length: default to 0
+            return ll_const(0)     # length: default to 0
 
     # ---------- fixed lists ----------
 
diff --git a/rpython/jit/codewriter/support.py 
b/rpython/jit/codewriter/support.py
--- a/rpython/jit/codewriter/support.py
+++ b/rpython/jit/codewriter/support.py
@@ -3,12 +3,13 @@
 from rpython.annotator import model as annmodel
 from rpython.rtyper.llannotation import lltype_to_annotation
 from rpython.annotator.policy import AnnotatorPolicy
-from rpython.flowspace.model import Variable, Constant
+from rpython.flowspace.model import Variable
 from rpython.jit.metainterp.typesystem import deref
 from rpython.rlib import rgc
 from rpython.rlib.jit import elidable, oopspec
 from rpython.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint, intmask
 from rpython.rlib.rarithmetic import LONG_BIT
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.rtyper import rlist
 from rpython.rtyper.lltypesystem import rlist as rlist_ll
 from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator
@@ -758,7 +759,7 @@
         if isinstance(obj, Index):
             result.append(opargs[obj.n])
         else:
-            result.append(Constant(obj, lltype.typeOf(obj)))
+            result.append(ll_const(obj))
     return result
 
 def get_call_oopspec_opargs(fnobj, opargs):
@@ -837,8 +838,8 @@
         mixlevelann.finish()
     else:
         # for testing only
-        c_func = Constant(oopspec_name,
-                          lltype.Ptr(lltype.FuncType(ll_args, ll_res)))
+        c_func = LLConstant(oopspec_name,
+                            lltype.Ptr(lltype.FuncType(ll_args, ll_res)))
     #
     if not hasattr(rtyper, '_builtin_func_for_spec_cache'):
         rtyper._builtin_func_for_spec_cache = {}
diff --git a/rpython/jit/codewriter/test/test_assembler.py 
b/rpython/jit/codewriter/test/test_assembler.py
--- a/rpython/jit/codewriter/test/test_assembler.py
+++ b/rpython/jit/codewriter/test/test_assembler.py
@@ -5,7 +5,7 @@
 from rpython.jit.codewriter.jitcode import MissingLiveness
 from rpython.jit.codewriter import heaptracker, longlong
 from rpython.jit.metainterp.history import AbstractDescr
-from rpython.flowspace.model import Constant
+from rpython.rtyper.rmodel import LLConstant
 from rpython.rtyper.lltypesystem import lltype, llmemory
 
 
@@ -30,10 +30,10 @@
     ssarepr = SSARepr("test")
     ssarepr.insns = [
         ('int_return', Register('int', 13)),
-        ('int_return', Constant(18, lltype.Signed)),
-        ('int_return', Constant(-4, lltype.Signed)),
-        ('int_return', Constant(128, lltype.Signed)),
-        ('int_return', Constant(-129, lltype.Signed)),
+        ('int_return', LLConstant(18, lltype.Signed)),
+        ('int_return', LLConstant(-4, lltype.Signed)),
+        ('int_return', LLConstant(128, lltype.Signed)),
+        ('int_return', LLConstant(-129, lltype.Signed)),
         ]
     assembler = Assembler()
     jitcode = assembler.assemble(ssarepr)
@@ -50,9 +50,9 @@
     ssarepr = SSARepr("test")
     ssarepr.insns = [
         ('float_return', Register('float', 13)),
-        ('float_return', Constant(18.0, lltype.Float)),
-        ('float_return', Constant(-4.0, lltype.Float)),
-        ('float_return', Constant(128.1, lltype.Float)),
+        ('float_return', LLConstant(18.0, lltype.Float)),
+        ('float_return', LLConstant(-4.0, lltype.Float)),
+        ('float_return', LLConstant(128.1, lltype.Float)),
         ]
     assembler = Assembler()
     jitcode = assembler.assemble(ssarepr)
@@ -71,9 +71,9 @@
     from rpython.rlib.rarithmetic import r_longlong, r_ulonglong
     ssarepr = SSARepr("test")
     ssarepr.insns = [
-        ('float_return', Constant(r_longlong(-18000000000000000),
+        ('float_return', LLConstant(r_longlong(-18000000000000000),
                                   lltype.SignedLongLong)),
-        ('float_return', Constant(r_ulonglong(9900000000000000000),
+        ('float_return', LLConstant(r_ulonglong(9900000000000000000),
                                   lltype.UnsignedLongLong)),
         ]
     assembler = Assembler()
@@ -91,10 +91,10 @@
     F = lltype.FuncType([], lltype.Signed)
     f = lltype.functionptr(F, 'f')
     ssarepr.insns = [
-        ('int_return', Constant('X', lltype.Char)),
-        ('int_return', Constant(unichr(0x1234), lltype.UniChar)),
-        ('int_return', Constant(f, lltype.Ptr(F))),
-        ('ref_return', Constant(s, lltype.Ptr(S))),
+        ('int_return', LLConstant('X', lltype.Char)),
+        ('int_return', LLConstant(unichr(0x1234), lltype.UniChar)),
+        ('int_return', LLConstant(f, lltype.Ptr(F))),
+        ('ref_return', LLConstant(s, lltype.Ptr(S))),
         ]
     assembler = Assembler()
     jitcode = assembler.assemble(ssarepr)
@@ -115,9 +115,9 @@
     i0, i1 = Register('int', 0x16), Register('int', 0x17)
     ssarepr.insns = [
         (Label('L1'),),
-        ('goto_if_not_int_gt', i0, Constant(4, lltype.Signed), TLabel('L2')),
+        ('goto_if_not_int_gt', i0, LLConstant(4, lltype.Signed), TLabel('L2')),
         ('int_add', i1, i0, '->', i1),
-        ('int_sub', i0, Constant(1, lltype.Signed), '->', i0),
+        ('int_sub', i0, LLConstant(1, lltype.Signed), '->', i0),
         ('goto', TLabel('L1')),
         (Label('L2'),),
         ('int_return', i1),
@@ -139,7 +139,7 @@
     ssarepr = SSARepr("test")
     i0, i1 = Register('int', 0x16), Register('int', 0x17)
     ssarepr.insns = [
-        ('foobar', ListOfKind('int', [i0, i1, Constant(42, lltype.Signed)]),
+        ('foobar', ListOfKind('int', [i0, i1, LLConstant(42, lltype.Signed)]),
                    ListOfKind('ref', [])),
         ]
     assembler = Assembler()
@@ -154,10 +154,10 @@
     # encoded directly.
     ssarepr = SSARepr("test")
     ssarepr.insns = [
-        ('foobar', ListOfKind('int', [Constant(42, lltype.Signed)])),
-        ('foobar', ListOfKind('int', [Constant(42, lltype.Signed)])),
-        ('baz', Constant(42, lltype.Signed)),
-        ('bok', Constant(41, lltype.Signed)),
+        ('foobar', ListOfKind('int', [LLConstant(42, lltype.Signed)])),
+        ('foobar', ListOfKind('int', [LLConstant(42, lltype.Signed)])),
+        ('baz', LLConstant(42, lltype.Signed)),
+        ('bok', LLConstant(41, lltype.Signed)),
         ]
     assembler = Assembler()
     jitcode = assembler.assemble(ssarepr)
@@ -214,10 +214,10 @@
     ssarepr = SSARepr("test")
     i0, i1, i2 = Register('int', 0), Register('int', 1), Register('int', 2)
     ssarepr.insns = [
-        ('int_add', i0, Constant(10, lltype.Signed), '->', i1),
+        ('int_add', i0, LLConstant(10, lltype.Signed), '->', i1),
         ('-live-', i0, i1),
         ('-live-', i1, i2),
-        ('int_add', i0, Constant(3, lltype.Signed), '->', i2),
+        ('int_add', i0, LLConstant(3, lltype.Signed), '->', i2),
         ('-live-', i2),
         ]
     assembler = Assembler()
@@ -233,7 +233,7 @@
 
 def test_assemble_error_string_constant():
     ssarepr = SSARepr("test")
-    c = Constant('foobar', lltype.Void)
+    c = LLConstant('foobar', lltype.Void)
     ssarepr.insns = [
         ('duh', c),
         ]
diff --git a/rpython/jit/codewriter/test/test_call.py 
b/rpython/jit/codewriter/test/test_call.py
--- a/rpython/jit/codewriter/test/test_call.py
+++ b/rpython/jit/codewriter/test/test_call.py
@@ -1,6 +1,7 @@
 import py
 
 from rpython.flowspace.model import SpaceOperation, Constant, Variable
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.translator.unsimplify import varoftype
 from rpython.rlib import jit
@@ -19,7 +20,7 @@
     F = lltype.FuncType([], lltype.Signed)
     f = lltype.functionptr(F, 'f', graph='fgraph')
     v = varoftype(lltype.Signed)
-    op = SpaceOperation('direct_call', [Constant(f, lltype.Ptr(F))], v)
+    op = SpaceOperation('direct_call', [ll_const(f)], v)
     #
     lst = cc.graphs_from(op, {}.__contains__)
     assert lst is None     # residual call
@@ -33,7 +34,7 @@
     v = varoftype(lltype.Signed)
     graphlst = ['f1graph', 'f2graph']
     op = SpaceOperation('indirect_call', [varoftype(lltype.Ptr(F)),
-                                          Constant(graphlst, lltype.Void)], v)
+                                          LLConstant(graphlst, lltype.Void)], 
v)
     #
     lst = cc.graphs_from(op, {'f1graph': True, 'f2graph': True}.__contains__)
     assert lst == ['f1graph', 'f2graph']     # normal indirect call
@@ -48,8 +49,8 @@
     cc = CallControl()
     F = lltype.FuncType([], lltype.Signed)
     v = varoftype(lltype.Signed)
-    op = SpaceOperation('indirect_call', [varoftype(lltype.Ptr(F)),
-                                          Constant(None, lltype.Void)], v)
+    op = SpaceOperation('indirect_call',
+                        [varoftype(lltype.Ptr(F)), ll_const(None)], v)
     lst = cc.graphs_from(op, {}.__contains__)
     assert lst is None
 
diff --git a/rpython/jit/codewriter/test/test_flatten.py 
b/rpython/jit/codewriter/test/test_flatten.py
--- a/rpython/jit/codewriter/test/test_flatten.py
+++ b/rpython/jit/codewriter/test/test_flatten.py
@@ -1,4 +1,4 @@
-import py, sys
+import py
 from rpython.jit.codewriter import support
 from rpython.jit.codewriter.heaptracker import int_signext
 from rpython.jit.codewriter.flatten import flatten_graph, reorder_renaming_list
@@ -9,7 +9,8 @@
 from rpython.jit.metainterp.history import AbstractDescr
 from rpython.rtyper.lltypesystem import lltype, rstr, rffi
 from rpython.rtyper import rclass
-from rpython.flowspace.model import SpaceOperation, Variable, Constant
+from rpython.flowspace.model import SpaceOperation
+from rpython.rtyper.rmodel import LLConstant, ll_const
 from rpython.translator.unsimplify import varoftype
 from rpython.rlib.rarithmetic import ovfcheck, r_uint, r_longlong, r_ulonglong
 from rpython.rlib.jit import dont_look_inside, _we_are_jitted, JitDriver
@@ -44,7 +45,7 @@
     def __getitem__(self, key):
         F = lltype.FuncType([lltype.Signed, lltype.Signed], lltype.Signed)
         f = lltype.functionptr(F, key[0])
-        c_func = Constant(f, lltype.typeOf(f))
+        c_func = ll_const(f)
         return c_func, lltype.Signed
 
 class FakeCPU:
@@ -140,7 +141,7 @@
 
     def encoding_test(self, func, args, expected,
                       transform=False, liveness=False, cc=None, jd=None):
-        
+
         graphs = self.make_graphs(func, args)
         #graphs[0].show()
         if transform:
@@ -252,7 +253,7 @@
         v4 = varoftype(lltype.Ptr(rstr.STR))
         v5 = varoftype(lltype.Float)
         op = SpaceOperation('residual_call_ir_f',
-                            [Constant(12345, lltype.Signed),  # function ptr
+                            [LLConstant(12345, lltype.Signed),  # function ptr
                              ListOfKind('int', [v1, v2]),     # int args
                              ListOfKind('ref', [v3, v4])],    # ref args
                             v5)                    # result
diff --git a/rpython/jit/codewriter/test/test_format.py 
b/rpython/jit/codewriter/test/test_format.py
--- a/rpython/jit/codewriter/test/test_format.py
+++ b/rpython/jit/codewriter/test/test_format.py
@@ -1,5 +1,5 @@
 import py
-from rpython.flowspace.model import Constant
+from rpython.rtyper.rmodel import ll_const
 from rpython.jit.codewriter.format import format_assembler, unformat_assembler
 from rpython.jit.codewriter.flatten import Label, TLabel, SSARepr, Register
 from rpython.jit.codewriter.flatten import ListOfKind
@@ -39,9 +39,7 @@
     s = lltype.malloc(S)
     s.x = 123
     ssarepr = SSARepr("test")
-    ssarepr.insns = [
-        ('foobar', '->', Constant(s, lltype.typeOf(s))),
-        ]
+    ssarepr.insns = [('foobar', '->', ll_const(s))]
     asm = format_assembler(ssarepr)
     expected = """
         foobar -> $<* struct S>
@@ -53,9 +51,9 @@
     i0, i1 = Register('int', 0), Register('int', 1)
     ssarepr.insns = [
         (Label('L1'),),
-        ('goto_if_not_int_gt', i0, Constant(0, lltype.Signed), TLabel('L2')),
+        ('goto_if_not_int_gt', i0, ll_const(0), TLabel('L2')),
         ('int_add', i1, i0, '->', i1),
-        ('int_sub', i0, Constant(1, lltype.Signed), '->', i0),
+        ('int_sub', i0, ll_const(1), '->', i0),
         ('goto', TLabel('L1')),
         (Label('L2'),),
         ('int_return', i1),
@@ -75,9 +73,7 @@
 def test_format_assembler_list():
     ssarepr = SSARepr("test")
     i0, i1 = Register('int', 0), Register('int', 1)
-    ssarepr.insns = [
-        ('foobar', ListOfKind('int', [i0, Constant(123, lltype.Signed), i1])),
-        ]
+    ssarepr.insns = [('foobar', ListOfKind('int', [i0, ll_const(123), i1]))]
     asm = format_assembler(ssarepr)
     expected = """
         foobar I[%i0, $123, %i1]
@@ -117,9 +113,7 @@
         foo $123
     """
     ssarepr = unformat_assembler(input)
-    assert ssarepr.insns == [
-        ('foo', Constant(123, lltype.Signed)),
-        ]
+    assert ssarepr.insns == [('foo', ll_const(123))]
 
 def test_unformat_assembler_single_return():
     input = """
diff --git a/rpython/jit/codewriter/test/test_jtransform.py 
b/rpython/jit/codewriter/test/test_jtransform.py
--- a/rpython/jit/codewriter/test/test_jtransform.py
+++ b/rpython/jit/codewriter/test/test_jtransform.py
@@ -1,22 +1,10 @@
-
 import py
 import random
-try:
-    from itertools import product
-except ImportError:
-    # Python 2.5, this is taken from the CPython docs, but simplified.
-    def product(*args):
-        # product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
-        # product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
-        pools = map(tuple, args)
-        result = [[]]
-        for pool in pools:
-            result = [x+[y] for x in result for y in pool]
-        for prod in result:
-            yield tuple(prod)
+from itertools import product
 
-from rpython.flowspace.model import FunctionGraph, Block, Link, 
c_last_exception
-from rpython.flowspace.model import SpaceOperation, Variable, Constant
+from rpython.flowspace.model import (
+    Block, Link, SpaceOperation, Variable, Constant)
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.rtyper.lltypesystem import lltype, llmemory, rstr, rffi
 from rpython.rtyper import rclass
 from rpython.rtyper.lltypesystem.module import ll_math
@@ -26,9 +14,6 @@
 from rpython.jit.codewriter.jtransform import Transformer, 
UnsupportedMallocFlags
 from rpython.jit.metainterp.history import getkind
 
-def const(x):
-    return Constant(x, lltype.typeOf(x))
-
 class FakeRTyper:
     instance_reprs = {}
 
@@ -212,7 +197,7 @@
     assert block.operations == []
     assert block.exitswitch == ('int_gt', v1, v2, '-live-before')
     assert block.exits == exits
-    assert exits[1].args == [const(True)]
+    assert exits[1].args == [ll_const(True)]
 
 def test_optimize_goto_if_not__unknownop():
     v3 = Variable(); v3.concretetype = lltype.Bool
@@ -264,8 +249,8 @@
            'float_gt': ('float_gt', 'float_lt'),
            }
     v3 = varoftype(lltype.Signed)
-    for v1 in [varoftype(lltype.Signed), const(42)]:
-        for v2 in [varoftype(lltype.Signed), const(43)]:
+    for v1 in [varoftype(lltype.Signed), ll_const(42)]:
+        for v2 in [varoftype(lltype.Signed), ll_const(43)]:
             for name1, name2 in ops.items():
                 op = SpaceOperation(name1, [v1, v2], v3)
                 op1 = Transformer(FakeCPU()).rewrite_operation(op)
@@ -282,8 +267,8 @@
 
 def test_symmetric_int_add_ovf():
     v3 = varoftype(lltype.Signed)
-    for v1 in [varoftype(lltype.Signed), const(42)]:
-        for v2 in [varoftype(lltype.Signed), const(43)]:
+    for v1 in [varoftype(lltype.Signed), ll_const(42)]:
+        for v2 in [varoftype(lltype.Signed), ll_const(43)]:
             op = SpaceOperation('int_add_nonneg_ovf', [v1, v2], v3)
             oplist = Transformer(FakeCPU()).rewrite_operation(op)
             op1, op0 = oplist
@@ -332,7 +317,7 @@
 def get_direct_call_op(argtypes, restype):
     FUNC = lltype.FuncType(argtypes, restype)
     fnptr = lltype.functionptr(FUNC, "g")    # no graph
-    c_fnptr = const(fnptr)
+    c_fnptr = ll_const(fnptr)
     vars = [varoftype(TYPE) for TYPE in argtypes]
     v_result = varoftype(restype)
     op = SpaceOperation('direct_call', [c_fnptr] + vars, v_result)
@@ -386,7 +371,7 @@
     op = get_direct_call_op(argtypes, restype)
     op.opname = 'indirect_call'
     op.args[0] = varoftype(op.args[0].concretetype)
-    op.args.append(Constant(['somegraph1', 'somegraph2'], lltype.Void))
+    op.args.append(LLConstant(['somegraph1', 'somegraph2'], lltype.Void))
     tr = Transformer(FakeCPU(), FakeResidualIndirectCallControl())
     tr.graph = 'someinitialgraph'
     oplist = tr.rewrite_operation(op)
@@ -414,7 +399,7 @@
     op = get_direct_call_op(argtypes, restype)
     op.opname = 'indirect_call'
     op.args[0] = varoftype(op.args[0].concretetype)
-    op.args.append(Constant(['somegraph1', 'somegraph2'], lltype.Void))
+    op.args.append(LLConstant(['somegraph1', 'somegraph2'], lltype.Void))
     tr = Transformer(FakeCPU(), FakeRegularIndirectCallControl())
     tr.graph = 'someinitialgraph'
     oplist = tr.rewrite_operation(op)
@@ -467,7 +452,7 @@
                          ('chr', 'i'),
                          ('unc', 'i')]:
         v_parent = varoftype(lltype.Ptr(S))
-        c_name = Constant(name, lltype.Void)
+        c_name = LLConstant(name, lltype.Void)
         v_result = varoftype(getattr(S, name))
         op = SpaceOperation('getfield', [v_parent, c_name], v_result)
         op1 = Transformer(FakeCPU()).rewrite_operation(op)
@@ -478,7 +463,7 @@
 
 def test_getfield_typeptr():
     v_parent = varoftype(rclass.OBJECTPTR)
-    c_name = Constant('typeptr', lltype.Void)
+    c_name = LLConstant('typeptr', lltype.Void)
     v_result = varoftype(rclass.OBJECT.typeptr)
     op = SpaceOperation('getfield', [v_parent, c_name], v_result)
     oplist = Transformer(FakeCPU()).rewrite_operation(op)
@@ -508,7 +493,7 @@
                          ('chr', 'i'),
                          ('unc', 'i')]:
         v_parent = varoftype(lltype.Ptr(S))
-        c_name = Constant(name, lltype.Void)
+        c_name = LLConstant(name, lltype.Void)
         v_newvalue = varoftype(getattr(S, name))
         op = SpaceOperation('setfield', [v_parent, c_name, v_newvalue],
                             varoftype(lltype.Void))
@@ -521,8 +506,8 @@
 def test_malloc_new():
     S = lltype.GcStruct('S')
     v = varoftype(lltype.Ptr(S))
-    op = SpaceOperation('malloc', [Constant(S, lltype.Void),
-                                   Constant({'flavor': 'gc'}, lltype.Void)], v)
+    op = SpaceOperation('malloc', [LLConstant(S, lltype.Void),
+                                   LLConstant({'flavor': 'gc'}, lltype.Void)], 
v)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'new'
     assert op1.args == [('sizedescr', S)]
@@ -530,8 +515,8 @@
 def test_malloc_new_zero_2():
     S = lltype.GcStruct('S', ('x', lltype.Signed))
     v = varoftype(lltype.Ptr(S))
-    op = SpaceOperation('malloc', [Constant(S, lltype.Void),
-                                   Constant({'flavor': 'gc',
+    op = SpaceOperation('malloc', [LLConstant(S, lltype.Void),
+                                   LLConstant({'flavor': 'gc',
                                              'zero': True}, lltype.Void)], v)
     op1, op2 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'new'
@@ -545,8 +530,8 @@
     S2 = lltype.GcStruct('S2', ('parent', S),
                          ('xx', lltype.Ptr(S0)))
     v = varoftype(lltype.Ptr(S2))
-    op = SpaceOperation('malloc', [Constant(S2, lltype.Void),
-                                   Constant({'flavor': 'gc',
+    op = SpaceOperation('malloc', [LLConstant(S2, lltype.Void),
+                                   LLConstant({'flavor': 'gc',
                                              'zero': True}, lltype.Void)], v)
     op1, op2, op3 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'new'
@@ -561,8 +546,8 @@
     S = lltype.GcStruct('S', ('parent', rclass.OBJECT))
     heaptracker.set_testing_vtable_for_gcstruct(S, vtable, 'S')
     v = varoftype(lltype.Ptr(S))
-    op = SpaceOperation('malloc', [Constant(S, lltype.Void),
-                                   Constant({'flavor': 'gc'}, lltype.Void)], v)
+    op = SpaceOperation('malloc', [LLConstant(S, lltype.Void),
+                                   LLConstant({'flavor': 'gc'}, lltype.Void)], 
v)
     cpu = FakeCPU()
     op1 = Transformer(cpu).rewrite_operation(op)
     assert op1.opname == 'new_with_vtable'
@@ -576,8 +561,8 @@
     lltype.attachRuntimeTypeInfo(S, destrptr=destructor)
     heaptracker.set_testing_vtable_for_gcstruct(S, vtable, 'S')
     v = varoftype(lltype.Ptr(S))
-    op = SpaceOperation('malloc', [Constant(S, lltype.Void),
-                                   Constant({'flavor': 'gc'}, lltype.Void)], v)
+    op = SpaceOperation('malloc', [LLConstant(S, lltype.Void),
+                                   LLConstant({'flavor': 'gc'}, lltype.Void)], 
v)
     tr = Transformer(FakeCPU(), FakeResidualCallControl())
     oplist = tr.rewrite_operation(op)
     op0, op1 = oplist
@@ -591,8 +576,8 @@
     S = rffi.CArray(lltype.Char)
     v1 = varoftype(lltype.Signed)
     v = varoftype(lltype.Ptr(S))
-    flags = Constant({'flavor': 'raw'}, lltype.Void)
-    op = SpaceOperation('malloc_varsize', [Constant(S, lltype.Void), flags,
+    flags = LLConstant({'flavor': 'raw'}, lltype.Void)
+    op = SpaceOperation('malloc_varsize', [LLConstant(S, lltype.Void), flags,
                                            v1], v)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op0, op1 = tr.rewrite_operation(op)
@@ -608,8 +593,8 @@
     S = rffi.CArray(lltype.Signed)
     v1 = varoftype(lltype.Signed)
     v = varoftype(lltype.Ptr(S))
-    flags = Constant({'flavor': 'raw', 'zero': True}, lltype.Void)
-    op = SpaceOperation('malloc_varsize', [Constant(S, lltype.Void), flags,
+    flags = LLConstant({'flavor': 'raw', 'zero': True}, lltype.Void)
+    op = SpaceOperation('malloc_varsize', [LLConstant(S, lltype.Void), flags,
                                            v1], v)
     tr = Transformer(FakeCPU(), FakeResidualCallControl())
     op0, op1 = tr.rewrite_operation(op)
@@ -622,8 +607,8 @@
     S = rffi.CArray(lltype.Signed)
     v1 = varoftype(lltype.Signed)
     v = varoftype(lltype.Ptr(S))
-    flags = Constant({'flavor': 'raw', 'unsupported_flag': True}, lltype.Void)
-    op = SpaceOperation('malloc_varsize', [Constant(S, lltype.Void), flags,
+    flags = LLConstant({'flavor': 'raw', 'unsupported_flag': True}, 
lltype.Void)
+    op = SpaceOperation('malloc_varsize', [LLConstant(S, lltype.Void), flags,
                                            v1], v)
     tr = Transformer(FakeCPU(), FakeResidualCallControl())
     py.test.raises(UnsupportedMallocFlags, tr.rewrite_operation, op)
@@ -631,8 +616,8 @@
 def test_raw_malloc_fixedsize():
     S = lltype.Struct('dummy', ('x', lltype.Signed))
     v = varoftype(lltype.Ptr(S))
-    flags = Constant({'flavor': 'raw', 'zero': True}, lltype.Void)
-    op = SpaceOperation('malloc', [Constant(S, lltype.Void), flags], v)
+    flags = LLConstant({'flavor': 'raw', 'zero': True}, lltype.Void)
+    op = SpaceOperation('malloc', [LLConstant(S, lltype.Void), flags], v)
     tr = Transformer(FakeCPU(), FakeResidualCallControl())
     op0, op1 = tr.rewrite_operation(op)
     assert op0.opname == 'residual_call_r_i'
@@ -642,7 +627,7 @@
 
 def test_raw_free():
     S = rffi.CArray(lltype.Char)
-    flags = Constant({'flavor': 'raw', 'track_allocation': True},
+    flags = LLConstant({'flavor': 'raw', 'track_allocation': True},
                      lltype.Void)
     op = SpaceOperation('free', [varoftype(lltype.Ptr(S)), flags],
                         varoftype(lltype.Void))
@@ -654,7 +639,7 @@
 
 def test_raw_free_no_track_allocation():
     S = rffi.CArray(lltype.Signed)
-    flags = Constant({'flavor': 'raw', 'track_allocation': False},
+    flags = LLConstant({'flavor': 'raw', 'track_allocation': False},
                      lltype.Void)
     op = SpaceOperation('free', [varoftype(lltype.Ptr(S)), flags],
                         varoftype(lltype.Void))
@@ -689,7 +674,7 @@
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(lltype.Signed)
     v3 = varoftype(lltype.Bool)
-    c0 = const(0)
+    c0 = ll_const(0)
     #
     for opname, reducedname in [('int_eq', 'int_is_zero'),
                                 ('int_ne', 'int_is_true')]:
@@ -712,7 +697,7 @@
     v1 = varoftype(lltype.Ptr(rstr.STR))
     v2 = varoftype(lltype.Ptr(rstr.STR))
     v3 = varoftype(lltype.Bool)
-    c0 = const(lltype.nullptr(rstr.STR))
+    c0 = ll_const(lltype.nullptr(rstr.STR))
     #
     for opname, reducedname in [('ptr_eq', 'ptr_iszero'),
                                 ('ptr_ne', 'ptr_nonzero')]:
@@ -735,7 +720,7 @@
     v1 = varoftype(rclass.OBJECTPTR)
     v2 = varoftype(rclass.OBJECTPTR)
     v3 = varoftype(lltype.Bool)
-    c0 = const(lltype.nullptr(rclass.OBJECT))
+    c0 = ll_const(lltype.nullptr(rclass.OBJECT))
 
     for opname, newopname, reducedname in [
         ('ptr_eq', 'instance_ptr_eq', 'ptr_iszero'),
@@ -760,7 +745,7 @@
     v1 = varoftype(rclass.NONGCOBJECTPTR)
     v2 = varoftype(rclass.NONGCOBJECTPTR)
     v3 = varoftype(lltype.Bool)
-    c0 = const(lltype.nullptr(rclass.NONGCOBJECT))
+    c0 = ll_const(lltype.nullptr(rclass.NONGCOBJECT))
     #
     for opname, reducedname in [('ptr_eq', 'int_is_zero'),
                                 ('ptr_ne', 'int_is_true')]:
@@ -793,7 +778,7 @@
     v = varoftype(lltype.Ptr(rstr.STR))
     v_result = varoftype(lltype.Signed)
     op = SpaceOperation('getinteriorarraysize',
-                        [v, Constant('chars', lltype.Void)],
+                        [v, LLConstant('chars', lltype.Void)],
                         v_result)
     op1 = Transformer().rewrite_operation(op)
     assert op1.opname == 'strlen'
@@ -804,7 +789,7 @@
     v = varoftype(lltype.Ptr(rstr.UNICODE))
     v_result = varoftype(lltype.Signed)
     op = SpaceOperation('getinteriorarraysize',
-                        [v, Constant('chars', lltype.Void)],
+                        [v, LLConstant('chars', lltype.Void)],
                         v_result)
     op1 = Transformer().rewrite_operation(op)
     assert op1.opname == 'unicodelen'
@@ -816,7 +801,7 @@
     v_index = varoftype(lltype.Signed)
     v_result = varoftype(lltype.Char)
     op = SpaceOperation('getinteriorfield',
-                        [v, Constant('chars', lltype.Void), v_index],
+                        [v, LLConstant('chars', lltype.Void), v_index],
                         v_result)
     op1 = Transformer().rewrite_operation(op)
     assert op1.opname == 'strgetitem'
@@ -828,7 +813,7 @@
     v_index = varoftype(lltype.Signed)
     v_result = varoftype(lltype.UniChar)
     op = SpaceOperation('getinteriorfield',
-                        [v, Constant('chars', lltype.Void), v_index],
+                        [v, LLConstant('chars', lltype.Void), v_index],
                         v_result)
     op1 = Transformer().rewrite_operation(op)
     assert op1.opname == 'unicodegetitem'
@@ -841,13 +826,13 @@
     v = varoftype(lltype.Ptr(DICT))
     i = varoftype(lltype.Signed)
     v_result = varoftype(lltype.Signed)
-    op = SpaceOperation('getinteriorfield', [v, i, Constant('v', lltype.Void)],
+    op = SpaceOperation('getinteriorfield', [v, i, LLConstant('v', 
lltype.Void)],
                         v_result)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'getinteriorfield_gc_i'
     assert op1.args == [v, i, ('interiorfielddescr', DICT, 'v')]
-    op = SpaceOperation('getinteriorfield', [v, i, Constant('v', lltype.Void)],
-                        Constant(None, lltype.Void))
+    op = SpaceOperation('getinteriorfield', [v, i, LLConstant('v', 
lltype.Void)],
+                        LLConstant(None, lltype.Void))
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1 is None
 
@@ -857,7 +842,7 @@
     v_newchr = varoftype(lltype.Char)
     v_void = varoftype(lltype.Void)
     op = SpaceOperation('setinteriorfield',
-                        [v, Constant('chars', lltype.Void), v_index, v_newchr],
+                        [v, LLConstant('chars', lltype.Void), v_index, 
v_newchr],
                         v_void)
     op1 = Transformer().rewrite_operation(op)
     assert op1.opname == 'strsetitem'
@@ -870,7 +855,7 @@
     v_newchr = varoftype(lltype.UniChar)
     v_void = varoftype(lltype.Void)
     op = SpaceOperation('setinteriorfield',
-                        [v, Constant('chars', lltype.Void), v_index, v_newchr],
+                        [v, LLConstant('chars', lltype.Void), v_index, 
v_newchr],
                         v_void)
     op1 = Transformer().rewrite_operation(op)
     assert op1.opname == 'unicodesetitem'
@@ -883,13 +868,13 @@
     v = varoftype(lltype.Ptr(DICT))
     i = varoftype(lltype.Signed)
     v_void = varoftype(lltype.Void)
-    op = SpaceOperation('setinteriorfield', [v, i, Constant('v', lltype.Void),
+    op = SpaceOperation('setinteriorfield', [v, i, LLConstant('v', 
lltype.Void),
                                              i],
                         v_void)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'setinteriorfield_gc_i'
     assert op1.args == [v, i, i, ('interiorfielddescr', DICT, 'v')]
-    op = SpaceOperation('setinteriorfield', [v, i, Constant('v', lltype.Void),
+    op = SpaceOperation('setinteriorfield', [v, i, LLConstant('v', 
lltype.Void),
                                              v_void], v_void)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert not op1
@@ -922,7 +907,7 @@
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(lltype.Signed)
     op = SpaceOperation('hint',
-                        [v1, Constant({'promote': True}, lltype.Void)],
+                        [v1, LLConstant({'promote': True}, lltype.Void)],
                         v2)
     oplist = Transformer().rewrite_operation(op)
     op0, op1, op2 = oplist
@@ -937,7 +922,7 @@
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(lltype.Signed)
     op = SpaceOperation('hint',
-                        [v1, Constant({'promote': True}, lltype.Void)],
+                        [v1, LLConstant({'promote': True}, lltype.Void)],
                         v2)
     returnblock = Block([varoftype(lltype.Signed)])
     returnblock.operations = ()
@@ -970,8 +955,8 @@
     vvoid2 = varoftype(lltype.Void)
     v5 = varoftype(lltype.Void)
     op = SpaceOperation('jit_marker',
-                        [Constant('jit_merge_point', lltype.Void),
-                         Constant(jd.jitdriver, lltype.Void),
+                        [LLConstant('jit_merge_point', lltype.Void),
+                         LLConstant(jd.jitdriver, lltype.Void),
                          v1, v2, vvoid1, v3, v4, vvoid2], v5)
     tr = Transformer()
     tr.portal_jd = jd
@@ -994,7 +979,7 @@
     S = lltype.GcStruct('S', ('x', lltype.Char))
     v1 = varoftype(lltype.Ptr(S))
     v2 = varoftype(lltype.Char)
-    op = SpaceOperation('getfield', [v1, Constant('x', lltype.Void)], v2)
+    op = SpaceOperation('getfield', [v1, LLConstant('x', lltype.Void)], v2)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'getfield_gc_i'
     assert op1.args == [v1, ('fielddescr', S, 'x')]
@@ -1005,7 +990,7 @@
                         hints={'immutable': True})
     v1 = varoftype(lltype.Ptr(S))
     v2 = varoftype(lltype.Char)
-    op = SpaceOperation('getfield', [v1, Constant('x', lltype.Void)], v2)
+    op = SpaceOperation('getfield', [v1, LLConstant('x', lltype.Void)], v2)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'getfield_gc_i_pure'
     assert op1.args == [v1, ('fielddescr', S, 'x')]
@@ -1023,7 +1008,7 @@
                         hints={'immutable': True})
     v1 = varoftype(lltype.Ptr(S))
     v2 = varoftype(lltype.Char)
-    op = SpaceOperation('getfield', [v1, Constant('x', lltype.Void)], v2)
+    op = SpaceOperation('getfield', [v1, LLConstant('x', lltype.Void)], v2)
     op1 = Transformer(FakeCPU(), FakeCC()).rewrite_operation(op)
     assert op1.opname == 'getfield_gc_i_greenfield'
     assert op1.args == [v1, ('fielddescr', S, 'x')]
@@ -1040,8 +1025,8 @@
     assert oplist[0].args[0] == 'somejitcode'
 
 def test_str_newstr():
-    c_STR = Constant(rstr.STR, lltype.Void)
-    c_flavor = Constant({'flavor': 'gc'}, lltype.Void)
+    c_STR = LLConstant(rstr.STR, lltype.Void)
+    c_flavor = LLConstant({'flavor': 'gc'}, lltype.Void)
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(lltype.Ptr(rstr.STR))
     op = SpaceOperation('malloc_varsize', [c_STR, c_flavor, v1], v2)
@@ -1051,10 +1036,10 @@
     assert op1.result == v2
 
 def test_malloc_varsize_zero():
-    c_A = Constant(lltype.GcArray(lltype.Signed), lltype.Void)
+    c_A = LLConstant(lltype.GcArray(lltype.Signed), lltype.Void)
     v1 = varoftype(lltype.Signed)
     v2 = varoftype(c_A.value)
-    c_flags = Constant({"flavor": "gc", "zero": True}, lltype.Void)
+    c_flags = LLConstant({"flavor": "gc", "zero": True}, lltype.Void)
     op = SpaceOperation('malloc_varsize', [c_A, c_flags, v1], v2)
     op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'new_array_clear'
@@ -1068,7 +1053,7 @@
     v1 = varoftype(PSTR)
     v2 = varoftype(PSTR)
     v3 = varoftype(PSTR)
-    op = SpaceOperation('direct_call', [const(func), v1, v2], v3)
+    op = SpaceOperation('direct_call', [ll_const(func), v1, v2], v3)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = tr.rewrite_operation(op)
     assert op1.opname == 'residual_call_r_r'
@@ -1082,7 +1067,7 @@
     v1 = varoftype(PSTR)
     v2 = varoftype(PSTR)
     op = SpaceOperation('hint',
-                        [v1, Constant({'promote_string': True}, lltype.Void)],
+                        [v1, LLConstant({'promote_string': True}, 
lltype.Void)],
                         v2)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op0, op1, _ = tr.rewrite_operation(op)
@@ -1098,10 +1083,10 @@
     v2 = varoftype(PSTR)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = SpaceOperation('hint',
-                         [v1, Constant({'promote_string': True}, lltype.Void)],
+                         [v1, LLConstant({'promote_string': True}, 
lltype.Void)],
                          v2)
     op2 = SpaceOperation('hint',
-                         [v1, Constant({'promote_string': True,
+                         [v1, LLConstant({'promote_string': True,
                                         'promote': True}, lltype.Void)],
                          v2)
     lst1 = tr.rewrite_operation(op1)
@@ -1113,10 +1098,10 @@
     v2 = varoftype(lltype.Signed)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = SpaceOperation('hint',
-                         [v1, Constant({'promote': True}, lltype.Void)],
+                         [v1, LLConstant({'promote': True}, lltype.Void)],
                          v2)
     op2 = SpaceOperation('hint',
-                         [v1, Constant({'promote_string': True,
+                         [v1, LLConstant({'promote_string': True,
                                         'promote': True}, lltype.Void)],
                          v2)
     lst1 = tr.rewrite_operation(op1)
@@ -1132,7 +1117,7 @@
     v1 = varoftype(PSTR)
     v2 = varoftype(PSTR)
     v3 = varoftype(PSTR)
-    op = SpaceOperation('direct_call', [const(func), v1, v2], v3)
+    op = SpaceOperation('direct_call', [ll_const(func), v1, v2], v3)
     cc = FakeBuiltinCallControl()
     tr = Transformer(FakeCPU(), cc)
     op1 = tr.rewrite_operation(op)
@@ -1159,7 +1144,7 @@
     v2 = varoftype(INT)
     v3 = varoftype(INT)
     v4 = varoftype(PSTR)
-    op = SpaceOperation('direct_call', [const(func), v1, v2, v3], v4)
+    op = SpaceOperation('direct_call', [ll_const(func), v1, v2, v3], v4)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = tr.rewrite_operation(op)
     assert op1.opname == 'residual_call_ir_r'
@@ -1180,7 +1165,7 @@
     v2 = varoftype(INT)
     v3 = varoftype(INT)
     v4 = varoftype(PUNICODE)
-    op = SpaceOperation('direct_call', [const(func), v1, v2, v3], v4)
+    op = SpaceOperation('direct_call', [ll_const(func), v1, v2, v3], v4)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = tr.rewrite_operation(op)
     assert op1.opname == 'residual_call_ir_r'
@@ -1199,7 +1184,7 @@
                             _callable=rstr.LLHelpers.ll_str2unicode)
     v1 = varoftype(PSTR)
     v2 = varoftype(PUNICODE)
-    op = SpaceOperation('direct_call', [const(func), v1], v2)
+    op = SpaceOperation('direct_call', [ll_const(func), v1], v2)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = tr.rewrite_operation(op)
     assert op1.opname == 'residual_call_r_r'
@@ -1217,7 +1202,7 @@
     v1 = varoftype(PUNICODE)
     v2 = varoftype(PUNICODE)
     v3 = varoftype(lltype.Bool)
-    op = SpaceOperation('direct_call', [const(func), v1, v2], v3)
+    op = SpaceOperation('direct_call', [ll_const(func), v1, v2], v3)
     cc = FakeBuiltinCallControl()
     tr = Transformer(FakeCPU(), cc)
     op1 = tr.rewrite_operation(op)
@@ -1244,7 +1229,7 @@
     v4 = varoftype(INT)
     v5 = varoftype(INT)
     v6 = varoftype(lltype.Void)
-    op = SpaceOperation('direct_call', [const(func), v1, v2, v3, v4, v5], v6)
+    op = SpaceOperation('direct_call', [ll_const(func), v1, v2, v3, v4, v5], 
v6)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = tr.rewrite_operation(op)
     assert op1.opname == 'residual_call_ir_v'
@@ -1261,7 +1246,7 @@
                               _callable=ll_math.sqrt_nonneg)
     v1 = varoftype(FLOAT)
     v2 = varoftype(FLOAT)
-    op = SpaceOperation('direct_call', [const(func), v1], v2)
+    op = SpaceOperation('direct_call', [ll_const(func), v1], v2)
     tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
     op1 = tr.rewrite_operation(op)
     assert op1.opname == 'residual_call_irf_f'
@@ -1280,8 +1265,8 @@
     STRUCT = lltype.GcStruct('struct', ('inst_x', lltype.Signed),
                              ('mutate_x', rclass.OBJECTPTR),
                              hints={'immutable_fields': accessor})
-    for v_x in [const(lltype.malloc(STRUCT)), varoftype(lltype.Ptr(STRUCT))]:
-        op = SpaceOperation('getfield', [v_x, Constant('inst_x', lltype.Void)],
+    for v_x in [ll_const(lltype.malloc(STRUCT)), 
varoftype(lltype.Ptr(STRUCT))]:
+        op = SpaceOperation('getfield', [v_x, LLConstant('inst_x', 
lltype.Void)],
                             v2)
         tr = Transformer(FakeCPU())
         [_, op1, op2] = tr.rewrite_operation(op)
@@ -1305,9 +1290,9 @@
     STRUCT = lltype.GcStruct('struct', ('inst_x', lltype.Signed),
                              ('mutate_x', rclass.OBJECTPTR),
                              hints={'immutable_fields': accessor})
-    for v_x in [const(lltype.malloc(STRUCT)), varoftype(lltype.Ptr(STRUCT))]:
+    for v_x in [ll_const(lltype.malloc(STRUCT)), 
varoftype(lltype.Ptr(STRUCT))]:
         op = SpaceOperation('jit_force_quasi_immutable',
-                            [v_x, Constant('mutate_x', lltype.Void)],
+                            [v_x, LLConstant('mutate_x', lltype.Void)],
                             varoftype(lltype.Void))
         tr = Transformer(FakeCPU(), FakeRegularCallControl())
         tr.graph = 'currentgraph'
@@ -1322,7 +1307,7 @@
     STRUCT = lltype.GcStruct('struct', ('parent', PARENT),
                                        ('x', lltype.Signed))
     v_x = varoftype(lltype.Ptr(STRUCT))
-    op = SpaceOperation('getfield', [v_x, Constant('x', lltype.Void)],
+    op = SpaceOperation('getfield', [v_x, LLConstant('x', lltype.Void)],
                         varoftype(lltype.Signed))
     tr = Transformer(None, None)
     py.test.raises(NotImplementedError, tr.rewrite_operation, op)
@@ -1332,7 +1317,7 @@
     tlfield = ThreadLocalField(lltype.Signed, 'foobar_test_',
                                loop_invariant=loop_inv)
     OS_THREADLOCALREF_GET = effectinfo.EffectInfo.OS_THREADLOCALREF_GET
-    c = const(tlfield.offset)
+    c = ll_const(tlfield.offset)
     v = varoftype(lltype.Signed)
     op = SpaceOperation('threadlocalref_get', [c], v)
     cc = FakeBuiltinCallControl()
diff --git a/rpython/jit/codewriter/test/test_list.py 
b/rpython/jit/codewriter/test/test_list.py
--- a/rpython/jit/codewriter/test/test_list.py
+++ b/rpython/jit/codewriter/test/test_list.py
@@ -1,6 +1,7 @@
 from rpython.rtyper.lltypesystem import lltype
 from rpython.translator.unsimplify import varoftype
-from rpython.flowspace.model import Constant, SpaceOperation
+from rpython.flowspace.model import SpaceOperation
+from rpython.rtyper.rmodel import LLConstant
 
 from rpython.jit.codewriter.jtransform import Transformer, NotSupported
 from rpython.jit.codewriter.flatten import GraphFlattener
@@ -63,7 +64,7 @@
             raise ValueError(property)
         tr._get_list_nonneg_canraise_flags = force_flags
     op = SpaceOperation('direct_call',
-                        [Constant("myfunc", lltype.Void)] + args,
+                        [LLConstant("myfunc", lltype.Void)] + args,
                         v_result)
     try:
         oplist = tr._handle_list_call(op, oopspec_name, args)
@@ -85,11 +86,11 @@
 def test_newlist():
     builtin_test('newlist', [], FIXEDLIST,
                  """new_array $0, <ArrayDescr> -> %r0""")
-    builtin_test('newlist', [Constant(5, lltype.Signed)], FIXEDLIST,
+    builtin_test('newlist', [LLConstant(5, lltype.Signed)], FIXEDLIST,
                  """new_array $5, <ArrayDescr> -> %r0""")
     builtin_test('newlist', [varoftype(lltype.Signed)], FIXEDLIST,
                  """new_array %i0, <ArrayDescr> -> %r0""")
-    builtin_test('newlist_clear', [Constant(5, lltype.Signed)], FIXEDLIST,
+    builtin_test('newlist_clear', [LLConstant(5, lltype.Signed)], FIXEDLIST,
                  """new_array_clear $5, <ArrayDescr> -> %r0""")
     builtin_test('newlist', [], FIXEDPTRLIST,
                  """new_array_clear $0, <ArrayDescr> -> %r0""")
@@ -98,8 +99,8 @@
     builtin_test('list.ll_arraycopy',
                  [varoftype(FIXEDLIST),
                   varoftype(FIXEDLIST),
-                  varoftype(lltype.Signed), 
-                  varoftype(lltype.Signed), 
+                  varoftype(lltype.Signed),
+                  varoftype(lltype.Signed),
                   varoftype(lltype.Signed)],
                  lltype.Void, """
                      residual_call_ir_v $'myfunc', I[%i0, %i1, %i2], R[%r0, 
%r1], <CallDescrOS1>
@@ -165,11 +166,11 @@
                  " <FieldDescr items>, <ArrayDescr>")
     builtin_test('newlist', [], VARLIST,
                  """newlist $0, """+alldescrs+""" -> %r0""")
-    builtin_test('newlist', [Constant(5, lltype.Signed)], VARLIST,
+    builtin_test('newlist', [LLConstant(5, lltype.Signed)], VARLIST,
                  """newlist $5, """+alldescrs+""" -> %r0""")
     builtin_test('newlist', [varoftype(lltype.Signed)], VARLIST,
                  """newlist %i0, """+alldescrs+""" -> %r0""")
-    builtin_test('newlist_clear', [Constant(5, lltype.Signed)], VARLIST,
+    builtin_test('newlist_clear', [LLConstant(5, lltype.Signed)], VARLIST,
                  """newlist_clear $5, """+alldescrs+""" -> %r0""")
 
 def test_resizable_getitem():
diff --git a/rpython/jit/codewriter/test/test_longlong.py 
b/rpython/jit/codewriter/test/test_longlong.py
--- a/rpython/jit/codewriter/test/test_longlong.py
+++ b/rpython/jit/codewriter/test/test_longlong.py
@@ -1,13 +1,12 @@
 import py, sys
 
 from rpython.rlib.rarithmetic import r_longlong, intmask, is_valid_int
-from rpython.flowspace.model import SpaceOperation, Variable, Constant
-from rpython.flowspace.model import Block, Link
+from rpython.flowspace.model import SpaceOperation, Variable
+from rpython.rtyper.rmodel import ll_const
 from rpython.translator.unsimplify import varoftype
 from rpython.rtyper.lltypesystem import lltype, rffi
-from rpython.jit.codewriter.jtransform import Transformer, NotSupported
+from rpython.jit.codewriter.jtransform import Transformer
 from rpython.jit.codewriter.effectinfo import EffectInfo
-from rpython.jit.codewriter.test.test_jtransform import const
 from rpython.jit.codewriter import longlong
 
 
@@ -79,7 +78,7 @@
             assert len(oplist) == 2
             assert oplist[0].opname == 'residual_call_irf_f'
             assert oplist[0].args[0].value == opname.split('_')[0]+'_from_int'
-            assert list(oplist[0].args[1]) == [const(0)]
+            assert list(oplist[0].args[1]) == [ll_const(0)]
             assert list(oplist[0].args[2]) == []
             assert list(oplist[0].args[3]) == []
             assert oplist[0].args[4] == 'calldescr-84'
@@ -104,7 +103,7 @@
         assert len(oplist) == 2
         assert oplist[0].opname == 'residual_call_irf_f'
         assert oplist[0].args[0].value == 'llong_from_int'
-        assert list(oplist[0].args[1]) == [const(0)]
+        assert list(oplist[0].args[1]) == [ll_const(0)]
         assert list(oplist[0].args[2]) == []
         assert list(oplist[0].args[3]) == []
         assert oplist[0].args[4] == 'calldescr-84'
@@ -224,7 +223,7 @@
     def test_constants(self):
         for TYPE in [lltype.SignedLongLong, lltype.UnsignedLongLong]:
             v_x = varoftype(TYPE)
-            vlist = [v_x, const(rffi.cast(TYPE, 7))]
+            vlist = [v_x, ll_const(rffi.cast(TYPE, 7))]
             v_result = varoftype(TYPE)
             op = SpaceOperation('llong_add', vlist, v_result)
             tr = Transformer(FakeCPU(), FakeBuiltinCallControl())
diff --git a/rpython/jit/codewriter/test/test_regalloc.py 
b/rpython/jit/codewriter/test/test_regalloc.py
--- a/rpython/jit/codewriter/test/test_regalloc.py
+++ b/rpython/jit/codewriter/test/test_regalloc.py
@@ -1,15 +1,14 @@
-import py, sys
 from rpython.jit.codewriter import support
 from rpython.jit.codewriter.regalloc import perform_register_allocation
 from rpython.jit.codewriter.flatten import flatten_graph, ListOfKind
 from rpython.jit.codewriter.format import assert_format
 from rpython.jit.metainterp.history import AbstractDescr
-from rpython.flowspace.model import Variable, Constant, SpaceOperation
+from rpython.flowspace.model import Variable, SpaceOperation
 from rpython.flowspace.model import FunctionGraph, Block, Link
 from rpython.flowspace.model import c_last_exception
+from rpython.rtyper.rmodel import ll_const
 from rpython.rtyper.lltypesystem import lltype, llmemory
 from rpython.rtyper import rclass
-from rpython.rlib.rarithmetic import ovfcheck
 
 
 class TestRegAlloc:
@@ -158,7 +157,7 @@
         v4 = Variable(); v4.concretetype = lltype.Signed
         block = Block([v1])
         block.operations = [
-            SpaceOperation('int_add', [v1, Constant(1, lltype.Signed)], v2),
+            SpaceOperation('int_add', [v1, ll_const(1)], v2),
             SpaceOperation('rescall', [ListOfKind('int', [v1, v2])], v3),
             ]
         graph = FunctionGraph('f', block, v4)
@@ -212,7 +211,7 @@
         v5 = Variable(); v5.concretetype = lltype.Signed
         block = Block([v1])
         block.operations = [
-            SpaceOperation('int_add', [v1, Constant(1, lltype.Signed)], v2),
+            SpaceOperation('int_add', [v1, ll_const(1)], v2),
             SpaceOperation('rescall', [ListOfKind('int', [v1, v2])], v5),
             SpaceOperation('rescall', [ListOfKind('int', [v1, v2])], v3),
             ]
diff --git a/rpython/jit/codewriter/test/test_support.py 
b/rpython/jit/codewriter/test/test_support.py
--- a/rpython/jit/codewriter/test/test_support.py
+++ b/rpython/jit/codewriter/test/test_support.py
@@ -1,15 +1,13 @@
 import py, sys
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.annlowlevel import llstr
-from rpython.flowspace.model import Variable, Constant, SpaceOperation
+from rpython.flowspace.model import Variable, SpaceOperation
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.jit.codewriter.support import decode_builtin_call, LLtypeHelpers
 from rpython.jit.codewriter.support import _ll_1_int_abs
 
-def newconst(x):
-    return Constant(x, lltype.typeOf(x))
-
 def voidconst(x):
-    return Constant(x, lltype.Void)
+    return LLConstant(x, lltype.Void)
 
 # ____________________________________________________________
 
@@ -27,14 +25,14 @@
     vc.concretetype = lltype.Char
     v_result = Variable('result')
     v_result.concretetype = lltype.Signed
-    op = SpaceOperation('direct_call', [newconst(fnobj),
+    op = SpaceOperation('direct_call', [ll_const(fnobj),
                                         vi,
                                         voidconst('mymarker'),
                                         vc],
                         v_result)
     oopspec, opargs = decode_builtin_call(op)
     assert oopspec == 'foobar'
-    assert opargs == [newconst(2), vc, vi]
+    assert opargs == [ll_const(2), vc, vi]
     #impl = runner.get_oopspec_impl('foobar', lltype.Signed)
     #assert impl(2, 'A', 5) == 5 * ord('A')
 
@@ -56,15 +54,15 @@
     v_result.concretetype = lltype.Signed
     myarray = lltype.malloc(A, 10)
     myarray[5] = 42
-    op = SpaceOperation('direct_call', [newconst(fnobj),
-                                        newconst(myarray),
+    op = SpaceOperation('direct_call', [ll_const(fnobj),
+                                        ll_const(myarray),
                                         vi,
                                         voidconst('mymarker'),
                                         vc],
                         v_result)
     oopspec, opargs = decode_builtin_call(op)
     assert oopspec == 'spam.foobar'
-    assert opargs == [newconst(myarray), newconst(2), vc, vi]
+    assert opargs == [ll_const(myarray), ll_const(2), vc, vi]
     #impl = runner.get_oopspec_impl('spam.foobar', lltype.Ptr(A))
     #assert impl(myarray, 2, 'A', 5) == 42 * ord('A')
 
diff --git a/rpython/jit/codewriter/test/test_void_list.py 
b/rpython/jit/codewriter/test/test_void_list.py
--- a/rpython/jit/codewriter/test/test_void_list.py
+++ b/rpython/jit/codewriter/test/test_void_list.py
@@ -1,6 +1,6 @@
+from rpython.rtyper.rmodel import ll_const
 from rpython.rtyper.lltypesystem import lltype
 from rpython.translator.unsimplify import varoftype
-from rpython.flowspace.model import Constant
 from rpython.jit.codewriter.jtransform import NotSupported
 
 from rpython.jit.codewriter.test.test_list import builtin_test
@@ -20,26 +20,23 @@
 def test_newlist():
     builtin_test('newlist', [], FIXEDLIST,
                  NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed)], FIXEDLIST,
+    builtin_test('newlist', [ll_const(5)], FIXEDLIST,
                  NotSupported)
     builtin_test('newlist', [varoftype(lltype.Signed)], FIXEDLIST,
                  NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed),
-                             Constant(0, lltype.Signed)], FIXEDLIST,
+    builtin_test('newlist', [ll_const(5), ll_const(0)], FIXEDLIST,
                  NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed),
-                             Constant(1, lltype.Signed)], FIXEDLIST,
+    builtin_test('newlist', [ll_const(5), ll_const(1)], FIXEDLIST,
                  NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed),
-                             varoftype(lltype.Signed)], FIXEDLIST,
+    builtin_test('newlist', [ll_const(5), varoftype(lltype.Signed)], FIXEDLIST,
                  NotSupported)
 
 def test_fixed_ll_arraycopy():
     builtin_test('list.ll_arraycopy',
                  [varoftype(FIXEDLIST),
                   varoftype(FIXEDLIST),
-                  varoftype(lltype.Signed), 
-                  varoftype(lltype.Signed), 
+                  varoftype(lltype.Signed),
+                  varoftype(lltype.Signed),
                   varoftype(lltype.Signed)],
                  lltype.Void,
                  NotSupported)
@@ -82,20 +79,12 @@
 # Resizable lists
 
 def test_resizable_newlist():
-    builtin_test('newlist', [], VARLIST,
-                 NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed)], VARLIST,
-                 NotSupported)
-    builtin_test('newlist', [varoftype(lltype.Signed)], VARLIST,
-                 NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed),
-                             Constant(0, lltype.Signed)], VARLIST,
-                 NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed),
-                             Constant(1, lltype.Signed)], VARLIST,
-                 NotSupported)
-    builtin_test('newlist', [Constant(5, lltype.Signed),
-                             varoftype(lltype.Signed)], VARLIST,
+    builtin_test('newlist', [], VARLIST, NotSupported)
+    builtin_test('newlist', [ll_const(5)], VARLIST, NotSupported)
+    builtin_test('newlist', [varoftype(lltype.Signed)], VARLIST, NotSupported)
+    builtin_test('newlist', [ll_const(5), ll_const(0)], VARLIST, NotSupported)
+    builtin_test('newlist', [ll_const(5), ll_const(1)], VARLIST, NotSupported)
+    builtin_test('newlist', [ll_const(5), varoftype(lltype.Signed)], VARLIST,
                  NotSupported)
 
 def test_resizable_getitem():
diff --git a/rpython/jit/metainterp/warmspot.py 
b/rpython/jit/metainterp/warmspot.py
--- a/rpython/jit/metainterp/warmspot.py
+++ b/rpython/jit/metainterp/warmspot.py
@@ -8,8 +8,9 @@
 from rpython.annotator import model as annmodel
 from rpython.rtyper.llinterp import LLException
 from rpython.rtyper.test.test_llinterp import get_interpreter, clear_tcache
-from rpython.flowspace.model import SpaceOperation, Variable, Constant
+from rpython.flowspace.model import SpaceOperation, Variable
 from rpython.flowspace.model import checkgraph, Link, copygraph
+from rpython.rtyper.rmodel import LLConstant
 from rpython.rlib.objectmodel import we_are_translated
 from rpython.rlib.unroll import unrolling_iterable
 from rpython.rlib.debug import fatalerror
@@ -364,7 +365,7 @@
             if not driver.inline_jit_merge_point:
                 continue
             new_driver = driver.clone()
-            c_new_driver = Constant(new_driver, v_driver.concretetype)
+            c_new_driver = LLConstant(new_driver, v_driver.concretetype)
             op.args[1] = c_new_driver
 
     def find_portals(self):
@@ -674,7 +675,7 @@
                                     jitdriver_name, func,
                                     ARGS, argspec)
             v_result = op.result
-            c_accessor = Constant(accessor, concretetype=lltype.Void)
+            c_accessor = LLConstant(accessor, concretetype=lltype.Void)
             newop = SpaceOperation('direct_call', [c_accessor] + op.args[2:],
                                    v_result)
             block.operations[index] = newop
@@ -728,7 +729,7 @@
                     op1.args[0].value == 'jit_merge_point')
             op0 = SpaceOperation(
                 'jit_marker',
-                [Constant('can_enter_jit', lltype.Void)] + op1.args[1:],
+                [LLConstant('can_enter_jit', lltype.Void)] + op1.args[1:],
                 None)
             operations.insert(0, op0)
             can_enter_jits = [(jd.portal_graph, jd.portal_graph.startblock, 0)]
@@ -741,7 +742,7 @@
             greens_v, reds_v = support.decode_hp_hint_args(op)
             args_v = greens_v + reds_v
 
-            vlist = [Constant(jit_enter_fnptr, FUNCPTR)] + args_v
+            vlist = [LLConstant(jit_enter_fnptr, FUNCPTR)] + args_v
 
             v_result = Variable()
             v_result.concretetype = lltype.Void
@@ -789,7 +790,7 @@
         FUNCPTR = lltype.Ptr(lltype.FuncType(ARGS, RESULT))
         ptr = self.helper_func(FUNCPTR, new_func)
         op.opname = 'direct_call'
-        op.args = [Constant(ptr, FUNCPTR)] + op.args[2:]
+        op.args = [LLConstant(ptr, FUNCPTR)] + op.args[2:]
 
     def rewrite_jit_merge_points(self, policy):
         for jd in self.jitdrivers_sd:
@@ -993,7 +994,7 @@
         assert op.opname == 'jit_marker'
         assert op.args[0].value == 'jit_merge_point'
         greens_v, reds_v = support.decode_hp_hint_args(op)
-        vlist = [Constant(jd.portal_runner_ptr, jd._PTR_PORTAL_FUNCTYPE)]
+        vlist = [LLConstant(jd.portal_runner_ptr, jd._PTR_PORTAL_FUNCTYPE)]
         vlist += greens_v
         vlist += reds_v
         v_result = Variable()
@@ -1046,7 +1047,7 @@
             else:
                 TP = PTR_SET_PARAM_FUNCTYPE
             funcptr = self.helper_func(TP, closure)
-            return Constant(funcptr, TP)
+            return LLConstant(funcptr, TP)
         #
         for graph, block, i in find_set_param(graphs):
 
@@ -1082,7 +1083,7 @@
             func = quasiimmut.make_invalidation_function(ARG, mutatefieldname)
             FUNC = lltype.Ptr(lltype.FuncType([ARG], lltype.Void))
             llptr = self.helper_func(FUNC, func)
-            cptr = Constant(llptr, FUNC)
+            cptr = LLConstant(llptr, FUNC)
             self._cache_force_quasiimmed_funcs[key] = cptr
         op.opname = 'direct_call'
         op.args = [cptr, op.args[0]]
diff --git a/rpython/memory/gctransform/asmgcroot.py 
b/rpython/memory/gctransform/asmgcroot.py
--- a/rpython/memory/gctransform/asmgcroot.py
+++ b/rpython/memory/gctransform/asmgcroot.py
@@ -1,8 +1,10 @@
-from rpython.flowspace.model import (Constant, Variable, Block, Link,
-     copygraph, SpaceOperation, checkgraph)
+import sys
+from rpython.flowspace.model import (
+    Variable, Block, Link, copygraph, SpaceOperation, checkgraph)
 from rpython.rlib.debug import ll_assert
 from rpython.rlib.nonconst import NonConstant
 from rpython.rlib import rgil
+from rpython.rtyper.rmodel import ll_const, LLConstant
 from rpython.rtyper.annlowlevel import llhelper
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.lltypesystem.lloperation import llop
@@ -12,7 +14,6 @@
 from rpython.rtyper.rbuiltin import gen_cast
 from rpython.translator.unsimplify import varoftype
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
-import sys
 
 
 #
@@ -94,7 +95,7 @@
                 CONTAINER = lltype.FixedSizeArray(TYPE, 1)
                 p = lltype.malloc(CONTAINER, flavor='raw', zero=True,
                                   immortal=True)
-                sradict[key] = Constant(p, lltype.Ptr(CONTAINER))
+                sradict[key] = ll_const(p)
             sra.append(sradict[key])
         #
         # make a copy of the graph that will reload the values
@@ -103,7 +104,7 @@
         #
         # edit the original graph to only store the value of the arguments
         block = Block(graph.startblock.inputargs)
-        c_item0 = Constant('item0', lltype.Void)
+        c_item0 = LLConstant('item0', lltype.Void)
         assert len(block.inputargs) == len(sra)
         for v_arg, c_p in zip(block.inputargs, sra):
             if isinstance(v_arg.concretetype, lltype.Ptr):
@@ -120,7 +121,7 @@
         fnptr2 = lltype.functionptr(FUNC2,
                                     fnptr._obj._name + '_reload',
                                     graph=graph2)
-        c_fnptr2 = Constant(fnptr2, lltype.Ptr(FUNC2))
+        c_fnptr2 = ll_const(fnptr2)
         HELPERFUNC = lltype.FuncType([lltype.Ptr(FUNC2),
                                       ASM_FRAMEDATA_HEAD_PTR], FUNC1.RESULT)
         v_asm_stackwalk = varoftype(lltype.Ptr(HELPERFUNC), "asm_stackwalk")
@@ -129,8 +130,7 @@
         v_result = varoftype(FUNC1.RESULT)
         block.operations.append(
             SpaceOperation("indirect_call", [v_asm_stackwalk, c_fnptr2,
-                                             c_gcrootanchor,
-                                             Constant(None, lltype.Void)],
+                                             c_gcrootanchor, ll_const(None)],
                            v_result))
         block.closeblock(Link([v_result], graph.returnblock))
         graph.startblock = block
@@ -819,7 +819,7 @@
 gcrootanchor = lltype.malloc(ASM_FRAMEDATA_HEAD_PTR.TO, immortal=True)
 gcrootanchor.prev = gcrootanchor
 gcrootanchor.next = gcrootanchor
-c_gcrootanchor = Constant(gcrootanchor, ASM_FRAMEDATA_HEAD_PTR)
+c_gcrootanchor = ll_const(gcrootanchor)
 
 eci = ExternalCompilationInfo(compile_extra=['-DPYPY_USE_ASMGCC'])
 
@@ -831,21 +831,20 @@
                                      _nowrapper=True,
                                      random_effects_on_gcobjs=True,
                                      compilation_info=eci)
-c_asm_stackwalk = Constant(pypy_asm_stackwalk,
-                           lltype.typeOf(pypy_asm_stackwalk))
+c_asm_stackwalk = ll_const(pypy_asm_stackwalk)
 
 pypy_asm_gcroot = rffi.llexternal('pypy_asm_gcroot',
                                   [llmemory.Address],
                                   llmemory.Address,
                                   sandboxsafe=True,
                                   _nowrapper=True)
-c_asm_gcroot = Constant(pypy_asm_gcroot, lltype.typeOf(pypy_asm_gcroot))
+c_asm_gcroot = ll_const(pypy_asm_gcroot)
 
 pypy_asm_nocollect = rffi.llexternal('pypy_asm_gc_nocollect',
                                      [rffi.CCHARP], lltype.Void,
                                      sandboxsafe=True,
                                      _nowrapper=True)
-c_asm_nocollect = Constant(pypy_asm_nocollect, 
lltype.typeOf(pypy_asm_nocollect))
+c_asm_nocollect = ll_const(pypy_asm_nocollect)
 
 QSORT_CALLBACK_PTR = lltype.Ptr(lltype.FuncType([llmemory.Address,
                                                  llmemory.Address], rffi.INT))
diff --git a/rpython/memory/gctransform/boehm.py 
b/rpython/memory/gctransform/boehm.py
--- a/rpython/memory/gctransform/boehm.py
+++ b/rpython/memory/gctransform/boehm.py
@@ -2,7 +2,7 @@
 from rpython.memory.gctransform.support import (get_rtti,
     _static_deallocator_body_for_type, LLTransformerOp, ll_call_destructor)
 from rpython.rtyper.lltypesystem import lltype, llmemory
-from rpython.flowspace.model import Constant
+from rpython.rtyper.rmodel import LLConstant
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.rtyper import rmodel
 
@@ -68,13 +68,13 @@
                           resulttype=llmemory.Address)
         finalizer_ptr = self.finalizer_funcptr_for_type(TYPE)
         if finalizer_ptr:
-            c_finalizer_ptr = Constant(finalizer_ptr, self.FINALIZER_PTR)
+            c_finalizer_ptr = LLConstant(finalizer_ptr, self.FINALIZER_PTR)
             hop.genop("boehm_register_finalizer", [v_raw, c_finalizer_ptr])
         return v_raw
 
     def gct_fv_gc_malloc_varsize(self, hop, flags, TYPE, v_length, 
c_const_size, c_item_size,
                                                                    
c_offset_to_length):
-        # XXX same behavior for zero=True: in theory that's wrong        
+        # XXX same behavior for zero=True: in theory that's wrong
         if c_offset_to_length is None:
             v_raw = hop.genop("direct_call",
                                [self.malloc_varsize_no_length_ptr, v_length,
diff --git a/rpython/memory/gctransform/test/test_framework.py 
b/rpython/memory/gctransform/test/test_framework.py
--- a/rpython/memory/gctransform/test/test_framework.py
+++ b/rpython/memory/gctransform/test/test_framework.py
@@ -1,6 +1,7 @@
 from rpython.annotator.listdef import s_list_of_strings
 from rpython.annotator.model import SomeInteger
-from rpython.flowspace.model import Constant, SpaceOperation, mkentrymap
+from rpython.flowspace.model import SpaceOperation, mkentrymap
+from rpython.rtyper.rmodel import LLConstant
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.lltypesystem.lloperation import llop
 from rpython.memory.gc.semispace import SemiSpaceGC
@@ -69,7 +70,7 @@
         return -x
     t = rtype(g, [int])
     gg = graphof(t, g)
-    assert not CollectAnalyzer(t).analyze_direct_call(gg)    
+    assert not CollectAnalyzer(t).analyze_direct_call(gg)
 
 def test_cancollect_external():
     fext1 = rffi.llexternal('fext1', [], lltype.Void, releasegil=False)
@@ -110,7 +111,7 @@
 
     def entrypoint(argv):
         return g() + 2
-    
+
     t = rtype(entrypoint, [s_list_of_strings])
     t.config.translation.gc = "minimark"
     cbuild = CStandaloneBuilder(t, entrypoint, t.config,
@@ -134,7 +135,7 @@
 
     def entrypoint(argv):
         return g() + 2
-    
+
     t = rtype(entrypoint, [s_list_of_strings])
     t.config.translation.gc = "minimark"
     cbuild = CStandaloneBuilder(t, entrypoint, t.config,
@@ -167,7 +168,7 @@
     assert 'can cause the GC to be called' in str(f.value)
     assert 'trace_func' in str(f.value)
     assert 'MyStructure' in str(f.value)
- 
+
 class WriteBarrierTransformer(ShadowStackFrameworkGCTransformer):
     clean_sets = {}
     GC_PARAMS = {}
@@ -198,7 +199,7 @@
     PTR_TYPE = lltype.Ptr(lltype.GcStruct('S', ('x', PTR_TYPE2)))
     write_barrier_check(SpaceOperation(
         "setfield",
-        [varoftype(PTR_TYPE), Constant('x', lltype.Void),
+        [varoftype(PTR_TYPE), LLConstant('x', lltype.Void),
          varoftype(PTR_TYPE2)],
         varoftype(lltype.Void)))
 
@@ -208,8 +209,8 @@
     PTR_TYPE = lltype.Ptr(lltype.GcStruct('S', ('x', PTR_TYPE2)))
     write_barrier_check(SpaceOperation(
         "setfield",
-        [varoftype(PTR_TYPE), Constant('x', lltype.Void),
-         Constant('foo', varoftype(PTR_TYPE2))],
+        [varoftype(PTR_TYPE), LLConstant('x', lltype.Void),
+         LLConstant('foo', varoftype(PTR_TYPE2))],
         varoftype(lltype.Void)), needs_write_barrier=False)
 
 def test_write_barrier_support_setarrayitem():
@@ -228,7 +229,7 @@
     write_barrier_check(SpaceOperation(
         "setinteriorfield",
         [varoftype(ARRAYPTR2), varoftype(lltype.Signed),
-         Constant('b', lltype.Void), varoftype(PTR_TYPE2)],
+         LLConstant('b', lltype.Void), varoftype(PTR_TYPE2)],
         varoftype(lltype.Void)))
 
 def test_remove_duplicate_write_barrier():
@@ -306,7 +307,7 @@
 def test_find_clean_setarrayitems():
     S = lltype.GcStruct('S')
     A = lltype.GcArray(lltype.Ptr(S))
-    
+
     def f():
         l = lltype.malloc(A, 3)
         l[0] = lltype.malloc(S)
@@ -327,7 +328,7 @@
 def test_find_clean_setarrayitems_2():
     S = lltype.GcStruct('S')
     A = lltype.GcArray(lltype.Ptr(S))
-    
+
     def f():
         l = lltype.malloc(A, 3)
         l[0] = lltype.malloc(S)
@@ -349,7 +350,7 @@
 def test_find_clean_setarrayitems_3():
     S = lltype.GcStruct('S')
     A = lltype.GcArray(lltype.Ptr(S))
-    
+
     def f():
         l = lltype.malloc(A, 3)
         l[0] = lltype.malloc(S)
diff --git a/rpython/memory/test/test_gctypelayout.py 
b/rpython/memory/test/test_gctypelayout.py
--- a/rpython/memory/test/test_gctypelayout.py
+++ b/rpython/memory/test/test_gctypelayout.py
@@ -6,7 +6,7 @@
 from rpython.rtyper import rclass
 from rpython.rtyper.rclass import IR_IMMUTABLE, IR_QUASIIMMUTABLE
 from rpython.rtyper.test.test_llinterp import get_interpreter
-from rpython.flowspace.model import Constant
+from rpython.flowspace.model import LLConstant
 
 class FakeGC:
     object_minimal_size = 0
@@ -92,7 +92,7 @@
            100000 * gc.is_gcarrayofgcptr(tid2))
     interp, graph = get_interpreter(f, [], backendopt=True)
     assert interp.eval_graph(graph, []) == 11001
-    assert graph.startblock.exits[0].args == [Constant(11001, lltype.Signed)]
+    assert graph.startblock.exits[0].args == [LLConstant(11001, lltype.Signed)]
 
 def test_gc_pointers_inside():
     from rpython.rtyper import rclass
diff --git a/rpython/memory/test/test_transformed_gc.py 
b/rpython/memory/test/test_transformed_gc.py
--- a/rpython/memory/test/test_transformed_gc.py
+++ b/rpython/memory/test/test_transformed_gc.py
@@ -741,7 +741,7 @@
 
         def fix_graph_of_g(translator):
             from rpython.translator.translator import graphof
-            from rpython.flowspace.model import Constant
+            from rpython.flowspace.model import LLConstant
             from rpython.rtyper.lltypesystem import rffi
             layoutbuilder = cls.ensure_layoutbuilder(translator)
 
@@ -751,11 +751,11 @@
             graph = graphof(translator, g)
             for op in graph.startblock.operations:
                 if op.opname == 'do_malloc_fixedsize':
-                    op.args = [Constant(type_id, llgroup.HALFWORD),
-                               Constant(llmemory.sizeof(P), lltype.Signed),
-                               Constant(False, lltype.Bool), # has_finalizer
-                               Constant(False, lltype.Bool), # 
is_finalizer_light
-                               Constant(False, lltype.Bool)] # contains_weakptr
+                    op.args = [LLConstant(type_id, llgroup.HALFWORD),
+                               LLConstant(llmemory.sizeof(P), lltype.Signed),
+                               LLConstant(False, lltype.Bool), # has_finalizer
+                               LLConstant(False, lltype.Bool), # 
is_finalizer_light
+                               LLConstant(False, lltype.Bool)] # 
contains_weakptr
                     break
             else:
                 assert 0, "oups, not found"
@@ -779,7 +779,7 @@
             return 0
         def fix_graph_of_g(translator):
             from rpython.translator.translator import graphof
-            from rpython.flowspace.model import Constant
+            from rpython.flowspace.model import LLConstant
             from rpython.rtyper.lltypesystem import rffi
             layoutbuilder = cls.ensure_layoutbuilder(translator)
             type_id = layoutbuilder.get_type_id(P)
@@ -788,11 +788,11 @@
             graph = graphof(translator, g)
             for op in graph.startblock.operations:
                 if op.opname == 'do_malloc_fixedsize':
-                    op.args = [Constant(type_id, llgroup.HALFWORD),
-                               Constant(llmemory.sizeof(P), lltype.Signed),
-                               Constant(False, lltype.Bool), # has_finalizer
-                               Constant(False, lltype.Bool), # 
is_finalizer_light
-                               Constant(False, lltype.Bool)] # contains_weakptr
+                    op.args = [LLConstant(type_id, llgroup.HALFWORD),
+                               LLConstant(llmemory.sizeof(P), lltype.Signed),
+                               LLConstant(False, lltype.Bool), # has_finalizer
+                               LLConstant(False, lltype.Bool), # 
is_finalizer_light
+                               LLConstant(False, lltype.Bool)] # 
contains_weakptr
                     break
             else:
                 assert 0, "oups, not found"
@@ -1071,7 +1071,7 @@
     def test_adr_of_nursery(self):
         run = self.runner("adr_of_nursery")
         res = run([])
-    
+
 
 class TestGenerationalNoFullCollectGC(GCTest):
     # test that nursery is doing its job and that no full collection
@@ -1131,7 +1131,7 @@
                          'large_object': 8*WORD,
                          'translated_to_c': False}
             root_stack_depth = 200
-    
+
     def define_ref_from_rawmalloced_to_regular(cls):
         import gc
         S = lltype.GcStruct('S', ('x', lltype.Signed))
@@ -1182,7 +1182,7 @@
         run = self.runner("write_barrier_direct")
         res = run([])
         assert res == 42
-    
+
 class TestMiniMarkGC(TestHybridGC):
     gcname = "minimark"
     GC_CAN_TEST_ID = True
@@ -1199,7 +1199,7 @@
                          'translated_to_c': False,
                          }
             root_stack_depth = 200
-    
+
     def define_no_clean_setarrayitems(cls):
         # The optimization find_clean_setarrayitems() in
         # gctransformer/framework.py does not work with card marking.
@@ -1224,7 +1224,7 @@
         run = self.runner("no_clean_setarrayitems")
         res = run([])
         assert res == 123
-    
+
     def define_nursery_hash_base(cls):
         class A:
             pass
@@ -1263,19 +1263,19 @@
                          'translated_to_c': False,
                          }
             root_stack_depth = 200
-    
+
     def define_malloc_array_of_gcptr(self):
         S = lltype.GcStruct('S', ('x', lltype.Signed))
         A = lltype.GcArray(lltype.Ptr(S))
         def f():
             lst = lltype.malloc(A, 5)
-            return (lst[0] == lltype.nullptr(S) 
+            return (lst[0] == lltype.nullptr(S)
                     and lst[1] == lltype.nullptr(S)
                     and lst[2] == lltype.nullptr(S)
                     and lst[3] == lltype.nullptr(S)
                     and lst[4] == lltype.nullptr(S))
         return f
-    
+
     def test_malloc_array_of_gcptr(self):
         run = self.runner('malloc_array_of_gcptr')
         res = run([])
@@ -1356,7 +1356,7 @@
     def define_gettypeid(cls):
         class A(object):
             pass
-        
+
         def fn():
             a = A()
             return rgc.get_typeid(a)
diff --git a/rpython/rlib/rgc.py b/rpython/rlib/rgc.py
--- a/rpython/rlib/rgc.py
+++ b/rpython/rlib/rgc.py
@@ -7,6 +7,7 @@
 from rpython.rlib.objectmodel import we_are_translated, enforceargs, specialize
 from rpython.rtyper.extregistry import ExtRegistryEntry
 from rpython.rtyper.lltypesystem import lltype, llmemory
+from rpython.rtyper.rmodel import ll_const
 
 # ____________________________________________________________
 # General GC features
@@ -46,7 +47,7 @@
     """
     _pinned_objects.append(obj)
     return True
-        
+
 
 class PinEntry(ExtRegistryEntry):
     _about_ = pin
@@ -617,14 +618,13 @@
 
     def specialize_call(self, hop):
         from rpython.rtyper.rclass import getclassrepr, CLASSTYPE
-        from rpython.flowspace.model import Constant
         Class = hop.args_s[0].const
         classdef = hop.rtyper.annotator.bookkeeper.getuniqueclassdef(Class)
         classrepr = getclassrepr(hop.rtyper, classdef)
         vtable = classrepr.getvtable()
         assert lltype.typeOf(vtable) == CLASSTYPE
         hop.exception_cannot_occur()
-        return Constant(vtable, concretetype=CLASSTYPE)
+        return ll_const(vtable)
 
 class Entry(ExtRegistryEntry):
     _about_ = dump_rpy_heap
@@ -774,7 +774,7 @@
             pending.extend(get_rpy_referents(gcref))
 
 all_typeids = {}
-        
+
 def get_typeid(obj):
     raise Exception("does not work untranslated")
 
diff --git a/rpython/translator/test/test_simplify.py 
b/rpython/translator/test/test_simplify.py
--- a/rpython/translator/test/test_simplify.py
+++ b/rpython/translator/test/test_simplify.py
@@ -3,6 +3,7 @@
 from rpython.translator.backendopt.all import backend_optimizations
 from rpython.translator.simplify import (get_graph, transform_dead_op_vars)
 from rpython.flowspace.model import Block, Constant, summary
+from rpython.rtyper.rmodel import ll_const
 from rpython.conftest import option
 
 def translate(func, argtypes, backend_optimize=True):
@@ -204,7 +205,6 @@
 
 def test_join_blocks_cleans_links():
     from rpython.rtyper.lltypesystem import lltype
-    from rpython.flowspace.model import Constant
     from rpython.translator.backendopt.removenoops import remove_same_as
     def f(x):
         return bool(x + 2)
@@ -215,7 +215,7 @@
             return 2
     graph, t = translate(g, [int], backend_optimize=False)
     fgraph = graphof(t, f)
-    fgraph.startblock.exits[0].args = [Constant(True, lltype.Bool)]
+    fgraph.startblock.exits[0].args = [ll_const(True)]
     # does not crash: previously join_blocks would barf on this
     remove_same_as(graph)
     backend_optimizations(t)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to