Skip to content

Commit

Permalink
Simplify code by using the right type.
Browse files Browse the repository at this point in the history
Removes some comditional compiling by replacing unsigned with llvm::Attributes.
  • Loading branch information
redstar committed Jul 29, 2012
1 parent dbb5a34 commit b53544b
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 57 deletions.
18 changes: 1 addition & 17 deletions gen/functions.cpp
Expand Up @@ -57,11 +57,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
else else
{ {
Type* rt = f->next; Type* rt = f->next;
#if LDC_LLVM_VER == 300
unsigned a = 0;
#else
llvm::Attributes a = None; llvm::Attributes a = None;
#endif
// sret return // sret return
if (abi->returnInArg(f)) if (abi->returnInArg(f))
{ {
Expand All @@ -77,13 +74,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
if (f->isref) if (f->isref)
t = t->pointerTo(); t = t->pointerTo();
#endif #endif
#if LDC_LLVM_VER == 300
if (unsigned se = DtoShouldExtend(t))
a = se;
#else
if (llvm::Attributes atts = DtoShouldExtend(t)) if (llvm::Attributes atts = DtoShouldExtend(t))
a = atts; a = atts;
#endif
} }
#if DMDV2 #if DMDV2
fty.ret = new IrFuncTyArg(rt, f->isref, a); fty.ret = new IrFuncTyArg(rt, f->isref, a);
Expand Down Expand Up @@ -157,11 +149,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
#endif #endif


Type* argtype = arg->type; Type* argtype = arg->type;
#if LDC_LLVM_VER == 300
unsigned a = 0;
#else
llvm::Attributes a = None; llvm::Attributes a = None;
#endif


// handle lazy args // handle lazy args
if (arg->storageClass & STClazy) if (arg->storageClass & STClazy)
Expand Down Expand Up @@ -424,11 +412,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati


// set attrs on the rest of the arguments // set attrs on the rest of the arguments
size_t n = Parameter::dim(f->parameters); size_t n = Parameter::dim(f->parameters);
#if LDC_LLVM_VER == 300
LLSmallVector<unsigned, 8> attrptr(n, 0);
#else
LLSmallVector<llvm::Attributes, 8> attrptr(n, None); LLSmallVector<llvm::Attributes, 8> attrptr(n, None);
#endif


for (size_t k = 0; k < n; ++k) for (size_t k = 0; k < n; ++k)
{ {
Expand Down
14 changes: 0 additions & 14 deletions gen/tocall.cpp
Expand Up @@ -277,23 +277,15 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
llvm::AttributeWithIndex Attr; llvm::AttributeWithIndex Attr;
// specify arguments // specify arguments
args.push_back(DtoLoad(typeinfoarrayparam)); 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) { if (llvm::Attributes atts = tf->fty.arg_arguments->attrs) {
#endif
Attr.Index = argidx; Attr.Index = argidx;
Attr.Attrs = atts; Attr.Attrs = atts;
attrs.push_back(Attr); attrs.push_back(Attr);
} }
++argidx; ++argidx;


args.push_back(gIR->ir->CreateBitCast(mem, getPtrToType(LLType::getInt8Ty(gIR->context())), "tmp")); 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) { if (llvm::Attributes atts = tf->fty.arg_argptr->attrs) {
#endif
Attr.Index = argidx; Attr.Index = argidx;
Attr.Attrs = atts; Attr.Attrs = atts;
attrs.push_back(Attr); attrs.push_back(Attr);
Expand Down Expand Up @@ -505,13 +497,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
} }


size_t n = Parameter::dim(tf->parameters); size_t n = Parameter::dim(tf->parameters);

#if LDC_LLVM_VER == 300
LLSmallVector<unsigned, 10> attrptr(n, 0);
#else
LLSmallVector<llvm::Attributes, 10> attrptr(n, llvm::Attribute::None); LLSmallVector<llvm::Attributes, 10> attrptr(n, llvm::Attribute::None);
#endif

std::vector<DValue*> argvals; std::vector<DValue*> argvals;
if (dfnval && dfnval->func->isArrayOp) { if (dfnval && dfnval->func->isArrayOp) {
// slightly different approach for array operators // slightly different approach for array operators
Expand Down
4 changes: 0 additions & 4 deletions gen/todebug.cpp
Expand Up @@ -2,11 +2,7 @@
#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/Support/Dwarf.h" #include "llvm/Support/Dwarf.h"
#include "llvm/Support/FileSystem.h" #include "llvm/Support/FileSystem.h"
#if LDC_LLVM_VER == 300
#include "llvm/Support/PathV2.h"
#else
#include "llvm/Support/Path.h" #include "llvm/Support/Path.h"
#endif


#include "declaration.h" #include "declaration.h"
#include "module.h" #include "module.h"
Expand Down
4 changes: 0 additions & 4 deletions gen/tollvm.cpp
Expand Up @@ -34,11 +34,7 @@ bool DtoIsPassedByRef(Type* type)
return (t == Tstruct || t == Tsarray); return (t == Tstruct || t == Tsarray);
} }


#if LDC_LLVM_VER == 300
unsigned DtoShouldExtend(Type* type)
#else
llvm::Attributes DtoShouldExtend(Type* type) llvm::Attributes DtoShouldExtend(Type* type)
#endif
{ {
type = type->toBasetype(); type = type->toBasetype();
if (type->isintegral()) if (type->isintegral())
Expand Down
4 changes: 0 additions & 4 deletions gen/tollvm.h
Expand Up @@ -19,11 +19,7 @@ LLType* DtoTypeNotVoid(Type* t);
bool DtoIsPassedByRef(Type* type); bool DtoIsPassedByRef(Type* type);


// should argument be zero or sign extended // should argument be zero or sign extended
#if LDC_LLVM_VER == 300
unsigned DtoShouldExtend(Type* type);
#else
llvm::Attributes DtoShouldExtend(Type* type); llvm::Attributes DtoShouldExtend(Type* type);
#endif


// tuple helper // tuple helper
// takes a arguments list and makes a struct type out of them // takes a arguments list and makes a struct type out of them
Expand Down
4 changes: 0 additions & 4 deletions ir/irfunction.cpp
Expand Up @@ -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) IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attributes a) : type(t)
#endif
{ {
ltype = t != Type::tvoid && bref ? DtoType(t->pointerTo()) : DtoType(t); ltype = t != Type::tvoid && bref ? DtoType(t->pointerTo()) : DtoType(t);
attrs = a; attrs = a;
Expand Down
10 changes: 0 additions & 10 deletions ir/irfuncty.h
Expand Up @@ -3,9 +3,7 @@


#include "ir/ir.h" #include "ir/ir.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#if LDC_LLVM_VER >= 301
#include "llvm/Attributes.h" #include "llvm/Attributes.h"
#endif


#include <vector> #include <vector>


Expand All @@ -30,11 +28,7 @@ struct IrFuncTyArg : IrBase


/** These are the final LLVM attributes used for the function. /** These are the final LLVM attributes used for the function.
* Must be valid for the LLVM Type and byref setting */ * Must be valid for the LLVM Type and byref setting */
#if LDC_LLVM_VER == 300
unsigned attrs;
#else
llvm::Attributes attrs; llvm::Attributes attrs;
#endif


/** 'true' if the final LLVM argument is a LLVM reference type. /** '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 * Must be true when the D Type is a value type, but the final
Expand All @@ -57,11 +51,7 @@ struct IrFuncTyArg : IrBase
* @param byref Initial value for the 'byref' field. If true the initial * @param byref Initial value for the 'byref' field. If true the initial
* LLVM Type will be of DtoType(type->pointerTo()), instead * LLVM Type will be of DtoType(type->pointerTo()), instead
* of just DtoType(type) */ * 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); IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attribute::None);
#endif
}; };


// represents a function type // represents a function type
Expand Down

0 comments on commit b53544b

Please sign in to comment.