From 1e4a8fffc2e0dc913e0e947ae3eeccb338c0a4b0 Mon Sep 17 00:00:00 2001 From: kai Date: Tue, 5 Mar 2013 18:37:09 +0100 Subject: [PATCH] Remove DMDV1 and DMDV2. --- driver/cl_options.cpp | 9 - driver/cl_options.h | 2 - driver/ldmd.cpp | 12 -- driver/main.cpp | 17 -- gen/aa.cpp | 54 ------ gen/abi-ppc64.cpp | 3 +- gen/abi-win64.cpp | 4 - gen/abi-x86-64.cpp | 3 +- gen/abi-x86.cpp | 3 +- gen/abi.cpp | 3 +- gen/arrays.cpp | 272 ---------------------------- gen/arrays.h | 5 - gen/asmstmt.cpp | 7 - gen/binops.cpp | 9 - gen/classes.cpp | 5 - gen/declarations.cpp | 12 +- gen/functions.cpp | 39 ---- gen/irstate.h | 6 - gen/llvmhelpers.cpp | 61 ------- gen/llvmhelpers.h | 2 - gen/module.cpp | 27 --- gen/nested.cpp | 50 +---- gen/nested.h | 4 - gen/passes/GarbageCollect2Stack.cpp | 5 - gen/pragma.cpp | 6 - gen/runtime.cpp | 139 -------------- gen/runtime.h | 6 - gen/statements.cpp | 33 +--- gen/structs.cpp | 2 - gen/tocall.cpp | 16 -- gen/todebug.cpp | 4 - gen/toir.cpp | 80 -------- gen/tollvm.cpp | 6 - gen/typinf.cpp | 59 ------ ir/irclass.cpp | 2 - ir/irlandingpad.cpp | 8 - ir/irstruct.cpp | 2 - ir/irtype.cpp | 4 - ir/irtype.h | 6 - ir/irtypeclass.cpp | 2 - 40 files changed, 8 insertions(+), 981 deletions(-) diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp index dda40e86..76878d02 100644 --- a/driver/cl_options.cpp +++ b/driver/cl_options.cpp @@ -31,12 +31,6 @@ cl::list runargs("run", cl::Positional, cl::PositionalEatsArgs); -#if DMDV1 -static cl::opt useDeprecated("d", - cl::desc("Allow deprecated language features"), - cl::ZeroOrMore, - cl::location(global.params.useDeprecated)); -#else static cl::opt useDeprecated( cl::desc("Allow deprecated code/language features:"), cl::ZeroOrMore, @@ -47,14 +41,11 @@ static cl::opt useDeprecated( clEnumValEnd), cl::location(global.params.useDeprecated), cl::init(2)); -#endif -#if DMDV2 cl::opt enforcePropertySyntax("property", cl::desc("Enforce property syntax"), cl::ZeroOrMore, cl::location(global.params.enforcePropertySyntax)); -#endif static cl::opt useDv1( cl::desc("Force language version:"), diff --git a/driver/cl_options.h b/driver/cl_options.h index 605b21e3..d1320894 100644 --- a/driver/cl_options.h +++ b/driver/cl_options.h @@ -31,9 +31,7 @@ namespace opts { extern cl::list fileList; extern cl::list runargs; extern cl::opt compileOnly; -#if DMDV2 extern cl::opt enforcePropertySyntax; -#endif extern cl::opt createStaticLib; extern cl::opt createSharedLib; extern cl::opt noAsm; diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp index 498d1032..d6de17b0 100644 --- a/driver/ldmd.cpp +++ b/driver/ldmd.cpp @@ -185,9 +185,7 @@ Usage:\n\ #if 0 " -map generate linker .map file\n" #endif -#if DMDV2 " -noboundscheck turns off array bounds checking for all functions\n" -#endif " -nofloat do not emit reference to floating point\n\ -O optimize\n\ -o- do not write object file\n\ @@ -450,18 +448,12 @@ Params parseArgs(size_t originalArgc, char** originalArgv, ls::Path ldcPath) result.verbose = true; else if (strcmp(p + 1, "vdmd") == 0) result.vdmd = true; -#if DMDV2 else if (strcmp(p + 1, "vtls") == 0) result.logTlsUse = true; -#endif else if (strcmp(p + 1, "v1") == 0) { -#if DMDV1 - // Just ignore, for backwards compatibility. -#else error("use DMD 1.0 series compilers for -v1 switch"); break; -#endif } else if (strcmp(p + 1, "w") == 0) result.warnings = Warnings::asErrors; @@ -582,10 +574,8 @@ Params parseArgs(size_t originalArgc, char** originalArgv, ls::Path ldcPath) result.quiet = 1; else if (strcmp(p + 1, "release") == 0) result.release = 1; -#if DMDV2 else if (strcmp(p + 1, "noboundscheck") == 0) result.noBoundsChecks = 1; -#endif else if (strcmp(p + 1, "unittest") == 0) result.emitUnitTests = 1; else if (p[1] == 'I') @@ -752,12 +742,10 @@ void buildCommandLine(std::vector& r, const Params& p) if (p.emitSharedLib) r.push_back("-shared"); if (p.pic) r.push_back("-relocation-model=pic"); if (p.emitMap) warning("Map file generation not yet supported by LDC."); -#ifndef DMDV1 // LDMD historically did not enable singleobj mode, so in order not to // break build systems as a D1 parting gift, don't change this right now. // This might change based on user feedback, though. if (!p.multiObj) r.push_back("-singleobj"); -#endif if (p.debugInfo == Debug::normal) r.push_back("-g"); else if (p.debugInfo == Debug::pretendC) r.push_back("-gc"); if (p.alwaysStackFrame) r.push_back("-disable-fp-elim"); diff --git a/driver/main.cpp b/driver/main.cpp index 608fbb17..4dd31edc 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -192,9 +192,7 @@ int main(int argc, char** argv) VersionCondition::addPredefinedGlobalIdent("LLVM"); // For backwards compatibility. VersionCondition::addPredefinedGlobalIdent("LDC"); VersionCondition::addPredefinedGlobalIdent("all"); -#if DMDV2 VersionCondition::addPredefinedGlobalIdent("D_Version2"); -#endif // build complete fixed up list of command line arguments std::vector final_args; @@ -210,11 +208,7 @@ int main(int argc, char** argv) ConfigFile cfg_file; // just ignore errors for now, they are still printed -#if DMDV2 #define CFG_FILENAME "ldc2.conf" -#else -#define CFG_FILENAME "ldc.conf" -#endif cfg_file.read(global.params.argv0, (void*)main, CFG_FILENAME); #undef CFG_FILENAME @@ -374,16 +368,7 @@ int main(int argc, char** argv) } else { -#if DMDV2 global.params.linkswitches->push(mem.strdup("-ldruntime-ldc")); -#else - global.params.linkswitches->push(mem.strdup("-lldc-runtime")); - global.params.linkswitches->push(mem.strdup("-ltango-cc-tango")); - global.params.linkswitches->push(mem.strdup("-ltango-gc-basic")); - // pass the runtime again to resolve issues - // with linking order - global.params.linkswitches->push(mem.strdup("-lldc-runtime")); -#endif } } @@ -748,7 +733,6 @@ int main(int argc, char** argv) if (global.params.doDocComments) VersionCondition::addPredefinedGlobalIdent("D_Ddoc"); -#if DMDV2 // unittests? if (global.params.useUnitTests) VersionCondition::addPredefinedGlobalIdent("unittest"); @@ -758,7 +742,6 @@ int main(int argc, char** argv) if (!global.params.useArrayBounds) VersionCondition::addPredefinedGlobalIdent("D_NoBoundsChecks"); -#endif // Initialization Type::init(&ir); diff --git a/gen/aa.cpp b/gen/aa.cpp index a88b108e..1f370611 100644 --- a/gen/aa.cpp +++ b/gen/aa.cpp @@ -21,7 +21,6 @@ #include "gen/tollvm.h" #include "ir/irmodule.h" -#if DMDV2 // returns the keytype typeinfo static LLValue* to_keyti(DValue* aa) { @@ -30,15 +29,6 @@ static LLValue* to_keyti(DValue* aa) TypeAArray * aatype = static_cast(aa->type->toBasetype()); return DtoTypeInfoOf(aatype->index, false); } -#else -// returns the keytype typeinfo -static LLValue* to_keyti(DValue* key) -{ - // keyti param - Type* keytype = key->getType(); - return DtoTypeInfoOf(keytype, false); -} -#endif ///////////////////////////////////////////////////////////////////////////////////// @@ -57,11 +47,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) // extern(C) void* _aaInX(AA aa*, TypeInfo keyti, void* pkey) // first get the runtime function -#if DMDV2 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGetX":"_aaInX"); -#else - llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGet":"_aaIn"); -#endif LLFunctionType* funcTy = func->getFunctionType(); // aa param @@ -69,11 +55,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param -#if DMDV2 LLValue* keyti = to_keyti(aa); -#else - LLValue* keyti = to_keyti(key); -#endif keyti = DtoBitCast(keyti, funcTy->getParamType(1)); // pkey param @@ -113,16 +95,10 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue) std::vector args; -#if DMDV2 // module param LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol(); LLType *moduleInfoType = DtoType(Module::moduleinfo->type); args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType))); -#else - // file param - IrModule* irmod = getIrModule(NULL); - args.push_back(DtoLoad(irmod->fileName)); -#endif // line param LLConstant* c = DtoConstUint(loc.linnum); @@ -154,11 +130,7 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key) // extern(C) void* _aaInX(AA aa*, TypeInfo keyti, void* pkey) // first get the runtime function -#if DMDV2 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaInX"); -#else - llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaIn"); -#endif LLFunctionType* funcTy = func->getFunctionType(); if (Logger::enabled()) @@ -174,11 +146,7 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key) aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param -#if DMDV2 LLValue* keyti = to_keyti(aa); -#else - LLValue* keyti = to_keyti(key); -#endif keyti = DtoBitCast(keyti, funcTy->getParamType(1)); // pkey param @@ -209,11 +177,7 @@ DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key) // extern(C) bool _aaDelX(AA aa, TypeInfo keyti, void* pkey) // first get the runtime function -#if DMDV2 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaDelX"); -#else - llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaDel"); -#endif LLFunctionType* funcTy = func->getFunctionType(); if (Logger::enabled()) @@ -229,11 +193,7 @@ DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key) aaval = DtoBitCast(aaval, funcTy->getParamType(0)); // keyti param -#if DMDV2 LLValue* keyti = to_keyti(aa); -#else - LLValue* keyti = to_keyti(key); -#endif keyti = DtoBitCast(keyti, funcTy->getParamType(1)); // pkey param @@ -249,11 +209,7 @@ DValue *DtoAARemove(Loc& loc, DValue* aa, DValue* key) // call runtime LLCallSite call = gIR->CreateCallOrInvoke(func, args); -#if DMDV2 return new DImValue(Type::tbool, call.getInstruction()); -#else - return NULL; -#endif } ///////////////////////////////////////////////////////////////////////////////////// @@ -262,7 +218,6 @@ LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r) { Type* t = l->getType()->toBasetype(); assert(t == r->getType()->toBasetype() && "aa equality is only defined for aas of same type"); -#if DMDV2 llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEqual"); LLFunctionType* funcTy = func->getFunctionType(); @@ -270,15 +225,6 @@ LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r) LLValue* abval = DtoBitCast(r->getRVal(), funcTy->getParamType(2)); LLValue* aaTypeInfo = DtoTypeInfoOf(t); LLValue* res = gIR->CreateCallOrInvoke3(func, aaTypeInfo, aaval, abval, "aaEqRes").getInstruction(); -#else - llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEq"); - LLFunctionType* funcTy = func->getFunctionType(); - - LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(0)); - LLValue* abval = DtoBitCast(r->getRVal(), funcTy->getParamType(1)); - LLValue* aaTypeInfo = DtoTypeInfoOf(t); - LLValue* res = gIR->CreateCallOrInvoke3(func, aaval, abval, aaTypeInfo, "aaEqRes").getInstruction(); -#endif res = gIR->ir->CreateICmpNE(res, DtoConstInt(0), "tmp"); if (op == TOKnotequal) res = gIR->ir->CreateNot(res, "tmp"); diff --git a/gen/abi-ppc64.cpp b/gen/abi-ppc64.cpp index bb77d295..d707193c 100644 --- a/gen/abi-ppc64.cpp +++ b/gen/abi-ppc64.cpp @@ -44,10 +44,9 @@ struct PPC64TargetABI : TargetABI { bool returnInArg(TypeFunction* tf) { -#if DMDV2 if (tf->isref) return false; -#endif + // Return structs and static arrays on the stack. The latter is needed // because otherwise LLVM tries to actually return the array in a number // of physical registers, which leads, depending on the target, to diff --git a/gen/abi-win64.cpp b/gen/abi-win64.cpp index 12330644..bd76d5cb 100644 --- a/gen/abi-win64.cpp +++ b/gen/abi-win64.cpp @@ -127,10 +127,8 @@ llvm::CallingConv::ID Win64TargetABI::callingConv(LINK l) bool Win64TargetABI::returnInArg(TypeFunction* tf) { -#if DMDV2 if (tf->isref) return false; -#endif Type* rt = tf->next->toBasetype(); @@ -164,9 +162,7 @@ void Win64TargetABI::rewriteFunctionType(TypeFunction* tf) // RETURN VALUE -#if DMDV2 if (!tf->isref) -#endif { if (rt->ty == Tcomplex80) { diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index 7ac2ae89..69771f1f 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -439,10 +439,9 @@ bool X86_64TargetABI::returnInArg(TypeFunction* tf) { Type* rt = tf->next->toBasetype(); if (tf->linkage == LINKd) { -#if DMDV2 if (tf->isref) return false; -#endif + // All non-structs can be returned in registers. return rt->ty == Tstruct #if SARRAYVALUE diff --git a/gen/abi-x86.cpp b/gen/abi-x86.cpp index f7734604..9dd4ef92 100644 --- a/gen/abi-x86.cpp +++ b/gen/abi-x86.cpp @@ -70,10 +70,9 @@ struct X86TargetABI : TargetABI bool returnInArg(TypeFunction* tf) { -#if DMDV2 if (tf->isref) return false; -#endif + Type* rt = tf->next->toBasetype(); // D only returns structs on the stack if (tf->linkage == LINKd) diff --git a/gen/abi.cpp b/gen/abi.cpp index e2f9f3c1..b76e3d7e 100644 --- a/gen/abi.cpp +++ b/gen/abi.cpp @@ -58,10 +58,9 @@ struct UnknownTargetABI : TargetABI bool returnInArg(TypeFunction* tf) { -#if DMDV2 if (tf->isref) return false; -#endif + // Return structs and static arrays on the stack. The latter is needed // because otherwise LLVM tries to actually return the array in a number // of physical registers, which leads, depending on the target, to diff --git a/gen/arrays.cpp b/gen/arrays.cpp index 609b5683..bbebb884 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -114,13 +114,11 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value, int op) Logger::println("DtoArrayInit"); LOG_SCOPE; -#if DMDV2 if (op != -1 && op != TOKblit && arrayNeedsPostblit(array->type)) { DtoArraySetAssign(loc, array, value, op); return; } -#endif LLValue* dim = DtoArrayLen(array); LLValue* ptr = DtoArrayPtr(array); @@ -183,8 +181,6 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value, int op) ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - Type *DtoArrayElementType(Type *arrayType) { assert(arrayType->toBasetype()->nextOf()); @@ -252,8 +248,6 @@ void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op) call.setCallingConv(llvm::CallingConv::C); } -#endif - ////////////////////////////////////////////////////////////////////////////////////////// void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr) @@ -451,11 +445,9 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit) // be used as an initializer for a static T[] - where modifying contents is allowed. LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, constarr->getType(), false, LLGlobalValue::InternalLinkage, constarr, ".constarray"); -#if DMDV2 if (arrty->ty == Tpointer) // we need to return pointer to the static array. return DtoBitCast(gvar, DtoType(arrty)); -#endif LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; @@ -589,8 +581,6 @@ DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool default defaultInit = false; bool zeroInit = eltType->isZeroInit(); -#if DMDV2 - const char* fnname = zeroInit ? "_d_newarrayT" : "_d_newarrayiT"; LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); @@ -598,27 +588,6 @@ DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool default LLValue* newArray = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction(); return getSlice(arrayType, newArray); - -#else - - const char* fnname = defaultInit ? (zeroInit ? "_d_newarrayT" : "_d_newarrayiT") : "_d_newarrayvT"; - LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); - - // call allocator - LLValue* newptr = gIR->CreateCallOrInvoke2(fn, arrayTypeInfo, arrayLen, ".gc_mem").getInstruction(); - - // cast to wanted type - LLType* dstType = DtoType(arrayType)->getContainedType(1); - if (newptr->getType() != dstType) - newptr = DtoBitCast(newptr, dstType, ".gc_mem"); - - if (Logger::enabled()) - Logger::cout() << "final ptr = " << *newptr << '\n'; - - return new DSliceValue(arrayType, arrayLen, newptr); - - -#endif } ////////////////////////////////////////////////////////////////////////////////////////// @@ -640,7 +609,6 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size if (defaultInit && !isInitialized(vtype)) defaultInit = false; -#if DMDV2 const char* fnname = zeroInit ? "_d_newarraymT" : "_d_newarraymiT"; LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); @@ -660,35 +628,6 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size Logger::cout() << "final ptr = " << *newptr << '\n'; return getSlice(arrayType, newptr); -#else - - const char* fnname = defaultInit ? (zeroInit ? "_d_newarraymT" : "_d_newarraymiT") : "_d_newarraymvT"; - LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, fnname); - - // build dims - LLValue* dimsArg = DtoArrayAlloca(Type::tsize_t, ndims, ".newdims"); - LLValue* firstDim = NULL; - for (size_t i=0; igetRVal(); - if (!firstDim) firstDim = dim; - DtoStore(dim, DtoGEPi1(dimsArg, i)); - } - - // call allocator - LLValue* newptr = gIR->CreateCallOrInvoke3(fn, arrayTypeInfo, DtoConstSize_t(ndims), dimsArg, ".gc_mem").getInstruction(); - - // cast to wanted type - LLType* dstType = DtoType(arrayType)->getContainedType(1); - if (newptr->getType() != dstType) - newptr = DtoBitCast(newptr, dstType, ".gc_mem"); - - if (Logger::enabled()) - Logger::cout() << "final ptr = " << *newptr << '\n'; - - assert(firstDim); - return new DSliceValue(arrayType, firstDim, newptr); -#endif } ////////////////////////////////////////////////////////////////////////////////////////// @@ -712,33 +651,13 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, LLValue* newdim) args.push_back(DtoTypeInfoOf(arrayType)); args.push_back(newdim); -#if DMDV2 - args.push_back(DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(2))); LLValue* newArray = gIR->CreateCallOrInvoke(fn, args, ".gc_mem").getInstruction(); return getSlice(arrayType, newArray); - -#else - - args.push_back(DtoArrayLen(array)); - - LLValue* arrPtr = DtoArrayPtr(array); - if (Logger::enabled()) - Logger::cout() << "arrPtr = " << *arrPtr << '\n'; - args.push_back(DtoBitCast(arrPtr, fn->getFunctionType()->getParamType(3), "tmp")); - - LLValue* newptr = gIR->CreateCallOrInvoke(fn, args, ".gc_mem").getInstruction(); - if (newptr->getType() != arrPtr->getType()) - newptr = DtoBitCast(newptr, arrPtr->getType(), ".gc_mem"); - - return new DSliceValue(arrayType, newdim, newptr); - -#endif } ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* exp) { @@ -768,32 +687,8 @@ void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* e callPostblit(loc, exp, val); } -#else - -void DtoCatAssignElement(Loc& loc, Type* arrayType, DValue* array, Expression* exp) -{ - Logger::println("DtoCatAssignElement"); - LOG_SCOPE; - - assert(array); - - LLValue *valueToAppend = makeLValue(loc, exp->toElem(gIR)); - - LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_arrayappendcT"); - LLSmallVector args; - args.push_back(DtoTypeInfoOf(arrayType)); - args.push_back(DtoBitCast(array->getLVal(), fn->getFunctionType()->getParamType(1))); - args.push_back(DtoBitCast(valueToAppend, getVoidPtrType())); - - gIR->CreateCallOrInvoke(fn, args, ".appendedArray"); -} - -#endif - ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp) { Logger::println("DtoCatAssignArray"); @@ -818,44 +713,8 @@ DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp) return getSlice(arrayType, newArray); } -#else - -DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp) -{ - Logger::println("DtoCatAssignArray"); - LOG_SCOPE; - - DValue* e = exp->toElem(gIR); - - llvm::Value *len1, *len2, *src1, *src2, *res; - - len1 = DtoArrayLen(arr); - len2 = DtoArrayLen(e); - res = gIR->ir->CreateAdd(len1,len2,"tmp"); - - DValue* newdim = new DImValue(Type::tsize_t, res); - DSliceValue* slice = DtoResizeDynArray(arr->getType(), arr, newdim->getRVal()); - - src1 = slice->ptr; - src2 = DtoArrayPtr(e); - - // advance ptr - src1 = gIR->ir->CreateGEP(src1,len1,"tmp"); - - // memcpy - LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(src2->getType()->getContainedType(0))); - LLValue* bytelen = gIR->ir->CreateMul(len2, elemSize, "tmp"); - DtoMemCpy(src1,src2,bytelen); - - return slice; -} - -#endif - ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2) { Logger::println("DtoCatAssignArray"); @@ -904,117 +763,6 @@ DSliceValue* DtoCatArrays(Type* arrayType, Expression* exp1, Expression* exp2) return getSlice(arrayType, newArray); } -#else - -DSliceValue* DtoCatArrays(Type* type, Expression* exp1, Expression* exp2) -{ - Logger::println("DtoCatArrays"); - LOG_SCOPE; - - Type* t1 = exp1->type->toBasetype(); - Type* t2 = exp2->type->toBasetype(); - - assert(t1->ty == Tarray || t1->ty == Tsarray); - assert(t2->ty == Tarray || t2->ty == Tsarray); - - DValue* e1 = exp1->toElem(gIR); - DValue* e2 = exp2->toElem(gIR); - - llvm::Value *len1, *len2, *src1, *src2, *res; - - len1 = DtoArrayLen(e1); - len2 = DtoArrayLen(e2); - res = gIR->ir->CreateAdd(len1,len2,"tmp"); - - DValue* lenval = new DImValue(Type::tsize_t, res); - DSliceValue* slice = DtoNewDynArray(exp1->loc, type, lenval, false); - LLValue* mem = slice->ptr; - - src1 = DtoArrayPtr(e1); - src2 = DtoArrayPtr(e2); - - // first memcpy - LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(src1->getType()->getContainedType(0))); - LLValue* bytelen = gIR->ir->CreateMul(len1, elemSize, "tmp"); - DtoMemCpy(mem,src1,bytelen); - - // second memcpy - mem = gIR->ir->CreateGEP(mem,len1,"tmp"); - bytelen = gIR->ir->CreateMul(len2, elemSize, "tmp"); - DtoMemCpy(mem,src2,bytelen); - - return slice; -} - -#endif - -////////////////////////////////////////////////////////////////////////////////////////// - -#if DMDV1 - -DSliceValue* DtoCatArrayElement(Type* type, Expression* exp1, Expression* exp2) -{ - Logger::println("DtoCatArrayElement"); - LOG_SCOPE; - - Type* t1 = exp1->type->toBasetype(); - Type* t2 = exp2->type->toBasetype(); - - DValue* e1 = exp1->toElem(gIR); - DValue* e2 = exp2->toElem(gIR); - - llvm::Value *len1, *src1, *res; - - // handle prefix case, eg. int~int[] - if (t2->nextOf() && t1 == t2->nextOf()->toBasetype()) - { - len1 = DtoArrayLen(e2); - res = gIR->ir->CreateAdd(len1,DtoConstSize_t(1),"tmp"); - - DValue* lenval = new DImValue(Type::tsize_t, res); - DSliceValue* slice = DtoNewDynArray(exp1->loc, type, lenval, false); - LLValue* mem = slice->ptr; - - DVarValue* memval = new DVarValue(e1->getType(), mem); - DtoAssign(exp1->loc, memval, e1); - - src1 = DtoArrayPtr(e2); - - mem = gIR->ir->CreateGEP(mem,DtoConstSize_t(1),"tmp"); - - LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(src1->getType()->getContainedType(0))); - LLValue* bytelen = gIR->ir->CreateMul(len1, elemSize, "tmp"); - DtoMemCpy(mem,src1,bytelen); - - - return slice; - } - // handle suffix case, eg. int[]~int - else - { - len1 = DtoArrayLen(e1); - res = gIR->ir->CreateAdd(len1,DtoConstSize_t(1),"tmp"); - - DValue* lenval = new DImValue(Type::tsize_t, res); - DSliceValue* slice = DtoNewDynArray(exp1->loc, type, lenval, false); - LLValue* mem = slice->ptr; - - src1 = DtoArrayPtr(e1); - - LLValue* elemSize = DtoConstSize_t(getTypePaddedSize(src1->getType()->getContainedType(0))); - LLValue* bytelen = gIR->ir->CreateMul(len1, elemSize, "tmp"); - DtoMemCpy(mem,src1,bytelen); - - mem = gIR->ir->CreateGEP(mem,len1,"tmp"); - DVarValue* memval = new DVarValue(e2->getType(), mem); - DtoAssign(exp1->loc, memval, e2); - - return slice; - } -} - -#endif - ////////////////////////////////////////////////////////////////////////////////////////// DSliceValue* DtoAppendDChar(DValue* arr, Expression* exp, const char *func) @@ -1357,13 +1105,8 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to) void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, DValue* lowerBound) { Type* arrty = arr->getType()->toBasetype(); -#if DMDV2 assert((arrty->ty == Tsarray || arrty->ty == Tarray || arrty->ty == Tpointer) && "Can only array bounds check for static or dynamic arrays"); -#else - assert((arrty->ty == Tsarray || arrty->ty == Tarray) && - "Can only array bounds check for static or dynamic arrays"); -#endif // static arrays could get static checks for static indices // but shouldn't since it might be generic code that's never executed @@ -1405,25 +1148,10 @@ void DtoArrayBoundsCheck(Loc& loc, DValue* arr, DValue* index, DValue* lowerBoun std::vector args; Module* funcmodule = gIR->func()->decl->getModule(); -#if DMDV2 // module param LLValue *moduleInfoSymbol = funcmodule->moduleInfoSymbol(); LLType *moduleInfoType = DtoType(Module::moduleinfo->type); args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType))); -#else - // file param - // we might be generating for an imported template function - const char* cur_file = funcmodule->srcfile->name->toChars(); - if (loc.filename && strcmp(loc.filename, cur_file) != 0) - { - args.push_back(DtoConstString(loc.filename)); - } - else - { - IrModule* irmod = getIrModule(funcmodule); - args.push_back(DtoLoad(irmod->fileName)); - } -#endif // line param LLConstant* c = DtoConstUint(loc.linnum); diff --git a/gen/arrays.h b/gen/arrays.h index d32ac898..391eda32 100644 --- a/gen/arrays.h +++ b/gen/arrays.h @@ -36,12 +36,10 @@ void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src); void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src); void DtoArrayInit(Loc& loc, DValue* array, DValue* value, int op); -#if DMDV2 Type *DtoArrayElementType(Type *arrayType); bool arrayNeedsPostblit(Type *t); void DtoArrayAssign(DValue *from, DValue *to, int op); void DtoArraySetAssign(Loc &loc, DValue *array, DValue *value, int op); -#endif void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr); void DtoSetArrayToNull(LLValue* v); @@ -52,9 +50,6 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, llvm::Value* newd void DtoCatAssignElement(Loc& loc, Type* type, DValue* arr, Expression* exp); DSliceValue* DtoCatAssignArray(DValue* arr, Expression* exp); DSliceValue* DtoCatArrays(Type* type, Expression* e1, Expression* e2); -#if DMDV1 -DSliceValue* DtoCatArrayElement(Type* type, Expression* exp1, Expression* exp2); -#endif DSliceValue* DtoAppendDCharToString(DValue* arr, Expression* exp); DSliceValue* DtoAppendDCharToUnicodeString(DValue* arr, Expression* exp); diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index b8aff97b..621a0665 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -153,10 +153,8 @@ bool d_have_inline_asm() { return true; } Statement *AsmStatement::semantic(Scope *sc) { -#if DMDV2 if (sc->func && sc->func->isSafe()) error("inline assembler not allowed in @safe function %s", sc->func->toChars()); -#endif bool err = false; llvm::Triple const t = global.params.targetTriple; @@ -176,9 +174,6 @@ Statement *AsmStatement::semantic(Scope *sc) //puts(toChars()); -#if DMDV1 - sc->func->inlineAsm = true; -#endif sc->func->hasReturnExp |= 8; // empty statement -- still do the above things because they might be expected? @@ -201,10 +196,8 @@ Statement *AsmStatement::semantic(Scope *sc) int AsmStatement::blockExit(bool mustNotThrow) { //printf("AsmStatement::blockExit(%p)\n", this); -#if DMDV2 if (mustNotThrow) error("asm statements are assumed to throw"); -#endif // Assume the worst return BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt; } diff --git a/gen/binops.cpp b/gen/binops.cpp index bcf32c76..fb65e59b 100644 --- a/gen/binops.cpp +++ b/gen/binops.cpp @@ -137,7 +137,6 @@ LLValue* DtoBinNumericEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op) LLValue* DtoBinFloatsEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op) { LLValue* res = 0; -#if DMDV2 if (op == TOKequal) { res = gIR->ir->CreateFCmpOEQ(lhs->getRVal(), rhs->getRVal(), "tmp"); } else if (op == TOKnotequal) { @@ -153,14 +152,6 @@ LLValue* DtoBinFloatsEquals(Loc loc, DValue* lhs, DValue* rhs, TOK op) LLValue* val = DtoMemCmp(makeLValue(loc, lhs), makeLValue(loc, rhs), sz); res = gIR->ir->CreateICmp(cmpop, val, LLConstantInt::get(val->getType(), 0, false), "tmp"); } -#else - LLValue* lv = lhs->getRVal(); - LLValue* rv = rhs->getRVal(); - res = (op == TOKidentity || op == TOKequal) ? - gIR->ir->CreateFCmpOEQ(lv, rv, "tmp") : - gIR->ir->CreateFCmpUNE(lv, rv, "tmp"); - -#endif assert(res); return res; } diff --git a/gen/classes.cpp b/gen/classes.cpp index cf3535d9..5a268b48 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -796,7 +796,6 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) VarDeclaration* defConstructorVar = static_cast(cinfo->fields.data[10]); b.push_funcptr(cd->defaultCtor, defConstructorVar->type); -#if DMDV2 // immutable(void)* m_RTInfo; // The cases where getRTInfo is null are not quite here, but the code is // modelled after what DMD does. @@ -806,10 +805,6 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) b.push_size_as_vp(0); // no pointers else b.push_size_as_vp(1); // has pointers -#else - // typeinfo - since 1.045 - b.push_typeinfo(cd->type); -#endif /*size_t n = inits.size(); for (size_t i=0; icodegen(p); // global variable -#if DMDV2 // taken from dmd2/structs if (isDataseg() || (storage_class & (STCconst | STCimmutable) && init)) -#else - if (isDataseg()) -#endif { Logger::println("data segment"); - #if DMDV2 && 0 // TODO: + #if 0 // TODO: assert(!(storage_class & STCmanifest) && "manifest constant being codegen'd!"); #endif @@ -147,12 +143,8 @@ void VarDeclaration::codegen(Ir* p) Logger::println("parent: %s (%s)", parent->toChars(), parent->kind()); - #if DMDV2 // not sure why this is only needed for d2 bool _isconst = isConst() && init; - #else - bool _isconst = isConst(); - #endif Logger::println("Creating global variable"); @@ -260,10 +252,8 @@ void TemplateInstance::codegen(Ir* p) #if LOG printf("TemplateInstance::codegen('%s', this = %p)\n", toChars(), this); #endif -#if DMDV2 if (ignore) return; -#endif if (!errors && members) { diff --git a/gen/functions.cpp b/gen/functions.cpp index dc1b604a..a48b6d77 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -121,10 +121,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, else { Type *t = rt; -#if DMDV2 if (f->isref) t = t->pointerTo(); -#endif #if LDC_LLVM_VER >= 303 if (llvm::Attribute::AttrKind a = DtoShouldExtend(t)) attrBuilder.addAttribute(a); @@ -140,11 +138,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, #elif LDC_LLVM_VER == 302 llvm::Attributes a = llvm::Attributes::get(gIR->context(), attrBuilder); #endif -#if DMDV2 fty.ret = new IrFuncTyArg(rt, f->isref, a); -#else - fty.ret = new IrFuncTyArg(rt, false, a); -#endif } lidx++; @@ -426,7 +420,6 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl) Type *dthis=0, *dnest=0; -#if DMDV2 if (fdecl->ident == Id::ensure || fdecl->ident == Id::require) { FuncDeclaration *p = fdecl->parent->isFuncDeclaration(); assert(p); @@ -434,7 +427,6 @@ llvm::FunctionType* DtoFunctionType(FuncDeclaration* fdecl) assert(ad); dnest = Type::tvoid->pointerTo(); } else -#endif if (fdecl->needThis()) { if (AggregateDeclaration* ad = fdecl->isMember2()) { Logger::println("isMember = this is: %s", ad->type->toChars()); @@ -752,12 +744,10 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) // calling convention LINK link = f->linkage; if (vafunc || fdecl->llvmInternal == LLVMintrinsic -#if DMDV2 // DMD treats _Dmain as having C calling convention and this has been // hardcoded into druntime, even if the frontend type has D linkage. // See Bugzilla issue 9028. || fdecl->isMain() -#endif ) { link = LINKc; @@ -815,7 +805,6 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) gIR->mainFunc = func; } -#if DMDV2 // shared static ctor if (fdecl->isSharedStaticCtorDeclaration()) { if (mustDefineSymbol(fdecl)) { @@ -830,7 +819,6 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) gIR->sharedGates.push_front(dtorDecl->vgate); } } else -#endif // static ctor if (fdecl->isStaticCtorDeclaration()) { if (mustDefineSymbol(fdecl)) { @@ -841,10 +829,8 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) else if (StaticDtorDeclaration *dtorDecl = fdecl->isStaticDtorDeclaration()) { if (mustDefineSymbol(fdecl)) { gIR->dtors.push_front(fdecl); -#if DMDV2 if (dtorDecl->vgate) gIR->gates.push_front(dtorDecl->vgate); -#endif } } @@ -1063,13 +1049,6 @@ void DtoDefineFunction(FuncDeclaration* fd) IrParameter* irparam = vd->ir.irParam; assert(irparam); - #if DMDV1 - if (vd->nestedref) - { - fd->nestedVars.insert(vd); - } - #endif - bool refout = vd->storage_class & (STCref | STCout); bool lazy = vd->storage_class & STClazy; if (!refout && (!irparam->arg->byref || lazy)) @@ -1095,31 +1074,13 @@ void DtoDefineFunction(FuncDeclaration* fd) } } - -#if DMDV1 - // need result variable? (nested) - if (fd->vresult && fd->vresult->nestedref) { - Logger::println("nested vresult value: %s", fd->vresult->toChars()); - fd->nestedVars.insert(fd->vresult); - } - - if (fd->vthis && fd->vthis->nestedref && !fd->nestedVars.empty()) { - Logger::println("nested vthis value: %s", fd->vthis->toChars()); - fd->nestedVars.insert(fd->vthis); - } -#endif - FuncGen fg; irfunction->gen = &fg; DtoCreateNestedContext(fd); if (fd->vresult && ! -#if DMDV2 fd->vresult->nestedrefs.dim // FIXME: not sure here :/ -#else - fd->vresult->nestedref -#endif ) { DtoVarDeclaration(fd->vresult); diff --git a/gen/irstate.h b/gen/irstate.h index 9aa17124..80f263ba 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -73,10 +73,8 @@ struct IRScope const IRScope& operator=(const IRScope& rhs); -#if DMDV2 // list of variables needing destruction std::vector varsInScope; -#endif }; struct IRBuilderHelper @@ -159,9 +157,7 @@ struct IRState // basic block scopes std::vector scopes; IRScope& scope(); -#if DMDV2 std::vector &varsInScope() { return scope().varsInScope; } -#endif llvm::BasicBlock* scopebb(); llvm::BasicBlock* scopeend(); bool scopereturned(); @@ -193,12 +189,10 @@ struct IRState typedef std::list GatesList; FuncDeclList ctors; FuncDeclList dtors; -#if DMDV2 FuncDeclList sharedCtors; FuncDeclList sharedDtors; GatesList gates; GatesList sharedGates; -#endif FuncDeclList unitTests; // all template instances that had members emitted diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 713d2482..e11f0dfa 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -71,12 +71,10 @@ void DtoDeleteClass(LLValue* inst) llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delclass"); // build args LLSmallVector arg; -#if DMDV2 // druntime wants a pointer to object LLValue *ptr = DtoRawAlloca(inst->getType(), 0, "objectPtr"); DtoStore(inst, ptr); inst = ptr; -#endif arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp")); // call gIR->CreateCallOrInvoke(fn, arg); @@ -93,8 +91,6 @@ void DtoDeleteInterface(LLValue* inst) gIR->CreateCallOrInvoke(fn, arg); } -#if DMDV2 - void DtoDeleteArray(DValue* arr) { // get runtime function @@ -109,24 +105,6 @@ void DtoDeleteArray(DValue* arr) gIR->CreateCallOrInvoke(fn, arg); } -#else - -void DtoDeleteArray(DValue* arr) -{ - // get runtime function - llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delarray"); - - // build args - LLSmallVector arg; - arg.push_back(DtoArrayLen(arr)); - arg.push_back(DtoBitCast(DtoArrayPtr(arr), getVoidPtrType(), ".tmp")); - - // call - gIR->CreateCallOrInvoke(fn, arg); -} - -#endif - /****************************************************************************************/ /*//////////////////////////////////////////////////////////////////////////////////////// // ALLOCA HELPERS @@ -416,7 +394,6 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit) if (t->nextOf()->toBasetype()->equals(t2)) { DtoArrayInit(loc, lhs, rhs, op); } -#if DMDV2 else if (DtoArrayElementType(t)->equals(stripModifiers(t2))) { DtoArrayInit(loc, s, rhs, op); } @@ -425,7 +402,6 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit) ) { DtoArrayAssign(s, rhs, op); } -#endif else if (DSliceValue *s2 = rhs->isSlice()) { DtoArrayCopySlices(s, s2); } @@ -456,7 +432,6 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit) if (t->nextOf()->toBasetype()->equals(t2)) { DtoArrayInit(loc, lhs, rhs, op); } -#if DMDV2 else if (DtoArrayElementType(t)->equals(stripModifiers(t2))) { DtoArrayInit(loc, lhs, rhs, op); } @@ -465,7 +440,6 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit) ) { DtoArrayAssign(lhs, rhs, op); } -#endif // T[n] = T[n] else if (DtoType(lhs->getType()) == DtoType(rhs->getType())) { DtoStaticArrayCopy(lhs->getLVal(), rhs->getRVal()); @@ -772,7 +746,6 @@ DValue* DtoCastNull(Loc& loc, DValue* val, Type* to) } } -#if DMDV2 DValue* DtoCastVector(Loc& loc, DValue* val, Type* to) { assert(val->getType()->toBasetype()->ty == Tvector); @@ -828,19 +801,16 @@ DValue* DtoCastVector(Loc& loc, DValue* val, Type* to) fatal(); } } -#endif DValue* DtoCast(Loc& loc, DValue* val, Type* to) { Type* fromtype = val->getType()->toBasetype(); Type* totype = to->toBasetype(); -#if DMDV2 if (fromtype->ty == Taarray) fromtype = static_cast(fromtype)->getImpl()->type; if (totype->ty == Taarray) totype = static_cast(totype)->getImpl()->type; -#endif if (fromtype->equals(totype)) return val; @@ -848,12 +818,10 @@ DValue* DtoCast(Loc& loc, DValue* val, Type* to) Logger::println("Casting from '%s' to '%s'", fromtype->toChars(), to->toChars()); LOG_SCOPE; -#if DMDV2 if (fromtype->ty == Tvector) { return DtoCastVector(loc, val, to); } else -#endif if (fromtype->isintegral()) { return DtoCastInt(loc, val, to); } @@ -967,13 +935,11 @@ TemplateInstance* DtoIsTemplateInstance(Dsymbol* s, bool checkLiteralOwner) if (!s) return NULL; if (s->isTemplateInstance() && !s->isTemplateMixin()) return s->isTemplateInstance(); -#if DMDV2 if (FuncLiteralDeclaration* fld = s->isFuncLiteralDeclaration()) { if (checkLiteralOwner && fld->owningTemplate) return fld->owningTemplate; } -#endif if (s->parent) return DtoIsTemplateInstance(s->parent, checkLiteralOwner); return NULL; @@ -1061,11 +1027,7 @@ void DtoVarDeclaration(VarDeclaration* vd) Logger::println("vdtype = %s", vd->type->toChars()); -#if DMDV2 if (vd->nestedrefs.dim) -#else - if (vd->nestedref) -#endif { Logger::println("has nestedref set (referenced by nested function/delegate)"); assert(vd->ir.irLocal && "irLocal is expected to be already set by DtoCreateNestedContext"); @@ -1075,7 +1037,6 @@ void DtoVarDeclaration(VarDeclaration* vd) { // Nothing to do if it has already been allocated. } -#if DMDV2 /* Named Return Value Optimization (NRVO): T f(){ T ret; // &ret == hidden pointer @@ -1088,12 +1049,10 @@ void DtoVarDeclaration(VarDeclaration* vd) vd->ir.irLocal = new IrLocal(vd); vd->ir.irLocal->value = gIR->func()->retArg; } -#endif // normal stack variable, allocate storage on the stack if it has not already been done else { vd->ir.irLocal = new IrLocal(vd); -#if DMDV2 /* NRVO again: T t = f(); // t's memory address is taken hidden pointer */ @@ -1123,7 +1082,6 @@ void DtoVarDeclaration(VarDeclaration* vd) } } } -#endif Type* type = isSpecialRefVar(vd) ? vd->type->pointerTo() : vd->type; LLType* lltype = DtoType(type); @@ -1144,7 +1102,6 @@ void DtoVarDeclaration(VarDeclaration* vd) DtoInitializer(vd->ir.irLocal->value, vd->init); // TODO: Remove altogether? -#if DMDV2 Lexit: /* Mark the point of construction of a variable that needs to be destructed. */ @@ -1153,7 +1110,6 @@ Lexit: // Put vd on list of things needing destruction gIR->varsInScope().push_back(vd); } -#endif } DValue* DtoDeclarationExp(Dsymbol* declaration) @@ -1285,11 +1241,7 @@ LLValue* DtoRawVarDeclaration(VarDeclaration* var, LLValue* addr) } // referenced by nested function? -#if DMDV2 if (var->nestedrefs.dim) -#else - if (var->nestedref) -#endif { assert(var->ir.irLocal); if(!var->ir.irLocal->value) @@ -1508,13 +1460,8 @@ static LLConstant* expand_to_sarray(Type *base, Expression* exp) LLConstant* DtoConstExpInit(Loc loc, Type* type, Expression* exp) { -#if DMDV2 Type* expbase = stripModifiers(exp->type->toBasetype())->merge(); Type* base = stripModifiers(type->toBasetype())->merge(); -#else - Type* expbase = exp->type->toBasetype(); - Type* base = type->toBasetype(); -#endif // if not the same basetypes, we won't get the same llvm types either if (!expbase->equals(base)) @@ -1529,7 +1476,6 @@ LLConstant* DtoConstExpInit(Loc loc, Type* type, Expression* exp) return expand_to_sarray(base, exp); } -#if DMDV2 if (base->ty == Tvector) { LLConstant* val = exp->toConstElem(gIR); @@ -1541,7 +1487,6 @@ LLConstant* DtoConstExpInit(Loc loc, Type* type, Expression* exp) return llvm::ConstantVector::getSplat(tv->size(loc), val); #endif } -#endif error(loc, "LDC internal error: cannot yet convert default initializer %s of type %s to %s", exp->toChars(), exp->type->toChars(), type->toChars()); @@ -1793,13 +1738,9 @@ size_t realignOffset(size_t offset, Type* type) Type * stripModifiers( Type * type ) { -#if DMDV2 if (type->ty == Tfunction) return type; return type->castMod(0); -#else - return type; -#endif } ////////////////////////////////////////////////////////////////////////////////////////// @@ -1839,7 +1780,6 @@ LLValue* makeLValue(Loc& loc, DValue* value) ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 void callPostblit(Loc &loc, Expression *exp, LLValue *val) { @@ -1859,7 +1799,6 @@ void callPostblit(Loc &loc, Expression *exp, LLValue *val) } } } -#endif ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/gen/llvmhelpers.h b/gen/llvmhelpers.h index e099dcd8..4a9ec3f8 100644 --- a/gen/llvmhelpers.h +++ b/gen/llvmhelpers.h @@ -166,9 +166,7 @@ size_t realignOffset(size_t offset, Type* type); /// functions without problems. LLValue* makeLValue(Loc& loc, DValue* value); -#if DMDV2 void callPostblit(Loc &loc, Expression *exp, LLValue *val); -#endif /// Returns whether the given variable is a DMD-internal "ref variable". /// diff --git a/gen/module.cpp b/gen/module.cpp index 9d153db8..6788b448 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -56,10 +56,7 @@ #endif #endif -#if DMDV2 #define NEW_MODULEINFO_LAYOUT 1 -#endif - static llvm::Function* build_module_function(const std::string &name, const std::list &funcs, const std::list &gates = std::list()) @@ -116,11 +113,7 @@ llvm::Function* build_module_ctor() std::string name("_D"); name.append(gIR->dmodule->mangle()); name.append("6__ctorZ"); -#if DMDV2 return build_module_function(name, gIR->ctors, gIR->gates); -#else - return build_module_function(name, gIR->ctors); -#endif } // build module dtor @@ -143,8 +136,6 @@ static llvm::Function* build_module_unittest() return build_module_function(name, gIR->unitTests); } -#if DMDV2 - // build module shared ctor llvm::Function* build_module_shared_ctor() @@ -165,8 +156,6 @@ static llvm::Function* build_module_shared_dtor() return build_module_function(name, gIR->sharedDtors); } -#endif - // build ModuleReference and register function, to register the module info in the global linked list static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo) { @@ -372,11 +361,7 @@ void Module::genmoduleinfo() // check for patch else { -#if DMDV2 unsigned sizeof_ModuleInfo = 16 * PTRSIZE; -#else - unsigned sizeof_ModuleInfo = 14 * PTRSIZE; -#endif if (sizeof_ModuleInfo != moduleinfo->structsize) { error("object.d ModuleInfo class is incorrect"); @@ -606,20 +591,12 @@ void Module::genmoduleinfo() LLType* fnptrTy = getPtrToType(LLFunctionType::get(LLType::getVoidTy(gIR->context()), std::vector(), false)); // ctor -#if DMDV2 llvm::Function* fctor = build_module_shared_ctor(); -#else - llvm::Function* fctor = build_module_ctor(); -#endif c = fctor ? fctor : getNullValue(fnptrTy); b.push(c); // dtor -#if DMDV2 llvm::Function* fdtor = build_module_shared_dtor(); -#else - llvm::Function* fdtor = build_module_dtor(); -#endif c = fdtor ? fdtor : getNullValue(fnptrTy); b.push(c); @@ -636,8 +613,6 @@ void Module::genmoduleinfo() c = getNullValue(fnptrTy); b.push(c); -#if DMDV2 - // tls ctor fctor = build_module_ctor(); c = fctor ? fctor : getNullValue(fnptrTy); @@ -653,8 +628,6 @@ void Module::genmoduleinfo() c = getNullValue(AT); b.push(c); -#endif - #endif // create and set initializer diff --git a/gen/nested.cpp b/gen/nested.cpp index e32e6447..eaee88d3 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -44,7 +44,6 @@ static FuncDeclaration* getParentFunc(Dsymbol* sym, bool stopOnStatic) { static void storeVariable(VarDeclaration *vd, LLValue *dst) { LLValue *value = vd->ir.irLocal->value; -#if DMDV2 int ty = vd->type->ty; FuncDeclaration *fd = getParentFunc(vd, true); assert(fd && "No parent function for nested variable?"); @@ -54,7 +53,6 @@ static void storeVariable(VarDeclaration *vd, LLValue *dst) DtoAggrCopy(mem, value); DtoAlignedStore(mem, dst); } else -#endif // Store the address into the frame DtoAlignedStore(value, dst); } @@ -99,27 +97,11 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref) LLValue* ctx = 0; if (irfunc->decl->isMember2()) { - #if DMDV2 AggregateDeclaration* cd = irfunc->decl->isMember2(); LLValue* val = irfunc->thisArg; if (cd->isClassDeclaration()) val = DtoLoad(val); ctx = DtoLoad(DtoGEPi(val, 0, cd->vthis->ir.irField->index, ".vthis")); - #else - ClassDeclaration* cd = irfunc->decl->isMember2()->isClassDeclaration(); - LLValue* val = DtoLoad(irfunc->thisArg); - ctx = DtoGEPi(val, 0, cd->vthis->ir.irField->index, ".vthis"); - - if (!irfunc->frameType && vd->isThisDeclaration()) - { - // If the only "nested" variable is the outer this pointer, we don't - // emit a normal context, but just store the this pointer - see - // GitHub #127. - return new DVarValue(astype, vd, ctx); - } - - ctx = DtoLoad(ctx); - #endif } else if (irfunc->nestedVar) { ctx = irfunc->nestedVar; @@ -189,11 +171,7 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref) return new DVarValue(astype, vd, val); } -#if DMDV2 void DtoResolveNestedContext(Loc loc, AggregateDeclaration *decl, LLValue *value) -#else -void DtoResolveNestedContext(Loc loc, ClassDeclaration *decl, LLValue *value) -#endif { Logger::println("Resolving nested context"); LOG_SCOPE; @@ -238,7 +216,6 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym) // or just have a this argument else if (irfunc->thisArg) { -#if DMDV2 AggregateDeclaration* ad = irfunc->decl->isMember2(); val = ad->isClassDeclaration() ? DtoLoad(irfunc->thisArg) : irfunc->thisArg; if (!ad->vthis) @@ -247,12 +224,6 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym) // function (but without any variables in the nested context). return val; } -#else - ClassDeclaration* ad = irfunc->decl->isMember2()->isClassDeclaration(); - val = DtoLoad(irfunc->thisArg); - if (!ad || !ad->vthis) - return val; -#endif val = DtoLoad(DtoGEPi(val, 0, ad->vthis->ir.irField->index, ".vthis")); } else @@ -264,20 +235,14 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym) } struct FuncDeclaration* fd = 0; -#if DMDV2 if (AggregateDeclaration *ad = sym->isAggregateDeclaration()) // If sym is a nested struct or a nested class, pass the frame // of the function where sym is declared. fd = ad->toParent()->isFuncDeclaration(); else -#endif if (FuncDeclaration* symfd = sym->isFuncDeclaration()) { // Make sure we've had a chance to analyze nested context usage -#if DMDV2 DtoCreateNestedContextType(symfd); -#else - DtoDefineFunction(symfd); -#endif // if this is for a function that doesn't access variables from // enclosing scopes, it doesn't matter what we pass. @@ -331,7 +296,6 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) { return; fd->ir.irFunc->nestedContextCreated = true; -#if DMDV2 if (fd->nestedVars.empty()) { // fill nestedVars size_t nnest = fd->closureVars.dim; @@ -341,7 +305,6 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) { fd->nestedVars.insert(vd); } } -#endif // construct nested variables array if (!fd->nestedVars.empty()) @@ -455,13 +418,10 @@ void DtoCreateNestedContext(FuncDeclaration* fd) { // Create frame for current function and append to frames list // FIXME: alignment ? LLValue* frame = 0; -#if DMDV2 if (fd->needsClosure()) frame = DtoGcMalloc(frameType, ".frame"); else -#endif - frame = DtoRawAlloca(frameType, 0, ".frame"); - + frame = DtoRawAlloca(frameType, 0, ".frame"); // copy parent frames into beginning if (depth != 0) { @@ -470,20 +430,14 @@ void DtoCreateNestedContext(FuncDeclaration* fd) { assert(irfunction->thisArg); assert(fd->isMember2()); LLValue* thisval = DtoLoad(irfunction->thisArg); -#if DMDV2 AggregateDeclaration* cd = fd->isMember2(); -#else - ClassDeclaration* cd = fd->isMember2()->isClassDeclaration(); -#endif assert(cd); assert(cd->vthis); Logger::println("Indexing to 'this'"); -#if DMDV2 if (cd->isStructDeclaration()) src = DtoExtractValue(thisval, cd->vthis->ir.irField->index, ".vthis"); else -#endif - src = DtoLoad(DtoGEPi(thisval, 0, cd->vthis->ir.irField->index, ".vthis")); + src = DtoLoad(DtoGEPi(thisval, 0, cd->vthis->ir.irField->index, ".vthis")); } else { src = DtoLoad(src); } diff --git a/gen/nested.h b/gen/nested.h index 3eaa6fa9..397236f6 100644 --- a/gen/nested.h +++ b/gen/nested.h @@ -28,11 +28,7 @@ void DtoCreateNestedContext(FuncDeclaration* fd); /// Resolves the nested context for classes and structs with arbitrary nesting. -#if DMDV2 void DtoResolveNestedContext(Loc loc, AggregateDeclaration *decl, LLValue *value); -#else -void DtoResolveNestedContext(Loc loc, ClassDeclaration *decl, LLValue *value); -#endif /// Gets the context value for a call to a nested function or creating a nested /// class or struct with arbitrary nesting. diff --git a/gen/passes/GarbageCollect2Stack.cpp b/gen/passes/GarbageCollect2Stack.cpp index 65f3bd3c..a14c5679 100644 --- a/gen/passes/GarbageCollect2Stack.cpp +++ b/gen/passes/GarbageCollect2Stack.cpp @@ -359,12 +359,7 @@ GarbageCollect2Stack::GarbageCollect2Stack() : FunctionPass(ID), AllocMemoryT(0, true, false), NewArrayVT(0, true, false, false, 1), -#ifdef DMDV1 - // _d_newarrayT returns just the void* ptr in the LDC D1 runtime. - NewArrayT(0, true, false, true, 1) -#else NewArrayT(0, true, true, true, 1) -#endif { KnownFunctions["_d_allocmemoryT"] = &AllocMemoryT; KnownFunctions["_d_newarrayvT"] = &NewArrayVT; diff --git a/gen/pragma.cpp b/gen/pragma.cpp index be2d62b6..806f9df9 100644 --- a/gen/pragma.cpp +++ b/gen/pragma.cpp @@ -46,7 +46,6 @@ static bool parseIntExp(Expression* e, dinteger_t& res) static void pragmaDeprecated(Identifier* oldIdent, Identifier* newIdent) { -#if !DMDV1 // Do not print a deprecation warning for D1 – we do not want to // introduce needless breakage at this stage. if (global.params.useDeprecated == 0) @@ -59,7 +58,6 @@ static void pragmaDeprecated(Identifier* oldIdent, Identifier* newIdent) warning("non-vendor-prefixed pragma '%s' is deprecated; use '%s' instead", oldIdent->toChars(), newIdent->toChars()); } -#endif } bool matchPragma(Identifier* needle, Identifier* ident, Identifier* oldIdent) @@ -388,11 +386,7 @@ void DtoCheckPragma(PragmaDeclaration *decl, Dsymbol *s, TypeFunction* type = static_cast(fd->type); Type* retType = type->next; if (retType->ty != Tvoid || type->parameters->dim > 0 || ( -#if DMDV2 fd->isAggregateMember() -#else - fd->isThis() -#endif && !fd->isStatic())) { error(s->loc, "the '%s' pragma is only allowed on void functions which take no arguments", ident->toChars()); diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 3c63aa16..ddee7b7e 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -218,10 +218,6 @@ static void LLVM_D_BuildRuntimeModule() = NoAttrs.addAttribute(gIR->context(), 1, llvm::Attribute::NoCapture), Attr_NoAlias_1_NoCapture = Attr_1_NoCapture.addAttribute(gIR->context(), 0, llvm::Attribute::NoAlias), -#if DMDV1 - Attr_NoAlias_3_NoCapture - = Attr_NoAlias.addAttribute(gIR->context(), 3, llvm::Attribute::NoCapture), -#endif Attr_1_2_NoCapture = Attr_1_NoCapture.addAttribute(gIR->context(), 2, llvm::Attribute::NoCapture), Attr_1_3_NoCapture @@ -251,10 +247,6 @@ static void LLVM_D_BuildRuntimeModule() = NoAttrs.addAttr(gIR->context(), 1, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), Attr_NoAlias_1_NoCapture = Attr_1_NoCapture.addAttr(gIR->context(), 0, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias))), -#if DMDV1 - Attr_NoAlias_3_NoCapture - = Attr_NoAlias.addAttr(gIR->context(), 3, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), -#endif Attr_1_2_NoCapture = Attr_1_NoCapture.addAttr(gIR->context(), 2, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), Attr_1_3_NoCapture @@ -284,10 +276,6 @@ static void LLVM_D_BuildRuntimeModule() = NoAttrs.addAttr(1, NoCapture), Attr_NoAlias_1_NoCapture = Attr_1_NoCapture.addAttr(0, NoAlias), -#if DMDV1 - Attr_NoAlias_3_NoCapture - = Attr_NoAlias.addAttr(3, NoCapture), -#endif Attr_1_2_NoCapture = Attr_1_NoCapture.addAttr(2, NoCapture), Attr_1_3_NoCapture @@ -308,21 +296,13 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } - // D1: - // void _d_array_bounds( char[] file, uint line ) - // void _d_switch_error( char[] file, uint line ) - // D2: // void _d_array_bounds(ModuleInfo* m, uint line) // void _d_switch_error(ModuleInfo* m, uint line) { llvm::StringRef fname("_d_array_bounds"); llvm::StringRef fname2("_d_switch_error"); LLType *types[] = { -#if DMDV2 getPtrToType(DtoType(Module::moduleinfo->type)), -#else - stringTy, -#endif intTy }; LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false); @@ -360,40 +340,6 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) ->setAttributes(Attr_NoAlias); } -#if DMDV1 - // void* _d_newarrayT(TypeInfo ti, size_t length) - // void* _d_newarrayiT(TypeInfo ti, size_t length) - // void* _d_newarrayvT(TypeInfo ti, size_t length) - { - llvm::StringRef fname("_d_newarrayT"); - llvm::StringRef fname2("_d_newarrayiT"); - llvm::StringRef fname3("_d_newarrayvT"); - LLType *types[] = { typeInfoTy, sizeTy }; - LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) - ->setAttributes(Attr_NoAlias); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) - ->setAttributes(Attr_NoAlias); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M) - ->setAttributes(Attr_NoAlias); - } - // void* _d_newarraymT(TypeInfo ti, size_t length, size_t* dims) - // void* _d_newarraymiT(TypeInfo ti, size_t length, size_t* dims) - // void* _d_newarraymvT(TypeInfo ti, size_t length, size_t* dims) - { - llvm::StringRef fname("_d_newarraymT"); - llvm::StringRef fname2("_d_newarraymiT"); - llvm::StringRef fname3("_d_newarraymvT"); - LLType *types[] = { typeInfoTy, sizeTy, rt_ptr(sizeTy) }; - LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) - ->setAttributes(Attr_NoAlias_3_NoCapture); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M) - ->setAttributes(Attr_NoAlias_3_NoCapture); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M) - ->setAttributes(Attr_NoAlias_3_NoCapture); - } -#else // void[] _d_newarrayT(TypeInfo ti, size_t length) // void[] _d_newarrayiT(TypeInfo ti, size_t length) { @@ -414,12 +360,7 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); } -#endif - // D1: - // void* _d_arraysetlengthT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) - // void* _d_arraysetlengthiT(TypeInfo ti, size_t newlength, size_t plength, void* pdata) - // D2: // void[] _d_arraysetlengthT(TypeInfo ti, size_t newlength, void[] *array) // void[] _d_arraysetlengthiT(TypeInfo ti, size_t newlength, void[] *array) { @@ -428,21 +369,13 @@ static void LLVM_D_BuildRuntimeModule() LLType *types[] = { typeInfoTy, sizeTy, -#if DMDV2 voidArrayPtrTy }; LLFunctionType* fty = llvm::FunctionType::get(voidArrayTy, types, false); -#else - sizeTy, - voidPtrTy - }; - LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); -#endif llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname2, M); } -#if DMDV2 // byte[] _d_arrayappendcTX(TypeInfo ti, ref byte[] px, size_t n) { llvm::StringRef fname("_d_arrayappendcTX"); @@ -485,15 +418,6 @@ static void LLVM_D_BuildRuntimeModule() LLFunctionType* fty = llvm::FunctionType::get(voidArrayTy, types, true); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } -#else // DMDV1 - // byte[] _d_arrayappendcT(TypeInfo ti, void* array, void* element) - { - llvm::StringRef fname("_d_arrayappendcT"); - LLType *types[] = { typeInfoTy, voidPtrTy, voidPtrTy }; - LLFunctionType* fty = llvm::FunctionType::get(voidArrayTy, types, false); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); - } -#endif // Object _d_allocclass(ClassInfo ci) { @@ -504,8 +428,6 @@ static void LLVM_D_BuildRuntimeModule() ->setAttributes(Attr_NoAlias); } -#if DMDV2 - // void _d_delarray_t(Array *p, TypeInfo ti) { llvm::StringRef fname("_d_delarray_t"); @@ -514,23 +436,6 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } -#else - - // void _d_delarray(size_t plength, void* pdata) - { - llvm::StringRef fname("_d_delarray"); - LLType *types[] = { sizeTy, voidPtrTy }; - LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); - } - -#endif - - // D1: - // void _d_delmemory(void* p) - // void _d_delinterface(void* p) - // void _d_callfinalizer(void* p) - // D2: // void _d_delmemory(void **p) // void _d_delinterface(void **p) // void _d_callfinalizer(void *p) @@ -545,16 +450,11 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname3, M); } - // D1: void _d_delclass(Object p) // D2: void _d_delclass(Object* p) { llvm::StringRef fname("_d_delclass"); LLType *types[] = { -#if DMDV2 rt_ptr(objectTy) -#else - objectTy -#endif }; LLFunctionType* fty = llvm::FunctionType::get(voidTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); @@ -654,8 +554,6 @@ static void LLVM_D_BuildRuntimeModule() ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - // void[] _d_arrayassign(TypeInfo ti, void[] from, void[] to) // void[] _d_arrayctor(TypeInfo ti, void[] from, void[] to) { @@ -680,8 +578,6 @@ static void LLVM_D_BuildRuntimeModule() ->setAttributes(Attr_NoAlias); } -#endif - ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// @@ -802,50 +698,28 @@ static void LLVM_D_BuildRuntimeModule() ->setAttributes(Attr_ReadOnly_NoUnwind_1_NoCapture); } - // D1: - // void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) - // D2: // void* _aaGetX(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) { -#if DMDV2 llvm::StringRef fname("_aaGetX"); -#else - llvm::StringRef fname("_aaGet"); -#endif LLType *types[] = { aaTy, typeInfoTy, sizeTy, voidPtrTy }; LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) ->setAttributes(Attr_1_4_NoCapture); } - // D1: - // void* _aaIn(AA aa, TypeInfo keyti, void* pkey) - // D2: // void* _aaInX(AA aa, TypeInfo keyti, void* pkey) { -#if DMDV2 llvm::StringRef fname("_aaInX"); -#else - llvm::StringRef fname("_aaIn"); -#endif LLType *types[] = { aaTy, typeInfoTy, voidPtrTy }; LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) ->setAttributes(Attr_ReadOnly_1_3_NoCapture); } - // D1: - // void _aaDel(AA aa, TypeInfo keyti, void* pkey) - // D2: // bool _aaDelX(AA aa, TypeInfo keyti, void* pkey) { -#if DMDV2 llvm::StringRef fname("_aaDelX"); LLType *retType = boolTy; -#else - llvm::StringRef fname("_aaDel"); - LLType *retType = voidTy; -#endif LLType *types[] = { aaTy, typeInfoTy, voidPtrTy }; LLFunctionType* fty = llvm::FunctionType::get(retType, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) @@ -896,7 +770,6 @@ static void LLVM_D_BuildRuntimeModule() ->setAttributes(Attr_1_NoCapture); } -#if DMDV2 // int _aaEqual(TypeInfo_AssociativeArray ti, AA e1, AA e2) { llvm::StringRef fname("_aaEqual"); @@ -912,16 +785,6 @@ static void LLVM_D_BuildRuntimeModule() LLFunctionType* fty = llvm::FunctionType::get(voidPtrTy, types, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } -#else - // int _aaEq(AA aa, AA ab, TypeInfo_AssociativeArray ti) - { - llvm::StringRef fname("_aaEq"); - LLType *types[] = { aaTy, aaTy, typeInfoTy }; - LLFunctionType* fty = llvm::FunctionType::get(intTy, types, false); - llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M) - ->setAttributes(Attr_1_2_NoCapture); - } -#endif ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// @@ -1040,12 +903,10 @@ static void LLVM_D_BuildRuntimeModule() llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } -#if DMDV2 // void _d_hidden_func() { llvm::StringRef fname("_d_hidden_func"); LLFunctionType* fty = llvm::FunctionType::get(voidTy, false); llvm::Function::Create(fty, llvm::GlobalValue::ExternalLinkage, fname, M); } -#endif } diff --git a/gen/runtime.h b/gen/runtime.h index 05e62c09..f64e3ae4 100644 --- a/gen/runtime.h +++ b/gen/runtime.h @@ -30,14 +30,8 @@ llvm::Function* LLVM_D_GetRuntimeFunction(llvm::Module* target, const char* name llvm::GlobalVariable* LLVM_D_GetRuntimeGlobal(llvm::Module* target, const char* name); -#if DMDV1 -#define _d_allocclass "_d_allocclass" -#define _adEq "_adEq" -#define _adCmp "_adCmp" -#else #define _d_allocclass "_d_newclass" #define _adEq "_adEq2" #define _adCmp "_adCmp2" -#endif #endif // LDC_GEN_RUNTIME_H diff --git a/gen/statements.cpp b/gen/statements.cpp index 09fcefc3..f6f61355 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -83,11 +83,10 @@ void ReturnStatement::toIR(IRState* p) DValue* e = exp->toElemDtor(p); // store return value DtoAssign(loc, rvar, e); -#if DMDV2 + // call postblit if necessary if (!p->func()->type->isref && !(f->decl->nrvo_can && f->decl->nrvo_var)) callPostblit(loc, exp, rvar->getLVal()); -#endif // emit scopes DtoEnclosingHandlers(loc, NULL); @@ -108,7 +107,6 @@ void ReturnStatement::toIR(IRState* p) } else { if (exp->op == TOKnull) exp->type = p->func()->type->next; -#if DMDV2 DValue* dval = 0; // call postblit if necessary if (!p->func()->type->isref) { @@ -120,10 +118,6 @@ void ReturnStatement::toIR(IRState* p) } // do abi specific transformations on the return value v = p->func()->type->fty.putRet(exp->type, dval); -#else - DValue* dval = exp->toElemDtor(p); - v = p->func()->type->fty.putRet(exp->type, dval); -#endif } if (Logger::enabled()) @@ -137,9 +131,7 @@ void ReturnStatement::toIR(IRState* p) int ty = f->type->next->toBasetype()->ty; if (v->getType() != p->topfunc()->getReturnType() && (ty == Tstruct -#if DMDV2 || ty == Tsarray -#endif ) && isaPointer(v->getType())) { Logger::println("Loading value for return"); @@ -214,8 +206,6 @@ void ExpStatement::toIR(IRState* p) ////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - void DtorExpStatement::toIR(IRState *irs) { assert(irs->func()); @@ -233,8 +223,6 @@ void DtorExpStatement::toIR(IRState *irs) } } -#endif - ////////////////////////////////////////////////////////////////////////////// void IfStatement::toIR(IRState* p) @@ -1290,8 +1278,6 @@ void ForeachStatement::toIR(IRState* p) ////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - void ForeachRangeStatement::toIR(IRState* p) { Logger::println("ForeachRangeStatement::toIR(): %s", loc.toChars()); @@ -1394,8 +1380,6 @@ void ForeachRangeStatement::toIR(IRState* p) p->scope() = IRScope(endbb,oldend); } -#endif // D2 - ////////////////////////////////////////////////////////////////////////////// void LabelStatement::toIR(IRState* p) @@ -1627,16 +1611,10 @@ void SwitchErrorStatement::toIR(IRState* p) std::vector args; -#if DMDV2 // module param LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol(); LLType *moduleInfoType = DtoType(Module::moduleinfo->type); args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType))); -#else - // file param - IrModule* irmod = getIrModule(NULL); - args.push_back(DtoLoad(irmod->fileName)); -#endif // line param LLConstant* c = DtoConstUint(loc.linnum); @@ -1645,19 +1623,13 @@ void SwitchErrorStatement::toIR(IRState* p) // call LLCallSite call = gIR->CreateCallOrInvoke(fn, args); call.setDoesNotReturn(); - -#if DMDV1 - gIR->ir->CreateUnreachable(); -#endif } ////////////////////////////////////////////////////////////////////////////// -#if DMDV2 void ImportStatement::toIR(IRState *irs) { } -#endif ////////////////////////////////////////////////////////////////////////////// @@ -1693,10 +1665,7 @@ STUBST(Statement); //STUBST(GotoStatement); //STUBST(UnrolledLoopStatement); //STUBST(OnScopeStatement); - -#if DMDV2 STUBST(PragmaStatement); -#endif ////////////////////////////////////////////////////////////////////////////// diff --git a/gen/structs.cpp b/gen/structs.cpp index 43a4e5bb..efa17310 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -253,12 +253,10 @@ std::vector DtoStructLiteralValues(const StructDeclaration* sd, // update offsets lastoffset = os; -#if DMDV2 // sometimes size of the initializer is less than size of the variable, // so make sure that lastsize is correct if (inits[i]->getType()->isSized()) sz = ceil(gDataLayout->getTypeSizeInBits(init->getType()) / 8.0); -#endif lastsize = sz; // go to next explicit init diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 2b44b69d..c6e2ea82 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -135,11 +135,7 @@ static LLValue *fixArgument(DValue *argval, TypeFunction* tf, LLType *callableAr // pointer to a struct, load from it before passing it in. int ty = argval->getType()->toBasetype()->ty; if (isaPointer(arg) && !isaPointer(callableArgType) && -#if DMDV2 (ty == Tstruct || ty == Tsarray)) -#else - ty == Tstruct) -#endif { Logger::println("Loading struct type for function argument"); arg = DtoLoad(arg); @@ -408,7 +404,6 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // then comes a context argument... if(thiscall || delegatecall || nestedcall) { -#if DMDV2 if (dfnval && (dfnval->func->ident == Id::ensure || dfnval->func->ident == Id::require)) { // ... which can be the this "context" argument for a contract // invocation (in D2, we do not generate a full nested contexts @@ -420,7 +415,6 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* args.push_back(thisarg); } else -#endif if (thiscall && dfnval && dfnval->vthis) { // ... or a normal 'this' argument @@ -630,9 +624,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // a stack slot before continuing. int ty = tf->next->toBasetype()->ty; if ((ty == Tstruct && !isaPointer(retllval)) -#if DMDV2 || (ty == Tsarray && isaArray(retllval)) -#endif ) { Logger::println("Storing return value to stack slot"); @@ -652,11 +644,9 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* switch(rbase->ty) { case Tarray: - #if DMDV2 if (tf->isref) retllval = DtoBitCast(retllval, DtoType(rbase->pointerTo())); else - #endif retllval = DtoAggrPaint(retllval, DtoType(rbase)); break; @@ -667,15 +657,12 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* case Tclass: case Taarray: case Tpointer: - #if DMDV2 if (tf->isref) retllval = DtoBitCast(retllval, DtoType(rbase->pointerTo())); else - #endif retllval = DtoBitCast(retllval, DtoType(rbase)); break; -#if DMDV2 case Tstruct: if (nextbase->ty == Taarray && !tf->isref) { @@ -694,7 +681,6 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* break; } // Fall through. -#endif default: // Unfortunately, DMD has quirks resp. bugs with regard to name @@ -766,9 +752,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // or if we are returning a reference // make sure we provide a lvalue back! if (retinptr -#if DMDV2 || tf->isref -#endif ) return new DVarValue(resulttype, retllval); diff --git a/gen/todebug.cpp b/gen/todebug.cpp index eb6791b0..6792c7b2 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -298,11 +298,7 @@ static llvm::DIType dwarfCompositeType(Type* type) static llvm::DIGlobalVariable dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd) { -#if DMDV2 assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCimmutable) && vd->init)); -#else - assert(vd->isDataseg()); -#endif return gIR->dibuilder.createGlobalVariable( vd->toChars(), // name TODO: mangle() or toPrettyChars() instead? diff --git a/gen/toir.cpp b/gen/toir.cpp index cec9a779..c12d3366 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -60,7 +60,6 @@ void Expression::cacheLvalue(IRState* irs) DValue *Expression::toElemDtor(IRState *irs) { -#if DMDV2 Logger::println("Expression::toElemDtor(): %s", toChars()); LOG_SCOPE @@ -76,9 +75,6 @@ DValue *Expression::toElemDtor(IRState *irs) vd->edtor->toElem(gIR); } return val; -#else - return toElem(irs); -#endif } ////////////////////////////////////////////////////////////////////////////////////////// @@ -117,13 +113,11 @@ DValue* VarExp::toElem(IRState* p) { Logger::println("VarDeclaration ' %s ' of type ' %s '", vd->toChars(), vd->type->toChars()); -#if DMDV2 /* The magic variable __ctfe is always false at runtime */ if (vd->ident == Id::ctfe) { return new DConstValue(type, DtoConstBool(false)); } -#endif // this is an error! must be accessed with DotVarExp if (var->needThis()) @@ -179,11 +173,7 @@ DValue* VarExp::toElem(IRState* p) return new DImValue(type, m); } // nested variable - #if DMDV2 else if (vd->nestedrefs.dim) { - #else - else if (vd->nestedref) { - #endif Logger::println("nested variable"); return DtoNestedVariable(loc, type, vd); } @@ -238,9 +228,7 @@ DValue* VarExp::toElem(IRState* p) { Logger::println("FuncDeclaration"); LLValue* func = 0; -#if DMDV2 fdecl = fdecl->toAliasFunc(); -#endif if (fdecl->llvmInternal == LLVMinline_asm) { error("special ldc inline asm is not a normal function"); fatal(); @@ -608,11 +596,9 @@ DValue* AssignExp::toElem(IRState* p) Logger::println("performing aggregate zero initialization"); assert(e2->toInteger() == 0); DtoAggrZeroInit(l->getLVal()); -#if DMDV2 TypeStruct *ts = static_cast(e1->type); if (ts->sym->isNested() && ts->sym->vthis) DtoResolveNestedContext(loc, ts->sym, l->getLVal()); -#endif // Return value should be irrelevant. return r; } @@ -933,7 +919,6 @@ DValue* CallExp::toElem(IRState* p) // llvm doesn't need the second param hence the override Expression* exp = static_cast(arguments->data[0]); LLValue* arg = exp->toElem(p)->getLVal(); -#if DMDV2 if (LLValue *argptr = gIR->func()->_argptr) { DtoStore(DtoLoad(argptr), DtoBitCast(arg, getPtrToType(getVoidPtrType()))); return new DImValue(type, arg); @@ -943,13 +928,11 @@ DValue* CallExp::toElem(IRState* p) va_list = DtoBitCast(va_list, getVoidPtrType()); return new DImValue(type, gIR->ir->CreateCall(GET_INTRINSIC_DECL(vastart), va_list, "")); } else -#endif { arg = DtoBitCast(arg, getVoidPtrType()); return new DImValue(type, gIR->ir->CreateCall(GET_INTRINSIC_DECL(vastart), arg, "")); } } -#if DMDV2 else if (fndecl->llvmInternal == LLVMva_copy && global.params.targetTriple.getArch() == llvm::Triple::x86_64) { if (arguments->dim != 2) { @@ -967,7 +950,6 @@ DValue* CallExp::toElem(IRState* p) DtoStore(DtoLoad(DtoLoad(arg2)), DtoLoad(arg1)); return new DVarValue(type, arg1); } -#endif // va_arg instruction else if (fndecl->llvmInternal == LLVMva_arg) { if (arguments->dim != 1) { @@ -1523,7 +1505,6 @@ DValue* ThisExp::toElem(IRState* p) LLValue* v; Dsymbol* vdparent = vd->toParent2(); Identifier *ident = p->func()->decl->ident; -#if DMDV2 // In D1, contracts are treated as normal nested methods, 'this' is // just passed in the context struct along with any used parameters. if (ident == Id::ensure || ident == Id::require) { @@ -1531,7 +1512,6 @@ DValue* ThisExp::toElem(IRState* p) v = p->func()->nestArg; v = DtoBitCast(v, DtoType(type)->getPointerTo()); } else -#endif if (vdparent != p->func()->decl) { Logger::println("nested this exp"); #if STRUCTTHISREF @@ -1648,11 +1628,7 @@ DValue* SliceExp::toElem(IRState* p) LLValue* vlo = lo->getRVal(); LLValue* vup = up->getRVal(); -#if DMDV2 if(global.params.useArrayBounds) -#else - if(global.params.useArrayBounds && (etype->ty == Tsarray || etype->ty == Tarray)) -#endif DtoArrayBoundsCheck(loc, e, up, lo); // offset by lower @@ -1993,7 +1969,6 @@ DValue* NewExp::toElem(IRState* p) Logger::println("new struct on heap: %s\n", newtype->toChars()); // allocate LLValue* mem = 0; -#if DMDV2 if (allocator) { // custom allocator @@ -2002,7 +1977,6 @@ DValue* NewExp::toElem(IRState* p) DValue* res = DtoCallFunction(loc, NULL, &dfn, newargs); mem = DtoBitCast(res->getRVal(), DtoType(ntype->pointerTo()), ".newstruct_custom"); } else -#endif { // default allocator mem = DtoNew(newtype); @@ -2017,7 +1991,6 @@ DValue* NewExp::toElem(IRState* p) ts->sym->codegen(Type::sir); DtoAggrCopy(mem, ts->sym->ir.irStruct->getInitSymbol()); } -#if DMDV2 if (ts->sym->isNested() && ts->sym->vthis) DtoResolveNestedContext(loc, ts->sym, mem); @@ -2030,7 +2003,6 @@ DValue* NewExp::toElem(IRState* p) DFuncValue dfn(member, member->ir.irFunc->func, mem); DtoCallFunction(loc, ts, &dfn, arguments); } -#endif return new DImValue(type, mem); } // new basic type @@ -2066,14 +2038,7 @@ DValue* DeleteExp::toElem(IRState* p) // simple pointer if (et->ty == Tpointer) { -#if DMDV2 DtoDeleteMemory(dval->isLVal() ? dval->getLVal() : makeLValue(loc, dval)); -#else - LLValue* rval = dval->getRVal(); - DtoDeleteMemory(rval); - if (dval->isVar()) - DtoStore(LLConstant::getNullValue(rval->getType()), dval->getLVal()); -#endif } // class else if (et->ty == Tclass) @@ -2082,11 +2047,7 @@ DValue* DeleteExp::toElem(IRState* p) TypeClass* tc = static_cast(et); if (tc->sym->isInterfaceDeclaration()) { -#if DMDV2 LLValue *val = dval->getLVal(); -#else - LLValue *val = dval->getRVal(); -#endif DtoDeleteInterface(val); onstack = true; } @@ -2618,23 +2579,7 @@ DValue* CatExp::toElem(IRState* p) Logger::print("CatExp::toElem: %s @ %s\n", toChars(), type->toChars()); LOG_SCOPE; -#if DMDV2 return DtoCatArrays(type, e1, e2); -#else - - bool arrNarr = e1->type->toBasetype() == e2->type->toBasetype(); - // array ~ array - if (arrNarr) - { - return DtoCatArrays(type, e1, e2); - } - // array ~ element - // element ~ array - else - { - return DtoCatArrayElement(type, e1, e2); - } -#endif } ////////////////////////////////////////////////////////////////////////////////////////// @@ -2704,17 +2649,14 @@ DValue* FuncExp::toElem(IRState* p) LLValue* cval; IrFunction* irfn = p->func(); if (irfn->nestedVar -#if DMDV2 // We cannot use a frame allocated in one function // for a delegate created in another function // (that happens with anonymous functions) && fd->toParent2() == irfn->decl -#endif ) cval = irfn->nestedVar; else if (irfn->nestArg) cval = DtoLoad(irfn->nestArg); -#if DMDV2 // TODO: should we enable that for D1 as well? else if (irfn->thisArg) { @@ -2726,7 +2668,6 @@ DValue* FuncExp::toElem(IRState* p) cval = DtoLoad(DtoGEPi(cval, 0,ad->vthis->ir.irField->index, ".vthis")); } } -#endif else cval = getNullPtr(getVoidPtrType()); cval = DtoBitCast(cval, dgty->getContainedType(0)); @@ -2882,11 +2823,9 @@ LLConstant* ArrayLiteralExp::toConstElem(IRState* p) LLConstant* globalstore = new LLGlobalVariable(*gIR->module, t, false, LLGlobalValue::InternalLinkage, initval, ".dynarrayStorage"); globalstore = DtoBitCast(globalstore, getPtrToType(arrtype)); -#if DMDV2 if (bt->ty == Tpointer) // we need to return pointer to the static array. return globalstore; -#endif // build a constant dynamic array reference with the .ptr field pointing into globalstore LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; @@ -2911,8 +2850,6 @@ DValue* StructLiteralExp::toElem(IRState* p) Logger::print("StructLiteralExp::toElem: %s @ %s\n", toChars(), type->toChars()); LOG_SCOPE; - -#if DMDV2 if (sinit) { // Copied from VarExp::toElem, need to clean this mess up. @@ -2927,7 +2864,6 @@ DValue* StructLiteralExp::toElem(IRState* p) initsym = DtoBitCast(initsym, DtoType(ts->pointerTo())); return new DVarValue(type, initsym); } -#endif // make sure the struct is fully resolved sd->codegen(Type::sir); @@ -2974,13 +2910,11 @@ DValue* StructLiteralExp::toElem(IRState* p) IF_LOG Logger::println("expr %zu = %s", it.index, expr->toChars()); val = expr->toElem(gIR); } -#if DMDV2 else if (vd == sd->vthis) { IF_LOG Logger::println("initializing vthis"); LOG_SCOPE val = new DImValue(vd->type, DtoBitCast(DtoNestedContext(loc, sd), DtoType(vd->type))); } -#endif else { if (vd->init && vd->init->isVoidInitializer()) @@ -2997,10 +2931,8 @@ DValue* StructLiteralExp::toElem(IRState* p) // store the initializer there DtoAssign(loc, &field, val, TOKconstruct); -#if DMDV2 if (expr) callPostblit(loc, expr, field.getLVal()); -#endif // Also zero out padding bytes counted as being part of the type in DMD // but not in LLVM; e.g. real/x86_fp80. @@ -3028,7 +2960,6 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p) Logger::print("StructLiteralExp::toConstElem: %s @ %s\n", toChars(), type->toChars()); LOG_SCOPE; -#if DMDV2 if (sinit) { // Copied from VarExp::toConstElem, need to clean this mess up. @@ -3040,7 +2971,6 @@ LLConstant* StructLiteralExp::toConstElem(IRState* p) return ts->sym->ir.irStruct->getDefaultInit(); } -#endif // make sure the struct is resolved sd->codegen(Type::sir); @@ -3118,7 +3048,6 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) Type* aatype = basetype; Type* vtype = aatype->nextOf(); -#if DMDV2 if (!keys->dim) goto LruntimeInit; @@ -3183,7 +3112,6 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) } LruntimeInit: -#endif // it should be possible to avoid the temporary in some cases LLValue* tmp = DtoAlloca(type, "aaliteral"); @@ -3276,8 +3204,6 @@ DValue* TupleExp::toElem(IRState *p) ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - DValue* VectorExp::toElem(IRState* p) { Logger::print("VectorExp::toElem() %s\n", toChars()); @@ -3312,20 +3238,14 @@ DValue* VectorExp::toElem(IRState* p) return new DVarValue(to, vector); } -#endif - - ////////////////////////////////////////////////////////////////////////////////////////// #define STUB(x) DValue *x::toElem(IRState * p) {error("Exp type "#x" not implemented: %s", toChars()); fatal(); return 0; } STUB(Expression); STUB(ScopeExp); - -#if DMDV2 STUB(SymbolExp); STUB(PowExp); STUB(PowAssignExp); -#endif #define CONSTSTUB(x) LLConstant* x::toConstElem(IRState * p) { \ error("expression '%s' is not a constant", toChars()); \ diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 85347fb9..38c5b9ae 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -202,12 +202,10 @@ LLType* DtoType(Type* t) case Taarray: return getVoidPtrType(); -#if DMDV2 case Tvector: { return IrTypeVector::get(t)->getLLType(); } -#endif /* Not needed atm as VarDecls for tuples are rewritten as a string of @@ -1036,11 +1034,7 @@ LLStructType* DtoModuleReferenceType() // add members LLType *types[] = { getPtrToType(st), -#if DMDV1 - DtoType(Module::moduleinfo->type) -#else DtoType(Module::moduleinfo->type->pointerTo()) -#endif }; // resolve type diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 404c450d..cb531eb1 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -82,10 +82,8 @@ Expression *Type::getInternalTypeInfo(Scope *sc) goto Linternal; case Tarray: - #if DMDV2 // convert to corresponding dynamic array type t = t->nextOf()->mutableOf()->arrayOf(); - #endif if (t->nextOf()->ty != Tclass) break; goto Linternal; @@ -129,7 +127,6 @@ Expression *Type::getTypeInfo(Scope *sc) if (!t->vtinfo) { -#if DMDV2 if (t->isShared()) t->vtinfo = new TypeInfoSharedDeclaration(t); else if (t->isConst()) @@ -139,7 +136,6 @@ Expression *Type::getTypeInfo(Scope *sc) else if (t->isWild()) t->vtinfo = new TypeInfoWildDeclaration(t); else -#endif t->vtinfo = t->getTypeInfoDeclaration(); assert(t->vtinfo); @@ -218,12 +214,10 @@ TypeInfoDeclaration *TypeClass::getTypeInfoDeclaration() return new TypeInfoClassDeclaration(this); } -#if DMDV2 TypeInfoDeclaration *TypeVector::getTypeInfoDeclaration() { return new TypeInfoVectorDeclaration(this); } -#endif TypeInfoDeclaration *TypeEnum::getTypeInfoDeclaration() { @@ -258,22 +252,14 @@ int Type::builtinTypeInfo() int TypeBasic::builtinTypeInfo() { -#if DMDV2 return mod ? 0 : 1; -#else - return 1; -#endif } int TypeDArray::builtinTypeInfo() { -#if DMDV2 return !mod && ((next->isTypeBasic() != NULL && !next->mod) || // strings are so common, make them builtin (next->ty == Tchar && next->mod == MODimmutable)); -#else - return next->isTypeBasic() != NULL; -#endif } int TypeClass::builtinTypeInfo() @@ -466,11 +452,7 @@ void TypeInfoEnumDeclaration::llvmDefine() else { LLType* memty = DtoType(sd->memtype); -#if DMDV2 LLConstant* C = LLConstantInt::get(memty, sd->defaultval->toInteger(), !isLLVMUnsigned(sd->memtype)); -#else - LLConstant* C = LLConstantInt::get(memty, sd->defaultval, !isLLVMUnsigned(sd->memtype)); -#endif b.push_void_array(C, sd->memtype, sd); } @@ -546,10 +528,8 @@ void TypeInfoAssociativeArrayDeclaration::llvmDefine() // key typeinfo b.push_typeinfo(tc->index); -#if DMDV2 // impl typeinfo b.push_typeinfo(tc->getImpl()->type); -#endif // finish b.finalize(ir.irGlobal); @@ -646,16 +626,10 @@ void TypeInfoStructDeclaration::llvmDefine() { Scope sc; tftohash = new TypeFunction(NULL, Type::thash_t, 0, LINKd); -#if DMDV2 tftohash ->mod = MODconst; -#endif tftohash = static_cast(tftohash->semantic(0, &sc)); -#if DMDV2 Type *retType = Type::tchar->invariantOf()->arrayOf(); -#else - Type *retType = Type::tchar->arrayOf(); -#endif tftostring = new TypeFunction(NULL, retType, 0, LINKd); tftostring = static_cast(tftostring->semantic(0, &sc)); } @@ -675,9 +649,7 @@ void TypeInfoStructDeclaration::llvmDefine() #endif arguments->push(arg); tfcmpptr = new TypeFunction(arguments, Type::tint32, 0, LINKd); -#if DMDV2 tfcmpptr->mod = MODconst; -#endif tfcmpptr = static_cast(tfcmpptr->semantic(0, &sc)); } @@ -689,11 +661,7 @@ void TypeInfoStructDeclaration::llvmDefine() b.push_funcptr(fd); // opEquals -#if DMDV2 fd = sd->xeq; -#else - fd = find_method_overload(sd, Id::eq, tfcmpptr, gm); -#endif b.push_funcptr(fd); // opCmp @@ -708,8 +676,6 @@ void TypeInfoStructDeclaration::llvmDefine() unsigned hasptrs = tc->hasPointers() ? 1 : 0; b.push_uint(hasptrs); -#if DMDV2 - ClassDeclaration* tscd = Type::typeinfostruct; // On x86_64, class TypeInfo_Struct contains 2 additional fields @@ -759,15 +725,12 @@ void TypeInfoStructDeclaration::llvmDefine() else b.push_size_as_vp(1); // has pointers -#endif - // finish b.finalize(ir.irGlobal); } /* ========================================================================= */ -#if DMDV2 void TypeInfoClassDeclaration::codegen(Ir*i) { @@ -778,28 +741,10 @@ void TypeInfoClassDeclaration::codegen(Ir*i) tc->sym->codegen(Type::sir); // make sure class is resolved irg->value = tc->sym->ir.irStruct->getClassInfoSymbol(); } -#endif void TypeInfoClassDeclaration::llvmDefine() { -#if DMDV2 llvm_unreachable("TypeInfoClassDeclaration should not be called for D2"); -#endif - Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars()); - LOG_SCOPE; - - // make sure class is resolved - assert(tinfo->ty == Tclass); - TypeClass *tc = static_cast(tinfo); - tc->sym->codegen(Type::sir); - - RTTIBuilder b(Type::typeinfoclass); - - // TypeInfo base - b.push_classinfo(tc->sym); - - // finish - b.finalize(ir.irGlobal); } /* ========================================================================= */ @@ -861,8 +806,6 @@ void TypeInfoTupleDeclaration::llvmDefine() /* ========================================================================= */ -#if DMDV2 - void TypeInfoConstDeclaration::llvmDefine() { Logger::println("TypeInfoConstDeclaration::llvmDefine() %s", toChars()); @@ -933,5 +876,3 @@ void TypeInfoVectorDeclaration::llvmDefine() // finish b.finalize(ir.irGlobal); } - -#endif diff --git a/ir/irclass.cpp b/ir/irclass.cpp index 219f92f5..21c4b057 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -185,7 +185,6 @@ LLConstant * IrStruct::getVtblInit() fd->codegen(Type::sir); assert(fd->ir.irFunc && "invalid vtbl function"); c = fd->ir.irFunc->func; -#if DMDV2 if (cd->isFuncHidden(fd)) { /* fd is hidden from the view of this class. * If fd overlaps with any function in the vtbl[], then @@ -218,7 +217,6 @@ LLConstant * IrStruct::getVtblInit() } } } -#endif } constants.push_back(c); } diff --git a/ir/irlandingpad.cpp b/ir/irlandingpad.cpp index 8f4c25ca..55b0e54d 100644 --- a/ir/irlandingpad.cpp +++ b/ir/irlandingpad.cpp @@ -28,11 +28,7 @@ IRLandingPadInfo::IRLandingPadInfo(Catch* catchstmt_, llvm::BasicBlock* end_) : catchType->codegen(Type::sir); if(catchstmt->var) { - #if DMDV2 if(!catchstmt->var->nestedrefs.dim) { - #else - if(!catchstmt->var->nestedref) { - #endif gIR->func()->gen->landingPadInfo.getExceptionStorage(); } } @@ -56,11 +52,7 @@ void IRLandingPadInfo::toIR() if(catchstmt->var) { // use the same storage for all exceptions that are not accessed in // nested functions - #if DMDV2 if(!catchstmt->var->nestedrefs.dim) { - #else - if(!catchstmt->var->nestedref) { - #endif assert(!catchstmt->var->ir.irLocal); catchstmt->var->ir.irLocal = new IrLocal(catchstmt->var); LLValue* catch_var = gIR->func()->gen->landingPadInfo.getExceptionStorage(); diff --git a/ir/irstruct.cpp b/ir/irstruct.cpp index db7410e3..0873f403 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -67,11 +67,9 @@ LLGlobalVariable * IrStruct::getInitSymbol() // set alignment init->setAlignment(type->alignsize()); -#if DMDV2 StructDeclaration *sd = aggrdecl->isStructDeclaration(); if (sd && sd->alignment != STRUCTALIGN_DEFAULT) init->setAlignment(sd->alignment); -#endif return init; } diff --git a/ir/irtype.cpp b/ir/irtype.cpp index c25f206e..f73c71f6 100644 --- a/ir/irtype.cpp +++ b/ir/irtype.cpp @@ -266,8 +266,6 @@ IrTypeArray* IrTypeArray::get(Type* dt) ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - IrTypeVector::IrTypeVector(Type* dt) : IrType(dt, vector2llvm(dt)) { @@ -297,6 +295,4 @@ llvm::Type* IrTypeVector::vector2llvm(Type* dt) return llvm::VectorType::get(elemType, dim); } -#endif - ////////////////////////////////////////////////////////////////////////////// diff --git a/ir/irtype.h b/ir/irtype.h index 14e5c6a7..c3205350 100644 --- a/ir/irtype.h +++ b/ir/irtype.h @@ -37,9 +37,7 @@ class IrTypeFunction; class IrTypePointer; class IrTypeSArray; class IrTypeStruct; -#if DMDV2 class IrTypeVector; -#endif ////////////////////////////////////////////////////////////////////////////// @@ -72,10 +70,8 @@ public: virtual IrTypeSArray* isSArray() { return NULL; } /// virtual IrTypeStruct* isStruct() { return NULL; } -#if DMDV2 /// IrTypeVector* isVector() { return NULL; } -#endif /// Type* getDType() { return dtype; } @@ -170,7 +166,6 @@ protected: ////////////////////////////////////////////////////////////////////////////// -#if DMDV2 /// IrType for vectors class IrTypeVector : public IrType { @@ -187,6 +182,5 @@ protected: static llvm::Type* vector2llvm(Type* dt); }; -#endif #endif diff --git a/ir/irtypeclass.cpp b/ir/irtypeclass.cpp index 49635811..e29aa7d4 100644 --- a/ir/irtypeclass.cpp +++ b/ir/irtypeclass.cpp @@ -323,7 +323,6 @@ std::vector IrTypeClass::buildVtblType(Type* first, Array* vtbl_arr IF_LOG Logger::println("Adding type of %s", fd->toPrettyChars()); -#if DMDV2 // If inferring return type and semantic3 has not been run, do it now. // This pops up in some other places in the frontend as well, however // it is probably a bug that it still occurs that late. @@ -336,7 +335,6 @@ std::vector IrTypeClass::buildVtblType(Type* first, Array* vtbl_arr if (spec && global.errors != olderrs) spec->errors = global.errors - olderrs; } -#endif if (!fd->type->nextOf()) { // Return type of the function has not been inferred. This seems to