Commit Graph

18 Commits

Author SHA1 Message Date
Dan Gohman
272d03d8fc Add a utility for generating Rust 'match' expressions.
This makes it a little simpler to generate 'match' statements, and
it performs deduplication of identical arms. And it means I don't
have to think about as many strings like '{} {{ {}.. }} => {}'
when I'm trying to think about how instructions work :-).
2018-03-14 10:51:09 -07:00
Dan Gohman
2b9229d715 Fix > 80-column lines for flake8. 2018-03-12 13:02:55 -07:00
Dan Gohman
30f8daa9d6 Replace assert! with debug_assert! in production code paths.
This allows the assertions to be disabled in release builds, so that
the code is faster and smaller, at the expense of not performing the
checks. Assertions can be re-enabled in release builds with the
debug-assertions flag in Cargo.toml, as the top-level Cargo.toml
file does.
2018-03-12 12:38:30 -07:00
Jakob Stoklund Olesen
2f58c371bc Make specific ISA sub-modules private.
We don't want ISA-specific details exposed in the public Cretonne APIs.
2018-02-21 12:06:58 -08:00
Pat Hickey
ed24320eda gen_settings: dont try to display a Preset descriptor in Flags (#241)
* gen_settings: dont try to display a Preset descriptor in Flags

Trying to display a preset doesnt make sense, and before this commit it
does not display anything meaningful - the printout just says e.g.
"haswell =\n".

The offset byte a preset descriptor isnt a valid offset into the
flag bytes, it is actually an offset into the PRESETS table. It will
cause a panic when the offset is out of bounds for the flag bytes,
which happens in the intel isa as of this commit.

* intel settings: test that display impl doesnt panic
2018-02-14 11:51:40 -08:00
Dan Gohman
fae5ffb556 Make generated code more consistent with current rustfmt. 2017-10-30 10:06:23 -07:00
Jakob Stoklund Olesen
98f0a8b8b4 Remove the name field from the PredNode union type.
The name of a predicate was only ever used for named settings that are
computed as a boolean expression of other settings.

- Record the names of these settings in named_predicates instead.
- Remove the name field from all predicates.

Named predicates does not interact well with the interning of predicates
through isa.unique_pred().
2017-07-26 10:14:26 -07:00
Jakob Stoklund Olesen
f651ec4f78 Add a PredicateView type to abstract the predicate bit vector a bit.
The encoding tables contain references to numbered ISA predicates.

- Give the ISA Flags types a predicate_view() method which returns a
  PredicateView.
- Delete the old predicate_bytes() method which returned a raw &[u8].
- Use a 'static lifetime for the encoding list slice in the Encodings
  iterator, and a single 'a lifetime for everything else.
2017-07-24 09:10:58 -07:00
Jakob Stoklund Olesen
f91d747bda Add support for setting presets.
Fixes #11.

Presets are groups of settings and values applied at once. This is used
as a shorthand in test files, so for example "isa intel nehalem" enables
all of the CPUID bits that the Nehalem micro-architecture provides.
2017-07-14 13:57:44 -07:00
Aleksey Kuznetsov
3693735874 Implement an iterator over encodings (#96)
* Implement an iterator over encodings

* Implement TargetIsa::legal_encodings

* Exclude non-boolean settings of isa flags bytes

* Address flake8 long line error
2017-06-19 08:52:19 -07:00
Jakob Stoklund Olesen
ee5f035e31 Upgrade to Rust 1.17.
- Remove some uses of 'static in const and static globals that are no
  longer needed.
- Use the new struct initialization shorthand.
2017-04-27 12:46:44 -07:00
Jakob Stoklund Olesen
fc979c474f Add mypy types for gen_settings.py. 2017-03-30 18:42:06 -07:00
rep-nop
b23f1fb347 Converts all try! macros to ? syntax.
Fixes #46
2017-02-26 07:50:55 -08:00
Jakob Stoklund Olesen
fb4db38dd6 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
0b9b956695 Split out instruction definitions.
- cdsl.instructions defines the Instruction class.
- base.instructions defines the base instruction set.
2016-11-08 12:33:50 -08:00
Jakob Stoklund Olesen
e6b959436d Split out predicates and settings.
- cdsl.predicates defines classes for describing predicates.
- cdsl.settings defines classes for describing settings.
- base.settings defines shared settings.
2016-11-08 10:37:17 -08:00
Jakob Stoklund Olesen
80823b5fc4 Require documentation on cretonne public items. 2016-10-26 19:10:06 -07:00
Jakob Stoklund Olesen
af6355e2ef 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