Add changes for LLVM 3.2

- The Attributes class was changed again
- TargetData was renamed to DataLayout

Compiles again with LLVm 3.0, 3.1 and trunk(3.2).
This commit is contained in:
kai
2012-10-13 18:54:42 +02:00
parent d523be3010
commit a7c7b514c0
23 changed files with 267 additions and 29 deletions

View File

@@ -1,4 +1,8 @@
#if LDC_LLVM_VER >= 302
#include "llvm/DataLayout.h"
#else
#include "llvm/Target/TargetData.h"
#endif
#include "gen/irstate.h"
#include "gen/tollvm.h"
@@ -10,22 +14,22 @@
unsigned GetTypeAlignment(Ir* ir, Type* t)
{
return gTargetData->getABITypeAlignment(DtoType(t));
return gDataLayout->getABITypeAlignment(DtoType(t));
}
unsigned GetPointerSize(Ir* ir)
{
return gTargetData->getPointerSize();
return gDataLayout->getPointerSize();
}
unsigned GetTypeStoreSize(Ir* ir, Type* t)
{
return gTargetData->getTypeStoreSize(DtoType(t));
return gDataLayout->getTypeStoreSize(DtoType(t));
}
unsigned GetTypeAllocSize(Ir* ir, Type* t)
{
return gTargetData->getTypeAllocSize(DtoType(t));
return gDataLayout->getTypeAllocSize(DtoType(t));
}
Ir::Ir()

View File

@@ -33,7 +33,11 @@ namespace llvm
class Constant;
class ConstantStruct;
class ConstantArray;
#if LDC_LLVM_VER >= 302
class DataLayout;
#else
class TargetData;
#endif
class Type;
class StructType;
class ArrayType;

View File

@@ -21,9 +21,15 @@ IrFuncTyArg::IrFuncTyArg(Type* t, bool bref, llvm::Attributes a) : type(t)
rewrite = NULL;
}
#if LDC_LLVM_VER >= 302
bool IrFuncTyArg::isInReg() const { return attrs.hasAttribute(llvm::Attributes::InReg); }
bool IrFuncTyArg::isSRet() const { return attrs.hasAttribute(llvm::Attributes::StructRet); }
bool IrFuncTyArg::isByVal() const { return attrs.hasAttribute(llvm::Attributes::ByVal); }
#else
bool IrFuncTyArg::isInReg() const { return (attrs & llvm::Attribute::InReg) != 0; }
bool IrFuncTyArg::isSRet() const { return (attrs & llvm::Attribute::StructRet) != 0; }
bool IrFuncTyArg::isByVal() const { return (attrs & llvm::Attribute::ByVal) != 0; }
#endif
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -152,19 +158,21 @@ IrFunction::IrFunction(FuncDeclaration* fd)
void IrFunction::setNeverInline()
{
#if LDC_LLVM_VER >= 302
assert(!func->getFnAttributes().hasAlwaysInlineAttr() && "function can't be never- and always-inline at the same time");
assert(!func->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) && "function can't be never- and always-inline at the same time");
func->addFnAttr(llvm::Attributes::NoInline);
#else
assert(!func->hasFnAttr(llvm::Attribute::AlwaysInline) && "function can't be never- and always-inline at the same time");
#endif
func->addFnAttr(llvm::Attribute::NoInline);
#endif
}
void IrFunction::setAlwaysInline()
{
#if LDC_LLVM_VER >= 302
assert(!func->getFnAttributes().hasNoInlineAttr() && "function can't be never- and always-inline at the same time");
assert(!func->getFnAttributes().hasAttribute(llvm::Attributes::NoInline) && "function can't be never- and always-inline at the same time");
func->addFnAttr(llvm::Attributes::AlwaysInline);
#else
assert(!func->hasFnAttr(llvm::Attribute::NoInline) && "function can't be never- and always-inline at the same time");
#endif
func->addFnAttr(llvm::Attribute::AlwaysInline);
#endif
}

View File

@@ -51,7 +51,11 @@ 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 >= 302
IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attributes());
#else
IrFuncTyArg(Type* t, bool byref, llvm::Attributes a = llvm::Attribute::None);
#endif
};
// represents a function type