Commit Graph

12 Commits

Author SHA1 Message Date
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
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
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
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
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
Jakob Stoklund Olesen
593b7bbd51 Generate an InstructionFormat enum.
This is a no-payload enum which will have the same variants as InstructionData.
This makes it possible to talk about the format of an instruction without
actually creating an InstructionData instance.
2016-05-13 11:54:05 -07:00
Jakob Stoklund Olesen
af535acdc6 Add an InstructionFormat class to the meta language.
Define all known instruction formats in the cretonne.formats module.
2016-05-13 09:12:06 -07:00
Jakob Stoklund Olesen
ea46a17f56 PEP8 formatting. 2016-05-12 13:37:03 -07:00
Jakob Stoklund Olesen
1b7d5d849f Generate a constant hash table for recognizing opcodes.
Use a simple quadratically probed, open addressed hash table. We could use a
parfect hash function, but it would take longer to compute in Python, and this
is not in the critical path performancewise.
2016-04-07 20:24:21 -07:00
Jakob Stoklund Olesen
85248a4b18 Generate an opcode_name() function.
This function returning a &'static str is more primitive that the Display
implementation. It allows the opcode strings to be reused by the parser.
2016-04-07 13:49:35 -07:00
Jakob Stoklund Olesen
ee09a39aef Include generated Opcode enum in the immediates module.
Generate nice doc comments for the Opcode enum variants that 'cargo doc'
will pick up.

Include a `Display` trait implementation that prints the lower
snake-case version of the opcode name.
2016-04-06 14:55:21 -07:00
Jakob Stoklund Olesen
eba396546a Begin source generation.
Start out easy by emiting an opcodes.rs file containing an opcode enumeration.
2016-04-06 12:22:56 -07:00