Commit Graph

9103 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
74038d153c Ignore comments in .cton files.
The lexer still recognizes comments and generates tokens for them. They may be
useful for test annotations at some point.
2016-07-05 12:51:02 -07:00
Jakob Stoklund Olesen
56996adabd Don't return any values from inst_results() for VOID instructions.
Instructions that don't produce any result values are marked with first_type() =
VOID. The inst_results() iterator should not return any values for such
instructions.
2016-07-05 12:35:29 -07:00
Jakob Stoklund Olesen
a985bc18bc Don't return any values from inst_results() for VOID instructions.
Instructions that don't produce any result values are marked with first_type() =
VOID. The inst_results() iterator should not return any values for such
instructions.
2016-07-05 12:35:29 -07:00
Jakob Stoklund Olesen
ab35a6e596 Add a script for reformatting all sources.
This is mostly useful when updating to a new version of rustfmt with different
behavior.
2016-07-01 14:32:04 -07:00
Jakob Stoklund Olesen
9b5760d544 Add a script for reformatting all sources.
This is mostly useful when updating to a new version of rustfmt with different
behavior.
2016-07-01 14:32:04 -07:00
Jakob Stoklund Olesen
320d5b369a rustfmt v0.5.0 2016-07-01 14:26:24 -07:00
Jakob Stoklund Olesen
a981fc5605 rustfmt v0.5.0 2016-07-01 14:26:24 -07:00
Jakob Stoklund Olesen
8e1de5c0f8 Give a better error message for unknown opcodes.
Include the name of the unrecognized opcode along with the line number.
2016-07-01 14:23:54 -07:00
Jakob Stoklund Olesen
cb4e9fbae0 Give a better error message for unknown opcodes.
Include the name of the unrecognized opcode along with the line number.
2016-07-01 14:23:54 -07:00
Jakob Stoklund Olesen
5ce1a4f0e8 Parse and write IR in the 'cat' subcommand.
The 'cton-util cat' command parses the given files and writes them out again to
stdout. This has the effect of reformatting and stripping comments.

Fix a writer bug that inverted the blank line before the first EBB.
2016-07-01 14:12:39 -07:00
Jakob Stoklund Olesen
7519475f91 Parse and write IR in the 'cat' subcommand.
The 'cton-util cat' command parses the given files and writes them out again to
stdout. This has the effect of reformatting and stripping comments.

Fix a writer bug that inverted the blank line before the first EBB.
2016-07-01 14:12:39 -07:00
Jakob Stoklund Olesen
61094f6909 Begin a basic command line interface.
Add an external dependency to the docopt package and use it for a scaffold
command line interface for the cton-util command.

I am not too happy about taking external dependencies, and docopt pulls in 13
other packages. However, I really don't want to be writing command line parsers,
and as long as the external dependencies are confined to the tools crate, we
should be fine.

The core cretonne crate should stay free of external dependencies to avoid
trouble with embedding it.

Implement a basic 'cat' subcommand which currently behaves like unix 'cat'. It
will gain parser powers soon.
2016-07-01 13:47:17 -07:00
Jakob Stoklund Olesen
96e88893be Begin a basic command line interface.
Add an external dependency to the docopt package and use it for a scaffold
command line interface for the cton-util command.

I am not too happy about taking external dependencies, and docopt pulls in 13
other packages. However, I really don't want to be writing command line parsers,
and as long as the external dependencies are confined to the tools crate, we
should be fine.

The core cretonne crate should stay free of external dependencies to avoid
trouble with embedding it.

Implement a basic 'cat' subcommand which currently behaves like unix 'cat'. It
will gain parser powers soon.
2016-07-01 13:47:17 -07:00
Jakob Stoklund Olesen
49aa38b15f Use an err! macro to build parser errors with format! arguments. 2016-06-02 08:40:47 -07:00
Jakob Stoklund Olesen
8fac050bb5 Use an err! macro to build parser errors with format! arguments. 2016-06-02 08:40:47 -07:00
Jakob Stoklund Olesen
441001c1ad Avoid allocating a temporary Vec in the parser.
Wrangle the borrow checker into allowing us to iterate over function result
values while mutating the ctx.values table.
2016-06-01 20:45:58 -07:00
Jakob Stoklund Olesen
4eb327d027 Avoid allocating a temporary Vec in the parser.
Wrangle the borrow checker into allowing us to iterate over function result
values while mutating the ctx.values table.
2016-06-01 20:45:58 -07:00
Jakob Stoklund Olesen
8ebf6e775d Parse controlling type variable. Do basic type inference.
Replace the make_multi_inst() function with a make_inst_results() which uses
the constraint system to create the result values. A typevar argument ensures
that this function does not infer anything from the instruction data arguments.
These arguments may not be valid during parsing.

Implement basic type inference in the parser. If the designated value operand
on a polymorphic instruction refers to a known value, use that to infer the
controlling type variable.

This simple method of type inference requires the operand value to be defined
above the use in the text. Since reordering the EBBs could place a dominating
EBB below the current one, this is a bit fragile. One possibility would be to
require the value is defined in the same EBB. In all other cases, the
controlling typevar should be explicit.
2016-06-01 10:38:34 -07:00
Jakob Stoklund Olesen
ecd8287eb0 Parse controlling type variable. Do basic type inference.
Replace the make_multi_inst() function with a make_inst_results() which uses
the constraint system to create the result values. A typevar argument ensures
that this function does not infer anything from the instruction data arguments.
These arguments may not be valid during parsing.

Implement basic type inference in the parser. If the designated value operand
on a polymorphic instruction refers to a known value, use that to infer the
controlling type variable.

This simple method of type inference requires the operand value to be defined
above the use in the text. Since reordering the EBBs could place a dominating
EBB below the current one, this is a bit fragile. One possibility would be to
require the value is defined in the same EBB. In all other cases, the
controlling typevar should be explicit.
2016-06-01 10:38:34 -07:00
Jakob Stoklund Olesen
9af18728fa Clean up unused-import warnings. 2016-06-01 09:38:24 -07:00
Jakob Stoklund Olesen
fc8d2f92fd Clean up unused-import warnings. 2016-06-01 09:38:24 -07:00
Jakob Stoklund Olesen
840b483972 Generate Value and Ebb references in lexer.
During parsing, it is possible to see instruction operands that reference
values or EBBs that have not been created yet. These references have to be
resolved by a second pass following parsing once all EBBs and values have been
created.

To prepare for this second pass, start creating Ebb and Value references that
use the numbering from the source file rather than the in-memory real
references. Maintain Value -> Value and Ebb -> Ebb mappings. This makes it
possible to store source-numbered Ebb and Value references in instructions.

All other entities are created in the preamble, so they should have been created
before they are referenced.
2016-06-01 09:38:14 -07:00
Jakob Stoklund Olesen
f0fc9c9477 Generate Value and Ebb references in lexer.
During parsing, it is possible to see instruction operands that reference
values or EBBs that have not been created yet. These references have to be
resolved by a second pass following parsing once all EBBs and values have been
created.

To prepare for this second pass, start creating Ebb and Value references that
use the numbering from the source file rather than the in-memory real
references. Maintain Value -> Value and Ebb -> Ebb mappings. This makes it
possible to store source-numbered Ebb and Value references in instructions.

All other entities are created in the preamble, so they should have been created
before they are referenced.
2016-06-01 09:38:14 -07:00
Jakob Stoklund Olesen
96cfb40507 Add vector instructions.
Use derived type variables with the 'LaneOf' function.

Add u8 immediates to be used for lane indexes and bit shifts.
2016-05-20 15:36:03 -07:00
Jakob Stoklund Olesen
b1dd4ad373 Add vector instructions.
Use derived type variables with the 'LaneOf' function.

Add u8 immediates to be used for lane indexes and bit shifts.
2016-05-20 15:36:03 -07:00
Jakob Stoklund Olesen
cc71744b74 Implement select and vselect instructions.
This gives us the opportunity to use the AsBool derived type variables and a
Select instruction format with a non-default typevar_operand setting.
2016-05-20 15:11:17 -07:00
Jakob Stoklund Olesen
b44d6c6541 Implement select and vselect instructions.
This gives us the opportunity to use the AsBool derived type variables and a
Select instruction format with a non-default typevar_operand setting.
2016-05-20 15:11:17 -07:00
Jakob Stoklund Olesen
ad01af40e4 Generate value type constraints.
Add an Opcode::constraints() method which returns an OpcodeConstraints object.
This object provides information on instruction polymorphism and how many
results is produced.

Generate a list of TypeSet objects for checking free type variables. The type
sets are parametrized rather than being represented as fully general sets.

Add UniqueTable and UniqueSeqTable classes to the meta code generator. Use for
compressing tabular data by removing duplicates.
2016-05-20 14:43:16 -07:00
Jakob Stoklund Olesen
692a85d720 Generate value type constraints.
Add an Opcode::constraints() method which returns an OpcodeConstraints object.
This object provides information on instruction polymorphism and how many
results is produced.

Generate a list of TypeSet objects for checking free type variables. The type
sets are parametrized rather than being represented as fully general sets.

Add UniqueTable and UniqueSeqTable classes to the meta code generator. Use for
compressing tabular data by removing duplicates.
2016-05-20 14:43:16 -07:00
Jakob Stoklund Olesen
c3b76b67ca Verify restrictions on polymorphism.
Add a typevar_operand argument to the InstructionFormat constructor which
determines the operand used for inferring the controlling type variable.

Identify polymorphic instructions when they are created, determine if the
controlling type variable can be inferred from the typevar_operand, and verify
the use of type variables in the other operands.

Generate type variable summary in the documentation, including how the
controlling type variable is inferred.
2016-05-19 14:59:46 -07:00
Jakob Stoklund Olesen
1e631fdbd6 Verify restrictions on polymorphism.
Add a typevar_operand argument to the InstructionFormat constructor which
determines the operand used for inferring the controlling type variable.

Identify polymorphic instructions when they are created, determine if the
controlling type variable can be inferred from the typevar_operand, and verify
the use of type variables in the other operands.

Generate type variable summary in the documentation, including how the
controlling type variable is inferred.
2016-05-19 14:59:46 -07:00
Jakob Stoklund Olesen
ceb134ac32 Add a BinaryOverflow instruction format.
This will eventualy be used for add-with-carry and add-with-overflow type
instructions. For now it only serves as a representative of instruction formats
that have multiple_results=True and boxed_storage=False at the same time.
2016-05-19 10:43:14 -07:00
Jakob Stoklund Olesen
210139c4bd Add a BinaryOverflow instruction format.
This will eventualy be used for add-with-carry and add-with-overflow type
instructions. For now it only serves as a representative of instruction formats
that have multiple_results=True and boxed_storage=False at the same time.
2016-05-19 10:43:14 -07:00
Jakob Stoklund Olesen
6d0486cced Auto-generate boilerplate for 'impl InstructionData'.
Accessors for shared fields and multiple results can be generated automatically.

Add a 'boxed_storage' flag to the instruction format definitions to enable
generated code to access 'data'.
2016-05-19 10:16:40 -07:00
Jakob Stoklund Olesen
2ce5f05bed Auto-generate boilerplate for 'impl InstructionData'.
Accessors for shared fields and multiple results can be generated automatically.

Add a 'boxed_storage' flag to the instruction format definitions to enable
generated code to access 'data'.
2016-05-19 10:16:40 -07:00
Jakob Stoklund Olesen
b06f5ef72f Define control flow instructions.
Rename 'br' to 'jump'. We'll use jump/br to mean unconditional/conditional
control transfer respectively.
2016-05-19 09:01:40 -07:00
Jakob Stoklund Olesen
ebe224a912 Define control flow instructions.
Rename 'br' to 'jump'. We'll use jump/br to mean unconditional/conditional
control transfer respectively.
2016-05-19 09:01:40 -07:00
Jakob Stoklund Olesen
27a311701d Add entity references as a new operand kind.
Define known entities in the cretonne.entities module.
2016-05-18 15:31:02 -07:00
Jakob Stoklund Olesen
d85fda0346 Add entity references as a new operand kind.
Define known entities in the cretonne.entities module.
2016-05-18 15:31:02 -07:00
Jakob Stoklund Olesen
25e78fdbff Parse basic blocks and instructions.
Create map entries for ebbs and values as they are defined, but leave ebb and
value operands unresolved on instructions as they are parsed. Instruction
operands can refer to ebbs and values that may not have been defined yet.

Don't infer or check result types yet.
2016-05-18 12:27:12 -07:00
Jakob Stoklund Olesen
1dcac579fb Parse basic blocks and instructions.
Create map entries for ebbs and values as they are defined, but leave ebb and
value operands unresolved on instructions as they are parsed. Instruction
operands can refer to ebbs and values that may not have been defined yet.

Don't infer or check result types yet.
2016-05-18 12:27:12 -07:00
Jakob Stoklund Olesen
74625a9b79 Add restrictions on polymorphism.
Also introduce the concept of a derived type variable, and provide two
methods for deriving type vars: lane() and as_bool().
2016-05-18 12:27:12 -07:00
Jakob Stoklund Olesen
2dc15b78ae Add restrictions on polymorphism.
Also introduce the concept of a derived type variable, and provide two
methods for deriving type vars: lane() and as_bool().
2016-05-18 12:27:12 -07:00
Jakob Stoklund Olesen
639d92177a Reorganize meta language reference.
Separate instruction descriptions from instruction formats which deal with the
Rust representation.

Add type class restrictions to type variables.
2016-05-18 12:27:12 -07:00
Jakob Stoklund Olesen
bd221af412 Reorganize meta language reference.
Separate instruction descriptions from instruction formats which deal with the
Rust representation.

Add type class restrictions to type variables.
2016-05-18 12:27:12 -07:00
Jakob Stoklund Olesen
1be81c4352 Implement write_instruction and write_ebb.
Use the new iterators to write out the contents of a function.
2016-05-14 11:33:07 -07:00
Jakob Stoklund Olesen
9838a4040e Implement write_instruction and write_ebb.
Use the new iterators to write out the contents of a function.
2016-05-14 11:33:07 -07:00
Jakob Stoklund Olesen
dd5c1a1a3f Track instruction order in an EBB.
Place instructions in a doubly linked list and point to the first and last
instruction in an EBB.

Provide an iterator for all the EBBs too. This doesn't reflect the layout
order, but simply the order blocks were created.
2016-05-13 17:58:55 -07:00
Jakob Stoklund Olesen
5e0e923464 Track instruction order in an EBB.
Place instructions in a doubly linked list and point to the first and last
instruction in an EBB.

Provide an iterator for all the EBBs too. This doesn't reflect the layout
order, but simply the order blocks were created.
2016-05-13 17:58:55 -07:00
Jakob Stoklund Olesen
e735836383 Synchronize InstructionFormat and InstructionData.
These two enums must have identical variants. One is generated from the
instruction formats in meta/cretonne/formats.py, the other defines the contents
of an instruction.

Emit a conversion from InstructionData to InstructionFormat which also serves
to verify the correspondence. Rustc will error is the match is not complete.
2016-05-13 14:29:14 -07:00