Skip to content

Commit

Permalink
riscv64: Restrict bitcasts to 16bit floating point values from/to vec…
Browse files Browse the repository at this point in the history
…tors
  • Loading branch information
afonso360 committed Aug 16, 2024
1 parent e279680 commit 494e56b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cranelift/codegen/src/isa/riscv64/inst.isle
Original file line number Diff line number Diff line change
Expand Up @@ -2924,9 +2924,13 @@
;; Generates a bitcast instruction.
;; Args are: src, src_ty, dst_ty
(decl gen_bitcast (Reg Type Type) Reg)
(rule 5 (gen_bitcast r (ty_supported_float src_ty) (ty_supported_vec _)) (rv_vfmv_sf r src_ty))
(rule 4 (gen_bitcast r (ty_int_ref_scalar_64 src_ty) (ty_supported_vec _)) (rv_vmv_sx r src_ty))
(rule 3 (gen_bitcast r (ty_supported_vec _) (ty_supported_float dst_ty)) (rv_vfmv_fs r dst_ty))

;; To support FP16 vfmv.* we need to check for the `zvfh` isa flag, which we currently don't
;; support, so restrict the floating point types to 32/64 bits.
(rule 5 (gen_bitcast r (ty_supported_float (ty_32_or_64 src_ty)) (ty_supported_vec _)) (rv_vfmv_sf r src_ty))
(rule 4 (gen_bitcast r (ty_supported_vec _) (ty_supported_float (ty_32_or_64 dst_ty))) (rv_vfmv_fs r dst_ty))

(rule 3 (gen_bitcast r (ty_int_ref_scalar_64 src_ty) (ty_supported_vec _)) (rv_vmv_sx r src_ty))
(rule 2 (gen_bitcast r (ty_supported_vec _) (ty_int_ref_scalar_64 dst_ty)) (rv_vmv_xs r dst_ty))
(rule 1 (gen_bitcast r $F16 $I16) (rv_fmvxh r))
(rule 1 (gen_bitcast r $F32 $I32) (rv_fmvxw r))
Expand Down

0 comments on commit 494e56b

Please sign in to comment.