diff --git a/gen/toir.c b/gen/toir.c index b667f9d2..8afb6c41 100644 --- a/gen/toir.c +++ b/gen/toir.c @@ -328,10 +328,11 @@ llvm::Constant* RealExp::toConstElem(IRState* p) { Logger::print("RealExp::toConstElem: %s | %s\n", toChars(), type->toChars()); LOG_SCOPE; - const llvm::Type* fty = LLVM_DtoType(type); - if (type->ty == Tfloat32) + Type* t = LLVM_DtoDType(type); + const llvm::Type* fty = LLVM_DtoType(t); + if (t->ty == Tfloat32 || t->ty == Timaginary32) return llvm::ConstantFP::get(fty,float(value)); - else if (type->ty == Tfloat64 || type->ty == Tfloat80) + else if (t->ty == Tfloat64 || t->ty == Timaginary64 || t->ty == Tfloat80 || t->ty == Timaginary80) return llvm::ConstantFP::get(fty,double(value)); assert(0); return NULL; diff --git a/gen/tollvm.c b/gen/tollvm.c index d1ade25b..ca5c883e 100644 --- a/gen/tollvm.c +++ b/gen/tollvm.c @@ -65,11 +65,20 @@ const llvm::Type* LLVM_DtoType(Type* t) // floats case Tfloat32: + case Timaginary32: return llvm::Type::FloatTy; case Tfloat64: + case Timaginary64: case Tfloat80: + case Timaginary80: return llvm::Type::DoubleTy; + // complex + case Tcomplex32: + case Tcomplex64: + case Tcomplex80: + assert(0 && "complex number types not yet implemented"); + // pointers case Tpointer: { assert(t->next); diff --git a/lphobos/build.sh b/lphobos/build.sh index 98960711..0b38812c 100755 --- a/lphobos/build.sh +++ b/lphobos/build.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "removing old objects" -mkdir obj +mkdir -p obj rm -f obj/*.bc rm -f ../lib/*.bc diff --git a/lphobos/typeinfo1/ti_idouble.d b/lphobos/typeinfo1/ti_idouble.d new file mode 100644 index 00000000..671e3585 --- /dev/null +++ b/lphobos/typeinfo1/ti_idouble.d @@ -0,0 +1,12 @@ + +// idouble + +module typeinfo1.ti_idouble; + +private import typeinfo1.ti_double; + +class TypeInfo_p : TypeInfo_d +{ + char[] toString() { return "idouble"; } +} + diff --git a/lphobos/typeinfo1/ti_ifloat.d b/lphobos/typeinfo1/ti_ifloat.d new file mode 100644 index 00000000..ce2d6fa2 --- /dev/null +++ b/lphobos/typeinfo1/ti_ifloat.d @@ -0,0 +1,12 @@ + +// ifloat + +module typeinfo1.ti_ifloat; + +private import typeinfo1.ti_float; + +class TypeInfo_o : TypeInfo_f +{ + char[] toString() { return "ifloat"; } +} + diff --git a/lphobos/typeinfo1/ti_ireal.d b/lphobos/typeinfo1/ti_ireal.d new file mode 100644 index 00000000..f5b16df9 --- /dev/null +++ b/lphobos/typeinfo1/ti_ireal.d @@ -0,0 +1,12 @@ + +// ireal + +module typeinfo1.ti_ireal; + +private import typeinfo1.ti_real; + +class TypeInfo_j : TypeInfo_e +{ + char[] toString() { return "ireal"; } +} + diff --git a/lphobos/typeinfo2/ti_Adouble.d b/lphobos/typeinfo2/ti_Adouble.d index fabd9511..634d40dc 100644 --- a/lphobos/typeinfo2/ti_Adouble.d +++ b/lphobos/typeinfo2/ti_Adouble.d @@ -100,7 +100,7 @@ class TypeInfo_Ad : TypeInfo } // idouble[] -version(none) + class TypeInfo_Ap : TypeInfo_Ad { char[] toString() { return "idouble[]"; } diff --git a/lphobos/typeinfo2/ti_Afloat.d b/lphobos/typeinfo2/ti_Afloat.d index 759c8a3c..27c2261a 100644 --- a/lphobos/typeinfo2/ti_Afloat.d +++ b/lphobos/typeinfo2/ti_Afloat.d @@ -99,7 +99,7 @@ class TypeInfo_Af : TypeInfo } // ifloat[] -version(none) + class TypeInfo_Ao : TypeInfo_Af { char[] toString() { return "ifloat[]"; } diff --git a/lphobos/typeinfo2/ti_Areal.d b/lphobos/typeinfo2/ti_Areal.d index 77e3b904..9fee6805 100644 --- a/lphobos/typeinfo2/ti_Areal.d +++ b/lphobos/typeinfo2/ti_Areal.d @@ -101,7 +101,7 @@ class TypeInfo_Ae : TypeInfo } // ireal[] -version(none) + class TypeInfo_Aj : TypeInfo_Ae { char[] toString() { return "ireal[]"; } diff --git a/lphobos/typeinfos1.d b/lphobos/typeinfos1.d index 9d40da8d..349308b1 100644 --- a/lphobos/typeinfos1.d +++ b/lphobos/typeinfos1.d @@ -7,7 +7,10 @@ typeinfo1.ti_delegate, typeinfo1.ti_dchar, typeinfo1.ti_double, typeinfo1.ti_float, +typeinfo1.ti_ifloat, +typeinfo1.ti_idouble, typeinfo1.ti_int, +typeinfo1.ti_ireal, typeinfo1.ti_long, typeinfo1.ti_ptr, typeinfo1.ti_real, diff --git a/test/imag1.d b/test/imag1.d new file mode 100644 index 00000000..83ef1de0 --- /dev/null +++ b/test/imag1.d @@ -0,0 +1,7 @@ +module imag1; + +void main() +{ + ifloat f = 1.0i; + auto x = 2.0i*f; +}