Skip to content

Commit

Permalink
pulley: Refactor and reuse imm for floats
Browse files Browse the repository at this point in the history
This was originally added long ago and this brings the method up-to-date
with the current pulley opcode set.
  • Loading branch information
alexcrichton committed Dec 19, 2024
1 parent a179f95 commit 4a511f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
14 changes: 2 additions & 12 deletions cranelift/codegen/src/isa/pulley_shared/inst.isle
Original file line number Diff line number Diff line change
Expand Up @@ -389,18 +389,8 @@
(rule 0 (imm $I64 x) (pulley_xconst64 (u64_as_i64 x)))

;; Base cases for floats.
(rule 0 (imm $F32 c) (gen_bitcast (imm $I32 c) $I32 $F32))
(rule 0 (imm $F64 c) (gen_bitcast (imm $I64 c) $I64 $F64))

;;;; Bitcasts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Bitcast from the first type, into the second type.
(decl gen_bitcast (Reg Type Type) Reg)
(rule (gen_bitcast r $F32 $I32) (pulley_bitcast_float_from_int_32 r))
(rule (gen_bitcast r $F64 $I64) (pulley_bitcast_float_from_int_64 r))
(rule (gen_bitcast r $I32 $F32) (pulley_bitcast_int_from_float_32 r))
(rule (gen_bitcast r $I64 $F64) (pulley_bitcast_int_from_float_64 r))
(rule -1 (gen_bitcast r ty ty) r)
(rule 0 (imm $F32 (u64_as_u32 c)) (pulley_fconst32 c))
(rule 0 (imm $F64 c) (pulley_fconst64 c))

;;;; Instruction Constructors ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand Down
6 changes: 2 additions & 4 deletions cranelift/codegen/src/isa/pulley_shared/lower.isle
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@

;;;; Rules for `f32const`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(rule (lower (f32const (u32_from_ieee32 x)))
(pulley_fconst32 x))
(rule (lower (f32const (u32_from_ieee32 x))) (imm $F32 x))

;;;; Rules for `f64const`;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(rule (lower (f64const (u64_from_ieee64 x)))
(pulley_fconst64 x))
(rule (lower (f64const (u64_from_ieee64 x))) (imm $F64 x))

;;;; Rules for `iadd` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand Down

0 comments on commit 4a511f8

Please sign in to comment.