Skip to content

Commit a415485

Browse files
authored
pulley: Refactor and reuse imm for floats (bytecodealliance#9872)
This was originally added long ago and this brings the method up-to-date with the current pulley opcode set.
1 parent adcaed3 commit a415485

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

cranelift/codegen/src/isa/pulley_shared/inst.isle

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,18 +389,8 @@
389389
(rule 0 (imm $I64 x) (pulley_xconst64 (u64_as_i64 x)))
390390

391391
;; Base cases for floats.
392-
(rule 0 (imm $F32 c) (gen_bitcast (imm $I32 c) $I32 $F32))
393-
(rule 0 (imm $F64 c) (gen_bitcast (imm $I64 c) $I64 $F64))
394-
395-
;;;; Bitcasts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
396-
397-
;; Bitcast from the first type, into the second type.
398-
(decl gen_bitcast (Reg Type Type) Reg)
399-
(rule (gen_bitcast r $F32 $I32) (pulley_bitcast_float_from_int_32 r))
400-
(rule (gen_bitcast r $F64 $I64) (pulley_bitcast_float_from_int_64 r))
401-
(rule (gen_bitcast r $I32 $F32) (pulley_bitcast_int_from_float_32 r))
402-
(rule (gen_bitcast r $I64 $F64) (pulley_bitcast_int_from_float_64 r))
403-
(rule -1 (gen_bitcast r ty ty) r)
392+
(rule 0 (imm $F32 (u64_as_u32 c)) (pulley_fconst32 c))
393+
(rule 0 (imm $F64 c) (pulley_fconst64 c))
404394

405395
;;;; Instruction Constructors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
406396

cranelift/codegen/src/isa/pulley_shared/lower.isle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,11 @@
161161

162162
;;;; Rules for `f32const`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
163163

164-
(rule (lower (f32const (u32_from_ieee32 x)))
165-
(pulley_fconst32 x))
164+
(rule (lower (f32const (u32_from_ieee32 x))) (imm $F32 x))
166165

167166
;;;; Rules for `f64const`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
168167

169-
(rule (lower (f64const (u64_from_ieee64 x)))
170-
(pulley_fconst64 x))
168+
(rule (lower (f64const (u64_from_ieee64 x))) (imm $F64 x))
171169

172170
;;;; Rules for `iadd` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
173171

0 commit comments

Comments
 (0)