@@ -35,32 +35,88 @@ def : Pat<(i64 (anyext I32:$src)), (I64_EXTEND_U_I32 I32:$src)>;
35
35
36
36
let Defs = [ARGUMENTS] in {
37
37
38
+ // Conversion from floating point to integer instructions which don't trap on
39
+ // overflow or invalid.
40
+ def I32_TRUNC_S_SAT_F32 : I<(outs I32:$dst), (ins F32:$src),
41
+ [(set I32:$dst, (fp_to_sint F32:$src))],
42
+ "i32.trunc_s:sat/f32\t$dst, $src", 0xfc00>,
43
+ Requires<[HasNontrappingFPToInt]>;
44
+ def I32_TRUNC_U_SAT_F32 : I<(outs I32:$dst), (ins F32:$src),
45
+ [(set I32:$dst, (fp_to_uint F32:$src))],
46
+ "i32.trunc_u:sat/f32\t$dst, $src", 0xfc01>,
47
+ Requires<[HasNontrappingFPToInt]>;
48
+ def I64_TRUNC_S_SAT_F32 : I<(outs I64:$dst), (ins F32:$src),
49
+ [(set I64:$dst, (fp_to_sint F32:$src))],
50
+ "i64.trunc_s:sat/f32\t$dst, $src", 0xfc04>,
51
+ Requires<[HasNontrappingFPToInt]>;
52
+ def I64_TRUNC_U_SAT_F32 : I<(outs I64:$dst), (ins F32:$src),
53
+ [(set I64:$dst, (fp_to_uint F32:$src))],
54
+ "i64.trunc_u:sat/f32\t$dst, $src", 0xfc05>,
55
+ Requires<[HasNontrappingFPToInt]>;
56
+ def I32_TRUNC_S_SAT_F64 : I<(outs I32:$dst), (ins F64:$src),
57
+ [(set I32:$dst, (fp_to_sint F64:$src))],
58
+ "i32.trunc_s:sat/f64\t$dst, $src", 0xfc02>,
59
+ Requires<[HasNontrappingFPToInt]>;
60
+ def I32_TRUNC_U_SAT_F64 : I<(outs I32:$dst), (ins F64:$src),
61
+ [(set I32:$dst, (fp_to_uint F64:$src))],
62
+ "i32.trunc_u:sat/f64\t$dst, $src", 0xfc03>,
63
+ Requires<[HasNontrappingFPToInt]>;
64
+ def I64_TRUNC_S_SAT_F64 : I<(outs I64:$dst), (ins F64:$src),
65
+ [(set I64:$dst, (fp_to_sint F64:$src))],
66
+ "i64.trunc_s:sat/f64\t$dst, $src", 0xfc06>,
67
+ Requires<[HasNontrappingFPToInt]>;
68
+ def I64_TRUNC_U_SAT_F64 : I<(outs I64:$dst), (ins F64:$src),
69
+ [(set I64:$dst, (fp_to_uint F64:$src))],
70
+ "i64.trunc_u:sat/f64\t$dst, $src", 0xfc07>,
71
+ Requires<[HasNontrappingFPToInt]>;
72
+
73
+ // Conversion from floating point to integer pseudo-instructions which don't
74
+ // trap on overflow or invalid.
75
+ let usesCustomInserter = 1, isCodeGenOnly = 1 in {
76
+ def FP_TO_SINT_I32_F32 : I<(outs I32:$dst), (ins F32:$src),
77
+ [(set I32:$dst, (fp_to_sint F32:$src))], "", 0>,
78
+ Requires<[NotHasNontrappingFPToInt]>;
79
+ def FP_TO_UINT_I32_F32 : I<(outs I32:$dst), (ins F32:$src),
80
+ [(set I32:$dst, (fp_to_uint F32:$src))], "", 0>,
81
+ Requires<[NotHasNontrappingFPToInt]>;
82
+ def FP_TO_SINT_I64_F32 : I<(outs I64:$dst), (ins F32:$src),
83
+ [(set I64:$dst, (fp_to_sint F32:$src))], "", 0>,
84
+ Requires<[NotHasNontrappingFPToInt]>;
85
+ def FP_TO_UINT_I64_F32 : I<(outs I64:$dst), (ins F32:$src),
86
+ [(set I64:$dst, (fp_to_uint F32:$src))], "", 0>,
87
+ Requires<[NotHasNontrappingFPToInt]>;
88
+ def FP_TO_SINT_I32_F64 : I<(outs I32:$dst), (ins F64:$src),
89
+ [(set I32:$dst, (fp_to_sint F64:$src))], "", 0>,
90
+ Requires<[NotHasNontrappingFPToInt]>;
91
+ def FP_TO_UINT_I32_F64 : I<(outs I32:$dst), (ins F64:$src),
92
+ [(set I32:$dst, (fp_to_uint F64:$src))], "", 0>,
93
+ Requires<[NotHasNontrappingFPToInt]>;
94
+ def FP_TO_SINT_I64_F64 : I<(outs I64:$dst), (ins F64:$src),
95
+ [(set I64:$dst, (fp_to_sint F64:$src))], "", 0>,
96
+ Requires<[NotHasNontrappingFPToInt]>;
97
+ def FP_TO_UINT_I64_F64 : I<(outs I64:$dst), (ins F64:$src),
98
+ [(set I64:$dst, (fp_to_uint F64:$src))], "", 0>,
99
+ Requires<[NotHasNontrappingFPToInt]>;
100
+ } // usesCustomInserter, isCodeGenOnly = 1
101
+
38
102
// Conversion from floating point to integer traps on overflow and invalid.
39
103
let hasSideEffects = 1 in {
40
104
def I32_TRUNC_S_F32 : I<(outs I32:$dst), (ins F32:$src),
41
- [(set I32:$dst, (fp_to_sint F32:$src))],
42
- "i32.trunc_s/f32\t$dst, $src", 0xa8>;
105
+ [], "i32.trunc_s/f32\t$dst, $src", 0xa8>;
43
106
def I32_TRUNC_U_F32 : I<(outs I32:$dst), (ins F32:$src),
44
- [(set I32:$dst, (fp_to_uint F32:$src))],
45
- "i32.trunc_u/f32\t$dst, $src", 0xa9>;
107
+ [], "i32.trunc_u/f32\t$dst, $src", 0xa9>;
46
108
def I64_TRUNC_S_F32 : I<(outs I64:$dst), (ins F32:$src),
47
- [(set I64:$dst, (fp_to_sint F32:$src))],
48
- "i64.trunc_s/f32\t$dst, $src", 0xae>;
109
+ [], "i64.trunc_s/f32\t$dst, $src", 0xae>;
49
110
def I64_TRUNC_U_F32 : I<(outs I64:$dst), (ins F32:$src),
50
- [(set I64:$dst, (fp_to_uint F32:$src))],
51
- "i64.trunc_u/f32\t$dst, $src", 0xaf>;
111
+ [], "i64.trunc_u/f32\t$dst, $src", 0xaf>;
52
112
def I32_TRUNC_S_F64 : I<(outs I32:$dst), (ins F64:$src),
53
- [(set I32:$dst, (fp_to_sint F64:$src))],
54
- "i32.trunc_s/f64\t$dst, $src", 0xaa>;
113
+ [], "i32.trunc_s/f64\t$dst, $src", 0xaa>;
55
114
def I32_TRUNC_U_F64 : I<(outs I32:$dst), (ins F64:$src),
56
- [(set I32:$dst, (fp_to_uint F64:$src))],
57
- "i32.trunc_u/f64\t$dst, $src", 0xab>;
115
+ [], "i32.trunc_u/f64\t$dst, $src", 0xab>;
58
116
def I64_TRUNC_S_F64 : I<(outs I64:$dst), (ins F64:$src),
59
- [(set I64:$dst, (fp_to_sint F64:$src))],
60
- "i64.trunc_s/f64\t$dst, $src", 0xb0>;
117
+ [], "i64.trunc_s/f64\t$dst, $src", 0xb0>;
61
118
def I64_TRUNC_U_F64 : I<(outs I64:$dst), (ins F64:$src),
62
- [(set I64:$dst, (fp_to_uint F64:$src))],
63
- "i64.trunc_u/f64\t$dst, $src", 0xb1>;
119
+ [], "i64.trunc_u/f64\t$dst, $src", 0xb1>;
64
120
} // hasSideEffects = 1
65
121
66
122
def F32_CONVERT_S_I32 : I<(outs F32:$dst), (ins I32:$src),
0 commit comments