Commit Graph

6452 Commits

Author SHA1 Message Date
Keith Yeung
c7e25e6a35 Limit type inference for controlling type variables in write.rs 2017-03-22 14:45:38 -07:00
Keith Yeung
07740b5e3c Limit type inference for controlling type variables in write.rs 2017-03-22 14:45:38 -07:00
Jakob Stoklund Olesen
26ee382b57 Fix weird indentation. 2017-03-22 13:17:25 -07:00
Jakob Stoklund Olesen
098a48e332 Fix weird indentation. 2017-03-22 13:17:25 -07:00
Jakob Stoklund Olesen
272df6489c Iteratively split EBB arguments.
When the legalizer splits a value into halves, it would previously stop
if the value was an EBB argument. With this change, we also split EBB
arguments and iteratively split arguments on branches to the EBB.

The iterative splitting stops when we hit the entry block arguments or
an instruction that isn't one of the concatenation instructions.
2017-03-22 13:12:19 -07:00
Jakob Stoklund Olesen
19db81f6a8 Iteratively split EBB arguments.
When the legalizer splits a value into halves, it would previously stop
if the value was an EBB argument. With this change, we also split EBB
arguments and iteratively split arguments on branches to the EBB.

The iterative splitting stops when we hit the entry block arguments or
an instruction that isn't one of the concatenation instructions.
2017-03-22 13:12:19 -07:00
Jakob Stoklund Olesen
d32c19c81d Add a DataFlowGraph::replace_ebb_arg() method.
This is needed for rewriting EBB arguments with legalized types.
2017-03-22 10:36:42 -07:00
Jakob Stoklund Olesen
2ebbc78f74 Add a DataFlowGraph::replace_ebb_arg() method.
This is needed for rewriting EBB arguments with legalized types.
2017-03-22 10:36:42 -07:00
Jakob Stoklund Olesen
ca6e402b90 Add a ControlFlowGraph argument to legalize_function.
Legalizing some instructions may require modifications to the control
flow graph, and some operations need to use the CFG analysis.

The CFG reference is threaded through all the legalization functions to
reach the generated expansion functions as well as the legalizer::split
module where it will be used first.
2017-03-21 16:00:28 -07:00
Jakob Stoklund Olesen
e941a7db5f Add a ControlFlowGraph argument to legalize_function.
Legalizing some instructions may require modifications to the control
flow graph, and some operations need to use the CFG analysis.

The CFG reference is threaded through all the legalization functions to
reach the generated expansion functions as well as the legalizer::split
module where it will be used first.
2017-03-21 16:00:28 -07:00
Jakob Stoklund Olesen
a9056f699e Rename the 'cfg' module to 'flowgraph'.
The 'cfg' name was easy to confuse with 'configuration'.
2017-03-21 15:33:23 -07:00
Jakob Stoklund Olesen
f84e218a93 Rename the 'cfg' module to 'flowgraph'.
The 'cfg' name was easy to confuse with 'configuration'.
2017-03-21 15:33:23 -07:00
Jakob Stoklund Olesen
697246658d Avoid generating value split instructions.
The legalizer often splits values into parts with the vsplit and
isplit_lohi instructions. Avoid doing that for values that are already
defined by the corresponding concatenation instructions.

This reduces the number of instructions created during legalization, and
it simplifies later optimizations. A number of dead concatenation
instructions are left behind. They can be trivially cleaned up by a dead
code elimination pass.
2017-03-21 15:10:50 -07:00
Jakob Stoklund Olesen
22334bcb54 Avoid generating value split instructions.
The legalizer often splits values into parts with the vsplit and
isplit_lohi instructions. Avoid doing that for values that are already
defined by the corresponding concatenation instructions.

This reduces the number of instructions created during legalization, and
it simplifies later optimizations. A number of dead concatenation
instructions are left behind. They can be trivially cleaned up by a dead
code elimination pass.
2017-03-21 15:10:50 -07:00
Jakob Stoklund Olesen
2a321f42fb Strip the _lohi suffix from the isplit instructions.
For symmetry with the vector splitting instructions, we now have:

    isplit iconcat
    vsplit vconcat

No functional change.
2017-03-21 13:22:50 -07:00
Jakob Stoklund Olesen
a44a4d2718 Strip the _lohi suffix from the isplit instructions.
For symmetry with the vector splitting instructions, we now have:

    isplit iconcat
    vsplit vconcat

No functional change.
2017-03-21 13:22:50 -07:00
Jakob Stoklund Olesen
dfdc1ed514 Move ABI boundary legalization into a sub-module.
Keep things organized.
2017-03-20 15:14:51 -07:00
Jakob Stoklund Olesen
159486c707 Move ABI boundary legalization into a sub-module.
Keep things organized.
2017-03-20 15:14:51 -07:00
Jakob Stoklund Olesen
34e5675d17 Add OpcodeConstraints::value_argument_constraint().
As discussed in #3.

Once we know the controlling type variable of a polymorphic instruction,
the types of input operands are either bound to known types, or they can
vary freely.
2017-03-20 14:47:09 -07:00
Jakob Stoklund Olesen
90d68e0435 Add OpcodeConstraints::value_argument_constraint().
As discussed in #3.

Once we know the controlling type variable of a polymorphic instruction,
the types of input operands are either bound to known types, or they can
vary freely.
2017-03-20 14:47:09 -07:00
Angus Holder
d383a41851 Verify that all predecessors to an EBB are valid branches, and have the EBB recorded as a successor. 2017-03-20 08:41:11 -07:00
Angus Holder
bb0246c8c1 Verify that all predecessors to an EBB are valid branches, and have the EBB recorded as a successor. 2017-03-20 08:41:11 -07:00
Angus Holder
8b300a9efb Verify that values are defined by an EBB/instruction that dominates the instruction that uses them. 2017-03-20 08:41:11 -07:00
Angus Holder
c596ea1ac1 Verify that values are defined by an EBB/instruction that dominates the instruction that uses them. 2017-03-20 08:41:11 -07:00
Angus Holder
c50bf2aa68 Verify that values have a valid reference to either an instruction inserted in an EBB, or an EBB inserted in the layout. 2017-03-20 08:41:11 -07:00
Angus Holder
298cf2ed21 Verify that values have a valid reference to either an instruction inserted in an EBB, or an EBB inserted in the layout. 2017-03-20 08:41:11 -07:00
Jakob Stoklund Olesen
f15651132b Fix a bug in analyze_call().
The call arguments on call_indirect should not include the fixed callee
argument.

Add legalizer assertions to verify that signatures are actually valid
after legalization. If not, we would get infinite legalizer loops.
2017-03-17 12:34:03 -07:00
Jakob Stoklund Olesen
e83cccb6fc Fix a bug in analyze_call().
The call arguments on call_indirect should not include the fixed callee
argument.

Add legalizer assertions to verify that signatures are actually valid
after legalization. If not, we would get infinite legalizer loops.
2017-03-17 12:34:03 -07:00
Jakob Stoklund Olesen
d881ed331b Legalize return values from call instructions.
Like the entry block arguments, the return values from a call
instruction need to be converted back from their ABI representation.

Add tests of call instruction legalization.
2017-03-17 11:03:32 -07:00
Jakob Stoklund Olesen
a8a7cebe8c Legalize return values from call instructions.
Like the entry block arguments, the return values from a call
instruction need to be converted back from their ABI representation.

Add tests of call instruction legalization.
2017-03-17 11:03:32 -07:00
Jakob Stoklund Olesen
56d12b14ff Add attach_secondary_result and append_secondary_result.
These low-level functions allow us to build up a list of instruction
results incrementally. They are equivalent to the existing
attach_ebb_arg and append_ebb_arg.
2017-03-17 10:07:32 -07:00
Jakob Stoklund Olesen
6549065491 Add attach_secondary_result and append_secondary_result.
These low-level functions allow us to build up a list of instruction
results incrementally. They are equivalent to the existing
attach_ebb_arg and append_ebb_arg.
2017-03-17 10:07:32 -07:00
Jakob Stoklund Olesen
6dc11d1267 Use a closure to control the convert_from_abi() function.
This will be used for converting function return types soon, so
generalize it a bit.
2017-03-17 10:07:32 -07:00
Jakob Stoklund Olesen
a36160aa20 Use a closure to control the convert_from_abi() function.
This will be used for converting function return types soon, so
generalize it a bit.
2017-03-17 10:07:32 -07:00
Jakob Stoklund Olesen
4964502782 Break out differently purposed tests from abi.cton.
- abi.cton is for testing the actual RISC-V ABI.
- legalize-abi.cton is for testing the legalizer around ABI boundaries.
- parse-encoding.cton is for testing the parser's handling of RISC-V
  encoding and register annotations.
2017-03-17 10:07:32 -07:00
Jakob Stoklund Olesen
e4a83c8063 Break out differently purposed tests from abi.cton.
- abi.cton is for testing the actual RISC-V ABI.
- legalize-abi.cton is for testing the legalizer around ABI boundaries.
- parse-encoding.cton is for testing the parser's handling of RISC-V
  encoding and register annotations.
2017-03-17 10:07:32 -07:00
Jakob Stoklund Olesen
e90e59cedb Add DataFlowGraph::redefine_first_value()
This makes it possible to compute the first result of an instruction in
a different way without overwriting the original instruction with
replace().
2017-03-16 13:10:12 -07:00
Jakob Stoklund Olesen
578fec90cd Add DataFlowGraph::redefine_first_value()
This makes it possible to compute the first result of an instruction in
a different way without overwriting the original instruction with
replace().
2017-03-16 13:10:12 -07:00
Jakob Stoklund Olesen
2119c85224 Don't return a Values iterator from detach_secondary_results().
Instead, just return the first of the detached values, and provide a
next_secondary_result() method for traversing the list.

This is equivalent to how detach_ebb_args() works, and it allows the
data flow graph to be modified while traversing the list of results.
2017-03-15 15:38:47 -07:00
Jakob Stoklund Olesen
89f45a5c82 Don't return a Values iterator from detach_secondary_results().
Instead, just return the first of the detached values, and provide a
next_secondary_result() method for traversing the list.

This is equivalent to how detach_ebb_args() works, and it allows the
data flow graph to be modified while traversing the list of results.
2017-03-15 15:38:47 -07:00
Jakob Stoklund Olesen
db5aead1a5 Rename take_ebb_args to detach_ebb_args()
This better matches the detach_secondary_results cousin.

Also rename the converse put_ebb_arg -> attach_ebb_arg.
2017-03-15 15:21:57 -07:00
Jakob Stoklund Olesen
765c866971 Rename take_ebb_args to detach_ebb_args()
This better matches the detach_secondary_results cousin.

Also rename the converse put_ebb_arg -> attach_ebb_arg.
2017-03-15 15:21:57 -07:00
Jakob Stoklund Olesen
d15f25844a Legalize ABI arguments to call and return instructions.
The type signatures of functions can change when they are legalized for
a specific ABI. This means that all call and return instructions need to
be rewritten to use the correct arguments.

- Fix arguments to call instructions.
- Fix arguments to return instructions.

TBD:

- Fix return values from call instructions.
2017-03-15 14:35:22 -07:00
Jakob Stoklund Olesen
28153c97ea Legalize ABI arguments to call and return instructions.
The type signatures of functions can change when they are legalized for
a specific ABI. This means that all call and return instructions need to
be rewritten to use the correct arguments.

- Fix arguments to call instructions.
- Fix arguments to return instructions.

TBD:

- Fix return values from call instructions.
2017-03-15 14:35:22 -07:00
Jakob Stoklund Olesen
01cb51ece9 Add DataFlowGraph::display_inst().
This method returns an object that can display an instruction in the
standard textual format, but without any encoding annotations.
2017-03-15 13:52:45 -07:00
Jakob Stoklund Olesen
aa400d46ec Add DataFlowGraph::display_inst().
This method returns an object that can display an instruction in the
standard textual format, but without any encoding annotations.
2017-03-15 13:52:45 -07:00
Jakob Stoklund Olesen
9549cf603c Add a primitive debug tracing facility.
When the CRETONNE_DBG environment variable is set, send debug messages
to a file named cretonne.dbg.*.

The trace facility is only enabled when debug assertions are on.
2017-03-15 11:32:01 -07:00
Jakob Stoklund Olesen
210530da9c Add a primitive debug tracing facility.
When the CRETONNE_DBG environment variable is set, send debug messages
to a file named cretonne.dbg.*.

The trace facility is only enabled when debug assertions are on.
2017-03-15 11:32:01 -07:00
Jakob Stoklund Olesen
d604855b27 Fix logic bug in requires_typevar_operand.
The Python code computing this property had a bug. The property has only
been used for optimizing the ctrl_typevar() method so far.
2017-03-14 13:32:15 -07:00
Jakob Stoklund Olesen
d86854b286 Fix logic bug in requires_typevar_operand.
The Python code computing this property had a bug. The property has only
been used for optimizing the ctrl_typevar() method so far.
2017-03-14 13:32:15 -07:00