Commit Graph

2269 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
45cf655ce4 Generalize def_inst() to def_entity().
Use this source map method for assigning a location to any entity whose
source number is not exposed. This could be

- Instructions.
- Signatures defined implicitly by function decls.

These entities only appear in the location map, not the entity number
maps.
2016-10-18 09:38:05 -07:00
Jakob Stoklund Olesen
a8a79df620 Promote the src/tools crate to the top-level workspace.
The 'src' and 'tests' top-level directories now contain tools sources
and integration tests for any of the library crates.
2016-10-17 15:04:29 -07:00
Jakob Stoklund Olesen
0764df28b5 Move library crates under 'lib/'.
Give these crates each a more standard directory layout with sources in
a 'src' sub-sirectory and Cargo.toml in the top lib/foo directory.

Add license and description fields to each.

The build script for the cretonne crate now lives in
'lib/cretonne/build.rs' separating it from the normal library sources
under 'lib/cretonne/src'.
2016-10-17 14:44:43 -07:00
Jakob Stoklund Olesen
e7f30a40b4 Move the 'meta' dir to 'lib/cretonne/meta'.
The 'lib/cretonne' directory will be the new root of a stand-alone
cretonne crate containg both Python and Rust sources.

This is in preparation for publishing crates on crates.io.
2016-10-17 14:19:23 -07:00
Jakob Stoklund Olesen
8480879f3e Remove test_utils.
These test utilities have been subsumed by ir::Builder.
2016-10-14 15:17:34 -07:00
Jakob Stoklund Olesen
af8f8d98e6 Switch domtree tests to using Builder. 2016-10-14 15:16:29 -07:00
Jakob Stoklund Olesen
d4197ca731 Give Builder a Cursor.
The Builder keeps track of a position in the layout and inserts new
instructions there.

Add insert_ebb() and ebb() methods to Builder.

Use Builder in the cfg tests.
2016-10-14 15:02:58 -07:00
Jakob Stoklund Olesen
eb5cea7c6a Add Cursor::insert_ebb() method.
Insert an EBB at the current position and switch to inserting
instructions there. Call the relevant Layout methods to do so.
2016-10-14 14:01:49 -07:00
Jakob Stoklund Olesen
8592979fc9 Add Layout::insert_ebb_after() method.
Symmetrical with the existing insert_ebb().
2016-10-14 13:54:26 -07:00
Jakob Stoklund Olesen
10c579e0cd Add Layout::split_ebb().
This method splits an EBB in two and moves trailing instructions to a
new EBB.
2016-10-14 12:33:54 -07:00
Jakob Stoklund Olesen
6f68673e8a Add Cursor::insert_inst().
Insert an instruction at thecurrent cursor position.
2016-10-14 10:09:57 -07:00
Jakob Stoklund Olesen
d650d30b88 Add a LAyout Cursor data structure.
A layout cursor can be used instead of an iterator to keep track of a
position in a basic block *and* permitting instructions to be
manipulated.
2016-10-13 14:36:34 -07:00
Jakob Stoklund Olesen
8ca970ba5c Generate a Builder data type. WIP.
The Builder provides a convenient interface for inserting instructions
into an extended basic block.

The bulk of the builder methods are generated automatically from the
meta language instruction descriptions.

Still TODO: Keep track of an insertion position.
2016-10-12 16:47:11 -07:00
Jakob Stoklund Olesen
5a2f8cbdf8 Move second_result outside boxed storage.
In instruction formats that have multiple results AND boxed storage,
place the second_result field outside the boxed storage. The 16-byte
instruction format has room for opcode, type, second_result in the first
8 bytes, and the boxed pointer in the last 8 bytes.

This provides a simpler implementation of the second_result() and
second_result_mut() InstructionData methods.
2016-10-12 16:01:06 -07:00
Jakob Stoklund Olesen
f78baf9c0b Capture the Rust type used to represent an operand kind.
The Rust type is usually the camel-cased name of the operand kind, but
there are variations, so allow an explicit rust_type='IntCC' when
defining operand kinds.
2016-10-12 15:51:50 -07:00
Jakob Stoklund Olesen
b8a537bb13 Add simple Uimm8 and ImmVector immediate types.
Implement the boxed storage of the UnaryImmVector instruction format.
2016-10-12 15:51:22 -07:00
Jakob Stoklund Olesen
7cf25a073b Add FuncRef and SigRef entity references.
These refer to external functions and function signatures declared in
the preamble. Since we're already using the type names 'Signature' and
'Function', these entity references don't folow the usual EntityData /
Entity naming convention.
2016-10-12 15:20:46 -07:00
Jakob Stoklund Olesen
b42d85ae24 Move signatures into new ir::extfunc module.
This new module will gain more data types dealing with external function
calls.
2016-10-12 13:56:26 -07:00
Jakob Stoklund Olesen
b258644d07 Use 'varargs' consistently for VariableArgs members.
The meta code generators need to be able to infer these too.
2016-10-12 13:56:26 -07:00
Jakob Stoklund Olesen
2372486ec5 Track InstructionData member names.
Entity references in instruction format operands also have member names
in the InstructionData struct. Track them the same way we track immediate operand member names.

Value operands still go in the arg / args members.
2016-10-12 13:56:26 -07:00
Jakob Stoklund Olesen
02eae6afd0 Upgrade to rustfmt 0.6.2 2016-10-12 13:56:26 -07:00
Jakob Stoklund Olesen
67abb2d2f6 Create a phantom workspace manifest for all crates.
Share a single Cargo.lock and target directory at the repo top-level.
2016-10-10 10:52:48 -07:00
Jakob Stoklund Olesen
a460a637dd Add legalization patterns. 2016-10-07 14:18:36 -07:00
Jakob Stoklund Olesen
7c91bacafe Define AST nodes and instruction transformations.
Enable syntax: iadd(x, y) which creates an Apply node.
Enable syntax: z << iadd(x, y) which creates a Def node.

Add an XForm class which represents source and destination patterns as
RTL lists.
2016-10-07 14:18:36 -07:00
Jakob Stoklund Olesen
29c449f117 Add legalization helper instructions.
The isplit_lohi instruction breaks an integer into two halves. This will
typically be used to get the two halves of an `i64` value on 32-bit
CPUs.

The iconcat_lohi is the reverse operation. It reconstructs the `i64`
from the low and high bits.
2016-09-27 16:22:32 -07:00
Jakob Stoklund Olesen
2a2871e739 Expand OpcodeConstraints to 32 bits.
Make room for 255 different type sets and 2^16 entries in the operand
constraints table.
2016-09-27 16:09:26 -07:00
Jakob Stoklund Olesen
60b2257331 Add HalfWidth and DoubleWidth type variable functions.
These functions compute types with half or double the number of bits in
each lane.
2016-09-27 15:39:54 -07:00
Jakob Stoklund Olesen
65caf2d9a1 In-place intersection of type sets. 2016-09-27 14:54:44 -07:00
Jakob Stoklund Olesen
470507dd9b Add some Python tests for TypeSet. 2016-09-27 14:54:44 -07:00
Jakob Stoklund Olesen
d7e9d4dade Run Python unittests and doctests.
Add a meta/check.sh script that runs unit tests before the syntax
linters.

Add unittest converters for the existing doctests.
2016-09-27 13:45:05 -07:00
Jakob Stoklund Olesen
d45b011fa2 Represent type sets with ranges.
Allow limits on the smallest and largest integer type in the set, the
highest and lowest number of lanes etc.
2016-09-27 13:31:31 -07:00
Jakob Stoklund Olesen
b06668aa8a Move TypeVar and TypeSet into their own Python package.
These classes are not very entangled with the rest of __init__, and
we'll be expanding them a bit.
2016-09-27 10:53:53 -07:00
Jakob Stoklund Olesen
d915718526 Add documentation links to all existing instructions. 2016-09-23 16:53:48 -07:00
Jakob Stoklund Olesen
686aa4ec1d Add an autoinstgroup Sphinx directive.
This directive documents an instruction group and lists all instructions
contained in the group, whether they have been documented or not.
2016-09-23 16:53:47 -07:00
Jakob Stoklund Olesen
f66d84fd95 Integer subtraction with borrow flags.
This is the x86-style of borrow flags. ARM uses subtract-with-carry
which inverts the sense of the carry flag.
2016-09-23 15:47:39 -07:00
Jakob Stoklund Olesen
9cb3451432 Integer add with carry instructions.
Integer addition with carry in/out/both.
2016-09-23 13:42:00 -07:00
Jakob Stoklund Olesen
7ec54a5a01 Add a Cretonne testing guide.
Describe the basics of Rust-level tests, and go into more detail about
the file-level tests.
2016-09-23 11:37:40 -07:00
Jakob Stoklund Olesen
0dd16a360d Basic *.cton syntax mode for Vim. 2016-09-23 10:41:35 -07:00
Jakob Stoklund Olesen
65f69fb088 Add a 'test legaliser' filetest command.
This test command sends each function through legalize_function() and
then filecheck.
2016-09-21 17:36:06 -07:00
Jakob Stoklund Olesen
6a71613d92 Write out encoding annotations on instructions.
All instructions with associated encodings are now annotated with
encoding information in a column before the code.

When write_function() is givan a TargetIsa reference, the annotations use
ISA-specific names. Otherwise everything is numeric.
2016-09-21 17:36:05 -07:00
Jakob Stoklund Olesen
ea901653da Print encodings as [R#10c] instead of [R/10c].
The # is a more conventional prefix for hexadecimal, and when ISA
information is not available, there may be a decimal number in front
which would be confusing.

So prefer [1#10c] for the ISA-less encoding format. Here '1' is decimal
and '#10c' is hexadecimal.
2016-09-21 17:24:41 -07:00
Jakob Stoklund Olesen
1c4eb44ef7 Expose Vec::get() in EntityMap. 2016-09-21 17:24:41 -07:00
Jakob Stoklund Olesen
7587a51bd7 Pass flags and target ISAs to filetests.
Add a `needs_isa()` method to the SubTest trait, and pass a TargetIsa
trait object to those sub-tests that request it.

When multiple sub-tests and ISAs are specified, test the cross product.

If a sub-test requires an ISA, but none are specified, fail the test. In
the future, it may be a good idea to generate a default set of ISAs and
test against those.
2016-09-21 12:56:40 -07:00
Jakob Stoklund Olesen
36b143df99 Parse ISA specifications between test commands and functions.
Some tests are only applicable to specific ISAs. This can be indicated
with an ISA specification:

    test legalizer
    isa riscv
    function foo() {
        ....
    }

The ISA specifications have the same format as the test lines: The name
of the ISA following by optional settings until the end of the line.

Also parse `set` commands mixed in with the `isa` commands. These are
used to set ISA-independent settings as defined in
meta/cretonne/settings.py.
2016-09-21 09:25:24 -07:00
Jakob Stoklund Olesen
83adf341ec Allow settings::Builder to be reused.
When constructing the Flags object from the Builder, don't consume it,
but take a reference instead.

This makes it possible for the parser to accept multiple 'set' lines and
apply them to different ISA specifications.
2016-09-20 16:11:39 -07:00
Jakob Stoklund Olesen
26332f6f91 Share split_entity_name between lexer and sourcemap.
There's only one way of parsing entity names correctly.
2016-09-20 13:20:33 -07:00
Jakob Stoklund Olesen
64490a3587 Don't have keywords in the lexer and parser.
Instead of recognizing "function" as a keyword, simply match it as a
context-sensitive keyword in the parser outside functions.
2016-09-20 13:00:37 -07:00
Jakob Stoklund Olesen
fab16941c8 Add a stub implementation of the legalizer.
This basic version only fills in the encoding of already-legal
instructions. It doesn't have any way of transforming the illegal
instructions yet.
2016-09-20 10:53:05 -07:00
Jakob Stoklund Olesen
1d0ab91136 Store instruction encodings in Function.
This is a side-table of ISA-dependent information that will initially be
filled out by the legalizer.
2016-09-20 10:17:16 -07:00
Jakob Stoklund Olesen
57b6967ddd Add clear, is_empty, and resize methods to EntityMap.
These are simply forwards from the underlying Vec.
2016-09-20 10:00:30 -07:00