Add value_opnums and imm_opnums fields to Instruction.

These two tuples contain operand indexes of the explicit value operands
and immediate operands respectively. We can no longer use the
instruction format value_operands field.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-10 09:23:55 -08:00
parent e217b04347
commit 2b209c791d
2 changed files with 21 additions and 1 deletions

View File

@@ -104,9 +104,18 @@ class Instruction(object):
self.ins = self._to_operand_tuple(ins)
self.outs = self._to_operand_tuple(outs)
self.format = InstructionFormat.lookup(self.ins, self.outs)
# Indexes into outs for value results. Others are `variable_args`.
# Indexes into `self.outs` for value results.
# Other results are `variable_args`.
self.value_results = tuple(
i for i, o in enumerate(self.outs) if o.is_value())
# Indexes into `self.ins` for value operands.
self.value_opnums = tuple(
i for i, o in enumerate(self.ins) if o.is_value())
# Indexes into `self.ins` for non-value operands.
self.imm_opnums = tuple(
i for i, o in enumerate(self.ins) if o.is_immediate())
self._verify_polymorphic()
for attr in Instruction.ATTRIBS:
setattr(self, attr, not not kwargs.get(attr, False))