diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-11-06 20:52:01 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-11-07 23:11:48 +0100 |
commit | 1091a4274eb5c91b6279905688759105ab95bfb4 (patch) | |
tree | 24bf02de9bb5524163c7f9b4b905c8c1597bea8d /src/codegen/mod.rs | |
parent | c314a2f1b3b70a1322a23f785995124941ed632a (diff) |
Add an option to avoid converting to f32/f64 automatically float types.
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 e7fa62ee..7d470be4 100755 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -1458,12 +1458,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) + } } } } |