|
1055 | 1055 | (extern constructor has_zicond has_zicond)
|
1056 | 1056 |
|
1057 | 1057 |
|
| 1058 | +;;;; Type Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1059 | + |
| 1060 | +;; Helper that matches any supported type. This extractor checks the ISA flags |
| 1061 | +;; to determine if the type is supported. |
| 1062 | +(decl ty_supported (Type) Type) |
| 1063 | +(extern extractor ty_supported ty_supported) |
| 1064 | + |
| 1065 | +;; Helper that matches any scalar floating point type |
| 1066 | +(decl ty_supported_float (Type) Type) |
| 1067 | +(extern extractor ty_supported_float ty_supported_float) |
| 1068 | + |
| 1069 | +;; Helper that matches any supported vector type |
| 1070 | +(decl ty_supported_vec (Type) Type) |
| 1071 | +(extern extractor ty_supported_vec ty_supported_vec) |
| 1072 | + |
| 1073 | + |
1058 | 1074 | ;;;; Instruction Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1059 | 1075 |
|
1060 | 1076 | ;; RV32I Base Integer Instruction Set
|
|
1869 | 1885 | (rule 8 (imm $F64 0) (gen_bitcast (zero_reg) $I64 $F64))
|
1870 | 1886 |
|
1871 | 1887 | ;; If Zfa is enabled, we can load certain constants with the `fli` instruction.
|
1872 |
| -(rule 7 (imm (ty_scalar_float ty) imm) |
| 1888 | +(rule 7 (imm (ty_supported_float ty) imm) |
1873 | 1889 | (if-let $true (has_zfa))
|
1874 | 1890 | (if-let const (fli_constant_from_u64 ty imm))
|
1875 | 1891 | (rv_fli ty const))
|
|
1879 | 1895 | ;;
|
1880 | 1896 | ;; For f64's this saves one instruction, and for f32's it avoids
|
1881 | 1897 | ;; having to allocate an integer register, reducing integer register pressure.
|
1882 |
| -(rule 6 (imm (ty_scalar_float ty) imm) |
| 1898 | +(rule 6 (imm (ty_supported_float ty) imm) |
1883 | 1899 | (if-let $true (has_zfa))
|
1884 | 1900 | (if-let const (fli_constant_from_negated_u64 ty imm))
|
1885 | 1901 | (rv_fneg ty (rv_fli ty const)))
|
|
2930 | 2946 | ;; Generates a bitcast instruction.
|
2931 | 2947 | ;; Args are: src, src_ty, dst_ty
|
2932 | 2948 | (decl gen_bitcast (Reg Type Type) Reg)
|
2933 |
| -(rule 5 (gen_bitcast r (ty_scalar_float src_ty) (ty_vec_fits_in_register _)) (rv_vfmv_sf r src_ty)) |
2934 |
| -(rule 4 (gen_bitcast r (ty_int_ref_scalar_64 src_ty) (ty_vec_fits_in_register _)) (rv_vmv_sx r src_ty)) |
2935 |
| -(rule 3 (gen_bitcast r (ty_vec_fits_in_register _) (ty_scalar_float dst_ty)) (rv_vfmv_fs r dst_ty)) |
2936 |
| -(rule 2 (gen_bitcast r (ty_vec_fits_in_register _) (ty_int_ref_scalar_64 dst_ty)) (rv_vmv_xs r dst_ty)) |
| 2949 | +(rule 5 (gen_bitcast r (ty_supported_float src_ty) (ty_supported_vec _)) (rv_vfmv_sf r src_ty)) |
| 2950 | +(rule 4 (gen_bitcast r (ty_int_ref_scalar_64 src_ty) (ty_supported_vec _)) (rv_vmv_sx r src_ty)) |
| 2951 | +(rule 3 (gen_bitcast r (ty_supported_vec _) (ty_supported_float dst_ty)) (rv_vfmv_fs r dst_ty)) |
| 2952 | +(rule 2 (gen_bitcast r (ty_supported_vec _) (ty_int_ref_scalar_64 dst_ty)) (rv_vmv_xs r dst_ty)) |
2937 | 2953 | (rule 1 (gen_bitcast r $F32 $I32) (rv_fmvxw r))
|
2938 | 2954 | (rule 1 (gen_bitcast r $F64 $I64) (rv_fmvxd r))
|
2939 | 2955 | (rule 1 (gen_bitcast r $I32 $F32) (rv_fmvwx r))
|
|
0 commit comments