Mercurial > projects > ldc
diff gen/functions.cpp @ 797:340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Fixed function literals in static initializers.
Changed alignment of delegates from 2*PTRSIZE to just PTRSIZE.
Changed errors to go to stderr instead of stdout.
Fairly major rewriting of struct/union/class handling, STILL A BIT BUGGY !!!
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 29 Nov 2008 21:25:43 +0100 |
parents | f04dde6e882c |
children | 504a21e81a46 |
line wrap: on
line diff
--- a/gen/functions.cpp Sat Nov 29 12:28:10 2008 +0100 +++ b/gen/functions.cpp Sat Nov 29 21:25:43 2008 +0100 @@ -97,16 +97,8 @@ } if (dVararg) { - ClassDeclaration* ti = Type::typeinfo; - ti->toObjFile(0); // TODO: multiobj - DtoForceConstInitDsymbol(ti); - assert(ti->ir.irStruct->constInit); - std::vector<const LLType*> types; - types.push_back(DtoSize_t()); - types.push_back(getPtrToType(getPtrToType(ti->ir.irStruct->constInit->getType()))); - const LLType* t1 = llvm::StructType::get(types); - paramvec.push_back(t1); - paramvec.push_back(getPtrToType(LLType::Int8Ty)); + paramvec.push_back(DtoType(Type::typeinfo->type->arrayOf())); // _arguments + paramvec.push_back(getVoidPtrType()); // _argptr } // number of formal params @@ -286,7 +278,7 @@ Logger::println("isMember = this is: %s", ad->type->toChars()); thisty = DtoType(ad->type); //Logger::cout() << "this llvm type: " << *thisty << '\n'; - if (isaStruct(thisty) || (!gIR->structs.empty() && thisty == gIR->topstruct()->recty.get())) + if (isaStruct(thisty) || (!gIR->structs.empty() && thisty == gIR->topstruct()->type->ir.type->get())) thisty = getPtrToType(thisty); } else { @@ -547,35 +539,36 @@ } // we never reference parameters of function prototypes + std::string str; if (!declareOnly) { // name parameters llvm::Function::arg_iterator iarg = func->arg_begin(); if (f->retInPtr) { - iarg->setName(".sretarg"); + iarg->setName(".sret_arg"); fdecl->ir.irFunc->retArg = iarg; ++iarg; } if (f->usesThis) { - iarg->setName("this"); + iarg->setName(".this_arg"); fdecl->ir.irFunc->thisArg = iarg; assert(fdecl->ir.irFunc->thisArg); ++iarg; } else if (f->usesNest) { - iarg->setName(".nest"); + iarg->setName(".nest_arg"); fdecl->ir.irFunc->nestArg = iarg; assert(fdecl->ir.irFunc->nestArg); ++iarg; } if (f->linkage == LINKd && f->varargs == 1) { - iarg->setName("_arguments"); + iarg->setName("._arguments"); fdecl->ir.irFunc->_arguments = iarg; ++iarg; - iarg->setName("_argptr"); + iarg->setName("._argptr"); fdecl->ir.irFunc->_argptr = iarg; ++iarg; } @@ -597,7 +590,10 @@ assert(!argvd->ir.irLocal); argvd->ir.irLocal = new IrLocal(argvd); argvd->ir.irLocal->value = iarg; - iarg->setName(argvd->ident->toChars()); + + str = argvd->ident->toChars(); + str.append("_arg"); + iarg->setName(str); k++; } @@ -671,8 +667,7 @@ if (fd->isMain()) gIR->emitMain = true; - std::string entryname("entry_"); - entryname.append(fd->toPrettyChars()); + std::string entryname("entry"); llvm::BasicBlock* beginbb = llvm::BasicBlock::Create(entryname,func); llvm::BasicBlock* endbb = llvm::BasicBlock::Create("endentry",func); @@ -710,7 +705,7 @@ LLValue* thisvar = irfunction->thisArg; assert(thisvar); - LLValue* thismem = DtoAlloca(thisvar->getType(), ".this"); + LLValue* thismem = DtoAlloca(thisvar->getType(), "this"); DtoStore(thisvar, thismem); irfunction->thisArg = thismem; @@ -760,7 +755,7 @@ if (!refout && (!DtoIsPassedByRef(vd->type) || lazy)) { LLValue* a = irloc->value; - LLValue* v = DtoAlloca(a->getType(), "."+a->getName()); + LLValue* v = DtoAlloca(a->getType(), vd->ident->toChars()); DtoStore(a,v); irloc->value = v; } @@ -822,7 +817,7 @@ ClassDeclaration* cd = fd->isMember2()->isClassDeclaration(); assert(cd); assert(cd->vthis); - src = DtoLoad(DtoGEPi(thisval, 0,2+cd->vthis->ir.irField->index, ".vthis")); + src = DtoLoad(DtoGEPi(thisval, 0,cd->vthis->ir.irField->index, ".vthis")); } DtoMemCpy(nestedVars, src, DtoConstSize_t(nparelems*PTRSIZE)); }