Commit Graph

1790 Commits

Author SHA1 Message Date
Peter Huene
8923bac7e8 Implement emitting Windows unwind information for fastcall functions. (#1155)
* Implement emitting Windows unwind information for fastcall functions.

This commit implements emitting Windows unwind information for x64 fastcall
calling convention functions.

The unwind information can be used to construct a Windows function table at
runtime for JIT'd code, enabling stack walking and unwinding by the operating
system.

* Address code review feedback.

This commit addresses code review feedback:

* Remove unnecessary unsafe code.
* Emit the unwind information always as little endian.
* Fix comments.

A dependency from cranelift-codegen to the byteorder crate was added.
The byteorder crate is a no-dependencies crate with a reasonable
abstraction for writing binary data for a specific endianness.

* Address code review feedback.

* Disable default features for the `byteorder` crate.
* Add a comment regarding the Windows ABI unwind code numerical values.
* Panic if we encounter a Windows function with a prologue greater than 256
  bytes in size.
2019-11-05 13:14:30 -08:00
Andrew Brown
96f5a6b561 Fix documentation link issues 2019-10-31 09:35:08 -07:00
Benjamin Bouvier
8c2d9fd32f Tweak comments in regalloc code. 2019-10-31 16:54:30 +01:00
Josh Triplett
7e725cf880 Migrate from failure to thiserror
The failure crate invents its own traits that don't use
std::error::Error (because failure predates certain features added to
Error); this prevents using ? on an error from failure in a function
using Error. The thiserror crate integrates with the standard Error
trait instead.
2019-10-30 17:15:09 -07: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
a3f55cdf1f Regalloc solver: check that a variable doesn't exist to test if it can be added (fixes #1123);
This situation could be triggered that can_add_var would return true
while a variable was already added for the given register.

For instance, when we have a reassignment (because of a fixed register
input requirement) and a fixed input conflict on the same fixed
register, this register will not be available in the regs_in set after
inputs_done (because of the fixed input conflict diversion) but will
have its own variable.
2019-10-17 08:42:08 -07:00
Benjamin Bouvier
beca77c2f8 Regalloc: rename "constraint" to "rc" and "op" to "constraint"; 2019-10-17 08:42:08 -07:00
Andrew Brown
67733bd2fc Use ConstantData exclusively for inserting data into the constant pool
Previously we allowed anything that could be converted into ConstantData (e.g. a Vec).
2019-10-15 15:19:00 -07:00
Andrew Brown
ff93564c55 Update predicate documentation to match new ConstantData parameter 2019-10-15 15:19:00 -07:00
Andrew Brown
a03f905d08 Replace V128Imm functionality with ConstantData
This moves most original uses of V128Imm (e.g. in parsing) to ConstantData and shifts the unit tests from V128Imm to ConstantData.
2019-10-15 15:19:00 -07:00
Andrew Brown
1600dba634 Make ConstantData a container for any-size constant values
Previously, ConstantData was a type alias for `Vec<u8>` which prevented it from having an implementation; this meant that `V128Imm` and `&[u8; 16]` were used in places that otherwise could have accepted types of different byte lengths.
2019-10-15 15:19:00 -07:00
Andrew Brown
1f728c1797 Add x86 legalization for SIMD bnot 2019-10-11 11:05:24 -07:00
Benjamin Bouvier
9c159ac17c Cleanup: Mark ebb as unused in legalization; 2019-10-10 09:01:40 -07:00
Benjamin Bouvier
f668869508 Share constants between codegen and the meta crate; 2019-10-10 16:45:48 +02:00
Benjamin Bouvier
d404368dea Share constant_hash code between the meta and codegen crates; 2019-10-10 16:45:48 +02:00
Ujjwal Sharma
c062f12d7c [codegen] legalize icmp for 64 and 128 bit operands
Add legalizations for icmp and icmp_imm for i64 and i128 operands for
the narrow legalization set, allowing 32-bit ISAs (like x86-32) to
compare 64-bit integers and all ISAs to compare 128-bit integers.

Fixes: https://github.com/bnjbvr/cranelift-x86/issues/2
2019-10-10 11:06:19 +02:00
bjorn3
68b671e0ee Fix isplit legalization for ebb params when jumping forward
Fixes #1106
2019-10-09 08:56:48 -07:00
Benjamin Bouvier
cbbd94db02 Allow wrap-around when subtracting type size to immediate in try_fold_extended_move; 2019-10-08 20:16:48 +02:00
julian-seward1
13676cafd1 RedundantReloadRemover::run: use cached state rather than allocating it new for each function. (#1118)
RedundantReloadRemover participates in the state-recycling machinery
implemented in cranelift-codegen/src/context.rs, whose goal it is to cache
per-pass state so it can be used for compilation of multiple functions without
reallocation.  Unfortunately RedundantReloadRemover::run simply ignores the
cached state and reallocates it new for each function.  This patch fixes that.
This reduces the number of malloc'd blocks by about 2%.
2019-10-08 18:13:35 +02:00
bjorn3
bb8fa40ef0 Rustfmt 2019-10-02 11:50:44 -07:00
bjorn3
c274d81b5b Fix it 2019-10-02 11:50:44 -07:00
bjorn3
10e226f9ff Always use extern crate std in cranelift-codegen 2019-10-02 11:50:44 -07:00
Erin Power
dadfbcd32b Re-export ReplaceBuilder
ReplaceBuilder is available in the public API through
`DataFlowGraph::replace`, however it's documentation is not available
through rustdoc as the type isn't publicly importable.
2019-10-02 13:56:27 +02:00
Nicolas B. Pierron
e0005f1e6c Insert split-edge of conditional branches before the destination. 2019-10-02 12:03:56 +02:00
Andrew Brown
c932f9b2b5 Add parsing of 16-bit signed integers 2019-09-30 13:54:30 -07:00
Andrew Brown
ba393afd4d Add x86 legalization for SIMD ineg 2019-09-30 13:54:30 -07:00
Benjamin Bouvier
4e3cb25983 Use a sorted array for (Ebb, Inst) interval again (fixes #1084); 2019-09-30 16:25:41 +02:00
Benjamin Bouvier
c3d01756a3 Baldrdash: uses ECX for the WasmTableCallSigReg on x86 32-bits; 2019-09-30 15:11:06 +02:00
Joshua Nelson
a1f6457e8a Allow building without std (#1069)
Closes https://github.com/CraneStation/cranelift/issues/1067
2019-09-26 18:00:03 +02:00
Benjamin Bouvier
46ab1b4103 Liverange: use a macro to make Order comparisons simpler to read; 2019-09-25 11:43:29 +02:00
Benjamin Bouvier
5beb10e77a Regalloc: remove the transient LiveRangeContext data structure; 2019-09-25 11:43:29 +02:00
Benjamin Bouvier
b9b1c842e9 Use LiveRange::reaches_use instead of reimplementing it in liveness checks; 2019-09-25 11:43:29 +02:00
Benjamin Bouvier
59f5f12c60 [codegen] Rename GenLiveRange to GenericLiveRange;
(to avoid confuson with Gen interpreted as Generator)
2019-09-25 11:43:29 +02:00
Benjamin Bouvier
b036ab77dc Update comment about the live range implementation details; 2019-09-25 11:43:29 +02:00
Ujjwal Sharma
43a891dfa2 [codegen] add intcc conditions for reading overflow flag
Add conditions to IntCC for checking the overflow flag (Overflow,
NotOverflow).
2019-09-25 11:42:58 +02:00
Ujjwal Sharma
6e131e5347 [codegen] add intcc conditions for reading carry flag
Add conditions to IntCC for checking the carry flag (Carry, NotCarry).

Fixes: https://github.com/CraneStation/cranelift/issues/980
2019-09-24 15:12:09 -07:00
Artur Jamro
1431ab5201 Derive serde traits for TrapCode 2019-09-24 10:50:52 -07:00
Andrew Brown
636ef98024 Use existing is_equal predicate with the newly-shared condition codes
This removes the `HasConditionCode(&'static str)` predicate and the associated issues with that.
2019-09-24 09:33:07 -07:00
Andrew Brown
c648fa3d06 Move condcodes.rs to a new crate, cranelift-codegen-shared
This move allows the `IntCC`/`FloatCC` enums to be used in both meta (for predicate matching) and in codegen. To avoid breaking any code dependent on the previous location of condcodes.rs (`cranelift-codegen/src/condcodes.rs`), the module is re-exported under `cranelift_codegen::ir`.
2019-09-24 09:33:07 -07:00
Andrew Brown
a3db30d97e Add x86 encoding for SIMD icmp eq
Also adds a predicate for matching the `eq` IntCC code (TODO this should be replaced by something more general)
2019-09-24 09:33:07 -07:00
Andrew Brown
702155b19b Optimize vconst for x86 when immediate contains all zeroes or ones
Instead of using MOVUPS to expensively load bits from memory, this change uses a predicate to optimize vconst without a memory access:
 - when the 128-bit immediate is all zeroes in all bits, use PXOR to zero out an XMM register
 - when the 128-bit immediate is all ones in all bits, use PCMPEQB to set an XMM register to all ones

This leaves the constant data in the constant pool, which may increase code size (TODO)
2019-09-24 09:33:07 -07:00
Erin Power
947fce194e Replaced instances of SparseSet with EntitySet 2019-09-23 17:20:25 +02:00
Benjamin Bouvier
3ab8eed7d3 Remove unused core::mem import; 2019-09-23 14:41:07 +02:00
Anthony Ramine
26accbadf8 Use f32::to_bits and f64::to_bits 2019-09-23 10:36:03 +02:00
Anthony Ramine
178241625c Use slice::from_ref and slice::from_mut 2019-09-23 10:36:03 +02:00
Andrew Brown
cd426cb7bc Rename Uimm128 to V128Imm 2019-09-19 12:04:14 -07:00
Wander Lairson Costa
1e74d01111 Check for types::INVALID in the function signature, resolves #493 (#1046) 2019-09-19 11:26:17 -07:00
Andrew Brown
af1499ce99 Add x86 implementation of shuffle 2019-09-19 10:53:40 -07:00
julian-seward1
9e088e4164 Reorganise optimisation level settings, and make the insn shrink pass optional (#1044)
This patch:

* removes the "default" opt level, on the basis that it has no definition and
  is referred to nowhere in the compiler.

* renames the "fastest" level to "none".  The resulting set of transformations
  is unchanged.

* renames the "best" level to "speed_and_size".  The resulting set of
  transformations is unchanged.

* adds a new level, "speed".  This is the same as "speed_and_size" except that
  it omits transformations aimed only at reducing code size.  Currently it
  omits only the insn shrinking pass.
2019-09-19 18:51:25 +02:00
Joshua Nelson
59139c6c46 Add more documentation for entities, fixes #1038 (#1041)
Also fixes broken links to point to docs.rs; see
https://github.com/CraneStation/cranelift/pull/1041#issuecomment-532356880,
there doesn't currently seem to be a way to link to a type in a
dependent crate.
2019-09-18 16:48:57 -07:00