GitLab will be upgraded on June 2nd 2020 at 2.00 pm (AEDT) to 3.00 pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to local Gitlab admin team.

Commit b904d16b authored by Carl Friedrich Bolz's avatar Carl Friedrich Bolz

merge

parents dfbafb14 d3f05ab2
......@@ -47,21 +47,15 @@ class OptRewrite(Optimization):
def find_rewritable_bool(self, op, args):
try:
oldopnum = opboolinvers[op.getopnum()]
except KeyError:
pass
else:
oldopnum = opboolinvers[op.getopnum()]
if oldopnum != -1:
targs = self.optimizer.make_args_key(ResOperation(oldopnum, [args[0], args[1]],
None))
if self.try_boolinvers(op, targs):
return True
try:
oldopnum = opboolreflex[op.getopnum()] # FIXME: add INT_ADD, INT_MUL
except KeyError:
pass
else:
oldopnum = opboolreflex[op.getopnum()] # FIXME: add INT_ADD, INT_MUL
if oldopnum != -1:
targs = self.optimizer.make_args_key(ResOperation(oldopnum, [args[1], args[0]],
None))
oldop = self.get_pure_result(targs)
......@@ -69,15 +63,14 @@ class OptRewrite(Optimization):
self.make_equal_to(op.result, self.getvalue(oldop.result))
return True
try:
oldopnum = opboolinvers[opboolreflex[op.getopnum()]]
except KeyError:
pass
else:
targs = self.optimizer.make_args_key(ResOperation(oldopnum, [args[1], args[0]],
None))
if self.try_boolinvers(op, targs):
return True
reflex = opboolreflex[op.getopnum()]
if reflex != -1:
oldopnum = opboolinvers[reflex]
if oldopnum != -1:
targs = self.optimizer.make_args_key(ResOperation(oldopnum, [args[1], args[0]],
None))
if self.try_boolinvers(op, targs):
return True
return False
......
......@@ -185,7 +185,7 @@ class OptimizeOptTest(BaseTestWithUnroll):
op = opname[opnum]
except KeyError:
continue
if 'FLOAT' in op:
if 'float' in op:
continue
args = []
for _ in range(oparity[opnum]):
......
......@@ -19,7 +19,7 @@ def _findall(Class, name_prefix, op_prefix=None):
opname = name[len(name_prefix):]
if opname.isupper():
assert hasattr(resoperation.rop, opname)
for value, name in resoperation.opname.items():
for value, name in enumerate(resoperation.opname):
if op_prefix and not name.startswith(op_prefix):
continue
if hasattr(Class, name_prefix + name):
......
......@@ -126,10 +126,7 @@ class AbstractResOp(object):
['descr=%r' % descr]))
def getopname(self):
try:
return opname[self.getopnum()].lower()
except KeyError:
return '<%d>' % self.getopnum()
return opname[self.getopnum()]
def is_guard(self):
return rop._GUARD_FIRST <= self.getopnum() <= rop._GUARD_LAST
......@@ -549,7 +546,7 @@ class rop(object):
pass
opclasses = [] # mapping numbers to the concrete ResOp class
opname = {} # mapping numbers to the original names, for debugging
opname = [] # mapping numbers to the original names, for debugging
oparity = [] # mapping numbers to the arity of the operation or -1
opwithdescr = [] # mapping numbers to a flag "takes a descr"
......@@ -571,15 +568,16 @@ def setup(debug_print=False):
arity, withdescr, boolresult = -1, True, False # default
setattr(rop, name, i)
if not name.startswith('_'):
opname[i] = name
cls = create_class_for_op(name, i, arity, withdescr)
cls._cls_has_bool_result = boolresult
else:
name = '<%d>' % i
cls = None
opname.append(name.lower())
opclasses.append(cls)
oparity.append(arity)
opwithdescr.append(withdescr)
assert len(opclasses) == len(oparity) == len(opwithdescr) == len(_oplist)
assert len(opclasses) == len(oparity) == len(opwithdescr) == len(_oplist) == len(opname)
def get_base_class(mixin, base):
try:
......@@ -619,7 +617,10 @@ def create_class_for_op(name, opnum, arity, withdescr):
setup(__name__ == '__main__') # print out the table when run directly
del _oplist
opboolinvers = {
def opdict_to_list(d, default=-1):
return [d.get(i, default) for i in range(len(opname))]
opboolinvers = opdict_to_list({
rop.INT_EQ: rop.INT_NE,
rop.INT_NE: rop.INT_EQ,
rop.INT_LT: rop.INT_GE,
......@@ -641,9 +642,9 @@ opboolinvers = {
rop.PTR_EQ: rop.PTR_NE,
rop.PTR_NE: rop.PTR_EQ,
}
})
opboolreflex = {
opboolreflex = opdict_to_list({
rop.INT_EQ: rop.INT_EQ,
rop.INT_NE: rop.INT_NE,
rop.INT_LT: rop.INT_GT,
......@@ -665,7 +666,7 @@ opboolreflex = {
rop.PTR_EQ: rop.PTR_EQ,
rop.PTR_NE: rop.PTR_NE,
}
})
def get_deep_immutable_oplist(operations):
......
......@@ -326,13 +326,13 @@ def test_float_ops():
def make_args_for_op(op, a, b):
n=opname[op]
if n[0:3] == 'INT' or n[0:4] == 'UINT':
if n[0:3] == 'int' or n[0:4] == 'uint':
arg1 = ConstInt(a)
arg2 = ConstInt(b)
elif n[0:5] == 'FLOAT':
elif n[0:5] == 'float':
arg1 = constfloat(float(a))
arg2 = constfloat(float(b))
elif n[0:3] == 'PTR':
elif n[0:3] == 'ptr':
arg1 = ConstPtr(rffi.cast(llmemory.GCREF, a))
arg2 = ConstPtr(rffi.cast(llmemory.GCREF, b))
else:
......@@ -343,7 +343,9 @@ def make_args_for_op(op, a, b):
def test_opboolinvers():
cpu = FakeCPU()
for op1, op2 in opboolinvers.items():
for op1, op2 in enumerate(opboolinvers):
if op2 == -1:
continue
for a in (1,2,3):
for b in (1,2,3):
arg1, arg2 = make_args_for_op(op1, a, b)
......@@ -353,7 +355,9 @@ def test_opboolinvers():
def test_opboolreflex():
cpu = FakeCPU()
for op1, op2 in opboolreflex.items():
for op1, op2 in enumerate(opboolreflex):
if op2 == -1:
continue
for a in (1,2,3):
for b in (1,2,3):
arg1, arg2 = make_args_for_op(op1, a, b)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment