From d474fa027a7338615750092f6ff18968d87b8bf3 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Wed, 10 Sep 2008 12:33:33 -0700 Subject: [PATCH] Fixed most regressions from last commit. --- gen/arrays.cpp | 15 ++++++++++++--- gen/complex.cpp | 5 ++++- gen/runtime.cpp | 11 ++++++++++- runtime/internal/arrayInit.d | 24 ++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/gen/arrays.cpp b/gen/arrays.cpp index d38a5065..1712e496 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -194,6 +194,18 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value) funcname = "_d_array_init_real"; break; + case Tcomplex32: + funcname = "_d_array_init_cfloat"; + break; + + case Tcomplex64: + funcname = "_d_array_init_cdouble"; + break; + + case Tcomplex80: + funcname = "_d_array_init_creal"; + break; + case Tpointer: case Tclass: funcname = "_d_array_init_pointer"; @@ -207,9 +219,6 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value) case Tdelegate: case Tarray: case Tsarray: - case Tcomplex32: - case Tcomplex64: - case Tcomplex80: funcname = "_d_array_init_mem"; args[0] = DtoBitCast(args[0], getVoidPtrType()); args[2] = DtoBitCast(args[2], getVoidPtrType()); diff --git a/gen/complex.cpp b/gen/complex.cpp index 39b36216..19833250 100644 --- a/gen/complex.cpp +++ b/gen/complex.cpp @@ -119,9 +119,12 @@ DValue* DtoComplex(Loc& loc, Type* to, DValue* val) if (t->isimaginary()) { res = DtoAggrPair(complexTy, LLConstant::getNullValue(DtoType(baserety)), DtoCastFloat(loc, val, baseimty)->getRVal()); } - else if (t->isfloating() || t->isintegral()) { + else if (t->isfloating()) { res = DtoAggrPair(complexTy, DtoCastFloat(loc, val, baserety)->getRVal(), LLConstant::getNullValue(DtoType(baseimty))); } + else if (t->isintegral()) { + res = DtoAggrPair(complexTy, DtoCastInt(loc, val, baserety)->getRVal(), LLConstant::getNullValue(DtoType(baseimty))); + } else { assert(0); } diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 49419452..e7253ed4 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -163,6 +163,8 @@ static void LLVM_D_BuildRuntimeModule() const LLType* shortTy = LLType::Int16Ty; const LLType* intTy = LLType::Int32Ty; const LLType* longTy = LLType::Int64Ty; + const LLType* sizeTy = DtoSize_t(); + const LLType* floatTy = LLType::FloatTy; const LLType* doubleTy = LLType::DoubleTy; const LLType* realTy; @@ -170,7 +172,11 @@ static void LLVM_D_BuildRuntimeModule() realTy = LLType::X86_FP80Ty; else realTy = LLType::DoubleTy; - const LLType* sizeTy = DtoSize_t(); + + const LLType* cfloatTy = llvm::StructType::get(floatTy, floatTy, 0); + const LLType* cdoubleTy = llvm::StructType::get(doubleTy, doubleTy, 0); + const LLType* crealTy = llvm::StructType::get(realTy, realTy, 0); + const LLType* voidPtrTy = rt_ptr(byteTy); const LLType* stringTy = rt_array(byteTy); const LLType* wstringTy = rt_array(shortTy); @@ -338,6 +344,9 @@ static void LLVM_D_BuildRuntimeModule() ARRAY_INIT(floatTy,"float") ARRAY_INIT(doubleTy,"double") ARRAY_INIT(realTy,"real") + ARRAY_INIT(cfloatTy,"cfloat") + ARRAY_INIT(cdoubleTy,"cdouble") + ARRAY_INIT(crealTy,"creal") ARRAY_INIT(voidPtrTy,"pointer") #undef ARRAY_INIT diff --git a/runtime/internal/arrayInit.d b/runtime/internal/arrayInit.d index 190cf2b7..c4feb8f8 100644 --- a/runtime/internal/arrayInit.d +++ b/runtime/internal/arrayInit.d @@ -76,6 +76,30 @@ void _d_array_init_real(real* a, size_t n, real v) *p++ = v; } +void _d_array_init_cfloat(cfloat* a, size_t n, cfloat v) +{ + auto p = a; + auto end = a+n; + while (p !is end) + *p++ = v; +} + +void _d_array_init_cdouble(cdouble* a, size_t n, cdouble v) +{ + auto p = a; + auto end = a+n; + while (p !is end) + *p++ = v; +} + +void _d_array_init_creal(creal* a, size_t n, creal v) +{ + auto p = a; + auto end = a+n; + while (p !is end) + *p++ = v; +} + void _d_array_init_pointer(void** a, size_t n, void* v) { auto p = a;