From b53544b389451bc4195540a970cb5c2e68e9496c Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 29 Jul 2012 18:18:36 +0200 Subject: [PATCH] Simplify code by using the right type. Removes some comditional compiling by replacing unsigned with llvm::Attributes. --- gen/functions.cpp | 18 +----------------- gen/tocall.cpp | 14 -------------- gen/todebug.cpp | 4 ---- gen/tollvm.cpp | 4 ---- gen/tollvm.h | 4 ---- ir/irfunction.cpp | 4 ---- ir/irfuncty.h | 10 ---------- 7 files changed, 1 insertion(+), 57 deletions(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index d4ea7291..0342c452 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -57,11 +57,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, else { Type* rt = f->next; -#if LDC_LLVM_VER == 300 - unsigned a = 0; -#else llvm::Attributes a = None; -#endif + // sret return if (abi->returnInArg(f)) { @@ -77,13 +74,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, if (f->isref) t = t->pointerTo(); #endif -#if LDC_LLVM_VER == 300 - if (unsigned se = DtoShouldExtend(t)) - a = se; -#else if (llvm::Attributes atts = DtoShouldExtend(t)) a = atts; -#endif } #if DMDV2 fty.ret = new IrFuncTyArg(rt, f->isref, a); @@ -157,11 +149,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype, #endif Type* argtype = arg->type; -#if LDC_LLVM_VER == 300 - unsigned a = 0; -#else llvm::Attributes a = None; -#endif // handle lazy args if (arg->storageClass & STClazy) @@ -424,11 +412,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati // set attrs on the rest of the arguments size_t n = Parameter::dim(f->parameters); -#if LDC_LLVM_VER == 300 - LLSmallVector attrptr(n, 0); -#else LLSmallVector attrptr(n, None); -#endif for (size_t k = 0; k < n; ++k) { diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 71f639d8..e2bfe6b4 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -277,11 +277,7 @@ void DtoBuildDVarArgList(std::vector& args, llvm::AttributeWithIndex Attr; // specify arguments args.push_back(DtoLoad(typeinfoarrayparam)); -#if LDC_LLVM_VER == 300 - if (unsigned atts = tf->fty.arg_arguments->attrs) { -#else if (llvm::Attributes atts = tf->fty.arg_arguments->attrs) { -#endif Attr.Index = argidx; Attr.Attrs = atts; attrs.push_back(Attr); @@ -289,11 +285,7 @@ void DtoBuildDVarArgList(std::vector& args, ++argidx; args.push_back(gIR->ir->CreateBitCast(mem, getPtrToType(LLType::getInt8Ty(gIR->context())), "tmp")); -#if LDC_LLVM_VER == 300 - if (unsigned atts = tf->fty.arg_argptr->attrs) { -#else if (llvm::Attributes atts = tf->fty.arg_argptr->attrs) { -#endif Attr.Index = argidx; Attr.Attrs = atts; attrs.push_back(Attr); @@ -505,13 +497,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* } size_t n = Parameter::dim(tf->parameters); - -#if LDC_LLVM_VER == 300 - LLSmallVector attrptr(n, 0); -#else LLSmallVector attrptr(n, llvm::Attribute::None); -#endif - std::vector argvals; if (dfnval && dfnval->func->isArrayOp) { // slightly different approach for array operators diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 3f8618ca..4dabc9aa 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -2,11 +2,7 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/FileSystem.h" -#if LDC_LLVM_VER == 300 -#include "llvm/Support/PathV2.h" -#else #include "llvm/Support/Path.h" -#endif #include "declaration.h" #include "module.h" diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 6cd2a9b9..5fa3d24d 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -34,11 +34,7 @@ bool DtoIsPassedByRef(Type* type) return (t == Tstruct || t == Tsarray); } -#if LDC_LLVM_VER == 300 -unsigned DtoShouldExtend(Type* type) -#else llvm::Attributes DtoShouldExtend(Type* type) -#endif { type = type->toBasetype(); if (type->isintegral()) diff --git a/gen/tollvm.h b/gen/tollvm.h index 7d1700cf..eb9cbce1 100644 --- a/gen/tollvm.h +++ b/gen/tollvm.h @@ -19,11 +19,7 @@ LLType* DtoTypeNotVoid(Type* t); bool DtoIsPassedByRef(Type* type); // should argument be zero or sign extended -#if LDC_LLVM_VER == 300 -unsigned DtoShouldExtend(Type* type); -#else llvm::Attributes DtoShouldExtend(Type* type); -#endif // tuple helper // takes a arguments list and makes a struct type out of them diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index e78d1eed..efb2e469 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -13,11 +13,7 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#if LDC_LLVM_VER == 300 -IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, unsigned a) : type(t) -#else IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attributes a) : type(t) -#endif { ltype = t != Type::tvoid && bref ? DtoType(t->pointerTo()) : DtoType(t); attrs = a; diff --git a/ir/irfuncty.h b/ir/irfuncty.h index bf59d08b..10fb1eec 100644 --- a/ir/irfuncty.h +++ b/ir/irfuncty.h @@ -3,9 +3,7 @@ #include "ir/ir.h" #include "llvm/ADT/SmallVector.h" -#if LDC_LLVM_VER >= 301 #include "llvm/Attributes.h" -#endif #include @@ -30,11 +28,7 @@ struct IrFuncTyArg : IrBase /** These are the final LLVM attributes used for the function. * Must be valid for the LLVM Type and byref setting */ -#if LDC_LLVM_VER == 300 - unsigned attrs; -#else llvm::Attributes attrs; -#endif /** 'true' if the final LLVM argument is a LLVM reference type. * Must be true when the D Type is a value type, but the final @@ -57,11 +51,7 @@ struct IrFuncTyArg : IrBase * @param byref Initial value for the 'byref' field. If true the initial * LLVM Type will be of DtoType(type->pointerTo()), instead * of just DtoType(type) */ -#if LDC_LLVM_VER == 300 - IrFuncTyArg(Type* t, bool byref, unsigned a = 0); -#else IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attribute::None); -#endif }; // represents a function type