This method caused lots of import cycles when type checking.
Use isinstance() in the Operand constructor instead to decipher the
OperandSpec union type.
We want to separate the Python classes that make up the DSL used to
define the Cretonne language from the concrete definitions.
- cdsl.types defines the ValueType class hierarchy.
- base.types defines the concrete types.
Add an assertion for the value placements that we don't support yet.
1. A primary result in the source pattern becomes a secondary result in
the destination.
2. A secondary result becomes a secondary result, and the destination
instruction is not exactly matching the source.
Since we're deconstructing an instruction anyway, go ahead and resolve
any value aliases on its arguments before we construct the replacement
instructions.
If a secondary value in the source pattern becomes a primary value in
the destination pattern, it is not possible to overwrite the definition
of the source value.
Instead, change the original source value to an alias to the new promary
value.
If an instruction uses any values that are aliases of other values,
print out the alias mappings on lines preceding the instruction. This is
necessary to reconstruct the data flow graph.
We don't make any attempt to only write out each alias mapping once.
The parser does not yet support value aliases.
When the extended_values table is empty, the value to resolve is
definitely not an alias, but we still need as least one trip in the loop
to determine that.
Provide a generic way of accessing the value arguments on an
instruction. This is provided as two slice references. One for the fixed
arguments and one for any VariableArgs.
The arguments() methods return an array of two slices which is a bit
awkward. Also provide an each_arg() method which passes each argument
value to a closure.
When expanding iadd_cout, the original instruction is replaced with an
iadd, and an icmp is inserted after the iadd.
Make sure we advance the insertion position after replacing iadd_cout so
the icmp gets inserted *after* iadd.
Include the test file preamble comments when building a filecheck
instance for every function in the file.
This makes it possible to define common regex variables in the preamble
and use these definitions for all the functions.
When an illegal instruction is replaced with other instructions, back up
and revisit the expanded instructions. The new instructions need to have
encodings assigned too.
This also allows for expansions to contain illegal instructions that
need to be legalized themselves.
Make it possible to move a cursor to a new position.
In the current implementation of Layout and Cursor, this is a trivial
operation, but if we switch to a B-tree based function layout, this
involves navigating the tree.
Begin emitting legalization patterns in the form of two functions,
'expand' and 'narrow' that are included in legalizer.rs.
The generated code compiles, but it is not fully working yet. We need to
deal with the special cases of instructions producing multiple results.
When a Var is used in an XForm, it can be defined in the src or dst or
both patterns, and it is classified accordingly. When a Var is defined,
it is also useful to be able to find the `Def` that defined it.
Add src_def and dst_def reference members to Var, and initialize them in
the private Var copies that XForm creates for itself.
These two members also replace the defctx bitmask.
There's 4 classes of variables, depending on whether they have defs in
the source and destination patterns.
Add more XForm verification: In a legalize XForm, all source defs must
be outputs.
Fix a legalize pattern bug caught by this.
The check.sh script always runs the Python unittests with 'python', but
if 'python3' is in the path, run it with that too.
Fix a Python 3 compat issue and avoid passing None to max() and min().
Use an explicit intersect() function instead to intersect intervals.
This is a work in progress. The 'legalizer.rs' file generated by
gen_legalizer.py is not used for anything yet.
Add PEP 484 type annotations to a bunch of Python code.
The InstructionFormat objects make their non-value operands available as
FormatField attributes for use by predicates etc.
Compute these on demand instead of up front. This makes it possible for
the mypy tool to infer the types of these attributes from the
__getattr__ signature.