Commit Graph

94 Commits

Author SHA1 Message Date
wasmtime-publish
8043c1f919 Release Wasmtime 0.33.0 (#3648)
* Bump Wasmtime to 0.33.0

[automatically-tag-and-release-this-commit]

* Update relnotes for 0.33.0

* Wordsmithing relnotes

Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2022-01-05 13:26:50 -06:00
wasmtime-publish
c1c4c59670 Release Wasmtime 0.32.0 (#3589)
* Bump Wasmtime to 0.32.0

[automatically-tag-and-release-this-commit]

* Update release notes for 0.32.0

Co-authored-by: Wasmtime Publish <wasmtime-publish@users.noreply.github.com>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2021-12-13 13:47:30 -06:00
Nick Fitzgerald
6af8d2a292 Rename the isle crate to cranelift-isle
The `isle` crate name is already taken on crates.io :(
2021-12-07 14:56:26 -08:00
Benjamin Bouvier
1b33553cea Tidy up unused dependencies 2021-12-01 11:33:27 +01:00
Chris Fallin
5a765c65ea Add link to ISLE language reference to ISLE Cranelift integration doc. 2021-11-30 13:25:08 -08:00
Chris Fallin
edef533d1f Move ISLE docs into cranelift/isle/docs/ and update links. 2021-11-30 13:24:02 -08:00
Chris Fallin
b6bed81ba2 Add ISLE reference documentation.
This documentation provides details for all of the ISLE language
features, and detailed rationale for why many of them are designed in
the way that they are. It is hopefully both a reasonable tutorial and
reference for someone looking to understand the DSL.

Note that this documentation is separate from and orthogonal to the
work to document the Cranelift bindings and integration work that
@fitzgen has covered well in #3556. This document can link to that one
and vice-versa once they are both in-tree.
2021-11-30 11:42:17 -08:00
Alex Crichton
1141169ff8 aarch64: Initial work to transition backend to ISLE (#3541)
* aarch64: Initial work to transition backend to ISLE

This commit is what is hoped to be the initial commit towards migrating
the aarch64 backend to ISLE. There's seemingly a lot of changes here but
it's intended to largely be code motion. The current thinking is to
closely follow the x64 backend for how all this is handled and
organized.

Major changes in this PR are:

* The `Inst` enum is now defined in ISLE. This avoids having to define
  it in two places (once in Rust and once in ISLE). I've preserved all
  the comments in the ISLE and otherwise this isn't actually a
  functional change from the Rust perspective, it's still the same enum
  according to Rust.

* Lots of little enums and things were moved to ISLE as well. As with
  `Inst` their definitions didn't change, only where they're defined.
  This will give future ISLE PRs access to all these operations.

* Initial code for lowering `iconst`, `null`, and `bconst` are
  implemented. Ironically none of this is actually used right now
  because constant lowering is handled in `put_input_in_regs` which
  specially handles constants. Nonetheless I wanted to get at least
  something simple working which shows off how to special case various
  things that are specific to AArch64. In a future PR I plan to hook up
  const-lowering in ISLE to this path so even though
  `iconst`-the-clif-instruction is never lowered this should use the
  const lowering defined in ISLE rather than elsewhere in the backend
  (eventually leading to the deletion of the non-ISLE lowering).

* The `IsleContext` skeleton is created and set up for future additions.

* Some code for ISLE that's shared across all backends now lives in
  `isle_prelude_methods!()` and is deduplicated between the AArch64
  backend and the x64 backend.

* Register mapping is tweaked to do the same thing for AArch64 that it
  does for x64. Namely mapping virtual registers is supported instead of
  just virtual to machine registers.

My main goal with this PR was to get AArch64 into a place where new
instructions can be added with relative ease. Additionally I'm hoping to
figure out as part of this change how much to share for ISLE between
AArch64 and x64 (and other backends).

* Don't use priorities with rules

* Update .gitattributes with concise syntax

* Deduplicate some type definitions

* Rebuild ISLE

* Move isa::isle to machinst::isle
2021-11-18 10:38:16 -06:00
Nick Fitzgerald
6164ba3814 ISLE: match cranelift version 2021-11-15 11:17:31 -08:00
Nick Fitzgerald
f27b357702 ISLE: update repo in Cargo.toml 2021-11-15 11:16:24 -08:00
Nick Fitzgerald
b6fd3d0c40 Remove extra, unused Cargo.lock 2021-11-15 09:25:29 -08:00
Nick Fitzgerald
b8494822dc ISLE: finish porting imul lowering to ISLE 2021-11-05 15:41:24 -07:00
Nick Fitzgerald
00e7ca206f ISLE: add a missing type check for whether terms used in expressions have a constructor 2021-11-05 14:05:38 -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
Chris Fallin
f227699536 Make ISLE part of the root Cargo workspace. 2021-11-11 16:00:12 -08:00
Nick Fitzgerald
4c61c96c3f Add Cargo.toml metadata 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
e23564700d Add myself as a second author 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
bd8c7faf12 Add support for hex integer literals 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
8f5dffab72 Add better error messages for duplicate term declarations 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
22e18a9d98 Remove eprintln!s that shouldn't have been committed 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
037db8aab6 Make sure that infallible match operations come after fallible ones
Eventually we will probably want to sort by a partial ordering based on pattern
subsumption to break ties between rules with the same priority. This local
heuristic of making sure infallibilty comes last is good enough for now and
handles the cases we care about thus far.

Fixes #10
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
6c6b7a2b78 Add a method to pretty-print a trie 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
0411b20871 Fix allow declaration 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
7fab7c5eab Emit if lets against Option<x> instead of Option<(x,)> 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
0c6956376b Allow irrefutable let patterns in the generated code 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
e015a49270 Do not use 1-member tuples in external constructor/extractor trait methods
Just use the single member type directly.
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
0e02ec4cba Use BTree{Map,Set} instead of Hash{Map,Set} to ensure deterministic output
Fixes #8
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
efe7df7f45 Keep track of where primitives are defined for better error messages 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
fe836a2302 Yield source positions from lexer that have file-relative offsets
They were previously all source texts concatenated-relative offsets, which would
cause `miette` to error out when trying to find the line/col when displaying
errors. Not good to have errors when displaying errors! Gets very confusing when
trying to track down ISLE type errors and things.
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
7f8cb75e54 Allow terms to have both extractors and constructors
Fixes #4
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
fddff6ee2d Fix a panic when checking the call graph for an extractor with type errors in its definition 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
9af23bf061 Report the recursive calls when an extractor is recursive 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
31d1cf3808 Fill out implementation overview in README 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
381dadadd0 Move trie construction out to its own module 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
bffaccde1f Add a tutorial to the README 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
0e082e8d6f Make sure that every decl has a definition at the end of type checking 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
d2bd07c246 Check that integer literals are primitive types in patterns 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
ce207ee953 Check that integer literals are a primitive type 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
a099b2b590 Extend fuzzing to semantic analysis and codegen
* Fix a panic when we are substituting macro args, but we already had an error
  involving the macro.

* Fix a stack overflow when an internal extractor's definition is recursive.
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
9be1942b11 Use .copied() instead of .cloned() 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
6604a26e27 Add a top-level parse function
And make `parse_defs` take `self` by ownership. This avoids a couple `Vec`
clones.
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
e3aeb850b2 Fix a panic when parsing var patterns 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
f2b6244b9c Fix some panics on parsing error paths 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
6a523938de Fix overflows when tokenizing integer literals 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
825258939b Define a fuzz target for the parser 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
cfaa35d8c0 Use structopt to derive CLI flags
Instead of using `clap` directly
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
6ffb02d9f6 Use miette for reporting errors
This gives us errors with annotated context like this:

```
Error:
  × type error: Unknown variable 'x'
    ╭─[isle_examples/let.isle:24:1]
 24 │   (Lower (B.B z))
 25 │   (A.Add x y))
    ·          ┬
    ·          ╰── Unknown variable 'x'
    ╰────
```
2021-11-11 15:56:55 -08:00
Nick Fitzgerald
38da2cee3e Switch to using thiserror 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
b93304b327 Add docs to all public exports and deny(missing_docs) going forward 2021-11-11 15:56:55 -08:00
Nick Fitzgerald
922a3886d5 Fix let variable typing rules 2021-11-11 15:56:55 -08:00