Mercurial > projects > ldc
diff gen/arrays.cpp @ 100:5071469303d4 trunk
[svn r104] TONS OF FIXES.
Split up declaration, constant initializer gen and definition for globals, structs, classes and functions.
Improved ClassInfo support (not complete), not in vtable yet.
Fixed a bunch of forward reference problems.
Much more. Major commit! :)
author | lindquist |
---|---|
date | Fri, 16 Nov 2007 08:21:47 +0100 |
parents | a676a7743642 |
children | 027b8d8b71ec |
line wrap: on
line diff
--- a/gen/arrays.cpp Thu Nov 15 00:24:44 2007 +0100 +++ b/gen/arrays.cpp Fri Nov 16 08:21:47 2007 +0100 @@ -42,7 +42,7 @@ const llvm::ArrayType* DtoStaticArrayType(Type* t) { if (t->llvmType) - return isaArray(t->llvmType); + return isaArray(t->llvmType->get()); assert(t->ty == Tsarray); assert(t->next); @@ -53,7 +53,8 @@ assert(tsa->dim->type->isintegral()); const llvm::ArrayType* arrty = llvm::ArrayType::get(at,tsa->dim->toUInteger()); - tsa->llvmType = arrty; + assert(!tsa->llvmType); + tsa->llvmType = new llvm::PATypeHolder(arrty); return arrty; } @@ -547,7 +548,7 @@ ////////////////////////////////////////////////////////////////////////////////////////// // helper for eq and cmp -static llvm::Value* DtoArrayEqCmp_impl(const char* func, DValue* l, DValue* r) +static llvm::Value* DtoArrayEqCmp_impl(const char* func, DValue* l, DValue* r, bool useti) { llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, func); assert(fn); @@ -588,14 +589,17 @@ args.push_back(DtoBitCast(lmem,pt)); args.push_back(DtoBitCast(rmem,pt)); - TypeInfoDeclaration* ti = DtoDType(l->getType())->next->getTypeInfoDeclaration(); - if (!ti->llvmValue) { - ti->toObjFile(); + // pass element typeinfo ? + if (useti) { + TypeInfoDeclaration* ti = DtoDType(l->getType())->next->getTypeInfoDeclaration(); + if (!ti->llvmValue) { + ti->toObjFile(); + } + Logger::cout() << "typeinfo decl: " << *ti->llvmValue << '\n'; + + pt = fn->getFunctionType()->getParamType(2); + args.push_back(DtoBitCast(ti->llvmValue, pt)); } - Logger::cout() << "typeinfo decl: " << *ti->llvmValue << '\n'; - - pt = fn->getFunctionType()->getParamType(2); - args.push_back(DtoBitCast(ti->llvmValue, pt)); return gIR->ir->CreateCall(fn, args.begin(), args.end(), "tmp"); } @@ -606,7 +610,7 @@ llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_adEq"); assert(fn); - llvm::Value* res = DtoArrayEqCmp_impl("_adEq", l, r); + llvm::Value* res = DtoArrayEqCmp_impl("_adEq", l, r, true); if (op == TOKnotequal) res = gIR->ir->CreateNot(res, "tmp"); @@ -660,7 +664,11 @@ if (!skip) { - res = DtoArrayEqCmp_impl("_adCmp", l, r); + Type* t = DtoDType(DtoDType(l->getType())->next); + if (t->ty == Tchar) + res = DtoArrayEqCmp_impl("_adCmpChar", l, r, false); + else + res = DtoArrayEqCmp_impl("_adCmp", l, r, true); res = new llvm::ICmpInst(cmpop, res, DtoConstInt(0), "tmp", gIR->scopebb()); }