Commit Graph

353 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
e35811e120 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
75406ad5be 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
e5080fb64e 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
eeb6fe0983 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
6158b7449a Upgrade to rustfmt 0.6.2 2016-10-12 13:56:26 -07:00
Jakob Stoklund Olesen
6b784dd8dc 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
3207e60795 Add legalization patterns. 2016-10-07 14:18:36 -07:00
Jakob Stoklund Olesen
620f46202f 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
4db11d1ae7 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
2a4aaa3da1 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
d256c46f60 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
a14bb077ee In-place intersection of type sets. 2016-09-27 14:54:44 -07:00
Jakob Stoklund Olesen
f66a6b3509 Add some Python tests for TypeSet. 2016-09-27 14:54:44 -07:00
Jakob Stoklund Olesen
efa1b8a9ec 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
a616a46db7 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
8cbaacac48 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
6f243ab35d Add documentation links to all existing instructions. 2016-09-23 16:53:48 -07:00
Jakob Stoklund Olesen
6d3883cf78 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
f34da59bab 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
b1bd3140db Integer add with carry instructions.
Integer addition with carry in/out/both.
2016-09-23 13:42:00 -07:00
Jakob Stoklund Olesen
acf41a7c09 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
5112ddc13d Basic *.cton syntax mode for Vim. 2016-09-23 10:41:35 -07:00
Jakob Stoklund Olesen
51bcc78cea 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
ce0da25ce0 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
2ec50203fb 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
4e09b48dd4 Expose Vec::get() in EntityMap. 2016-09-21 17:24:41 -07:00
Jakob Stoklund Olesen
16dba4d35b 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
e4a8932962 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
8a764cba3f 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
a078f6a6b0 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
5aa1db2e4f 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
de35e715fa 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
ebadbdbe7e 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
7417f884b3 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
Jakob Stoklund Olesen
388154e06b Wrap FunctionName in a newtype struct.
Function names display differently than normal strings since they need
quotes and escaping.

Move the FunctionName type into its own module.
2016-09-19 15:09:25 -07:00
Jakob Stoklund Olesen
6fb566fa85 Add a TargetIsa::display_enc() method.
The interpretation of an encoding depends on the target ISA, and so does
the proper printing of the encoding.
2016-09-19 13:45:22 -07:00
Jakob Stoklund Olesen
fb1bc5d096 Move 'Encoding' into its own module. 2016-09-19 13:07:58 -07:00
Jakob Stoklund Olesen
b5ffd3af92 Rename 'encoding' modules to 'enc_tables'.
These modules contain encoding tables, not the 'Encoding' struct.
2016-09-19 13:00:16 -07:00
Jakob Stoklund Olesen
047bf5ab28 Remove the inst_locs vector in the parser.
Use the source map to track instruction locations instead.

The rewrite methods now take an AnyEntity argument as the location to
use for errors. This means that bad EBB references in jump tables are
now reported correctly.
2016-09-19 11:47:57 -07:00
Jakob Stoklund Olesen
1a73b4f3f2 Also record locations for tracked entities. 2016-09-19 11:29:55 -07:00
Jakob Stoklund Olesen
b5514748a4 Add an internal MutableSourceMap trait.
Use the SourceMap for mapping during parsing too.
2016-09-19 11:13:11 -07:00
Jakob Stoklund Olesen
ac46de7200 Extract Result and Error into their own module.
Also include the err! macro and make it usable outside the module.
2016-09-19 10:23:51 -07:00
Jakob Stoklund Olesen
b5828cb9a3 Print out a report of slow-running tests.
The slow tests are computed as those that would be printed as outliers
on a boxplot of all the test runtimes. These are more than 1.5
inter-quartile range away from the 75% quartile.
2016-09-18 11:35:10 -07:00
Jakob Stoklund Olesen
67c8ae7f14 Add --verbose flag to cton-util test. 2016-09-17 17:11:17 -07:00
Jakob Stoklund Olesen
23887358dd Simplify with unwrap_or_else(). 2016-09-17 12:36:35 -07:00
Jakob Stoklund Olesen
a4774ce87d Record the location of parsed functions.
Remember the location of the 'function' keyword that starts every
function. This can be useful for reporting test failures etc.
2016-09-17 11:42:08 -07:00
Jakob Stoklund Olesen
81f26422fa Tell Travis to cache Cargo intermediate build products.
The CI builds were using a lot of time downloading and building crates.
2016-09-17 11:29:52 -07:00
Jakob Stoklund Olesen
b2f0dd7da3 Run tests concurrently.
Spin up one worker thread per cpu, and run filetests on all of them. Use
a reorder buffer in Runner to make sure results are still reported in
order.

Individual test files given as command line arguments are still run
synchronously for easier debugging. Only directories are run on worker
threads. The recursive directory traversal is still happening on the
main thread.

Use a heartbeat thread to send ticks on the reply channel every second,
and use the ticks to detect tests that are stuck. When
Receiver::recv_timeout() is stabilized, we can probably get rid of the
heartbeat thread.

Catch panics on the worker threads and report them as test failures.
2016-09-17 10:58:53 -07:00
Jakob Stoklund Olesen
5ea9a43928 Simplify job queue.
Always keep PathBufs for every entry in the test list. When concurrent
testing is enabled, we'll want to clone the path for the worker threads.

Remove the Job struct for the same reason.
2016-09-16 21:50:15 -07:00
Jakob Stoklund Olesen
91167f0153 Move the code to run test into its own module.
Loading a file and running the test in it can be separated from the
mechanics of running multiple tests and scanning directories for test
files.
2016-09-16 21:09:37 -07:00