Commit Graph

532 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
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
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
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
Morgan Phillips
26cd358bd4 Rustfmt fixes 2016-08-29 13:17:08 -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
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
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
Morgan Phillips
125b79c06a Add additional test cases 2016-08-24 13:13:31 -07:00
Morgan Phillips
c0a9a4fe46 Move dominator tree test cases to their own folder. 2016-08-23 15:42:31 -07:00
Morgan Phillips
bdefbdeccc rustfmt changes 2016-08-23 13:37:04 -07:00
Morgan Phillips
d8c587a1bf Synchronize regex versions 2016-08-23 13:34:40 -07:00
Morgan Phillips
a9e302e861 Modify the dominator tree's intersect method to interact with Basic Blocks
Corresponding changes to test cases are also included.
2016-08-23 13:34:40 -07:00
Jakob Stoklund Olesen
96b648056d Upgrade to rustfmt 0.6.0 2016-08-23 11:01:08 -07:00
Morgan Phillips
202088837b Merge branch 'master' of github.com:stoklund/cretonne 2016-08-18 14:39:02 -07:00
Morgan Phillips
9b8d2a04fb Add basic block information to the dominator tree.
To be complete the dominator tree must represent idoms as Ebb, Inst pairs, i.e.
bais blocks.
2016-08-18 14:37:32 -07:00
Jakob Stoklund Olesen
f9850b1405 Use shared quadratic probing for settings. 2016-08-18 13:45:50 -07:00
Jakob Stoklund Olesen
722a3a6ae6 Add a generic implementation of quadratic hash table probing.
We have multiple pre-computed constant hash tables that all use the same
quadratic probing algorithm.

Add a constant_hash Rust module to match the meta/constant_hash.py module.

Move the simple_hash() function into constant_hash. Its Python equivalent is in
the constant_hash.py module.
2016-08-18 13:44:17 -07:00
Jakob Stoklund Olesen
f17ea61593 Move ir::Function into a sub-module.
Keep the top-level ir module free of implementation details that are
inadvertently exposed to sub-modules.
2016-08-12 16:46:44 -07:00
Jakob Stoklund Olesen
f4258ae293 Use an EntityMap for stack slots.
Delete the StackSlots iterator and move the remaining StackSlotData into its
own module.
2016-08-12 16:44:39 -07:00
Jakob Stoklund Olesen
b266c28767 Re-export common types in the cretonne::ir module.
Clients should not have to navigate the ir sub-modules to find commonly used
types.
2016-08-12 16:11:38 -07:00
Jakob Stoklund Olesen
9d6e30df92 Remove tests/lib.rs to avoid running tests twice.
The 'cargo test' command simply compiles each 'tests/*.rs' and runs the
enclosed tests. The 'lib.rs' source would get run as an individual test.
2016-08-12 11:05:29 -07:00
Jakob Stoklund Olesen
f7f157fb71 Move integration tests into src/tools/tests.
The integration tests use both libcretonne and libreader, so moving them avoids
the circular dev-dependency.

Also go back to building everything under src/tools/target to avoid rebuilding
the libraries when cargo is invoked in different subdirectories. This speeds up
test-all.sh quite a bit.

Finally, skip the pure debug build. We build "cargo test" and "cargo build
--release" which should cover everything we need.
2016-08-12 10:43:10 -07:00
Jakob Stoklund Olesen
c998c79fe8 Generate code to precompute predicates.
Each ISA predicate is assigned a bit the the Flags struct, and a corresponding
method is generated.
2016-08-12 10:13:50 -07:00
Jakob Stoklund Olesen
1087aa67f0 Implement the machinery to create a TargetIsa.
Add an isa::lookup() function which serves as a target registry for creating
Box<TargetIsa> trait objects.

An isa::Builder makes it possible to confugure the trait object before it is
created.
2016-08-11 11:52:11 -07:00
Jakob Stoklund Olesen
1ae9a37796 Document ISA builder. 2016-08-10 15:48:19 -07:00
Jakob Stoklund Olesen
6e6ad1ef52 Add a settings::Builder data type.
- Move detail data structures into a settings::detail module to avoid polluting
  the settings namespace.

- Rename generated data types to 'Flags' in anticipation of computed predicate
  flags that can't be set. The Flags struct is immutable.

- Use a settings::Builder struct to manipulate settings, then pass it to
  Flags::new().
2016-08-10 15:47:06 -07:00
Jakob Stoklund Olesen
56cb249e13 Add support for enumerated settings.
The EnumSetting objects can take one of 256 named values.
2016-08-09 15:13:43 -07:00
Jakob Stoklund Olesen
530234ad32 Add settings::Stringwise.
This trait allows settings to be manipulated as strings, using descriptors and
constant hash-table lookups.

Amend gen_settings.py to generate the necessary constant tables.
2016-08-09 15:04:42 -07:00
Jakob Stoklund Olesen
24ec62d030 Move simple_hash into its own module. 2016-08-09 15:04:42 -07:00