Commit Graph

502 Commits

Author SHA1 Message Date
Jakob Stoklund Olesen
6e33173fce Install rustfmt when running under Travis CI.
The built rustfmt should be cached.
2017-01-25 15:42:16 -08:00
Jakob Stoklund Olesen
5b71ec922a Add pip files to the cache. 2017-01-25 15:35:58 -08:00
Jakob Stoklund Olesen
c132b8c328 Upgrade to rustfmt 0.7.1 2017-01-25 15:17:27 -08:00
Jakob Stoklund Olesen
188ffb9881 Doesn't work with 12.02 LTS's Python 3.2.
Try switching to Trusty to get a newer Python 3.
2017-01-25 14:59:48 -08:00
Jakob Stoklund Olesen
f2b567b83f The python3-pip package does not exist on Ubuntu 12.04 LTS.
Try to go via python3-setuptools instead.
2017-01-25 14:51:48 -08:00
Jakob Stoklund Olesen
27e735b028 Pull in a python3 Ubuntu package for Travis CI.
Then use pip3 to install dependencies.
2017-01-25 14:45:41 -08:00
Jakob Stoklund Olesen
8635aedc20 Use Python 3.6 in Travis builds 2017-01-25 14:32:52 -08:00
Jakob Stoklund Olesen
c111361e19 Install Python packages without Travis root user. 2017-01-25 14:26:28 -08:00
Jakob Stoklund Olesen
42a0c27b24 Install mypy and flake8 in Travis environment. 2017-01-25 14:20:22 -08:00
Jakob Stoklund Olesen
2932d41f18 Run Python checks from test-all.sh
The Python style enforcements are easy to miss otherwise.
2017-01-25 14:12:36 -08:00
Jakob Stoklund Olesen
672e4abd7e Compute register class intersections.
Ensure that the set of register classes is closed under intersection.

Provide a RegClass::intersect() method which finds the register class
representing the intersection of two classes.

Generate a bit-mask of subclasses for each register class to be used by
the intersect() method.

Ensure that register classes are sorted topologically. This is also used
by the intersect() method.
2017-01-25 13:57:43 -08:00
Jakob Stoklund Olesen
0394f35034 Add operand register constraints.
Every encoding recipe must specify register constraints on input and
output values.

Generate recipe constraint tables along with the other encoding tables.
2017-01-25 13:35:18 -08:00
Jakob Stoklund Olesen
58dedb673a Add an AllocatableSet for registers.
This set of available register units also manages register aliasing in
an efficient way.

Detect if the units in a register straddles mask words. The algorithm
for allocating multi-unit registers expect the whole register to be
inside a single mask word. We could handle this if necessary, but so far
no ISAs need it.
2017-01-23 12:43:32 -08:00
Jakob Stoklund Olesen
ae926157c2 Generate register class descriptors.
Add a mechanism for defining sub-classes of register classes.
2017-01-20 14:23:06 -08:00
Jakob Stoklund Olesen
ac798c1aed Fix flake8 style issue. 2017-01-20 10:33:45 -08:00
Jakob Stoklund Olesen
8f2ca7c471 Remove EntityRef::wrap().
This has been superceded by PackedOption.
2017-01-20 09:35:57 -08:00
Jakob Stoklund Olesen
1221d94272 Remove NO_INST and the Default+Ord impls for Inst.
Clean up comments.

Add an assertion to check that PackedOption is working as designed.
2017-01-19 19:44:16 -08:00
Jakob Stoklund Olesen
4aa5c313ea Use PackedOption<Inst> in the dominator tree.
Also rework the algorithm to be more robust against unreachable blocks.

- Add an is_reachable(ebb) method.
- Change idom(ebb) to just return an instruction.
- Make idom() return None for the entry block as well as unreachable
  blocks.
2017-01-19 19:44:16 -08:00
Jakob Stoklund Olesen
2e6cf219e9 Use PackedOption<Value> instead of NO_VALUE.
- Remove NO_VALUE and ExpandedValue::None.
- Remove the Default implelmentation for Value.
- InstructionData::second_result() returns an Option<Value>.
- InstructionData::second_result() returns a reference to the packed
  option.
2017-01-19 15:55:18 -08:00
Jakob Stoklund Olesen
f2b9f62f24 Avoid using NO_INST in the parser.
This was only used for the comment rewrite mechanism, and we can just
predict the next allocated instruction number instead. See the other
uses of next_key() for gather_comments().
2017-01-19 14:49:55 -08:00
Jakob Stoklund Olesen
3fc0f80223 Use PackedOption<Inst> in the Layout implementation.
This also revealed that the last_inst() method should return an Option.
2017-01-19 14:26:47 -08:00
Jakob Stoklund Olesen
52db486500 Use PackedOption<Ebb> in the Layout implementation.
The doubly linked lists are terminated with None.

Remove NO_EBB and the Default impl for Ebb.
2017-01-19 14:05:32 -08:00
Jakob Stoklund Olesen
5fc222348d Use PackedOption<Ebb> to represent jump tables.
Avoid NO_EBB.
2017-01-19 13:41:56 -08:00
Jakob Stoklund Olesen
f004f370c5 Remove Default implementations from many entity references.
These types can be wrapped in a PackedOption now, so we don't need the
NO_* constants and default values.
2017-01-19 13:15:50 -08:00
Jakob Stoklund Olesen
c041a51e2e Move duplicated entity code into a macro.
Implement ReservedValue for all the entities.
2017-01-19 13:11:50 -08:00
Jakob Stoklund Olesen
e8993e79e4 Implement PackedOption to address #19.
The PackedOption<T> struct uses the same amount of memory as T, but can
represent None via a reserved value.
2017-01-19 13:10:32 -08:00
Jakob Stoklund Olesen
7b80bd03e3 Update regalloc document to reflect implementation. 2017-01-19 11:04:11 -08:00
Jakob Stoklund Olesen
8033deda3a Add a liveness analysis.
This code is best tested with larger functions with more EBBs.
Perhaps a new file-test category is in order?
2017-01-13 11:59:00 -08:00
Jakob Stoklund Olesen
8390c829d3 Implement DoubleEndedIterator for the ebb_insts() iterator.
Make it possible to iterate backwards over the instructions in an EBB.
2017-01-10 15:33:03 -08:00
Jakob Stoklund Olesen
29777e26ee Allow live ranges to be values in a SparseMap.
This requires the value number to be stored in the live range itself.
2017-01-10 14:21:56 -08:00
Jakob Stoklund Olesen
a26a8b5f0d Add iteration support to SparseMap.
This is simply the slice iterator for the dense vector.

- map.values() returns an iterator with references to the values.
- for i in &map iterates over references to the values.
2017-01-10 13:54:46 -08:00
Jakob Stoklund Olesen
56177ce351 Implement a SparseMap data structure.
This implements the classic Briggs/Torczon sparse set construct.

Adapt it to our existing EntityRef infrastructure so we can use types
keys instead of just integers like the original paper does.

Also provide a SparseSet<T> type alias which implements a sparse set of
entity refeences. This is actually closer to what the original paper
describes.
2017-01-10 11:38:26 -08:00
Jakob Stoklund Olesen
94a54eaf30 Add a LiveRange data structure.
We will track live ranges separately for each SSA value, rather than per
virtual register like LLVM does.

This is the basis for a register allocator, so place it in a new
regalloc module.
2017-01-06 17:16:25 -08:00
Jakob Stoklund Olesen
27483d9396 Encourage better optimization of ProgramOrder::cmp.
The ProgramOrder::cmp() comparison is often used where one or both
arguments are statically known to be an Inst or Ebb. Give the compiler a
better chance to discover this via inlining and other optimizations.

- Make cmp() generic with Into<ExpandedProgramPoint> bounds.
- Implement the natural From<T> traits for ExpandedProgramPoint.
- Make Layout::pp_seq() generic with the same bound.

Now, with inlining and constant folding, passing an Inst argument to
PO::cmp() will result in a call to a monomorphized Layout::seq::<Inst>()
which can avoid the dynamic match to select a table for looking up the
sequence number.

The result is that comparing two program points of statically known type
results in two direct table lookups and a sequence number comparison.

This all uses ExpandedProgramPoint because it is more likely to be
transparent to the constant folder than the bit-packed ProgramPoint
type.
2017-01-05 14:03:09 -08:00
Jakob Stoklund Olesen
f1234003a9 Implement ProgramOrder for Layout.
Assign sequence numbers to both instructions and EBB headers such that
their relative position can be determined in constant time simply by
comparing sequence numbers.

Implement the sequence numbers with a scheme similar to the line numbers
used in BASIC programs. Start out with 10, 20, 30, ... and pick numbers
in the gaps as long as possible. Renumber locally when needed.
2016-12-30 12:22:48 -08:00
Jakob Stoklund Olesen
893a630ca0 Upgrade to rustfmt 0.6.3 2016-12-21 10:06:49 -08:00
Jakob Stoklund Olesen
3568b93b84 Add program points.
Program points are used to represent a linear position in a function.
Thus will be used for the live ranges of values.
2016-12-20 15:50:29 -08:00
Jakob Stoklund Olesen
f9af88c49e Add a ValueLoc type and the locations table.
This table holds the result of register allocation.
2016-12-08 13:57:28 -10:00
Jakob Stoklund Olesen
3392a2b79a Fix Python formatting to keep flake8 happy.
Python coding style is verified by the lib/cretonne/meta/check.sh script
which is not run as part of test-all.sh.

cc @dinfuehr
2016-12-08 13:30:40 -10:00
Dominik Inführ
c1ecb29851 remove old is_terminating function
for InstructionData. Use generated `is_terminator()` for `Opcode`
instead. `is_terminator`, `can_trap` and `is_branch` functions are now
public.

fix syntax error
2016-12-07 10:16:01 -10:00
Dominik Inführ
93aa2b456e added Opcode flags methods
generate `is_branch`, `is_terminator`, `can_trap` methods for `enum
Opcode`.
2016-12-02 15:50:28 -08:00
Jakob Stoklund Olesen
19ac05577c Fill in boilerplate for Intel and ARM targets.
The intel, arm32, and arm32 targets were only defined in the meta
language previously. Add Rust implementations too.

This is mostly boilerplate, except for the unit tests in the
registers.rs files.
2016-11-23 10:42:07 -08:00
Jakob Stoklund Olesen
1f6dd0dab7 Generate register bank descriptions.
Use the information in the ISA's registers.py files to generate a
RegInfo Rust data structure.
2016-11-22 18:15:21 -08:00
Jakob Stoklund Olesen
9cdccf6691 Start a design document for the Cretonne register allocator. 2016-11-21 17:00:16 -08:00
ranma42
977adddc0a Fix some typos in the Language Reference 2016-11-15 08:13:08 -08:00
Jacob Shaffer
a8cd8bc18b Added link to README about nasal demons. 2016-11-14 07:59:23 -08:00
Jakob Stoklund Olesen
4192ba0532 Define register classes for 4 ISAs. 2016-11-11 15:08:12 -08:00
Jakob Stoklund Olesen
b0b6a8f693 Define register banks.
Add a RegBank class for describing CPU register banks.

Define register banks for all the ISA stubs. The ARM32 floating point
bank in particular requires attention.
2016-11-11 14:17:10 -08:00
Jakob Stoklund Olesen
c20d7d8f13 Move some utility functions into the cdsl package.
- is_power_of_two
- next_power_of_two

Make sure we run doctests on these functions.
2016-11-11 13:04:30 -08:00
Jakob Stoklund Olesen
77c672a279 Add stubs for Intel and ARM architectures.
The Intel ISA handles both 32-bit and 64-bit code.

ARM is split into separate arm32 and arm64 ISAs since the architectures
have little in common in instruction encodings and register files.
2016-11-11 11:32:05 -08:00