Commit Graph

1481 Commits

Author SHA1 Message Date
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
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
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
Angus Holder
e21bf444dc Added parsing of argument locations for functions and signatures. 2017-03-09 13:55:11 -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
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
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
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
04bddd73ba Add a 'regalloc' filetest command.
Run functions through the register allocator, and then filecheck.
2017-02-22 11:53:01 -08:00
Jakob Stoklund Olesen
377550b835 Add return_reg encodings for RISC-V. 2017-02-21 16:29:23 -08:00
Jakob Stoklund Olesen
5e4602efb4 Add expansion patterns for large immediates.
Expand foo_imm into iconst + foo.
2016-11-10 15:55:54 -08:00
Jakob Stoklund Olesen
be3577ad7e Resolve value aliases when legalizing instructions.
Since we're deconstructing an instruction anyway, go ahead and resolve
any value aliases on its arguments before we construct the replacement
instructions.
2016-11-04 15:54:58 -07:00
Jakob Stoklund Olesen
453a1b2d17 Create value aliases when necessary.
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.
2016-11-04 15:31:23 -07:00
Jakob Stoklund Olesen
b63d62c9e8 Advance the insertion cursor after replacinf an instruction.
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.
2016-11-04 11:56:21 -07:00
Jakob Stoklund Olesen
cb718b869c TestFile preamble comments apply to all functions.
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.
2016-11-04 10:49:09 -07:00
Jakob Stoklund Olesen
a2b7769a51 Revisit expanded instructions for legalization.
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.
2016-11-04 09:44:11 -07:00
Jakob Stoklund Olesen
1a9abdd158 Add narrowing legalization patterns for bitwise ops.
RISC-V 32-bit tests for band.i64, bor.i64, bxor.i64.
2016-11-04 08:02:37 -07:00
Jakob Stoklund Olesen
df06f19979 Parse signature and function declarations.
Also add support for parsing call and call_indirect instructions.
2016-10-18 13:19:24 -07:00
Jakob Stoklund Olesen
f34da59bab Integer subtraction with borrow flags.
This is the x86-style of borrow flags. ARM uses subtract-with-carry
which inverts the sense of the carry flag.
2016-09-23 15:47:39 -07:00
Jakob Stoklund Olesen
b1bd3140db Integer add with carry instructions.
Integer addition with carry in/out/both.
2016-09-23 13:42:00 -07:00
Jakob Stoklund Olesen
51bcc78cea Add a 'test legaliser' filetest command.
This test command sends each function through legalize_function() and
then filecheck.
2016-09-21 17:36:06 -07:00
Jakob Stoklund Olesen
5aa1db2e4f Don't have keywords in the lexer and parser.
Instead of recognizing "function" as a keyword, simply match it as a
context-sensitive keyword in the parser outside functions.
2016-09-20 13:00:37 -07:00
Jakob Stoklund Olesen
388154e06b Wrap FunctionName in a newtype struct.
Function names display differently than normal strings since they need
quotes and escaping.

Move the FunctionName type into its own module.
2016-09-19 15:09:25 -07:00
Jakob Stoklund Olesen
a98d6e5256 Add a 'test verifier' sub-test.
This test runs the verifier on each function and matches the resulting
verifier error against the "error:" annotation.

Move the existing verifier test into filetests/verifier/ and use the new
syntex.
2016-09-16 16:25:36 -07:00
Jakob Stoklund Olesen
770285d5c6 Implement a domtree sub-test.
This test verifies the computed dominator tree against annotations.

Move the existing testcases into filetests/ with the new syntax.
2016-09-16 14:50:32 -07:00
Jakob Stoklund Olesen
ec6a9df08a Make the source map available as filecheck variables.
This makes it possible to refer to entities defined in the source file,
using the source names prefixed with $.

For example, $v20 refers to the value by that name in the sources, even
if it was renumbered to 'vx0' in the parsed file.
2016-09-16 12:59:05 -07:00
Jakob Stoklund Olesen
5ac30b0075 Implement the 'test print-cfg' sub-test.
Move the CFG tests into the filetests directory.

Remove the tests directory, there are no more shell-driven tests left.
2016-09-15 17:21:56 -07:00
Jakob Stoklund Olesen
086bd601a2 Convert parser tests to filetests.
Create a new directory hierarchy under 'filetests' for all the tests
that are run by 'cton-util test'.

Convert the parser tests under 'tests/parser' to use 'test cat' and
filecheck directives.
2016-09-15 15:50:47 -07:00