Commit Graph

1724 Commits

Author SHA1 Message Date
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
AnthonyMikh
c0274eca24 Simplify and rename Stackmap::from_vec (#1032)
Co-Authored-By: bjorn3 <bjorn3@users.noreply.github.com>
2019-09-18 10:11:32 +02:00
bjorn3
add6a4f269 Correctly zero extend operand of fcvt_from_uint for 8ints and 16bit ints (#997)
Fixes #996
2019-09-18 10:06:15 +02:00
Andrew Brown
9b852fde09 Add verifier check to ensure each SIMD lane index is within bounds, fixes #1016 2019-09-17 09:29:36 -07:00
Wander Lairson Costa
863ac809d9 [codegen] Check for downcasting in bitcast instruction
Bitcasting to a smaller size is invalid.

closes #854
2019-09-17 17:07:07 +02:00
Andy Wortman
99380fad1a Use 'xor r, r' to set registers to 0 instead of mov (#766) 2019-09-16 16:35:55 +02:00
julian-seward1
b95508c51a legalizer/split.rs: split_ebb_params: avoid pointless Vec allocations. (#1025)
This function is responsible for 2.2% of all heap allocation (calls) in CL.
This change avoids all of them in the (presumably) common case where none of
the parameters require splitting.  It also slightly reduces the compiler's
instruction count.
2019-09-16 15:01:07 +02:00
Ujjwal Sharma
3418fb6e18 [codegen] reintroduce support for carry and borrow instructions in RI… (#1005)
Reintroduce support for iadd carry variants and isub borrow variants for
RISC ISAs which had been removed in
https://github.com/CraneStation/cranelift/pull/961 and
https://github.com/CraneStation/cranelift/pull/962 because of the lack
of a proper flags register in RISC architectures.
2019-09-13 17:27:49 +02:00
Benjamin Bouvier
cad2074587 [codegen] Don't simplify an operation if it would result in unnecessary legalization;
Converting something like iadd.i64 on a 32-bits architecture into a
iadd_imm.i64 will result in the instruction being legalized back to an
iadd.i64 later on, creating unnecessary churn.

This commit implements avoid doing so, and changes the target ISA to a
64-bits platform for tests than ran into this, as well as making sure
this won't happen on 32-bits platforms.
2019-09-10 19:50:34 +02:00
Benjamin Bouvier
3aa76b558c Legalize i64.const by breaking it into two i32.const, on 32-bits platforms; 2019-09-10 19:50:34 +02:00
Andrew Brown
295b2ef614 Avoid extra register movement when lowering an x86 insertlane to a float vector 2019-09-10 10:45:12 -07:00
Andrew Brown
00bedca274 Avoid extra register movement when lowering the x86 extractlane of a float vector
This commit is based on the assumption that floats are already stored in XMM registers in x86. When extracting a lane, cranelift was moving the float to a regular register and back to an XMM register; this change avoids this by shuffling the float value to the lowest bits of the XMM register. It also assumes that the upper bits can be left as is (instead of zeroing them out).
2019-09-10 10:45:12 -07:00
Andrew Brown
7f152611a4 Log compiled and legalized functions 2019-09-10 10:45:12 -07:00
Sean Stangl
4b085b9cf7 Avoid unnecessary reallocations in domtree::with_function() (#1011) 2019-09-10 08:18:06 -06:00
Philip Craig
3293ca6b69 Add cranelift-object 2019-09-09 21:54:20 -07:00
Nicolas B. Pierron
90b0b86f5c Simplify isa_builder macro 2019-09-09 13:30:02 +02:00
Julian Seward
d2443a75f3 legalizer/split.rs: simplify_branch_arguments: use SmallVec instead of Vec
This function is responsible for 8.5% of all heap allocation (calls) in CL.
This change avoids almost all of them by using a SmallVec::<[Value; 32]>
instead.  Dynamic instruction count falls by 0.25%.  The fixed size of 32 was
arrived at after profiling with fixed sizes of 1, 2, 4, 8, 16, 32, 64 and 128.
32 is as high as I can push it without the instruction count starting to creep
up again, and gets almost all the block-reduction win of 64 and 128.
2019-09-09 12:58:21 +02:00