Commit Graph

22 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
ef812408f4 Remove the number field from the PredNode union type.
Predicate numbers are available in the maps
isa.settings.predicate_number and isa.instp_number instead.

Like the name field, predicate numbers don't interact well with
unique_pred().
2017-07-26 11:06:43 -07:00
Jakob Stoklund Olesen
9ff785fabc Add a predicate_key() method to all predicates.
This enables interning of predicates to avoid duplicates.

Add a predicate registry to TargetIsa for interning predicates per ISA.
2017-07-26 09:58:16 -07:00
Jakob Stoklund Olesen
84aeb3eb56 Generate type check predicates for secondary type variables.
The encoding tables are keyed by the controlling type variable only. We
need to distinguish different encodings for instructions with multiple
type variables.

Add a TypePredicate instruction predicate which can check the type of an
instruction value operand. Combine type checks into the instruction
predicate for instructions with more than one type variable.

Add Intel encodings for fcvt_from_sint.f32.i64 which can now be
distinguished from fcvt_from_sint.f32.i32.
2017-07-26 08:19:44 -07:00
Jakob Stoklund Olesen
f39d75fa58 Generate a RECIPE_PREDICATES table for each ISA.
It turns out that most encoding predicates are expressed as recipe
predicates. This means that the encoding tables can be more compact
since we can check the recipe predicate separately from individual
instruction predicates, and the recipe number is already present in the
table.

- Don't combine recipe and encoding-specific predicates when creating an
  Encoding. Keep them separate.
- Generate a table of recipe predicates with function pointers. Many of
  these are null.
- Check any recipe predicate before accepting a recipe+bits pair.

This has the effect of making almost all instruction predicates
CODE_ALWAYS.
2017-07-24 14:19:17 -07:00
Dimo
b448574a49 Assert all InstructionGroups are closed in TargetIsa.__init__(); Close x86 group 2017-07-24 14:08:44 -07:00
Jakob Stoklund Olesen
716cd26fbf Make legalization actions configurable.
When an instruction doesn't have a valid encoding for the target ISA, it
needs to be legalized. Different legalization strategies can be
expressed as separate XFormGroup objects.

Make the choice of XFormGroup configurable per CPU mode, rather than
depending on a hard-coded default.

Add a CPUMode.legalize_type() method which assigns an XFormGroup to
controlling type variables and lets you set a default.

Add a `legalize` field to Level1Entry so the first-level hash table
lookup gives us the configured default legalization action for the
instruction's controlling type variable.
2017-07-24 12:49:06 -07:00
Jakob Stoklund Olesen
528e6ff3f5 Generate instruction unwrapping code for binemit recipes.
Generate code to:

- Unwrap the instruction and generate an error if the instruction format
  doesn't match the recipe.
- Look up the value locations of register and stack arguments.

The recipe_* functions in the ISA binemit modules now take these
unwrapped items as arguments.

Also add an optional `emit` argument to the EncRecipe constructor which
makes it possible to provide inline Rust code snippets for code
emission. This requires a lot less boilerplate than recipe_* functions.
2017-07-07 15:10:17 -07:00
Jakob Stoklund Olesen
5336bbd4cc Add RISC-V encodings for spill and fill.
Add a Stack() class for specifying operand constraints for values on the
stack.

Add encoding recipes for RISC-V spill and fill instructions. Don't
implement the encoding recipe functions yet since we don't have the
stack slot layout yet.
2017-06-13 13:39:52 -07:00
Jakob Stoklund Olesen
6787a4ea5c Add a RegClassMask typedef and a MAX_TOPRCS constant.
Avoid spreading u32 as a bitmask of register classes throughout the
code.

Enforce the limit of 32 register classes total. This could easily be
raised if needed.

The MAX_TOPRCS constant is the highest possible number of top-level
register classes in an ISA. The RegClassData.toprc field is always
smaller than this limit.
2017-05-15 16:22:22 -07:00
Jakob Stoklund Olesen
71bb7483b7 Compute top-level register classes for each register bank.
A top-level register class is one that has no sub-classes. It is
possible to have multiple top-level register classes in the same
register bank. For example, ARM's FPR bank has both D and Q top-level
register classes.

Number register classes such that all top-level register classes appear
as a contiguous sequence starting from 0. This will be used by the
register allocator when counting used registers per top-level register
class.
2017-05-15 15:19:49 -07:00
Jakob Stoklund Olesen
0f41cbdee2 Add support for tied operand constraints.
The register constraint for an output operand can be specified as an
integer indicating the input operand number to tie. The tied operands
must use the same register.

Generate operand constraints using ConstraintKind::Tied(n) for both the
tied operands. The n index refers to the opposite array. The input
operand refers to the outs array and vice versa.
2017-05-08 16:31:47 -07:00
Jakob Stoklund Olesen
b151e942d9 Stop tracking if instruction formats have multiple results.
All instruction formats can represent multiple results now, so a few
redundant formats can be removed: UnarySplit and BinaryOverflow.
2017-04-13 12:27:39 -07:00
Jakob Stoklund Olesen
598c81c12e Add encoding size information to EncInfo.
Two new pieces of information are available for all encoding recipes:

- The size in bytes of an encoded instruction, and
- The range of a branch encoded with the recipe, if any.

In the meta language, EncRecipe takes two new constructor arguments. The
size is required for all encodings and branch_range is required for all
recipes used to encode branches.
2017-04-05 11:46:19 -07:00
Jakob Stoklund Olesen
75b156e1c7 Allow for instructions with operands in encodings.
When defining an instruction encoding, allow part of the instruction
predicate to be provided as operands on the instruction opcode:

    icmp.i32(intcc.ult, x, y)

This generates an instruction predicate that checks

    IntCompare.cond == IntCC::UnsignedLessThan
2017-03-31 13:46:39 -07:00
Jakob Stoklund Olesen
cfe2c7f46f Add more mypy annotations. 2017-03-30 15:16:44 -07:00
Jakob Stoklund Olesen
02051c4764 Add mypy annotations to cdsl.predicates, settings.
Wherein we learned that only BoolSettings can be used as predicates.
2017-03-30 14:11:19 -07:00
Jakob Stoklund Olesen
dcdaeee4af 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.
2017-03-10 10:46:45 -08:00
Jakob Stoklund Olesen
c01ff670ed Fixed for mypy 0.501.
The List and Dict types are no longer implicitly available. They must be
imported from typing.

Type annotations must appear before the doc comment in a function. Also
fix type errors in these functions that weren't detected before.
2017-03-03 09:08:28 -08:00
Jakob Stoklund Olesen
130c4acf51 Compute register class intersections.
Ensure that the set of register classes is closed under intersection.

Provide a RegClass::intersect() method which finds the register class
representing the intersection of two classes.

Generate a bit-mask of subclasses for each register class to be used by
the intersect() method.

Ensure that register classes are sorted topologically. This is also used
by the intersect() method.
2017-01-25 13:57:43 -08:00
Jakob Stoklund Olesen
2390e3e3f0 Add operand register constraints.
Every encoding recipe must specify register constraints on input and
output values.

Generate recipe constraint tables along with the other encoding tables.
2017-01-25 13:35:18 -08:00
Jakob Stoklund Olesen
e1c0171b2c Define register banks.
Add a RegBank class for describing CPU register banks.

Define register banks for all the ISA stubs. The ARM32 floating point
bank in particular requires attention.
2016-11-11 14:17:10 -08:00
Jakob Stoklund Olesen
8846cb8105 Move ISA definitions into cdsl.isa.
The cretonne package is now split into two: cdsl and base.
2016-11-08 13:21:05 -08:00