diff options
Diffstat (limited to 'src/codegen/mod.rs')
-rwxr-xr-x | src/codegen/mod.rs | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 85ac13b5..bf6af82b 100755 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1465,12 +1465,25 @@ impl ToRustTy for Type { } TypeKind::Float(fk) => { use ir::ty::FloatKind; - // TODO: we probably should just take the type layout into - // account? - match fk { - FloatKind::Float => aster::ty::TyBuilder::new().f32(), - FloatKind::Double | FloatKind::LongDouble => { - aster::ty::TyBuilder::new().f64() + if ctx.options().convert_floats { + // TODO: we probably should just take the type layout into + // account? + // + // Also, maybe this one shouldn't be the default? + match fk { + FloatKind::Float => aster::ty::TyBuilder::new().f32(), + FloatKind::Double | FloatKind::LongDouble => { + aster::ty::TyBuilder::new().f64() + } + } + } else { + // FIXME: `c_longdouble` doesn't seem to be defined in some + // systems, so we use `c_double` directly. + match fk { + FloatKind::Float => raw!(c_float), + FloatKind::Double | FloatKind::LongDouble => { + raw!(c_double) + } } } } |