Commit Graph

462 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
20fc675fc0 Parse the BranchTable instruction format.
Resolve the jump table reference immediately since all jump tables are declared
in the preamble.
2016-07-22 15:16:14 -07:00
Jakob Stoklund Olesen
274671d12a Implement jump tables.
- Add a ir::jumptable module with a JumpTableData struct representing the vector
  of destinations.
- Add an entity map of jump tables to the Function.
- Parse and write jump tables in the function preamble.
- Rewrite EBB references in jumptables after parsing.
2016-07-22 14:48:53 -07:00
Morgan Phillips
5bcce51bd9 Add print-cfg tests 2016-07-14 13:43:11 -07:00
Jakob Stoklund Olesen
ad5e6b14cf Add tests for parsing call and return. 2016-07-08 16:28:19 -07:00
Jakob Stoklund Olesen
a39e418d32 Rewrite EBB and value references after parsing.
We llow forward references to values and EBBs, so it is not possible to rewrite
these from the source domain to the in-memory domain during parsing.

Instead go through all the instructions after parsing everything and rewrite the
value and EBB references when everything has been created and mapped.
2016-07-08 15:15:53 -07:00
Jakob Stoklund Olesen
4a929f5e41 Add meta definition for bitcast.
This instruction uses two type variables: input and output. Make sure that our
parser can handle it. The output type variable annotation is mandatory.

Add a ValueTypeSet::example() method which is used to provide better diagnostics
for a missing type variable.
2016-07-07 14:01:00 -07:00
Jakob Stoklund Olesen
86688053a6 Define icmp and fcmp comparison instructions.
Add new intcc and floatcc operand types for the immediate condition codes on
these instructions.

Add new IntCompare and FloatCompare instruction formats.

Add a generic match_enum() parser function that can match any identifier-like
enumerated operand kind that implements FromStr.

Define the icmp and fcmp instructions in case.py. Include documentation for the
condition codes with these two instructions.
2016-07-07 11:43:12 -07:00
Jakob Stoklund Olesen
a6c1362975 Parse insertlane and extractlane instruction formats.
These instruction formats take immediate lane index operands. We store these as
u8 fields and require them to be in decimal format in the source. No hexadecimal
lane indexes are supported.
2016-07-06 13:36:15 -07:00
Jakob Stoklund Olesen
e5feb864c7 Parse select instructions. 2016-07-05 16:51:26 -07:00
Jakob Stoklund Olesen
cdc2638f96 Parse branch and jump instructions.
These instruction formats take EBB references with lists of argument values. For
EBBs with no arguments, the argument value list may be omitted.
2016-07-05 15:23:42 -07:00
Jakob Stoklund Olesen
a82554192a Print a type suffix on some polymorphic instructions. 2016-07-05 13:45:15 -07:00
Jakob Stoklund Olesen
954fd015e0 Add very basic test framework for parser tests.
Start with a shell script that runs .cton files through 'cton-util cat' and
compares the output to a reference. This can get fancy later.
2016-07-05 12:51:02 -07:00