@@ -145,17 +145,30 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
145
145
"fabsf32" => {
146
146
let [ f] = check_arg_count ( args) ?;
147
147
let f = this. read_scalar ( f) ?. to_f32 ( ) ?;
148
- // Can be implemented in soft-floats.
149
148
// This is a "bitwise" operation, so there's no NaN non-determinism.
150
149
this. write_scalar ( Scalar :: from_f32 ( f. abs ( ) ) , dest) ?;
151
150
}
152
151
"fabsf64" => {
153
152
let [ f] = check_arg_count ( args) ?;
154
153
let f = this. read_scalar ( f) ?. to_f64 ( ) ?;
155
- // Can be implemented in soft-floats.
156
154
// This is a "bitwise" operation, so there's no NaN non-determinism.
157
155
this. write_scalar ( Scalar :: from_f64 ( f. abs ( ) ) , dest) ?;
158
156
}
157
+ "floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => {
158
+ let [ f] = check_arg_count ( args) ?;
159
+ let f = this. read_scalar ( f) ?. to_f32 ( ) ?;
160
+ let mode = match intrinsic_name {
161
+ "floorf32" => Round :: TowardNegative ,
162
+ "ceilf32" => Round :: TowardPositive ,
163
+ "truncf32" => Round :: TowardZero ,
164
+ "roundf32" => Round :: NearestTiesToAway ,
165
+ "rintf32" => Round :: NearestTiesToEven ,
166
+ _ => bug ! ( ) ,
167
+ } ;
168
+ let res = f. round_to_integral ( mode) . value ;
169
+ let res = this. adjust_nan ( res, & [ f] ) ;
170
+ this. write_scalar ( res, dest) ?;
171
+ }
159
172
#[ rustfmt:: skip]
160
173
| "sinf32"
161
174
| "cosf32"
@@ -165,11 +178,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
165
178
| "logf32"
166
179
| "log10f32"
167
180
| "log2f32"
168
- | "floorf32"
169
- | "ceilf32"
170
- | "truncf32"
171
- | "roundf32"
172
- | "rintf32"
173
181
=> {
174
182
let [ f] = check_arg_count ( args) ?;
175
183
let f = this. read_scalar ( f) ?. to_f32 ( ) ?;
@@ -184,18 +192,28 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
184
192
"logf32" => f_host. ln ( ) ,
185
193
"log10f32" => f_host. log10 ( ) ,
186
194
"log2f32" => f_host. log2 ( ) ,
187
- "floorf32" => f_host. floor ( ) ,
188
- "ceilf32" => f_host. ceil ( ) ,
189
- "truncf32" => f_host. trunc ( ) ,
190
- "roundf32" => f_host. round ( ) ,
191
- "rintf32" => f_host. round_ties_even ( ) ,
192
195
_ => bug ! ( ) ,
193
196
} ;
194
197
let res = res. to_soft ( ) ;
195
198
let res = this. adjust_nan ( res, & [ f] ) ;
196
199
this. write_scalar ( res, dest) ?;
197
200
}
198
201
202
+ "floorf64" | "ceilf64" | "truncf64" | "roundf64" | "rintf64" => {
203
+ let [ f] = check_arg_count ( args) ?;
204
+ let f = this. read_scalar ( f) ?. to_f64 ( ) ?;
205
+ let mode = match intrinsic_name {
206
+ "floorf64" => Round :: TowardNegative ,
207
+ "ceilf64" => Round :: TowardPositive ,
208
+ "truncf64" => Round :: TowardZero ,
209
+ "roundf64" => Round :: NearestTiesToAway ,
210
+ "rintf64" => Round :: NearestTiesToEven ,
211
+ _ => bug ! ( ) ,
212
+ } ;
213
+ let res = f. round_to_integral ( mode) . value ;
214
+ let res = this. adjust_nan ( res, & [ f] ) ;
215
+ this. write_scalar ( res, dest) ?;
216
+ }
199
217
#[ rustfmt:: skip]
200
218
| "sinf64"
201
219
| "cosf64"
@@ -205,11 +223,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
205
223
| "logf64"
206
224
| "log10f64"
207
225
| "log2f64"
208
- | "floorf64"
209
- | "ceilf64"
210
- | "truncf64"
211
- | "roundf64"
212
- | "rintf64"
213
226
=> {
214
227
let [ f] = check_arg_count ( args) ?;
215
228
let f = this. read_scalar ( f) ?. to_f64 ( ) ?;
@@ -224,11 +237,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
224
237
"logf64" => f_host. ln ( ) ,
225
238
"log10f64" => f_host. log10 ( ) ,
226
239
"log2f64" => f_host. log2 ( ) ,
227
- "floorf64" => f_host. floor ( ) ,
228
- "ceilf64" => f_host. ceil ( ) ,
229
- "truncf64" => f_host. trunc ( ) ,
230
- "roundf64" => f_host. round ( ) ,
231
- "rintf64" => f_host. round_ties_even ( ) ,
232
240
_ => bug ! ( ) ,
233
241
} ;
234
242
let res = res. to_soft ( ) ;
0 commit comments