# HG changeset patch # User lindquist # Date 1193298516 -7200 # Node ID b86e00b938a549c2254113924f214f98ef3c1167 # Parent 0258a7171a42b0f57f1e8e3c0753aebde81faf93 [svn r66] Added support for imaginary floating point types diff -r 0258a7171a42 -r b86e00b938a5 gen/toir.c --- a/gen/toir.c Thu Oct 25 09:26:17 2007 +0200 +++ b/gen/toir.c Thu Oct 25 09:48:36 2007 +0200 @@ -328,10 +328,11 @@ { 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 -r 0258a7171a42 -r b86e00b938a5 gen/tollvm.c --- a/gen/tollvm.c Thu Oct 25 09:26:17 2007 +0200 +++ b/gen/tollvm.c Thu Oct 25 09:48:36 2007 +0200 @@ -65,11 +65,20 @@ // 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 -r 0258a7171a42 -r b86e00b938a5 lphobos/build.sh --- a/lphobos/build.sh Thu Oct 25 09:26:17 2007 +0200 +++ b/lphobos/build.sh Thu Oct 25 09:48:36 2007 +0200 @@ -1,7 +1,7 @@ #!/bin/bash echo "removing old objects" -mkdir obj +mkdir -p obj rm -f obj/*.bc rm -f ../lib/*.bc diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfo1/ti_idouble.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lphobos/typeinfo1/ti_idouble.d Thu Oct 25 09:48:36 2007 +0200 @@ -0,0 +1,12 @@ + +// idouble + +module typeinfo1.ti_idouble; + +private import typeinfo1.ti_double; + +class TypeInfo_p : TypeInfo_d +{ + char[] toString() { return "idouble"; } +} + diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfo1/ti_ifloat.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lphobos/typeinfo1/ti_ifloat.d Thu Oct 25 09:48:36 2007 +0200 @@ -0,0 +1,12 @@ + +// ifloat + +module typeinfo1.ti_ifloat; + +private import typeinfo1.ti_float; + +class TypeInfo_o : TypeInfo_f +{ + char[] toString() { return "ifloat"; } +} + diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfo1/ti_ireal.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lphobos/typeinfo1/ti_ireal.d Thu Oct 25 09:48:36 2007 +0200 @@ -0,0 +1,12 @@ + +// ireal + +module typeinfo1.ti_ireal; + +private import typeinfo1.ti_real; + +class TypeInfo_j : TypeInfo_e +{ + char[] toString() { return "ireal"; } +} + diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfo2/ti_Adouble.d --- a/lphobos/typeinfo2/ti_Adouble.d Thu Oct 25 09:26:17 2007 +0200 +++ b/lphobos/typeinfo2/ti_Adouble.d Thu Oct 25 09:48:36 2007 +0200 @@ -100,7 +100,7 @@ } // idouble[] -version(none) + class TypeInfo_Ap : TypeInfo_Ad { char[] toString() { return "idouble[]"; } diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfo2/ti_Afloat.d --- a/lphobos/typeinfo2/ti_Afloat.d Thu Oct 25 09:26:17 2007 +0200 +++ b/lphobos/typeinfo2/ti_Afloat.d Thu Oct 25 09:48:36 2007 +0200 @@ -99,7 +99,7 @@ } // ifloat[] -version(none) + class TypeInfo_Ao : TypeInfo_Af { char[] toString() { return "ifloat[]"; } diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfo2/ti_Areal.d --- a/lphobos/typeinfo2/ti_Areal.d Thu Oct 25 09:26:17 2007 +0200 +++ b/lphobos/typeinfo2/ti_Areal.d Thu Oct 25 09:48:36 2007 +0200 @@ -101,7 +101,7 @@ } // ireal[] -version(none) + class TypeInfo_Aj : TypeInfo_Ae { char[] toString() { return "ireal[]"; } diff -r 0258a7171a42 -r b86e00b938a5 lphobos/typeinfos1.d --- a/lphobos/typeinfos1.d Thu Oct 25 09:26:17 2007 +0200 +++ b/lphobos/typeinfos1.d Thu Oct 25 09:48:36 2007 +0200 @@ -7,7 +7,10 @@ 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 -r 0258a7171a42 -r b86e00b938a5 test/imag1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/imag1.d Thu Oct 25 09:48:36 2007 +0200 @@ -0,0 +1,7 @@ +module imag1; + +void main() +{ + ifloat f = 1.0i; + auto x = 2.0i*f; +}