Commit Graph

257 Commits

Author SHA1 Message Date
Afonso Bordado
437f448a8d cranelift: Cleanup testing docs (#5549)
Removes some docs from tests that we no longer have.
Updates the ebb examples to the new block based examples.
2023-01-09 10:02:59 -08:00
Alexa VanHattum
4bc4fae571 Small update for filename in isle_integration.md (#5516)
* Small update for filename in `isle_integration.md`

The name "clif.isle" is stale (since #4953), now two files "clif_lower.isle" and "clif_opt.isle" are generated. Not sure if that PR necessitates other changes this this doc.

* Update cranelift/docs/isle-integration.md

Co-authored-by: Jamey Sharp <jsharp@fastly.com>
2023-01-04 20:06:49 +00:00
AnthonyMikh
0c615365c6 Fix link to object library (#5491) 2022-12-29 18:16:51 -08:00
Nick Fitzgerald
c0b587ac5f Remove heaps from core Cranelift, push them into cranelift-wasm (#5386)
* cranelift-wasm: translate Wasm loads into lower-level CLIF operations

Rather than using `heap_{load,store,addr}`.

* cranelift: Remove the `heap_{addr,load,store}` instructions

These are now legalized in the `cranelift-wasm` frontend.

* cranelift: Remove the `ir::Heap` entity from CLIF

* Port basic memory operation tests to .wat filetests

* Remove test for verifying CLIF heaps

* Remove `heap_addr` from replace_branching_instructions_and_cfg_predecessors.clif test

* Remove `heap_addr` from readonly.clif test

* Remove `heap_addr` from `table_addr.clif` test

* Remove `heap_addr` from the simd-fvpromote_low.clif test

* Remove `heap_addr` from simd-fvdemote.clif test

* Remove `heap_addr` from the load-op-store.clif test

* Remove the CLIF heap runtest

* Remove `heap_addr` from the global_value.clif test

* Remove `heap_addr` from fpromote.clif runtests

* Remove `heap_addr` from fdemote.clif runtests

* Remove `heap_addr` from memory.clif parser test

* Remove `heap_addr` from reject_load_readonly.clif test

* Remove `heap_addr` from reject_load_notrap.clif test

* Remove `heap_addr` from load_readonly_notrap.clif test

* Remove `static-heap-without-guard-pages.clif` test

Will be subsumed when we port `make-heap-load-store-tests.sh` to generating
`.wat` tests.

* Remove `static-heap-with-guard-pages.clif` test

Will be subsumed when we port `make-heap-load-store-tests.sh` over to `.wat`
tests.

* Remove more heap tests

These will be subsumed by porting `make-heap-load-store-tests.sh` over to `.wat`
tests.

* Remove `heap_addr` from `simple-alias.clif` test

* Remove `heap_addr` from partial-redundancy.clif test

* Remove `heap_addr` from multiple-blocks.clif test

* Remove `heap_addr` from fence.clif test

* Remove `heap_addr` from extends.clif test

* Remove runtests that rely on heaps

Heaps are not a thing in CLIF or the interpreter anymore

* Add generated load/store `.wat` tests

* Enable memory-related wasm features in `.wat` tests

* Remove CLIF heap from fcmp-mem-bug.clif test

* Add a mode for compiling `.wat` all the way to assembly in filetests

* Also generate WAT to assembly tests in `make-load-store-tests.sh`

* cargo fmt

* Reinstate `f{de,pro}mote.clif` tests without the heap bits

* Remove undefined doc link

* Remove outdated SVG and dot file from docs

* Add docs about `None` returns for base address computation helpers

* Factor out `env.heap_access_spectre_mitigation()` to a local

* Expand docs for `FuncEnvironment::heaps` trait method

* Restore f{de,pro}mote+load clif runtests with stack memory
2022-12-15 00:26:45 +00:00
Ulrich Weigand
e913cf3647 Remove IFLAGS/FFLAGS types (#5406)
All instructions using the CPU flags types (IFLAGS/FFLAGS) were already
removed.  This patch completes the cleanup by removing all remaining
instructions that define values of CPU flags types, as well as the
types themselves.

Specifically, the following features are removed:
- The IFLAGS and FFLAGS types and the SpecialType category.
- Special handling of IFLAGS and FFLAGS in machinst/isle.rs and
  machinst/lower.rs.
- The ifcmp, ifcmp_imm, ffcmp, iadd_ifcin, iadd_ifcout, iadd_ifcarry,
  isub_ifbin, isub_ifbout, and isub_ifborrow instructions.
- The writes_cpu_flags instruction property.
- The flags verifier pass.
- Flags handling in the interpreter.

All of these features are currently unused; no functional change
intended by this patch.

This addresses https://github.com/bytecodealliance/wasmtime/issues/3249.
2022-12-09 13:42:03 -08:00
Jamey Sharp
ff5abfd993 cranelift-isle: Minor error-handling cleanups (#5338)
- Remove remaining references to Miette
- Borrow implementation of `line_starts` from codespan-reporting
- Clean up a use of `Result` that no longer conflicts with a local
  definition
- When printing plain errors, add a blank line between errors for
  readability
2022-11-29 03:07:05 +00:00
Trevor Elliott
32a7593c94 cranelift: Remove booleans (#5031)
Remove the boolean types from cranelift, and the associated instructions breduce, bextend, bconst, and bint. Standardize on using 1/0 for the return value from instructions that produce scalar boolean results, and -1/0 for boolean vector elements.

Fixes #3205

Co-authored-by: Afonso Bordado <afonso360@users.noreply.github.com>
Co-authored-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Co-authored-by: Chris Fallin <chris@cfallin.org>
2022-10-17 16:00:27 -07:00
bjorn3
a4aa7258de Remove some dead code from the abi code (#4653)
These were originally used by the old backend framework as part of
legalizing function signatures for the respective ABI.
2022-08-09 12:21:55 -07:00
Chris Fallin
43f1765272 Cranellift: remove Baldrdash support and related features. (#4571)
* Cranellift: remove Baldrdash support and related features.

As noted in Mozilla's bugzilla bug 1781425 [1], the SpiderMonkey team
has recently determined that their current form of integration with
Cranelift is too hard to maintain, and they have chosen to remove it
from their codebase. If and when they decide to build updated support
for Cranelift, they will adopt different approaches to several details
of the integration.

In the meantime, after discussion with the SpiderMonkey folks, they
agree that it makes sense to remove the bits of Cranelift that exist
to support the integration ("Baldrdash"), as they will not need
them. Many of these bits are difficult-to-maintain special cases that
are not actually tested in Cranelift proper: for example, the
Baldrdash integration required Cranelift to emit function bodies
without prologues/epilogues, and instead communicate very precise
information about the expected frame size and layout, then stitched
together something post-facto. This was brittle and caused a lot of
incidental complexity ("fallthrough returns", the resulting special
logic in block-ordering); this is just one example. As another
example, one particular Baldrdash ABI variant processed stack args in
reverse order, so our ABI code had to support both traversal
orders. We had a number of other Baldrdash-specific settings as well
that did various special things.

This PR removes Baldrdash ABI support, the `fallthrough_return`
instruction, and pulls some threads to remove now-unused bits as a
result of those two, with the  understanding that the SpiderMonkey folks
will build new functionality as needed in the future and we can perhaps
find cleaner abstractions to make it all work.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1781425

* Review feedback.

* Fix (?) DWARF debug tests: add `--disable-cache` to wasmtime invocations.

The debugger tests invoke `wasmtime` from within each test case under
the control of a debugger (gdb or lldb). Some of these tests started to
inexplicably fail in CI with unrelated changes, and the failures were
only inconsistently reproducible locally. It seems to be cache related:
if we disable cached compilation on the nested `wasmtime` invocations,
the tests consistently pass.

* Review feedback.
2022-08-02 19:37:56 +00:00
Chris Fallin
d8ba1ddc86 Update Cranelift-ISLE integration docs to reflect no more checked-in code. (#4229)
* Update Cranelift-ISLE integration docs to reflect no more checked-in code.

In #4143, we removed the checked-in-generated-code aspect of the ISLE
build process, in order to simplify the development cycle and reduce
errors. However, I failed to update the docs at the same time. This PR
fixes that. Supersedes #4228 (thanks @jlb6740 for noticing this issue!).

* fix typo
2022-06-06 12:54:23 -07:00
Saúl Cabrera
2d8ff7a9a9 docs: Remove regalloc entry from documentation index (#4179)
This is a follow up to
https://github.com/bytecodealliance/wasmtime/pull/4013 in which the
outdated regalloc documentation was removed.
2022-05-22 15:40:38 -07:00
uint256_t
057c9865c2 Delete cranelift regalloc document (#4013) 2022-04-11 13:55:55 -07:00
Chris Fallin
9dbb8c25c5 Implicit type conversions in ISLE (#3807)
Add support for implicit type conversions to ISLE.

This feature allows the DSL user to register to the compiler that a
particular term (used as a constructor or extractor) converts from one
type to another. The compiler will then *automatically* insert this term
whenever a type mismatch involving that specific pair of types occurs.

This significantly cleans up many uses of the ISLE DSL. For example,
when defining the compiler backends, we often have newtypes like `Gpr`
around `Reg` (signifying a particular type of register); we can define
a conversion from Gpr to Reg automatically.

Conversions can also have side-effects, as long as these side-effects
are idempotent. For example, `put_value_in_reg` in a compiler backend
has the effect of marking the value as used, causing codegen to produce
it, and assigns a register to the value; but multiple invocations of
this will return the same register for the same value. Thus it is safe
to use it as an implicit conversion that may be invoked multiple times.
This is documented in the ISLE-Cranelift integration document.

This PR also adds some testing infrastructure to the ISLE compiler,
checking that "pass" tests pass through the DSL compiler, "fail" tests
do not, and "link" tests are able to generate code and link that code
with corresponding Rust code.
2022-02-23 13:15:27 -08:00
Nick Fitzgerald
98f32968f5 docs: Fix typo in ISLE and Cranelift integration docs (#3652) 2022-01-05 13:17:56 -06: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
001d91c73c Address review feedback. 2021-11-30 11:42:17 -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
Nick Fitzgerald
66432ab461 docs: Clarify isle integration docs 2021-11-29 17:01:55 -08:00
Nick Fitzgerald
f148b50201 Add a document describing how ISLE is integrated with Cranelift 2021-11-29 17:01:55 -08:00
Nick Fitzgerald
dbe01ff51e Remove references to the old postopt pass 2021-10-07 14:44:07 -07:00
Benjamin Bouvier
43a86f14d5 Remove more old backend ISA concepts (#3402)
This also paves the way for unifying TargetIsa and MachBackend, since now they map one to one. In theory the two traits could be merged, which would be nice to limit the number of total concepts. Also they have quite different responsibilities, so it might be fine to keep them separate.

Interestingly, this PR started as removing RegInfo from the TargetIsa trait since the adapter returned a dummy value there. From the fallout, noticed that all Display implementations didn't needed an ISA anymore (since these were only used to render ISA specific registers). Also the whole family of RegInfo / ValueLoc / RegUnit was exclusively used for the old backend, and these could be removed. Notably, some IR instructions needed to be removed, because they were using RegUnit too: this was the oddball of regfill / regmove / regspill / copy_special, which were IR instructions inserted by the old regalloc. Fare thee well!
2021-10-04 10:36:12 +02:00
Afonso Bordado
f4ff7c350a cranelift: Add heap support to filetest infrastructure (#3154)
* cranelift: Add heap support to filetest infrastructure

* cranelift: Explicit heap pointer placement in filetest annotations

* cranelift: Add documentation about the Heap directive

* cranelift: Clarify that heap filetests pointers must be laid out sequentially

* cranelift: Use wrapping add when computing bound pointer

* cranelift: Better error messages when invalid signatures are found for heap file tests.
2021-08-24 09:28:41 -07:00
LYK
3f2d36d532 Fix an incorrect link. 2021-03-20 03:41:03 +09:00
bjorn3
411ec3a857 Rename SimpleJIT to JIT as it isn't simple anymore 2020-12-04 13:21:13 -08:00
Pat Hickey
35c100fdca delete cranelift-faerie
see https://github.com/bytecodealliance/wasmtime/pull/1816

DEPRECATION NOTICE: the Cranelift developer team intends to stop maintaining
the `cranelift-faerie` crate and remove it from the `wasmtime` git repository
on or after August 3, 2020. We recommend users use its successor, the
`cranelift-object` crate.
2020-08-18 11:02:14 -07:00
Ömer Sinan Ağacan
0592b5a995 Fix umbrella crate URL in docs/index.md (#1694) 2020-05-13 17:05:55 -07:00
Cerberuser
f5eab5225f Fixed links in compare-llvm.md (#1690)
Several links were broken by line-breaks between the link caption and
the link itself. This commit fixes them by moving each on its own line.

Co-authored-by: k.bagrov <k.bagrov@g.nsu.ru>
2020-05-13 11:52:36 +02:00
Andrew Brown
d6796d0d23 Improve documentation of the filetest run command (#1645)
* Improve output display of RunCommand

The previous use of Debug for displaying `print` and `run` results was less than clear.

* Avoid checking the types of vectors during trampoline construction

Because DataValue only understands `V128` vectors, we avoid type-checking vector values when constructing the trampoline arguments.

* Improve the documentation of the filetest `run` command

Adds an up-to-date example of how to use the `run` and `print` directives and includes an actual use of the new directives in a SIMD arithmetic filetest.
2020-05-04 14:08:27 -05:00
Nick Fitzgerald
4471a82b0c Merge pull request #1635 from fitzgen/filetests-threads
Allow setting the number of filetest threads via the CRANELIFT_FILETESTS_THREADS env var
2020-05-01 10:06:26 -07:00
Nick Fitzgerald
c0503455be Add documentation about the CRANELIFT_FILETESTS_THREADS environment variable 2020-05-01 09:15:46 -07:00
Alex Crichton
d1aa86f91a Add AArch64 tests to CI (#1526)
* Add AArch64 tests to CI

This commit enhances our CI with an AArch64 builder. Currently we have
no physical hardware to run on so for now we run all tests in an
emulator. The AArch64 build is cross-compiled from x86_64 from Linux.
Tests all happen in release mode with a recent version of QEMU (recent
version because it's so much faster, and in release mode because debug
mode tests take quite a long time in an emulator).

The goal here was not to get all tests passing on CI, but rather to get
AArch64 running on CI and get it green at the same time. To achieve that
goal many tests are now ignored on aarch64 platforms. Many tests fail
due to unimplemented functionality in the aarch64 backend (#1521), and
all wasmtime tests involving compilation are also disabled due to
panicking attempting to generate generate instruction offset information
for trap symbolication (#1523).

Despite this, though, all Cranelift tests and other wasmtime tests
should be runnin on AArch64 through QEMU with this PR. Additionally
we'll have an AArch64 binary release of Wasmtime for Linux, although it
won't be too useful just yet since it will panic on almost all wasm
modules.

* Review comments
2020-04-22 12:56:54 -05:00
Samrat Man Singh
1958e8af96 [cranelift docs] Fix grammar code blocks and heap image (#1339)
* [cranelift docs] Move grammar segments in IR docs to code blocks

* [cranelift docs] Replace dot code in IR docs with generated image.

This is how the image was generated

$ cat > heap.dot << EOF
digraph {
        node [
              shape=record,
              fontsize=10,
              fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans"
              ]
        "static" [label="mapped\npages|unmapped\npages|offset_guard\npages"]
}
EOF

$ dot -Tsvg -O heap.dot

* [cranelift docs] Fix indentation in grammar block

Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-03-18 14:51:22 -07:00
Samrat Man Singh
50496efb6b [cranelift] Fix block and value names in IR documentation 2020-03-17 11:47:59 +01:00
Alex Crichton
3179dcf6f1 Update Cranelift's documentation after the merger. (#1238)
Update the documentation for the merger, and also for various changes in
Cranelift. Remove some old obsolete documentation, and convert the remaining
Sphinx files to Markdown. Some of the remaining content is still out of
date, but this is a step forward.
2020-03-05 15:51:12 -06:00
Ryan Hunt
832666c45e Mass rename Ebb and relatives to Block (#1365)
* Manually rename BasicBlock to BlockPredecessor

BasicBlock is a pair of (Ebb, Inst) that is used to represent the
basic block subcomponent of an Ebb that is a predecessor to an Ebb.

Eventually we will be able to remove this struct, but for now it
makes sense to give it a non-conflicting name so that we can start
to transition Ebb to represent a basic block.

I have not updated any comments that refer to BasicBlock, as
eventually we will remove BlockPredecessor and replace with Block,
which is a basic block, so the comments will become correct.

* Manually rename SSABuilder block types to avoid conflict

SSABuilder has its own Block and BlockData types. These along with
associated identifier will cause conflicts in a later commit, so
they are renamed to be more verbose here.

* Automatically rename 'Ebb' to 'Block' in *.rs

* Automatically rename 'EBB' to 'block' in *.rs

* Automatically rename 'ebb' to 'block' in *.rs

* Automatically rename 'extended basic block' to 'basic block' in *.rs

* Automatically rename 'an basic block' to 'a basic block' in *.rs

* Manually update comment for `Block`

`Block`'s wikipedia article required an update.

* Automatically rename 'an `Block`' to 'a `Block`' in *.rs

* Automatically rename 'extended_basic_block' to 'basic_block' in *.rs

* Automatically rename 'ebb' to 'block' in *.clif

* Manually rename clif constant that contains 'ebb' as substring to avoid conflict

* Automatically rename filecheck uses of 'EBB' to 'BB'

'regex: EBB' -> 'regex: BB'
'$EBB' -> '$BB'

* Automatically rename 'EBB' 'Ebb' to 'block' in *.clif

* Automatically rename 'an block' to 'a block' in *.clif

* Fix broken testcase when function name length increases

Test function names are limited to 16 characters. This causes
the new longer name to be truncated and fail a filecheck test. An
outdated comment was also fixed.
2020-02-07 10:46:47 -06:00
Nathan Froyd
a136d1cb00 add documentation mentions of cranelift-object where appropriate
This change makes it slightly more obvious that `cranelift-object` can
be used in lieu of `cranelift-faerie`.
2020-02-04 15:42:39 -06:00
Nick Fitzgerald
d1c53a18df Document the test run filetest mode (#1189)
* Document the `test run` filetest mode

* Clarify that `test run` functions can return any boolean
2019-10-31 10:05:10 -07:00
Benjamin Bouvier
2ee35b7ea1 Implement a Windows Baldrdash calling convention; 2019-08-16 14:25:15 +02:00
Benjamin Bouvier
abc3397017 [docs] Remove special handling of CDSL python modules; 2019-07-11 11:48:45 +02:00
Benjamin Bouvier
55f36ce81a [docs] Update docs to point to the docs.rs website; 2019-07-11 11:48:45 +02:00
Nicolas B. Pierron
bc75eee0cd Use BB-like EBB in docs/*.clif 2019-07-08 15:17:49 +02: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
Dan Gohman
b096d0606b Move ifcmp, icmp_imm, and ffcmp into the CPU flags doc section. 2019-01-02 11:46:15 -08:00
Bruce Mitchener
4f8753fa11 Fix typos. 2018-12-24 10:03:22 -08:00
Vincent Esche
c9666381f6 Fixed links in …/docs/compare-llvm.rst 2018-12-13 09:14:20 -05:00
Dan Gohman
a20c852148 Support heaps with no offset-guard pages.
Also, say "guard-offset pages" rather than just "guard pages" to describe the
region of a heap which is never accessible and which exists to support
optimizations for heap accesses with offsets.

And, introduce a `Uimm64` immediate type, and make all heap fields use
`Uimm64` instead of `Imm64` since they really are unsigned.
2018-12-11 15:40:24 -05:00
Dan Gohman
ef21fffa1c Clarify Cranelift's design with respect to mid-level optimization. (#619)
* Clarify Cranelift's design with respect to mid-level optimization.

Cranelift doesn't currently do much mid-level optimization, however it
is something we're thinking about, so remove text describing it as out of
scope, and add more text explaining the vision for how it would fit into
the overall system.
2018-11-28 08:54:40 -08:00
Dan Gohman
7c03ba43be Document which instructions are meant for producers to use.
This reorganizes some things in ir.rst to put all instructions not meant
for frontends to worry about in a dedicated section.

Fixes #282.
2018-11-28 06:53:04 -08:00
Dan Gohman
f0695a79d1 Add an autoinst line for fallthrough_return so that it's included in the docs. 2018-11-26 22:18:36 -08:00