Author: Armin Rigo <[email protected]>
Branch: stm
Changeset: r47628:af9b4a254b39
Date: 2011-09-27 15:39 +0200
http://bitbucket.org/pypy/pypy/changeset/af9b4a254b39/
Log: stm_setfield in genc.
diff --git a/pypy/rpython/lltypesystem/lloperation.py
b/pypy/rpython/lltypesystem/lloperation.py
--- a/pypy/rpython/lltypesystem/lloperation.py
+++ b/pypy/rpython/lltypesystem/lloperation.py
@@ -390,6 +390,7 @@
# to keep them as operations until the genc stage)
'stm_getfield': LLOp(sideeffects=False, canrun=True),
+ 'stm_setfield': LLOp(),
# __________ address operations __________
diff --git a/pypy/translator/c/funcgen.py b/pypy/translator/c/funcgen.py
--- a/pypy/translator/c/funcgen.py
+++ b/pypy/translator/c/funcgen.py
@@ -475,14 +475,23 @@
def generic_get(self, op, sourceexpr):
T = self.lltypemap(op.result)
newvalue = self.expr(op.result, special_case_void=False)
- result = '%s = %s;' % (newvalue, sourceexpr)
+ if op.opname.startswith('stm_'):
+ typename = self.db.gettype(T)
+ result = '%s = (%s)stm_read_word((void**)&%s);' % (
+ newvalue, cdecl(typename, ''), sourceexpr)
+ else:
+ result = '%s = %s;' % (newvalue, sourceexpr)
if T is Void:
result = '/* %s */' % result
return result
def generic_set(self, op, targetexpr):
newvalue = self.expr(op.args[-1], special_case_void=False)
- result = '%s = %s;' % (targetexpr, newvalue)
+ if op.opname.startswith('stm_'):
+ result = 'stm_write_word((void**)&%s, (void*)%s);' % (
+ targetexpr, newvalue)
+ else:
+ result = '%s = %s;' % (targetexpr, newvalue)
T = self.lltypemap(op.args[-1])
if T is Void:
result = '/* %s */' % result
@@ -589,21 +598,8 @@
return '%s = %s.length;'%(self.expr(op.result), expr)
- def OP_STM_GETFIELD(self, op):
- assert isinstance(op.args[1], Constant)
- STRUCT = self.lltypemap(op.args[0]).TO
- structdef = self.db.gettypedefnode(STRUCT)
- baseexpr_is_const = isinstance(op.args[0], Constant)
- sourceexpr = structdef.ptr_access_expr(self.expr(op.args[0]),
- op.args[1].value,
- baseexpr_is_const)
- #
- T = self.lltypemap(op.result)
- assert T is not Void
- typename = self.db.gettype(T)
- newvalue = self.expr(op.result)
- return '%s = (%s)stm_read_word((void**)&%s);' % (
- newvalue, cdecl(typename, ''), sourceexpr)
+ OP_STM_GETFIELD = OP_GETFIELD
+ OP_STM_SETFIELD = OP_BARE_SETFIELD
def OP_PTR_NONZERO(self, op):
diff --git a/pypy/translator/stm/rstm.py b/pypy/translator/stm/rstm.py
--- a/pypy/translator/stm/rstm.py
+++ b/pypy/translator/stm/rstm.py
@@ -33,3 +33,18 @@
c_fieldname = hop.inputconst(lltype.Void, fieldname)
return hop.genop('stm_getfield', [v_structptr, c_fieldname],
resulttype = lltype.Signed)
+
+
+class ExtEntry(ExtRegistryEntry):
+ _about_ = stm_setfield
+
+ def compute_result_annotation(self, s_structptr, s_fieldname, s_newvalue):
+ return None
+
+ def specialize_call(self, hop):
+ r_structptr = hop.args_r[0]
+ v_structptr = hop.inputarg(r_structptr, arg=0)
+ fieldname = hop.args_v[1].value
+ v_newvalue = hop.inputarg(hop.args_r[2], arg=2)
+ c_fieldname = hop.inputconst(lltype.Void, fieldname)
+ hop.genop('stm_setfield', [v_structptr, c_fieldname, v_newvalue])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit