Commit Graph

1293 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
9fbfd0d2a6 Remove the vconst instruction and the UnaryImmVector format.
No instruction sets actually have single instructions for materializing
vector constants. You always need to use a constant pool.

Cretonne doesn't have constant pools yet, but it will in the future, and
that is how vector constants should be represented.
2017-03-10 11:57:49 -08:00
Jakob Stoklund Olesen
c50e5f3f66 Separate immediate and value operands in the instruction format.
Instruction formats are now identified by a signature that doesn't
include the ordering of value operands relative to immediate operands.

This means that the BinaryRev instruction format becomes redundant, so
delete it. The isub_imm instruction was the only one using that format.
Rename it to irsub_imm to make it clear what it does now that it is
printed as 'irsub_imm v2, 45'.
2017-03-10 11:20:39 -08: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
cdb4cce3dc Change index domain for typevar_operand.
An instruction format is now seen as having two separate operand lists:
immediates and values. Change InstructionFormat.typevar_operand to be a
pure index into the value list.
2017-03-10 10:41:39 -08:00
Jakob Stoklund Olesen
da693f72e2 Eliminate InstructionFormat.members.
This field is no longer needed. We can use imm_members to get the names
of immediate fields, and num_value_operands to access values.
2017-03-10 10:04:30 -08:00
Jakob Stoklund Olesen
af3fa6b83d Avoid using 'members' and 'value_operands' in the legalizer.
Use the new Instruction fields instead.
2017-03-10 09:56:37 -08:00
Jakob Stoklund Olesen
d9c61373e2 Change InstBuilder low-level format constructor signatures.
The per-instruction format low-level constructors in InstBuilder should
be independent of the relative ordering of value and immediate operands
in order to prepare for the future instruction format merger.

Reorder their arguments such that all the immediate operands are placed
before the value operands.

For instruction formats that use a value list representation, just take
a single ValueList argument. The value lists are created by the
individual instruction constructors. This means that the format
constructor doesn't care how many of the instructions operands are
'fixed' and how many are 'variable' arguments.
2017-03-10 09:34:30 -08:00
Jakob Stoklund Olesen
054edeb765 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.
2017-03-10 09:34:30 -08:00
Jakob Stoklund Olesen
515e34f221 Clean up lifetimes a bit.
No functional change.
2017-03-10 09:34:30 -08:00
Davide Italiano
4ad8362e09 Initial B-tree interface. 2017-03-10 09:15:14 -08:00
Jakob Stoklund Olesen
618fefb7da Simplify the arguments() return type.
Now that variable arguments are always stored in a value list with the
fixed arguments, we no longer need the arcane [&[Value]; 2] return type.

Arguments are always stored contiguously, so just return a &[Value]
slice.

Also remove the each_arg() methods which were just trying to make it
easier to work with the old slice pair.
2017-03-09 22:09:22 -08:00
Jakob Stoklund Olesen
f3d7485494 Python InstructionFormat refactoring.
Make some changes that will make it easier to get rid of the
'value_operands' and 'members' fields in the Python InstructionFormat
class. This is necessary to be able to combine instruction formats that
all use a value list representation, but with different fixed value
operands. The goal is to eventually identify formats by a new signature:

   (multiple_results, imm_kinds, num_value_operands)

Start by adding new fields:

- imm_members and imm_kinds are lists describing the format operands,
  excluding any values and variable_args operands.
- num_value_operands is the number of fixed value operands, or None in a
  has_value-list format.

Use these new members in preference to the old ones where possible.
2017-03-09 21:54:22 -08:00
Jakob Stoklund Olesen
ec5ee70a5c Remove some has_value_list workarounds.
Now that all variable_args formats use has_value_list, we can remove
some workarounds that allowed the old boxed_storage form.
2017-03-09 19:12:00 -08:00
Jakob Stoklund Olesen
d301fb9f2b Convert return formats to value lists.
With the Return and ReturnReg formats converted to using value lists for
storing their arguments, thee are no remaining instruction formats with
variable argument lists in boxed storage.

The Return and ReturnReg formats are also going to be merged since
they are identical now.
2017-03-09 15:56:33 -08:00
Jakob Stoklund Olesen
5170ef6b5f Convert the Branch and Jump instruction formats to value_list.
The Branch format also stores its fixed argument in the value list. This
requires the value pool to be passed to a few more functions.

Note that this actually makes the Branch and Jump variants of
InstructionData identical. The instruction format hashing does not yet
understand that all value operands are stored in the value list. We'll
fix that in a later patch.

Also convert IndirectCall, noting that Call and IndirectCall remain
separate instruction formats because they have different immediate
fields.
2017-03-09 15:38:12 -08:00
Jakob Stoklund Olesen
a6c2cc71df Use value lists for call arguments.
Add a new kind of instruction format that keeps all of its value
arguments in a value list. These value lists are all allocated out of
the dfg.value_lists memory pool.

Instruction formats with the value_list property set store *all* of
their value arguments in a single value list. There is no distinction
between fixed arguments and variable arguments.

Change the Call instruction format to use the value list representation
for its arguments.

This change is only the beginning. The intent is to eliminate the
boxed_storage instruction formats completely. Value lists use less
memory, and when the transition is complete, InstructionData will have a
trivial Drop implementation.
2017-03-09 14:34:07 -08:00
Angus Holder
e21bf444dc Added parsing of argument locations for functions and signatures. 2017-03-09 13:55:11 -08:00
Angus Holder
20d6713f93 Some refactoring, relaxed error handling so we allow encoding specifiers even without a unique ISA. 2017-03-09 07:19:28 -08:00
Angus Holder
6fba5c4e0a We now parse and record a ValueLoc for each SSA value result of each instruction. Code currently not passing tests. 2017-03-09 07:19:28 -08:00
Jakob Stoklund Olesen
e0f7243523 Handle a half-full func.locations map.
If func.locations has not been properly resized to have an entry for all
values, we should just full in the default location for the missing
values instead of crashing.
2017-03-08 19:44:45 -08:00
Jakob Stoklund Olesen
ecc46e56e1 Add is_call and is_return instruction attributes. 2017-03-08 14:48:50 -08:00
Jakob Stoklund Olesen
cbbf5cc88b Use a unique ISA in 'test cat' file tests.
Add a Function::display() method which can include ISA-specific
information when printing the function.

If a test file has a unique ISA, use that in the `test cat`
implementation.
2017-03-08 13:04:30 -08:00
Angus Holder
4525929df2 Added tests, some refactoring, fixed a parsing bug. 2017-03-08 13:01:32 -08:00
Angus Holder
a58ccb1125 Added parsing of instruction encodings and result registers specifications. 2017-03-08 13:01:32 -08:00
Jakob Stoklund Olesen
5ac57220be Strip trailing white space from regex: directives.
This was particularly confusing when reading a file with Windows line
endings. The CR would become part of the regex.
2017-03-08 12:15:36 -08:00
Jakob Stoklund Olesen
2de210ddb6 Implement From traits on ArgAction for convenience. 2017-03-07 15:13:55 -08:00
Jakob Stoklund Olesen
40fc5da3d8 Heed uext and sext annotations on RISC-V arguments.
Translate the small integer arguments to i32 or i64 with the appropriate
extend and ireduce instructions.
2017-03-07 15:07:00 -08:00
Jakob Stoklund Olesen
fd58b7cc29 Add vsplit and vconcat instructions.
Add support for two new type variable functions: half_vector() and
double_vector().

Use these two instructions to break down unsupported SIMD types and
build them up again.
2017-03-07 14:31:57 -08:00
Jakob Stoklund Olesen
37b2e94c72 Legalize entry block arguments to match ABI types.
Insert conversion code that reconstructs the original function argument
types from the legalized ABI signature.

Add abi::legalize_abi_value(). This function is used when adapting code
to a legalized function signature.
2017-03-07 13:29:19 -08:00
Jakob Stoklund Olesen
77492aa463 Add take_ebb_args(), put_ebb_arg() method pair.
These two methods can be use to rewrite the argument values to an EBB.
In particular, we need to rewrite the arguments to the entry block to be
compatible with a legalized function signature.

Reuse the put_ebb_arg() method in the implementation of
append_ebb_arg().
2017-03-06 15:03:48 -08:00
Jakob Stoklund Olesen
42e7021865 Implement legalize_signature for RISC-V.
Add an abi module with code that is probably useful to all ISAs when
implementing this function.

Add a unit() method to RegClassData which can be used to index the
register units in a class.
2017-03-03 11:09:55 -08:00
Jakob Stoklund Olesen
07f459fb93 Add a legalize_signature method to TargetIsa.
This entry point will be used for controlling ABI conventions when
legalizing.

Provide an empty implementation for RISC-V and let the other ISAs crash
in legalization.

This is just the scaffolding. We still need to:

- Rewrite the entry block arguments to match the legalized signature.
- Rewrite call and return instructions.
- Implement the legalize_signature() function for all ISAs.
- Add shared generic types to help with the legalize_signature()
  functions.
2017-03-03 11:00:26 -08:00
Jakob Stoklund Olesen
cae4368a8a Use ISA information to display function signatures.
The argument locations contains register unit references that we want to
display with their correct names.
2017-03-03 10:58:45 -08:00
Jakob Stoklund Olesen
99c7e18fbf Add {ValueLoc,ArgumentLoc}::display().
These functions return an object containing the necessary ISA info to
print a ValueLoc or ArgumentLoc correctly.
2017-03-03 10:56:32 -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
Davide Italiano
5170219125 [EntityList] Fix typo. No functional change. 2017-02-28 12:43:53 -08:00
rep-nop
0bc27fca9a Fixes error on propagating a Result<()> with the ? operator 2017-02-26 07:50:55 -08:00
rep-nop
9f00a40b52 Ran rustfmt 2017-02-26 07:50:55 -08:00
rep-nop
af3f4703b9 Fixes formatting for settings.rs 2017-02-26 07:50:55 -08:00
rep-nop
b23f1fb347 Converts all try! macros to ? syntax.
Fixes #46
2017-02-26 07:50:55 -08:00
Jakob Stoklund Olesen
cf5701b137 Add ABI annotations to function signatures.
Specify the location of arguments as well as the size of stack argument
array needed. The ABI annotations are optional, just like the value
locations.

Remove the Eq implementation for Signature which was only used by a
single parser test.
2017-02-24 13:53:46 -08:00
Jakob Stoklund Olesen
cf7a729dc1 Add an ArgumentLoc data type.
This will be used to amend function signatures with ABI lowering
information.
2017-02-24 12:09:24 -08:00
Jakob Stoklund Olesen
aa7e349134 Add a section about implementation limits.
Fix a few other minor issues with the documentation.
2017-02-24 11:08:15 -08:00
Jakob Stoklund Olesen
db9e4ea979 Convert try! to ? in extfunc.rs 2017-02-24 10:33:08 -08:00
Angus Holder
65efefff38 Shortened comment to pass lint. 2017-02-23 09:22:16 -08:00
Angus Holder
54a53b7ab7 Added tests, some fixes. 2017-02-23 09:22:16 -08:00
Angus Holder
a08e177595 Lexer can now scan names, hex sequences, brackets and minus signs. 2017-02-23 09:22:16 -08:00
Jakob Stoklund Olesen
247be57042 Also write out register assignments in write_instruction.
The value locations appear after the encodings:

> [R#0c,%x2]              v0 = iadd vx0, vx1
> [Iret#19]               return_reg v0
2017-02-22 11:53:01 -08:00
Jakob Stoklund Olesen
bf9cf09622 Add a register allocation context module.
Collect the data structures that hang around between function
compilations.

Provide a main entry point to the register allocator passes.
2017-02-22 11:53:01 -08:00
Jakob Stoklund Olesen
8e421d666d SSA register coloring pass.
This is a bare-bones outline of the SSA coloring pass. Many features are
missing, including:

- Handling instruction operand constraints beyond simple register
  classes.
- Handling ABI requirements for function arguments and return values.
- Generating shuffle code for EBB arguments.
2017-02-22 11:53:01 -08:00