Commit Graph

11145 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
b6105ab79b Verifier results are always void.
No need for a type parameter.
2017-04-21 12:03:05 -07:00
Jakob Stoklund Olesen
bac47f2fb8 Add global CtonResult and CtonError types.
These are for reporting the overall result of compiling a function.
2017-04-21 11:48:56 -07:00
Jakob Stoklund Olesen
83381dadc5 Add global CtonResult and CtonError types.
These are for reporting the overall result of compiling a function.
2017-04-21 11:48:56 -07:00
Jakob Stoklund Olesen
866efd91b7 Add an enable_verifier setting.
This is off by default, but enabled by the parser when reading a textual
IL file. Test files can still override the default to turn off
verification.

The setting enables IL verifier passes at critical points of the
compilation pipeline.
2017-04-21 09:49:03 -07:00
Jakob Stoklund Olesen
4cf3babda0 Add an enable_verifier setting.
This is off by default, but enabled by the parser when reading a textual
IL file. Test files can still override the default to turn off
verification.

The setting enables IL verifier passes at critical points of the
compilation pipeline.
2017-04-21 09:49:03 -07:00
Jakob Stoklund Olesen
3005f903f7 Move the verifier into a verifier/mod.rs file.
Make room for verifier sub-modules in separate files.
2017-04-20 14:38:03 -07:00
Jakob Stoklund Olesen
c621770507 Move the verifier into a verifier/mod.rs file.
Make room for verifier sub-modules in separate files.
2017-04-20 14:38:03 -07:00
Jakob Stoklund Olesen
d66a9d196e Implement binary emission of RISC-V return instructions.
The return address is now always supplied in %x1, so the return address
predictor will recognize the jalr as a return and not some indirect
branch.
2017-04-19 16:26:04 -07:00
Jakob Stoklund Olesen
9c23196049 Implement binary emission of RISC-V return instructions.
The return address is now always supplied in %x1, so the return address
predictor will recognize the jalr as a return and not some indirect
branch.
2017-04-19 16:26:04 -07:00
Jakob Stoklund Olesen
0cb36c9031 Remove the return_reg instruction.
RISC architectures that take a return address in a register can use a
special-purpose `link` return value to do so.
2017-04-19 16:08:16 -07:00
Jakob Stoklund Olesen
832247019b Remove the return_reg instruction.
RISC architectures that take a return address in a register can use a
special-purpose `link` return value to do so.
2017-04-19 16:08:16 -07:00
Jakob Stoklund Olesen
e44a5a4391 Append link and sret arguments in legalize_signature.
These special-purpose arguments and return values are only relevant for
the function being compiled, so add a `current` flag to
legalize_signature().

- Add the necessary argument values to the entry block to represent
  the special-purpose arguments.
- Propagate the link and sret arguments to return instructions if the
  legalized signature asks for it.
2017-04-19 15:55:12 -07:00
Jakob Stoklund Olesen
315c858b48 Append link and sret arguments in legalize_signature.
These special-purpose arguments and return values are only relevant for
the function being compiled, so add a `current` flag to
legalize_signature().

- Add the necessary argument values to the entry block to represent
  the special-purpose arguments.
- Propagate the link and sret arguments to return instructions if the
  legalized signature asks for it.
2017-04-19 15:55:12 -07:00
Jakob Stoklund Olesen
d9ddf4fc5a Simplify check_arg_types().
Iterator tricks.
2017-04-19 14:59:02 -07:00
Jakob Stoklund Olesen
c040a495c0 Simplify check_arg_types().
Iterator tricks.
2017-04-19 14:59:02 -07:00
Jakob Stoklund Olesen
49c1209572 Fix broken test. 2017-04-17 15:45:55 -07:00
Jakob Stoklund Olesen
74595c6623 Fix broken test. 2017-04-17 15:45:55 -07:00
Jakob Stoklund Olesen
d424589daa Allow for special purpose function arguments and return values.
Enumerate a set of special purposes for function arguments that general
purpose code needs to know about. Some of these argument purposes will
only appear in the signature of the current function, representing
things the prologue and epilogues need to know about like the link
register and callee-saved registers.

Get rid of the 'inreg' argument flag. Arguments can be pre-assigned to a
specific register instead.
2017-04-17 15:06:30 -07:00
Jakob Stoklund Olesen
7e9bdcf059 Allow for special purpose function arguments and return values.
Enumerate a set of special purposes for function arguments that general
purpose code needs to know about. Some of these argument purposes will
only appear in the signature of the current function, representing
things the prologue and epilogues need to know about like the link
register and callee-saved registers.

Get rid of the 'inreg' argument flag. Arguments can be pre-assigned to a
specific register instead.
2017-04-17 15:06:30 -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
d3235eb81f 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
e5115d7793 Remove detach_secondary_results() and other cleanups.
- The detach_secondary_results() is a leftover from the two-plane value
  representation. Use detach_results() instead to remove all instruction
  results.
- Make the append_* DFG methods more direct. Don't depend on calling the
  corresponding attach_* methods. Just create a new value directly,
  using the values.next_key() trick.
2017-04-13 10:37:58 -07:00
Jakob Stoklund Olesen
bf74445eac Remove detach_secondary_results() and other cleanups.
- The detach_secondary_results() is a leftover from the two-plane value
  representation. Use detach_results() instead to remove all instruction
  results.
- Make the append_* DFG methods more direct. Don't depend on calling the
  corresponding attach_* methods. Just create a new value directly,
  using the values.next_key() trick.
2017-04-13 10:37:58 -07:00
Jakob Stoklund Olesen
3c8bdba15e Don't create value aliases when legalizing ABI boundaries.
When converting from ABI types to original program types, the final
conversion instruction can place its result into the original value, so
it doesn't need to be changed to an alias.
2017-04-13 10:16:58 -07:00
Jakob Stoklund Olesen
f9d3e65419 Don't create value aliases when legalizing ABI boundaries.
When converting from ABI types to original program types, the final
conversion instruction can place its result into the original value, so
it doesn't need to be changed to an alias.
2017-04-13 10:16:58 -07:00
Jakob Stoklund Olesen
7ad882c154 Avoid creating value aliases in legalizer/split.rs.
When we're splitting an EBB argument, we insert a iconcat/vconcat
instruction that computes the original value from the new split
arguments.

The concat instruction can now define the original value directly, it is
not necessary to define a new value and alias the old one.
2017-04-13 09:45:36 -07:00
Jakob Stoklund Olesen
c716d86c8d Avoid creating value aliases in legalizer/split.rs.
When we're splitting an EBB argument, we insert a iconcat/vconcat
instruction that computes the original value from the new split
arguments.

The concat instruction can now define the original value directly, it is
not necessary to define a new value and alias the old one.
2017-04-13 09:45:36 -07:00
Jakob Stoklund Olesen
d48f79aa72 Avoid creating aliases when expanding legalizer patterns.
Now that we can detach and reuse all values, there is no longer a need
to create a lot of alias values during pattern expansion. Instead, reuse
the values from the source pattern when emitting instructions in the
destination pattern.

If a destination instruction produces the exact same values as a source
instruction, simply leave the values attached and replace the
instruction it. Otherwise, detach the source values, reuse them in the
expansion, and remove the source instruction afterwards.
2017-04-13 09:30:21 -07:00
Jakob Stoklund Olesen
3ae0fe6e2b Avoid creating aliases when expanding legalizer patterns.
Now that we can detach and reuse all values, there is no longer a need
to create a lot of alias values during pattern expansion. Instead, reuse
the values from the source pattern when emitting instructions in the
destination pattern.

If a destination instruction produces the exact same values as a source
instruction, simply leave the values attached and replace the
instruction it. Otherwise, detach the source values, reuse them in the
expansion, and remove the source instruction afterwards.
2017-04-13 09:30:21 -07:00
Jakob Stoklund Olesen
48b2f421b4 Add a with_results() method to the InsertBuilder.
This makes it possible to reuse one or more result values in the
instruction that is being inserted.

Also add a with_result(v) method for the common case of reusing a single
result value. This could be specialized in the future.
2017-04-13 08:55:18 -07:00
Jakob Stoklund Olesen
e582183619 Add a with_results() method to the InsertBuilder.
This makes it possible to reuse one or more result values in the
instruction that is being inserted.

Also add a with_result(v) method for the common case of reusing a single
result value. This could be specialized in the future.
2017-04-13 08:55:18 -07:00
Jakob Stoklund Olesen
3197f240ff Add a make_inst_results_reusing() generic method.
This is a generalization of the existing make_inst_results() which lets
you provide some or all of the result values instead of creating all new
ones.
2017-04-13 08:18:52 -07:00
Jakob Stoklund Olesen
8252b05b92 Add a make_inst_results_reusing() generic method.
This is a generalization of the existing make_inst_results() which lets
you provide some or all of the result values instead of creating all new
ones.
2017-04-13 08:18:52 -07:00
Jakob Stoklund Olesen
d4f511ecfc Return the removed instruction from Cursor::remove_inst().
This is convenient for asserting that the right instruction was removed.
2017-04-13 08:18:52 -07:00
Jakob Stoklund Olesen
2e64bb88ba Return the removed instruction from Cursor::remove_inst().
This is convenient for asserting that the right instruction was removed.
2017-04-13 08:18:52 -07:00
Jakob Stoklund Olesen
801f4ade66 Add remove_inst() methods to Cursor and Layout.
We didn't have a way of removing instructions again.
2017-04-12 17:06:27 -07:00
Jakob Stoklund Olesen
bcb3882ef6 Add remove_inst() methods to Cursor and Layout.
We didn't have a way of removing instructions again.
2017-04-12 17:06:27 -07:00
Jakob Stoklund Olesen
84c15e0e66 Add some safety checks for detached values.
These methods are used to reattach detached values:

- change_to_alias
- attach_result
- attach_ebb_arg

Add an assertion to all of them to ensure that the provided value is not
already attached somewhere else. Use a new value_is_attached() method
for the test.

Also include a verifier check for uses of detached values.
2017-04-12 15:19:26 -07:00
Jakob Stoklund Olesen
e2f8924c30 Add some safety checks for detached values.
These methods are used to reattach detached values:

- change_to_alias
- attach_result
- attach_ebb_arg

Add an assertion to all of them to ensure that the provided value is not
already attached somewhere else. Use a new value_is_attached() method
for the test.

Also include a verifier check for uses of detached values.
2017-04-12 15:19:26 -07:00
Jakob Stoklund Olesen
18b567f88e Flatten the Value reference representation.
All values are now references into the value table, so drop the
distinction between direct and table values. Direct values don't exist
any more.

Also remove the parser support for the 'vxNN' syntax. Only 'vNN' values
can be parsed now.
2017-04-12 14:45:22 -07:00
Jakob Stoklund Olesen
23ae70cacf Flatten the Value reference representation.
All values are now references into the value table, so drop the
distinction between direct and table values. Direct values don't exist
any more.

Also remove the parser support for the 'vxNN' syntax. Only 'vNN' values
can be parsed now.
2017-04-12 14:45:22 -07:00
Jakob Stoklund Olesen
b165d9a313 Remove the first_type() methods from InstructionData.
Also remove the type field from all the variants. The type of the first
result value can be recovered from the value table now.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
7cac9dcb41 Remove the first_type() methods from InstructionData.
Also remove the type field from all the variants. The type of the first
result value can be recovered from the value table now.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
28ff7b7925 Move the ctrl_typevar function into dfg.
Soon, InstructionData won't have sufficient information to compute this.

Give TargetIsa::encode() an explicit ctrl_typevar argument. This
function does not require the instruction to be inserted in the DFG
tables.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
9c6a36d36d Move the ctrl_typevar function into dfg.
Soon, InstructionData won't have sufficient information to compute this.

Give TargetIsa::encode() an explicit ctrl_typevar argument. This
function does not require the instruction to be inserted in the DFG
tables.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
e653d44f39 Stop linking result values together.
Since results are in a value list, they don't need to form a linked
list any longer.

- Simplify make_inst_results() to create values in the natural order.
- Eliminate the last use of next_secondary_value().
- Delete unused result manipulation methods.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
00ee850e33 Stop linking result values together.
Since results are in a value list, they don't need to form a linked
list any longer.

- Simplify make_inst_results() to create values in the natural order.
- Eliminate the last use of next_secondary_value().
- Delete unused result manipulation methods.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
8a2398be08 Stop calling Value::new_direct.
We only ever create table values now.

Simplify legalizer::legalize_inst_results. Instead of calling
detach_secondary_results, just detach all the results and don't treat
the first result specially.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
b9808bedc4 Stop calling Value::new_direct.
We only ever create table values now.

Simplify legalizer::legalize_inst_results. Instead of calling
detach_secondary_results, just detach all the results and don't treat
the first result specially.
2017-04-12 14:32:13 -07:00
Jakob Stoklund Olesen
d133606fe7 Don't assume all first results are direct values.
We're about to change that.
2017-04-12 14:32:13 -07:00