Commit Graph

2829 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
4e3f0fc41d Collect comments while parsing functions.
The result from parsing a function is now a DetailedFunction which
includes all comments that can be associated with an entity.

Comments before the first function are ignored, everything else is
associated with the preceeding entity.

The parse_functions() function still returns plain functions.
2016-09-13 16:15:42 -07:00
Jakob Stoklund Olesen
458ecebe8f Add a next_key() method to primary entity maps.
It is sometimes useful to know the entity reference number that will be
assigned to the next thing added to a map.
2016-09-13 16:14:46 -07:00
Jakob Stoklund Olesen
1b6623f068 Add a representation of a parsed test case file.
The new exported function `parse_test()` will produce it eventually.
2016-09-13 16:14:29 -07:00
Jakob Stoklund Olesen
fcec517fc5 Simplify the interface to cretonne-reader.
Export a single function: parse_functions() which results a vector of
functions parsed from the source string.

Hide the parser and lexer modules. They are not useful to external
clients.
2016-09-13 11:01:21 -07:00
Jakob Stoklund Olesen
c80934d084 Add a data structure representing a parsed test command.
It's not used for anything yet.
2016-09-13 10:51:15 -07:00
Jakob Stoklund Olesen
b14be8b14b Add an AnyEntity enum type.
This type can reference any type of entity in a function. It will be
used for the location of verifier error messages and other annotations.
2016-09-12 15:14:15 -07:00
Jakob Stoklund Olesen
1c5547970a Idiomatic impl of unordered_begin. 2016-09-10 12:33:58 -07:00
Jakob Stoklund Olesen
38952eea00 Add an explainer mode to filecheck.
The -c flag to 'cton-util filecheck' will now print out a description of how
the directives are matching the input.

This explanation is also printed when a match fails.
2016-09-09 17:08:29 -07:00
Jakob Stoklund Olesen
1ce5bc3509 pub 2016-09-09 14:32:07 -07:00
Jakob Stoklund Olesen
d9cceb18d3 Add a MatchRange type alias.
The regex library also uses (usize, usize) for ranges. The type alias is just
to make it clearer what the tuple means.
2016-09-09 14:11:56 -07:00
Jakob Stoklund Olesen
9772398ae4 Convert the DFG tests to use filecheck. 2016-09-09 11:09:54 -07:00
Jakob Stoklund Olesen
42cdebd508 Add a cton-util filecheck sub-command. 2016-09-09 10:54:57 -07:00
Jakob Stoklund Olesen
71b742ec34 Add a libfilecheck crate.
This library implements functionality similar to LLVM's FileCheck utility, but
in library form.
2016-09-09 10:45:10 -07:00
Morgan Phillips
d8712b2ce6 Add a verifier
The current implementation only performs a few basic checks.
2016-09-06 14:09:09 -07:00
Jakob Stoklund Olesen
78a9e67a09 Emit ISA predicates in the encoding tables.
Use the new ISA predicate numbering to emit ISA predicate instructions in the
encoding tables.

Properly decode the ISA predicate number in RISC-V and add tests for RV32M iwth
and without 'supports_m' enabled.
2016-08-31 16:00:33 -07:00
Jakob Stoklund Olesen
de330402b8 Add casual string representation of named settings and predicates.
Use 'group.setting' format for named predicates, only display the expression
for anonymous predicates.
2016-08-31 15:46:05 -07:00
Jakob Stoklund Olesen
88c8e9a59a Move byte-vector layout into SettingGroup.layout().
Move all the byte-sized settings to the front of the byte-vector, and add a
mechanism for assigning numbers to predicates that have no name as well as
predicates from the parent settings group.

This way, all the boolean predicates that are used by a target ISA appear as a
contiguous bit-vector that is a suffix of the settings byte-vector. This
bit-vector can then be indexed linearly when resolving ISA predicates on
encodings.

Add a numbered_predicate() method to the generated Flags structs that can read
a predicate by number dynamically.
2016-08-31 12:25:57 -07:00
Jakob Stoklund Olesen
036fa46b37 Fix typo in predicate combination. 2016-08-31 08:48:31 -07:00
Jakob Stoklund Olesen
997919c696 Add encodings for imul instructions to RISC-V.
This is just the basic 'imul' the M instruction set also has mulh/mulhu which
yield the high bits of a multiplication, and there are div/rem instructions to
be implemented.

These instructions are gated by the use_m predicate, but ISA predicates are not
completely implemented yet.
2016-08-30 16:16:28 -07:00
Jakob Stoklund Olesen
09734f2033 Add controls for enabling M, F, and D RISC-V extensions.
Three predicates affect each extension:

- supports_m determines whether the target CPU supports the instruction set.
- enable_m determines if the instructions should be used, assuming they're
  available.
- use_m is the predicate used to actually use the instructions.
2016-08-30 15:44:26 -07:00
Jakob Stoklund Olesen
9944bcc928 Fix settings_size vs byte_size confusion in gen_settings.py. 2016-08-30 15:44:26 -07:00
Jakob Stoklund Olesen
cdac6d1c8e Add encoding tests for RV32.
The 32-bit CPU mode uses a different encoding for iadd_imm.i32, and 64-bit
instructions are not supported.
2016-08-30 14:54:18 -07:00
Jakob Stoklund Olesen
dddcc0b2ca Add an encoding test for RISC-V.
Test that the generated encoding tables work as expected.

Change isa::Encoding into a struct with named fields so the recipe and bits can
be accessed.
2016-08-30 14:22:12 -07:00
Jakob Stoklund Olesen
662e256e3f Generate a table of encoding recipe names for each ISA.
This will be used to pretty-print encodings in the textual IR.
2016-08-30 13:51:34 -07:00
Jakob Stoklund Olesen
6fc6e35585 Upgrade to rustfmt 0.6.0. 2016-08-30 07:56:12 -07:00
Jakob Stoklund Olesen
fc6cb2eac1 Add an isa/encoding module.
Define data types for the level 1 and level 2 hash tables. These data types are
generic over the offset integer type so they can be twice as compact for
typically small ISAs.

Use these new types when generating encoding hash tables.

Emit both level 1 and level 2 hash tables.

Define generic functions that perform lookups in the encoding tables.

Implement the TargetIsa::encode() method for RISC-V using these building
blocks.
2016-08-30 07:49:29 -07:00
Jakob Stoklund Olesen
d67bba1e85 Split the Encoding data type into two u16 values.
This hardcodes the division line between the recipe bits and the
encoding bits. It does not seem that any ISA will need more than 16 bits for
either.
2016-08-30 07:49:29 -07:00
Jakob Stoklund Olesen
6145f4ca13 Add an is_64bit shared setting.
Many ISAs and 64-bit and 32-bit variants. Use a shared is_64bit setting to
distinguish.
2016-08-30 07:49:29 -07:00
Jakob Stoklund Olesen
dcf0b49b07 Add comments to the level2 hash tables concatenation.
The large LEVEL2 table consists on multiple concatenated constant hash tables.
Add comments to the generated output delineating the individual tables.
2016-08-30 07:49:29 -07:00
Jakob Stoklund Olesen
0357ffe670 Require a specific rustfmt version in test-all script.
Rustfmt is still so immature that developers can't have different versions
installed, or there will be minute differences in formatting causing the tests
to fail.

Only run rustfmt as part of the test-all script if the expected version is
available.
2016-08-30 07:48:02 -07:00
Morgan Phillips
26cd358bd4 Rustfmt fixes 2016-08-29 13:17:08 -07:00
Jakob Stoklund Olesen
adde184042 Generate level 2 hashtables.
All of the level 2 hashtables are concatenated into one constant array per ISA.
2016-08-26 17:15:05 -07:00
Jakob Stoklund Olesen
a21935a5a2 Add 32-bit ops to RV64.
The 32-bit arithmetic instructions are encoded differently in the RISC-V 64-bit
mode.
2016-08-26 16:13:22 -07:00
Jakob Stoklund Olesen
0c8f251bee Emit encoding lists (WIP).
Compute the u16 representation of encoding lists and emit a big table
concatenating all of them. Use the UniqueSeqTable to share some table space
between CPU modes.
2016-08-26 16:07:18 -07:00
Jakob Stoklund Olesen
6a8a4c43c2 Collect and number all active encoding recipes.
The recipes are shared across CPU modes.
2016-08-26 15:14:33 -07:00
Jakob Stoklund Olesen
15b5576d99 Generate type numbers at meta-time.
We need to generate hash tables keyed by types, so the Python scripts need to
know the index used to represent types in Rust code.

To enforce this, add a new gen_types.py script which generates constant
definitions for the ir/types module.

Also generate constants for common SIMD vector sizes.
2016-08-26 14:02:32 -07:00
Morgan Phillips
ea3396c2ff Add another dominator tree test case 2016-08-26 13:41:57 -07:00
Jakob Stoklund Olesen
3e40c3e454 Flake8 lints. 2016-08-26 09:45:10 -07:00
Jakob Stoklund Olesen
c1ae0c99ed Move predicate collection into TargetISA.
Add a TargetISA.finish() method which computes derived data structures after
the ISA definitions have been loaded.
2016-08-26 09:37:05 -07:00
Jakob Stoklund Olesen
7cb975ce63 Add string conversions for predicates and encodings.
This is just used for printing better comments in generated code.
2016-08-26 08:50:47 -07:00
Jakob Stoklund Olesen
0c6e0e9cb7 Generate encoding tables. (WIP).
Amend build script to generate an encodings-<isa>.rs file for each target ISA.

Emit a function that can evaluate instruction predicates.

Describe the 3-level tables used for representing insrruction encoding tables.
Add Python classes representing the tables.

The generated code is incomplete and not used anywhere yet.
2016-08-25 16:19:10 -07:00
Jakob Stoklund Olesen
c166279bb9 Call function in the predicates module.
When generating Rust code for an instruction predicate, call the corresponding
function in the predicates module, using a qualified name.

We don't have methods corresponding to the predicates.
2016-08-25 14:26:44 -07:00
Jakob Stoklund Olesen
8641076369 Fix Python3 compat in docs directory.
Update copyright.
2016-08-25 11:55:57 -07:00
Jakob Stoklund Olesen
fb7997aa38 Collect list of CPU modes in TargetISA.
Fix a typo nearby.
2016-08-25 11:38:40 -07:00
Jakob Stoklund Olesen
a24daf5ded Add a predicate_leafs() method.
This collects all of the leaf predicates that go into a compound predicate.
Current leaf predicates are:

- Settings for ISA predicates, and
- FieldPredicates for instruction predicates.
2016-08-25 09:50:23 -07:00
Jakob Stoklund Olesen
46dec8a11d Verify Rust source code formatting as part of the unit tests.
Only do this is rustfmt is installed, which likely means don't run on Travis
CI.
2016-08-24 16:36:52 -07:00
Jakob Stoklund Olesen
33235b3981 Pass arguments on to rustfmt.
This allows the usage:

    src/format-all.sh --write-mode=diff
2016-08-24 16:29:54 -07:00
Jakob Stoklund Olesen
eb03abe864 Allow predicates on both EncRecipe and Encoding.
If both specify a predicate, combine them with 'And'.
2016-08-24 16:02:41 -07:00
Jakob Stoklund Olesen
1a92876989 Add module with commonly used immediate predicates. 2016-08-24 15:22:15 -07:00
Jakob Stoklund Olesen
055c7a0374 Clarify that Imm64 holds sign-extended values.
When representing smaller integer types, immediate values should be
sign-extended to i64.
2016-08-24 15:22:05 -07:00