Commit Graph

12 Commits

Author SHA1 Message Date
bjorn3
c4eab2beb6 Avoid spurious build script runs (#4150)
* Don't attempt to track the generated clif.isle in cargo

This causes the build script to rerun every time for me.

* Put build script debug messages on stderr instead of stdout

This keeps stdout reserved for cargo build script directives
2022-05-12 11:49:20 -07:00
Nick Fitzgerald
d377b665c6 Initial ISLE integration with the x64 backend
On the build side, this commit introduces two things:

1. The automatic generation of various ISLE definitions for working with
CLIF. Specifically, it generates extern type definitions for clif opcodes and
the clif instruction data `enum`, as well as extractors for matching each clif
instructions. This happens inside the `cranelift-codegen-meta` crate.

2. The compilation of ISLE DSL sources to Rust code, that can be included in the
main `cranelift-codegen` compilation.

Next, this commit introduces the integration glue code required to get
ISLE-generated Rust code hooked up in clif-to-x64 lowering. When lowering a clif
instruction, we first try to use the ISLE code path. If it succeeds, then we are
done lowering this instruction. If it fails, then we proceed along the existing
hand-written code path for lowering.

Finally, this commit ports many lowering rules over from hand-written,
open-coded Rust to ISLE.

In the process of supporting ISLE, this commit also makes the x64 `Inst` capable
of expressing SSA by supporting 3-operand forms for all of the existing
instructions that only have a 2-operand form encoding:

    dst = src1 op src2

Rather than only the typical x86-64 2-operand form:

    dst = dst op src

This allows `MachInst` to be in SSA form, since `dst` and `src1` are
disentangled.

("3-operand" and "2-operand" are a little bit of a misnomer since not all
operations are binary operations, but we do the same thing for, e.g., unary
operations by disentangling the sole operand from the result.)

There are two motivations for this change:

1. To allow ISLE lowering code to have value-equivalence semantics. We want ISLE
   lowering to translate a CLIF expression that evaluates to some value into a
   `MachInst` expression that evaluates to the same value. We want both the
   lowering itself and the resulting `MachInst` to be pure and referentially
   transparent. This is both a nice paradigm for compiler writers that are
   authoring and maintaining lowering rules and is a prerequisite to any sort of
   formal verification of our lowering rules in the future.

2. Better align `MachInst` with `regalloc2`'s API, which requires that the input
   be in SSA form.
2021-10-12 17:11:58 -07:00
bjorn3
18bd27e90b Remove legalizer support from cranelift-codegen-meta 2021-09-29 16:27:45 +02:00
Alex Crichton
9e142f8792 Fix some warnings on nightly Rust (#3148)
Looks like these trailing-semicolons-in-macros are likely to become a
hard error in the future, so this updates to remove them as necessary.
2021-08-05 13:02:44 -05:00
Benjamin Bouvier
5889dd2c64 [meta] Add more pub(crate) definitions. 2019-10-29 14:23:10 +01:00
Peter Huene
9f506692c2 Fix clippy warnings.
This commit fixes the current set of (stable) clippy warnings in the repo.
2019-10-24 17:20:12 -07:00
Benjamin Bouvier
e3e66acfb1 [meta] Generate legalizations in the Rust crate; 2019-04-25 11:44:56 +02:00
Benjamin Bouvier
00429ebe99 [meta] Fix outdented_line in srcgen; 2019-04-24 10:47:26 +02:00
Benjamin Bouvier
72b0d26ee9 [meta] Add features to srcgen;
- Adds a compiler warning when the fmtln! macro isn't correctly used.
- Allow to add an empty line.
- Make the output of generated matches more beautiful, by having one
struct per line on the clause.
- Add a method to add match with doesn't read any data from fields.
- Make sure that the placeholder clause of a match is put at the end.
2019-03-27 14:43:27 +01:00
Benjamin Bouvier
603d80615f [meta] Introduce the fmtln! macro to ease writing formatted strings; 2019-02-20 11:31:38 +01:00
Benjamin Bouvier
c8e09cb37f [meta] Use AsRef<str> to allow passing String or &str to Formatter functions; 2019-02-20 11:31:38 +01:00
lazypassion
747ad3c4c5 moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
2019-01-28 15:56:54 -08:00