@@ -186,7 +186,8 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
186
186
187
187
"sinf32" | "fabsf32" | "cosf32" | "sqrtf32" | "expf32" | "exp2f32" | "logf32" |
188
188
"log10f32" | "log2f32" | "floorf32" | "ceilf32" | "truncf32" => {
189
- let f = this. read_scalar ( args[ 0 ] ) ?. to_f32 ( ) ?;
189
+ // FIXME: Using host floats.
190
+ let f = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
190
191
let f = match intrinsic_name. get ( ) {
191
192
"sinf32" => f. sin ( ) ,
192
193
"fabsf32" => f. abs ( ) ,
@@ -202,12 +203,13 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
202
203
"truncf32" => f. trunc ( ) ,
203
204
_ => bug ! ( ) ,
204
205
} ;
205
- this. write_scalar ( Scalar :: from_f32 ( f ) , dest) ?;
206
+ this. write_scalar ( Scalar :: from_u32 ( f . to_bits ( ) ) , dest) ?;
206
207
}
207
208
208
209
"sinf64" | "fabsf64" | "cosf64" | "sqrtf64" | "expf64" | "exp2f64" | "logf64" |
209
210
"log10f64" | "log2f64" | "floorf64" | "ceilf64" | "truncf64" => {
210
- let f = this. read_scalar ( args[ 0 ] ) ?. to_f64 ( ) ?;
211
+ // FIXME: Using host floats.
212
+ let f = f64:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u64 ( ) ?) ;
211
213
let f = match intrinsic_name. get ( ) {
212
214
"sinf64" => f. sin ( ) ,
213
215
"fabsf64" => f. abs ( ) ,
@@ -223,7 +225,7 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
223
225
"truncf64" => f. trunc ( ) ,
224
226
_ => bug ! ( ) ,
225
227
} ;
226
- this. write_scalar ( Scalar :: from_f64 ( f ) , dest) ?;
228
+ this. write_scalar ( Scalar :: from_u64 ( f . to_bits ( ) ) , dest) ?;
227
229
}
228
230
229
231
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" => {
@@ -320,19 +322,21 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
320
322
}
321
323
322
324
"powf32" => {
323
- let f = this. read_scalar ( args[ 0 ] ) ?. to_f32 ( ) ?;
324
- let f2 = this. read_scalar ( args[ 1 ] ) ?. to_f32 ( ) ?;
325
+ // FIXME: Using host floats.
326
+ let f = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
327
+ let f2 = f32:: from_bits ( this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?) ;
325
328
this. write_scalar (
326
- Scalar :: from_f32 ( f. powf ( f2) ) ,
329
+ Scalar :: from_u32 ( f. powf ( f2) . to_bits ( ) ) ,
327
330
dest,
328
331
) ?;
329
332
}
330
333
331
334
"powf64" => {
332
- let f = this. read_scalar ( args[ 0 ] ) ?. to_f64 ( ) ?;
333
- let f2 = this. read_scalar ( args[ 1 ] ) ?. to_f64 ( ) ?;
335
+ // FIXME: Using host floats.
336
+ let f = f64:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u64 ( ) ?) ;
337
+ let f2 = f64:: from_bits ( this. read_scalar ( args[ 1 ] ) ?. to_u64 ( ) ?) ;
334
338
this. write_scalar (
335
- Scalar :: from_f64 ( f. powf ( f2) ) ,
339
+ Scalar :: from_u64 ( f. powf ( f2) . to_bits ( ) ) ,
336
340
dest,
337
341
) ?;
338
342
}
@@ -341,8 +345,9 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
341
345
let a = this. read_scalar ( args[ 0 ] ) ?. to_f32 ( ) ?;
342
346
let b = this. read_scalar ( args[ 1 ] ) ?. to_f32 ( ) ?;
343
347
let c = this. read_scalar ( args[ 2 ] ) ?. to_f32 ( ) ?;
348
+ let res = ( a* b) . value + c;
344
349
this. write_scalar (
345
- Scalar :: from_f32 ( a * b + c ) ,
350
+ Scalar :: from_f32 ( res . value ) ,
346
351
dest,
347
352
) ?;
348
353
}
@@ -351,26 +356,29 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a+'mir>: crate::MiriEvalContextExt<'a,
351
356
let a = this. read_scalar ( args[ 0 ] ) ?. to_f64 ( ) ?;
352
357
let b = this. read_scalar ( args[ 1 ] ) ?. to_f64 ( ) ?;
353
358
let c = this. read_scalar ( args[ 2 ] ) ?. to_f64 ( ) ?;
359
+ let res = ( a* b) . value + c;
354
360
this. write_scalar (
355
- Scalar :: from_f64 ( a * b + c ) ,
361
+ Scalar :: from_f64 ( res . value ) ,
356
362
dest,
357
363
) ?;
358
364
}
359
365
360
366
"powif32" => {
361
- let f = this. read_scalar ( args[ 0 ] ) ?. to_f32 ( ) ?;
367
+ // FIXME: Using host floats.
368
+ let f = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
362
369
let i = this. read_scalar ( args[ 1 ] ) ?. to_i32 ( ) ?;
363
370
this. write_scalar (
364
- Scalar :: from_f32 ( f. powi ( i) ) ,
371
+ Scalar :: from_u32 ( f. powi ( i) . to_bits ( ) ) ,
365
372
dest,
366
373
) ?;
367
374
}
368
375
369
376
"powif64" => {
370
- let f = this. read_scalar ( args[ 0 ] ) ?. to_f64 ( ) ?;
377
+ // FIXME: Using host floats.
378
+ let f = f64:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u64 ( ) ?) ;
371
379
let i = this. read_scalar ( args[ 1 ] ) ?. to_i32 ( ) ?;
372
380
this. write_scalar (
373
- Scalar :: from_f64 ( f. powi ( i) ) ,
381
+ Scalar :: from_u64 ( f. powi ( i) . to_bits ( ) ) ,
374
382
dest,
375
383
) ?;
376
384
}
0 commit comments