11
11
use llvm:: { self , ValueRef } ;
12
12
use rustc:: middle:: const_val:: { ConstEvalErr , ConstVal , ErrKind } ;
13
13
use rustc_const_math:: ConstInt :: * ;
14
- use rustc_const_math:: ConstFloat ;
15
14
use rustc_const_math:: { ConstInt , ConstMathErr } ;
16
15
use rustc:: hir:: def_id:: DefId ;
17
16
use rustc:: infer:: TransNormalize ;
@@ -27,7 +26,7 @@ use abi::{self, Abi};
27
26
use callee;
28
27
use builder:: Builder ;
29
28
use common:: { self , CrateContext , const_get_elt, val_ty} ;
30
- use common:: { C_array , C_bool , C_bytes , C_floating_f64 , C_integral , C_big_integral } ;
29
+ use common:: { C_array , C_bool , C_bytes , C_integral , C_big_integral , C_u32 , C_u64 } ;
31
30
use common:: { C_null , C_struct , C_str_slice , C_undef , C_uint , C_vector , is_undef} ;
32
31
use common:: const_to_opt_u128;
33
32
use consts;
@@ -37,6 +36,7 @@ use type_::Type;
37
36
use value:: Value ;
38
37
39
38
use syntax_pos:: Span ;
39
+ use syntax:: ast;
40
40
41
41
use std:: fmt;
42
42
use std:: ptr;
@@ -96,11 +96,11 @@ impl<'tcx> Const<'tcx> {
96
96
let llty = type_of:: type_of ( ccx, ty) ;
97
97
let val = match cv {
98
98
ConstVal :: Float ( v) => {
99
- let v_f64 = match v {
100
- ConstFloat :: F32 ( v ) => f32 :: from_bits ( v ) as f64 ,
101
- ConstFloat :: F64 ( v ) => f64 :: from_bits ( v )
99
+ let bits = match v. ty {
100
+ ast :: FloatTy :: F32 => C_u32 ( ccx , v . bits as u32 ) ,
101
+ ast :: FloatTy :: F64 => C_u64 ( ccx , v . bits as u64 )
102
102
} ;
103
- C_floating_f64 ( v_f64 , llty)
103
+ consts :: bitcast ( bits , llty)
104
104
}
105
105
ConstVal :: Bool ( v) => C_bool ( ccx, v) ,
106
106
ConstVal :: Integral ( ref i) => return Const :: from_constint ( ccx, i) ,
0 commit comments