summaryrefslogtreecommitdiff
path: root/src/codegen/mod.rs
diff options
context:
space:
mode:
authorNick Fitzgerald <fitzgen@gmail.com>2016-11-10 10:39:24 -0800
committerNick Fitzgerald <fitzgen@gmail.com>2016-11-11 10:10:29 -0800
commit53f7a50e2e4f5ef4784e005dee1e00089a7d4ec8 (patch)
tree14c3e7330b459a041c6d35071d08c760ea0f6e8a /src/codegen/mod.rs
parent8d83bdfb48e292abd7db5a3093aefce0c893d3a5 (diff)
Add rudimentary support for `__float128`
This adds `__float128` as a builtin type, and generates an opaque array of 16 `u8`s to represent it in the generated bindings since Rust doesn't have an `f128` type. Context and motivation: Somehow `__float128` is getting pulled into SpiderMonkey headers from somewhere, and the lack of `__float128` support was causing bindgen to hard fail in bindings generation.
Diffstat (limited to 'src/codegen/mod.rs')
-rwxr-xr-xsrc/codegen/mod.rs35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index 5e68da14..3bee69b6 100755
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1609,27 +1609,22 @@ impl ToRustTy for Type {
}
}
TypeKind::Float(fk) => {
+ // TODO: we probably should just take the type layout into
+ // account?
+ //
+ // Also, maybe this one shouldn't be the default?
+ //
+ // FIXME: `c_longdouble` doesn't seem to be defined in some
+ // systems, so we use `c_double` directly.
use ir::ty::FloatKind;
- 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)
- }
- }
+ match (fk, ctx.options().convert_floats) {
+ (FloatKind::Float, true) => aster::ty::TyBuilder::new().f32(),
+ (FloatKind::Double, true) |
+ (FloatKind::LongDouble, true) => aster::ty::TyBuilder::new().f64(),
+ (FloatKind::Float, false) => raw!(c_float),
+ (FloatKind::Double, false) |
+ (FloatKind::LongDouble, false) => raw!(c_double),
+ (FloatKind::Float128, _) => aster::ty::TyBuilder::new().array(16).u8(),
}
}
TypeKind::Function(ref fs) => {