Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cranelift/codegen/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ where
impl<'a, 'b, 'c> generated_code::Context for IsleContext<'a, 'b, 'c> {
isle_common_prelude_methods!();

fn zero_constant(&mut self, ty: Type) -> Constant {
let data = vec![0; ty.bytes() as usize];
self.ctx.func.dfg.constants.insert(data.into())
}

type inst_data_value_etor_returns = InstDataEtorIter<'a, 'b, 'c>;

fn inst_data_value_etor(&mut self, eclass: Value, returns: &mut InstDataEtorIter<'a, 'b, 'c>) {
Expand Down
4 changes: 2 additions & 2 deletions cranelift/codegen/src/opts/bitops.isle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
(rule 0 (all_zero (ty_int ty)) (iconst_u ty 0))
(rule 1 (all_zero $F32) (f32const $F32 (f32_from_uint 0)))
(rule 2 (all_zero $F64) (f64const $F64 (f64_from_uint 0)))
(rule 3 (all_zero (ty_vec64 ty)) (splat ty (all_zero (lane_type ty))))
(rule 4 (all_zero (ty_vec128 ty)) (splat ty (all_zero (lane_type ty))))
(rule 3 (all_zero (ty_vec64 ty)) (vconst ty (zero_constant ty)))
(rule 4 (all_zero (ty_vec128 ty)) (vconst ty (zero_constant ty)))

;; x ^ x == 0.
(rule (simplify (bxor ty x x))
Expand Down
6 changes: 6 additions & 0 deletions cranelift/codegen/src/prelude_opt.isle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

;; Any `extern` definitions here are generally implemented in `src/opts.rs`.

;;;;; constants ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Insert an all-zero constant whose size matches `ty` into the constant pool.
(decl zero_constant (Type) Constant)
(extern constructor zero_constant zero_constant)

;;;;; eclass and enode access ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Extract any node(s) for the given eclass ID.
Expand Down
18 changes: 9 additions & 9 deletions cranelift/filetests/filetests/egraph/bitops.clif
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ block0(v0: f32x4):
}

; check: const0 = 0x00000000000000000000000000000000
; check: v4 = vconst.f32x4 const0
; check: return v4
; check: v2 = vconst.f32x4 const0
; check: return v2

function %vector_bxor_x_x_f64x2(f64x2) -> f64x2 {
block0(v0: f64x2):
Expand All @@ -173,18 +173,18 @@ block0(v0: f64x2):
}

; check: const0 = 0x00000000000000000000000000000000
; check: v4 = vconst.f64x2 const0
; check: return v4
; check: v2 = vconst.f64x2 const0
; check: return v2

function %vector_bxor_x_x_f32x2(f32x2) -> f32x2 {
block0(v0: f32x2):
v1 = bxor v0, v0
return v1
}

; check: f32const 0.0
; check: splat.f32x2
; check: return
; check: const0 = 0x0000000000000000
; check: v2 = vconst.f32x2 const0
; check: return v2

function %vector_bxor_x_bnot_x(i32x4) -> i32x4 {
block0(v0: i32x4):
Expand Down Expand Up @@ -216,8 +216,8 @@ block0(v0: i32x4):
}

; check: const0 = 0x00000000000000000000000000000000
; check: v5 = vconst.i32x4 const0
; check: return v5
; check: v3 = vconst.i32x4 const0
; check: return v3

function %vector_bor_x_bnot_x(i32x4) -> i32x4 {
block0(v0: i32x4):
Expand Down
4 changes: 2 additions & 2 deletions tests/disas/gc/copying/v128-fields.wat
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
;; @002e jump block1
;;
;; block1:
;; v20 = vconst.i8x16 const0
;; @002e return v20 ; v20 = const0
;; v18 = vconst.i8x16 const0
;; @002e return v18 ; v18 = const0
;; }
4 changes: 2 additions & 2 deletions tests/disas/gc/null/v128-fields.wat
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
;; @002e jump block1
;;
;; block1:
;; v20 = vconst.i8x16 const0
;; @002e return v20 ; v20 = const0
;; v18 = vconst.i8x16 const0
;; @002e return v18 ; v18 = const0
;; }
Loading