Eliminate InstructionFormat.value_operands and .kinds.
Part of the refactoring of instruction formats. This list is now stored in the instruction itself as value_opnums.
This commit is contained in:
@@ -68,11 +68,7 @@ class InstructionFormat(object):
|
||||
# `has_value_list` is set.
|
||||
self.num_value_operands = 0
|
||||
|
||||
self.kinds = tuple(self._process_member_names(kinds))
|
||||
|
||||
# Which of self.kinds are `value`?
|
||||
self.value_operands = tuple(
|
||||
i for i, k in enumerate(self.kinds) if k is VALUE)
|
||||
sig_kinds = tuple(self._process_member_names(kinds))
|
||||
|
||||
# The typevar_operand argument must point to a 'value' operand.
|
||||
self.typevar_operand = kwargs.get('typevar_operand', None) # type: int
|
||||
@@ -85,7 +81,7 @@ class InstructionFormat(object):
|
||||
self.typevar_operand = 0
|
||||
|
||||
# Compute a signature for the global registry.
|
||||
sig = (self.multiple_results, self.kinds)
|
||||
sig = (self.multiple_results, sig_kinds)
|
||||
if sig in InstructionFormat._registry:
|
||||
raise RuntimeError(
|
||||
"Format '{}' has the same signature as existing format '{}'"
|
||||
|
||||
@@ -154,7 +154,7 @@ class Instruction(object):
|
||||
variables.
|
||||
"""
|
||||
poly_ins = [
|
||||
i for i in self.format.value_operands
|
||||
i for i in self.value_opnums
|
||||
if self.ins[i].typevar.free_typevar()]
|
||||
poly_outs = [
|
||||
i for i, o in enumerate(self.outs)
|
||||
@@ -206,8 +206,8 @@ class Instruction(object):
|
||||
"""
|
||||
other_tvs = []
|
||||
# Check value inputs.
|
||||
for opidx in self.format.value_operands:
|
||||
typ = self.ins[opidx].typevar
|
||||
for opnum in self.value_opnums:
|
||||
typ = self.ins[opnum].typevar
|
||||
tv = typ.free_typevar()
|
||||
# Non-polymorphic or derived form ctrl_typevar is OK.
|
||||
if tv is None or tv is ctrl_typevar:
|
||||
@@ -216,7 +216,7 @@ class Instruction(object):
|
||||
if typ is not tv:
|
||||
raise RuntimeError(
|
||||
"{}: type variable {} must be derived from {}"
|
||||
.format(self.ins[opidx], typ.name, ctrl_typevar))
|
||||
.format(self.ins[opnum], typ.name, ctrl_typevar))
|
||||
# Other free type variables can only be used once each.
|
||||
if tv in other_tvs:
|
||||
raise RuntimeError(
|
||||
|
||||
@@ -176,7 +176,8 @@ class EncRecipe(object):
|
||||
self.number = None # type: int
|
||||
|
||||
self.ins = self._verify_constraints(ins)
|
||||
assert len(self.ins) == len(format.value_operands)
|
||||
if not format.has_value_list:
|
||||
assert len(self.ins) == format.num_value_operands
|
||||
self.outs = self._verify_constraints(outs)
|
||||
if len(self.outs) > 1:
|
||||
assert format.multiple_results
|
||||
@@ -193,7 +194,9 @@ class EncRecipe(object):
|
||||
if isinstance(c, int):
|
||||
# An integer constraint is bound to a value operand.
|
||||
# Check that it is in range.
|
||||
assert c >= 0 and c < len(self.format.value_operands)
|
||||
assert c >= 0
|
||||
if not format.has_value_list:
|
||||
assert c < self.format.num_value_operands
|
||||
else:
|
||||
assert isinstance(c, RegClass) or isinstance(c, Register)
|
||||
return seq
|
||||
|
||||
@@ -224,7 +224,7 @@ class XForm(object):
|
||||
ctrl_var = d.defs[inst.value_results[0]]
|
||||
|
||||
# Reconcile arguments with the requirements of `inst`.
|
||||
for opnum in inst.format.value_operands:
|
||||
for opnum in inst.value_opnums:
|
||||
inst_tv = inst.ins[opnum].typevar
|
||||
v = d.expr.args[opnum]
|
||||
if isinstance(v, Var):
|
||||
|
||||
@@ -411,9 +411,9 @@ def gen_type_constraints(fmt, instrs):
|
||||
for idx in i.value_results:
|
||||
constraints.append(
|
||||
get_constraint(i.outs[idx], ctrl_typevar, type_sets))
|
||||
for idx in i.format.value_operands:
|
||||
for opnum in i.value_opnums:
|
||||
constraints.append(
|
||||
get_constraint(i.ins[idx], ctrl_typevar, type_sets))
|
||||
get_constraint(i.ins[opnum], ctrl_typevar, type_sets))
|
||||
offset = operand_seqs.add(constraints)
|
||||
fixed_results = len(i.value_results)
|
||||
# Can the controlling type variable be inferred from the designated
|
||||
|
||||
Reference in New Issue
Block a user