Merge pull request #418 from mmp/master

Fix build with LLVM top-of-tree, fix warnings, remove LLVM 3.0 support
This commit is contained in:
jbrodman
2013-01-08 10:28:02 -08:00
17 changed files with 358 additions and 369 deletions

View File

@@ -47,15 +47,25 @@
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <llvm/LLVMContext.h> #if defined(LLVM_3_2)
#if !defined(LLVM_3_0) && !defined(LLVM_3_1)
#include <llvm/Attributes.h> #include <llvm/Attributes.h>
#endif #endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#include <llvm/Intrinsics.h> #include <llvm/Intrinsics.h>
#include <llvm/DerivedTypes.h>
#else
#include <llvm/IR/Attributes.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Intrinsics.h>
#include <llvm/IR/DerivedTypes.h>
#endif
#include <llvm/Linker.h> #include <llvm/Linker.h>
#include <llvm/Target/TargetMachine.h> #include <llvm/Target/TargetMachine.h>
#include <llvm/ADT/Triple.h> #include <llvm/ADT/Triple.h>
@@ -700,10 +710,10 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module,
llvm::Function *func = module->getFunction(name); llvm::Function *func = module->getFunction(name);
Assert(func != NULL); // it should be declared already... Assert(func != NULL); // it should be declared already...
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_2)
func->addFnAttr(llvm::Attribute::AlwaysInline);
#else
func->addFnAttr(llvm::Attributes::AlwaysInline); func->addFnAttr(llvm::Attributes::AlwaysInline);
#else
func->addFnAttr(llvm::Attribute::AlwaysInline);
#endif #endif
llvm::BasicBlock *bblock = llvm::BasicBlock::Create(*g->ctx, "entry", func, 0); llvm::BasicBlock *bblock = llvm::BasicBlock::Create(*g->ctx, "entry", func, 0);
llvm::ReturnInst::Create(*g->ctx, LLVMInt32(val), bblock); llvm::ReturnInst::Create(*g->ctx, LLVMInt32(val), bblock);

View File

@@ -29,17 +29,28 @@
#include "llvmutil.h" #include "llvmutil.h"
#include "llvm/CallingConv.h" #if defined(LLVM_3_1) || defined(LLVM_3_2)
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
#include "llvm/CallingConv.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/Intrinsics.h" #include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h" #include "llvm/IntrinsicInst.h"
#include "llvm/InlineAsm.h" #include "llvm/InlineAsm.h"
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) #else
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/InlineAsm.h"
#endif
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#if !defined(LLVM_3_1)
#include "llvm/TypeFinder.h" #include "llvm/TypeFinder.h"
#endif // LLVM_3_2 + #endif // LLVM_3_2 +
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
@@ -61,10 +72,12 @@
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"
#else #elif defined(LLVM_3_2)
#include "llvm/DataLayout.h" #include "llvm/DataLayout.h"
#else // LLVM 3.3+
#include "llvm/IR/DataLayout.h"
#endif #endif
#include "llvm/Support/CallSite.h" #include "llvm/Support/CallSite.h"
#include "llvm/Support/CFG.h" #include "llvm/Support/CFG.h"
@@ -235,7 +248,7 @@ namespace {
const llvm::MCRegisterInfo *MRI; const llvm::MCRegisterInfo *MRI;
const llvm::MCObjectFileInfo *MOFI; const llvm::MCObjectFileInfo *MOFI;
llvm::MCContext *TCtx; llvm::MCContext *TCtx;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
const llvm::TargetData* TD; const llvm::TargetData* TD;
#else #else
// FIXME: it's ugly to have the name be "TD" here, but it saves us // FIXME: it's ugly to have the name be "TD" here, but it saves us
@@ -245,10 +258,8 @@ namespace {
#endif #endif
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap; std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
#ifndef LLVM_3_0
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap; std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
unsigned VectorConstantIndex; unsigned VectorConstantIndex;
#endif // !LLVM_3_0
std::set<llvm::Function*> intrinsicPrototypesAlreadyGenerated; std::set<llvm::Function*> intrinsicPrototypesAlreadyGenerated;
std::set<const llvm::Argument*> ByValParams; std::set<const llvm::Argument*> ByValParams;
unsigned FPCounter; unsigned FPCounter;
@@ -275,9 +286,7 @@ namespace {
vectorWidth(vecwidth) { vectorWidth(vecwidth) {
initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry()); initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry());
FPCounter = 0; FPCounter = 0;
#ifndef LLVM_3_0
VectorConstantIndex = 0; VectorConstantIndex = 0;
#endif // !LLVM_3_0
} }
virtual const char *getPassName() const { return "C backend"; } virtual const char *getPassName() const { return "C backend"; }
@@ -321,9 +330,7 @@ namespace {
delete MRI; delete MRI;
delete MOFI; delete MOFI;
FPConstantMap.clear(); FPConstantMap.clear();
#ifndef LLVM_3_0
VectorConstantMap.clear(); VectorConstantMap.clear();
#endif // !LLVM_3_0
ByValParams.clear(); ByValParams.clear();
intrinsicPrototypesAlreadyGenerated.clear(); intrinsicPrototypesAlreadyGenerated.clear();
UnnamedStructIDs.clear(); UnnamedStructIDs.clear();
@@ -335,13 +342,22 @@ namespace {
bool isSigned = false, bool isSigned = false,
const std::string &VariableName = "", const std::string &VariableName = "",
bool IgnoreName = false, bool IgnoreName = false,
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()); #if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
#else
const llvm::AttributeSet &PAL = llvm::AttributeSet()
#endif
);
llvm::raw_ostream &printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, llvm::raw_ostream &printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty,
bool isSigned, bool isSigned,
const std::string &NameSoFar = ""); const std::string &NameSoFar = "");
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out, void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL, const llvm::AttrListPtr &PAL,
#else
const llvm::AttributeSet &PAL,
#endif
llvm::PointerType *Ty); llvm::PointerType *Ty);
std::string getStructName(llvm::StructType *ST); std::string getStructName(llvm::StructType *ST);
@@ -395,9 +411,7 @@ namespace {
bool printConstExprCast(const llvm::ConstantExpr *CE, bool Static); bool printConstExprCast(const llvm::ConstantExpr *CE, bool Static);
void printConstantArray(llvm::ConstantArray *CPA, bool Static); void printConstantArray(llvm::ConstantArray *CPA, bool Static);
void printConstantVector(llvm::ConstantVector *CV, bool Static); void printConstantVector(llvm::ConstantVector *CV, bool Static);
#ifndef LLVM_3_0
void printConstantDataSequential(llvm::ConstantDataSequential *CDS, bool Static); void printConstantDataSequential(llvm::ConstantDataSequential *CDS, bool Static);
#endif
/// isAddressExposed - Return true if the specified value's name needs to /// isAddressExposed - Return true if the specified value's name needs to
/// have its address taken in order to get a C value of the correct type. /// have its address taken in order to get a C value of the correct type.
@@ -472,11 +486,6 @@ namespace {
void visitInvokeInst(llvm::InvokeInst &I) { void visitInvokeInst(llvm::InvokeInst &I) {
llvm_unreachable("Lowerinvoke pass didn't work!"); llvm_unreachable("Lowerinvoke pass didn't work!");
} }
#ifdef LLVM_3_0
void visitUnwindInst(llvm::UnwindInst &I) {
llvm_unreachable("Lowerinvoke pass didn't work!");
}
#endif // LLVM_3_0
void visitResumeInst(llvm::ResumeInst &I) { void visitResumeInst(llvm::ResumeInst &I) {
llvm_unreachable("DwarfEHPrepare pass didn't work!"); llvm_unreachable("DwarfEHPrepare pass didn't work!");
} }
@@ -567,7 +576,11 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) {
/// return type, except, instead of printing the type as void (*)(Struct*, ...) /// return type, except, instead of printing the type as void (*)(Struct*, ...)
/// print it as "Struct (*)(...)", for struct return functions. /// print it as "Struct (*)(...)", for struct return functions.
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL, const llvm::AttrListPtr &PAL,
#else
const llvm::AttributeSet &PAL,
#endif
llvm::PointerType *TheTy) { llvm::PointerType *TheTy) {
llvm::FunctionType *FTy = llvm::cast<llvm::FunctionType>(TheTy->getElementType()); llvm::FunctionType *FTy = llvm::cast<llvm::FunctionType>(TheTy->getElementType());
std::string tstr; std::string tstr;
@@ -582,19 +595,23 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
if (PrintedType) if (PrintedType)
FunctionInnards << ", "; FunctionInnards << ", ";
llvm::Type *ArgTy = *I; llvm::Type *ArgTy = *I;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#else #elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
#endif #endif
assert(ArgTy->isPointerTy()); assert(ArgTy->isPointerTy());
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType(); ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
} }
printType(FunctionInnards, ArgTy, printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt),
#endif #endif
""); "");
PrintedType = true; PrintedType = true;
@@ -608,10 +625,12 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
} }
FunctionInnards << ')'; FunctionInnards << ')';
printType(Out, RetTy, printType(Out, RetTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt),
#endif #endif
FunctionInnards.str()); FunctionInnards.str());
} }
@@ -707,7 +726,14 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned,
// //
llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
bool isSigned, const std::string &NameSoFar, bool isSigned, const std::string &NameSoFar,
bool IgnoreName, const llvm::AttrListPtr &PAL) { bool IgnoreName,
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL
#else
const llvm::AttributeSet &PAL
#endif
) {
if (Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) { if (Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) {
printSimpleType(Out, Ty, isSigned, NameSoFar); printSimpleType(Out, Ty, isSigned, NameSoFar);
return Out; return Out;
@@ -723,10 +749,12 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
for (llvm::FunctionType::param_iterator I = FTy->param_begin(), for (llvm::FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++I) { E = FTy->param_end(); I != E; ++I) {
llvm::Type *ArgTy = *I; llvm::Type *ArgTy = *I;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#else #elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
#endif #endif
assert(ArgTy->isPointerTy()); assert(ArgTy->isPointerTy());
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType(); ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
@@ -734,10 +762,12 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
if (I != FTy->param_begin()) if (I != FTy->param_begin())
FunctionInnards << ", "; FunctionInnards << ", ";
printType(FunctionInnards, ArgTy, printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt),
#endif #endif
""); "");
++Idx; ++Idx;
@@ -751,10 +781,12 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
} }
FunctionInnards << ')'; FunctionInnards << ')';
printType(Out, FTy->getReturnType(), printType(Out, FTy->getReturnType(),
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt),
#endif #endif
FunctionInnards.str()); FunctionInnards.str());
return Out; return Out;
@@ -864,61 +896,6 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
} }
void CWriter::printConstantArray(llvm::ConstantArray *CPA, bool Static) { void CWriter::printConstantArray(llvm::ConstantArray *CPA, bool Static) {
#ifdef LLVM_3_0
llvm::Type *ETy = CPA->getType()->getElementType();
// MMP: this looks like a bug: both sides of the || are the same
bool isString = ETy == llvm::Type::getInt8Ty(CPA->getContext());
// Make sure the last character is a null char, as automatically added by C
if (isString && (CPA->getNumOperands() == 0 ||
!llvm::cast<llvm::Constant>(*(CPA->op_end()-1))->isNullValue()))
isString = false;
if (isString) {
Out << "\"";
// Keep track of whether the last number was a hexadecimal escape.
bool LastWasHex = false;
// Do not include the last character, which we know is null
for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) {
unsigned char C = (unsigned char)(llvm::cast<llvm::ConstantInt>(CPA->getOperand(i))->getZExtValue());
// Print it out literally if it is a printable character. The only thing
// to be careful about is when the last letter output was a hex escape
// code, in which case we have to be careful not to print out hex digits
// explicitly (the C compiler thinks it is a continuation of the previous
// character, sheesh...)
//
if (isprint(C) && (!LastWasHex || !isxdigit(C))) {
LastWasHex = false;
if (C == '"' || C == '\\')
Out << "\\" << (char)C;
else
Out << (char)C;
} else {
LastWasHex = false;
switch (C) {
case '\n': Out << "\\n"; break;
case '\t': Out << "\\t"; break;
case '\r': Out << "\\r"; break;
case '\v': Out << "\\v"; break;
case '\a': Out << "\\a"; break;
case '\"': Out << "\\\""; break;
case '\'': Out << "\\\'"; break;
default:
Out << "\\x";
Out << (char)(( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A'));
Out << (char)(((C&15) < 10) ? ((C&15)+'0') : ((C&15)-10+'A'));
LastWasHex = true;
break;
}
}
}
Out << "\"";
return;
}
#endif // LLVM_3_0
printConstant(llvm::cast<llvm::Constant>(CPA->getOperand(0)), Static); printConstant(llvm::cast<llvm::Constant>(CPA->getOperand(0)), Static);
for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) { for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) {
Out << ", "; Out << ", ";
@@ -934,7 +911,6 @@ void CWriter::printConstantVector(llvm::ConstantVector *CP, bool Static) {
} }
} }
#ifndef LLVM_3_0
void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS, void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS,
bool Static) { bool Static) {
// As a special case, print the array as a string if it is an array of // As a special case, print the array as a string if it is an array of
@@ -991,9 +967,7 @@ void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS,
} }
} }
} }
#endif // !LLVM_3_0
#ifndef LLVM_3_0
static inline std::string ftostr(const llvm::APFloat& V) { static inline std::string ftostr(const llvm::APFloat& V) {
std::string Buf; std::string Buf;
if (&V.getSemantics() == &llvm::APFloat::IEEEdouble) { if (&V.getSemantics() == &llvm::APFloat::IEEEdouble) {
@@ -1005,7 +979,6 @@ static inline std::string ftostr(const llvm::APFloat& V) {
} }
return "<unknown format in ftostr>"; // error return "<unknown format in ftostr>"; // error
} }
#endif // !LLVM_3_0
// isFPCSafeToPrint - Returns true if we may assume that CFP may be written out // isFPCSafeToPrint - Returns true if we may assume that CFP may be written out
// textually as a double (rather than as a reference to a stack-allocated // textually as a double (rather than as a reference to a stack-allocated
@@ -1509,11 +1482,9 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
} }
if (llvm::ConstantArray *CA = llvm::dyn_cast<llvm::ConstantArray>(CPV)) { if (llvm::ConstantArray *CA = llvm::dyn_cast<llvm::ConstantArray>(CPV)) {
printConstantArray(CA, Static); printConstantArray(CA, Static);
#ifndef LLVM_3_0
} else if (llvm::ConstantDataSequential *CDS = } else if (llvm::ConstantDataSequential *CDS =
llvm::dyn_cast<llvm::ConstantDataSequential>(CPV)) { llvm::dyn_cast<llvm::ConstantDataSequential>(CPV)) {
printConstantDataSequential(CDS, Static); printConstantDataSequential(CDS, Static);
#endif // !LLVM_3_0
} else { } else {
assert(llvm::isa<llvm::ConstantAggregateZero>(CPV) || llvm::isa<llvm::UndefValue>(CPV)); assert(llvm::isa<llvm::ConstantAggregateZero>(CPV) || llvm::isa<llvm::UndefValue>(CPV));
if (AT->getNumElements()) { if (AT->getNumElements()) {
@@ -1568,8 +1539,6 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
Out << ")"; Out << ")";
} }
} }
#ifndef LLVM_3_0
// LLVM 3.1 and beyond have a different representation of constant vectors..
else if (llvm::ConstantDataVector *CDV = else if (llvm::ConstantDataVector *CDV =
llvm::dyn_cast<llvm::ConstantDataVector>(CPV)) { llvm::dyn_cast<llvm::ConstantDataVector>(CPV)) {
llvm::Constant *splatValue = CDV->getSplatValue(); llvm::Constant *splatValue = CDV->getSplatValue();
@@ -1601,7 +1570,6 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
Out << ")"; Out << ")";
} }
} }
#endif // !LLVM_3_0
else { else {
llvm::report_fatal_error("Unexpected vector type"); llvm::report_fatal_error("Unexpected vector type");
} }
@@ -1994,7 +1962,7 @@ void CWriter::writeOperandWithCast(llvm::Value* Operand, const llvm::ICmpInst &C
// directives to cater to specific compilers as need be. // directives to cater to specific compilers as need be.
// //
static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out, static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
const llvm::TargetData *TD) { const llvm::TargetData *TD) {
#else #else
const llvm::DataLayout *TD) { const llvm::DataLayout *TD) {
@@ -2184,7 +2152,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
// Initialize // Initialize
TheModule = &M; TheModule = &M;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
TD = new llvm::TargetData(&M); TD = new llvm::TargetData(&M);
#else #else
TD = new llvm::DataLayout(&M); TD = new llvm::DataLayout(&M);
@@ -2617,12 +2585,6 @@ void CWriter::printFloatingPointConstants(const llvm::Constant *C) {
// loads to get their values, rather than tediously inserting the // loads to get their values, rather than tediously inserting the
// individual values into the vector. // individual values into the vector.
void CWriter::printVectorConstants(llvm::Function &F) { void CWriter::printVectorConstants(llvm::Function &F) {
// LLVM 3.1 and beyond have a different representation of constant
// vectors than before--here we will only do this for 3.1 and later, as
// the separate code path isn't worth the trouble. This will hurt
// performance with 3.0 builds, though they should still generate
// correct code.
#ifndef LLVM_3_0
for (llvm::constant_iterator I = constant_begin(&F), E = constant_end(&F); for (llvm::constant_iterator I = constant_begin(&F), E = constant_end(&F);
I != E; ++I) { I != E; ++I) {
const llvm::ConstantDataVector *CDV = llvm::dyn_cast<llvm::ConstantDataVector>(*I); const llvm::ConstantDataVector *CDV = llvm::dyn_cast<llvm::ConstantDataVector>(*I);
@@ -2650,7 +2612,6 @@ void CWriter::printVectorConstants(llvm::Function &F) {
VectorConstantMap[CDV] = VectorConstantIndex++; VectorConstantMap[CDV] = VectorConstantIndex++;
} }
Out << "\n"; Out << "\n";
#endif // !LLVM_3_0
} }
/// printSymbolTable - Run through symbol table looking for type names. If a /// printSymbolTable - Run through symbol table looking for type names. If a
@@ -2667,7 +2628,7 @@ void CWriter::printModuleTypes() {
// Get all of the struct types used in the module. // Get all of the struct types used in the module.
std::vector<llvm::StructType*> StructTypes; std::vector<llvm::StructType*> StructTypes;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
TheModule->findUsedStructTypes(StructTypes); TheModule->findUsedStructTypes(StructTypes);
#else #else
llvm::TypeFinder typeFinder; llvm::TypeFinder typeFinder;
@@ -2796,7 +2757,11 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
// Loop over the arguments, printing them... // Loop over the arguments, printing them...
llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType()); llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType());
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = F->getAttributes(); const llvm::AttrListPtr &PAL = F->getAttributes();
#else
const llvm::AttributeSet &PAL = F->getAttributes();
#endif
std::string tstr; std::string tstr;
llvm::raw_string_ostream FunctionInnards(tstr); llvm::raw_string_ostream FunctionInnards(tstr);
@@ -2826,19 +2791,23 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
else else
ArgName = ""; ArgName = "";
llvm::Type *ArgTy = I->getType(); llvm::Type *ArgTy = I->getType();
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#else #elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
#endif #endif
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType(); ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
ByValParams.insert(I); ByValParams.insert(I);
} }
printType(FunctionInnards, ArgTy, printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt),
#endif #endif
ArgName); ArgName);
PrintedArg = true; PrintedArg = true;
@@ -2861,20 +2830,23 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
for (; I != E; ++I) { for (; I != E; ++I) {
if (PrintedArg) FunctionInnards << ", "; if (PrintedArg) FunctionInnards << ", ";
llvm::Type *ArgTy = *I; llvm::Type *ArgTy = *I;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
#else #elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
#endif #endif
assert(ArgTy->isPointerTy()); assert(ArgTy->isPointerTy());
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType(); ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
} }
printType(FunctionInnards, ArgTy, printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt) /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
#else
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt)
#endif #endif
); );
PrintedArg = true; PrintedArg = true;
@@ -2908,10 +2880,12 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
// Print out the return type and the signature built above. // Print out the return type and the signature built above.
printType(Out, RetTy, printType(Out, RetTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else
PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt),
#endif #endif
FunctionInnards.str()); FunctionInnards.str());
} }
@@ -3087,17 +3061,9 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) {
printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2); printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
Out << ";\n"; Out << ";\n";
#ifdef LLVM_3_0
// Skip the first item since that's the default case.
unsigned NumCases = SI.getNumCases();
for (unsigned i = 1; i < NumCases; ++i) {
llvm::ConstantInt* CaseVal = SI.getCaseValue(i);
llvm::BasicBlock* Succ = SI.getSuccessor(i);
#else
for (llvm::SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) { for (llvm::SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) {
llvm::ConstantInt* CaseVal = i.getCaseValue(); llvm::ConstantInt* CaseVal = i.getCaseValue();
llvm::BasicBlock* Succ = i.getCaseSuccessor(); llvm::BasicBlock* Succ = i.getCaseSuccessor();
#endif // !LLVM_3_0
Out << " case "; Out << " case ";
writeOperand(CaseVal); writeOperand(CaseVal);
Out << ":\n"; Out << ":\n";
@@ -3718,7 +3684,11 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
const char *BuiltinName = ""; const char *BuiltinName = "";
#define GET_GCC_BUILTIN_NAME #define GET_GCC_BUILTIN_NAME
#define Intrinsic llvm::Intrinsic #define Intrinsic llvm::Intrinsic
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include "llvm/Intrinsics.gen" #include "llvm/Intrinsics.gen"
#else
#include "llvm/IR/Intrinsics.gen"
#endif
#undef Intrinsic #undef Intrinsic
#undef GET_GCC_BUILTIN_NAME #undef GET_GCC_BUILTIN_NAME
// If we handle it, don't lower it. // If we handle it, don't lower it.
@@ -3779,7 +3749,11 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
// If this is a call to a struct-return function, assign to the first // If this is a call to a struct-return function, assign to the first
// parameter instead of passing it to the call. // parameter instead of passing it to the call.
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = I.getAttributes(); const llvm::AttrListPtr &PAL = I.getAttributes();
#else
const llvm::AttributeSet &PAL = I.getAttributes();
#endif
bool hasByVal = I.hasByValArgument(); bool hasByVal = I.hasByValArgument();
bool isStructRet = I.hasStructRetAttr(); bool isStructRet = I.hasStructRetAttr();
if (isStructRet) { if (isStructRet) {
@@ -3856,20 +3830,22 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
(*AI)->getType() != FTy->getParamType(ArgNo)) { (*AI)->getType() != FTy->getParamType(ArgNo)) {
Out << '('; Out << '(';
printType(Out, FTy->getParamType(ArgNo), printType(Out, FTy->getParamType(ArgNo),
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt) /*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt)
#else #elif defined(LLVM_3_2)
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt) PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
#else
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attribute::SExt)
#endif #endif
); );
Out << ')'; Out << ')';
} }
// Check if the argument is expected to be passed by value. // Check if the argument is expected to be passed by value.
if (I.paramHasAttr(ArgNo+1, if (I.paramHasAttr(ArgNo+1,
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_2)
llvm::Attribute::ByVal
#else
llvm::Attributes::ByVal llvm::Attributes::ByVal
#else
llvm::Attribute::ByVal
#endif #endif
)) ))
writeOperandDeref(*AI); writeOperandDeref(*AI);
@@ -3890,12 +3866,13 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID,
// If this is an intrinsic that directly corresponds to a GCC // If this is an intrinsic that directly corresponds to a GCC
// builtin, we emit it here. // builtin, we emit it here.
const char *BuiltinName = ""; const char *BuiltinName = "";
#ifdef LLVM_3_0
llvm::Function *F = I.getCalledFunction();
#endif // LLVM_3_0
#define GET_GCC_BUILTIN_NAME #define GET_GCC_BUILTIN_NAME
#define Intrinsic llvm::Intrinsic #define Intrinsic llvm::Intrinsic
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include "llvm/Intrinsics.gen" #include "llvm/Intrinsics.gen"
#else
#include "llvm/IR/Intrinsics.gen"
#endif
#undef Intrinsic #undef Intrinsic
#undef GET_GCC_BUILTIN_NAME #undef GET_GCC_BUILTIN_NAME
assert(BuiltinName[0] && "Unknown LLVM intrinsic!"); assert(BuiltinName[0] && "Unknown LLVM intrinsic!");
@@ -4476,7 +4453,7 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
matchType, NULL); matchType, NULL);
smearFunc = llvm::dyn_cast<llvm::Function>(sf); smearFunc = llvm::dyn_cast<llvm::Function>(sf);
assert(smearFunc != NULL); assert(smearFunc != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
smearFunc->setDoesNotThrow(true); smearFunc->setDoesNotThrow(true);
smearFunc->setDoesNotAccessMemory(true); smearFunc->setDoesNotAccessMemory(true);
#else #else
@@ -4627,7 +4604,7 @@ AndCmpCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
LLVMTypes::MaskType, NULL); LLVMTypes::MaskType, NULL);
andCmpFunc = llvm::dyn_cast<llvm::Function>(acf); andCmpFunc = llvm::dyn_cast<llvm::Function>(acf);
Assert(andCmpFunc != NULL); Assert(andCmpFunc != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
andCmpFunc->setDoesNotThrow(true); andCmpFunc->setDoesNotThrow(true);
andCmpFunc->setDoesNotAccessMemory(true); andCmpFunc->setDoesNotAccessMemory(true);
#else #else
@@ -4677,35 +4654,35 @@ public:
notFunc = notFunc =
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__not", mt, mt, NULL)); llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__not", mt, mt, NULL));
assert(notFunc != NULL); assert(notFunc != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_2)
notFunc->addFnAttr(llvm::Attribute::NoUnwind);
notFunc->addFnAttr(llvm::Attribute::ReadNone);
#else
notFunc->addFnAttr(llvm::Attributes::NoUnwind); notFunc->addFnAttr(llvm::Attributes::NoUnwind);
notFunc->addFnAttr(llvm::Attributes::ReadNone); notFunc->addFnAttr(llvm::Attributes::ReadNone);
#else
notFunc->addFnAttr(llvm::Attribute::NoUnwind);
notFunc->addFnAttr(llvm::Attribute::ReadNone);
#endif #endif
andNotFuncs[0] = andNotFuncs[0] =
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not1", mt, mt, mt, llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not1", mt, mt, mt,
NULL)); NULL));
assert(andNotFuncs[0] != NULL); assert(andNotFuncs[0] != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_2)
andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind);
andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone);
#else
andNotFuncs[0]->addFnAttr(llvm::Attributes::NoUnwind); andNotFuncs[0]->addFnAttr(llvm::Attributes::NoUnwind);
andNotFuncs[0]->addFnAttr(llvm::Attributes::ReadNone); andNotFuncs[0]->addFnAttr(llvm::Attributes::ReadNone);
#else
andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind);
andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone);
#endif #endif
andNotFuncs[1] = andNotFuncs[1] =
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not2", mt, mt, mt, llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not2", mt, mt, mt,
NULL)); NULL));
assert(andNotFuncs[1] != NULL); assert(andNotFuncs[1] != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_2)
andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind);
andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone);
#else
andNotFuncs[1]->addFnAttr(llvm::Attributes::NoUnwind); andNotFuncs[1]->addFnAttr(llvm::Attributes::NoUnwind);
andNotFuncs[1]->addFnAttr(llvm::Attributes::ReadNone); andNotFuncs[1]->addFnAttr(llvm::Attributes::ReadNone);
#else
andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind);
andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone);
#endif #endif
} }
@@ -4735,14 +4712,12 @@ lIsAllTrue(llvm::Value *v) {
ci->isOne()); ci->isOne());
} }
#ifndef LLVM_3_0
if (llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v)) { if (llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v)) {
llvm::ConstantInt *ci; llvm::ConstantInt *ci;
return (cdv->getSplatValue() != NULL && return (cdv->getSplatValue() != NULL &&
(ci = llvm::dyn_cast<llvm::ConstantInt>(cdv->getSplatValue())) != NULL && (ci = llvm::dyn_cast<llvm::ConstantInt>(cdv->getSplatValue())) != NULL &&
ci->isOne()); ci->isOne());
} }
#endif
return false; return false;
} }

21
ctx.cpp
View File

@@ -45,11 +45,18 @@
#include "module.h" #include "module.h"
#include "sym.h" #include "sym.h"
#include <map> #include <map>
#include <llvm/DerivedTypes.h>
#include <llvm/Instructions.h>
#include <llvm/Support/Dwarf.h> #include <llvm/Support/Dwarf.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Metadata.h> #include <llvm/Metadata.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Instructions.h>
#include <llvm/DerivedTypes.h>
#else
#include <llvm/IR/Metadata.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/DerivedTypes.h>
#endif
/** This is a small utility structure that records information related to one /** This is a small utility structure that records information related to one
level of nested control flow. It's mostly used in correctly restoring level of nested control flow. It's mostly used in correctly restoring
@@ -351,9 +358,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
mangledName, diFile, mangledName, diFile,
firstLine, diSubprogramType, firstLine, diSubprogramType,
isStatic, true, /* is defn */ isStatic, true, /* is defn */
#ifndef LLVM_3_0
firstLine, firstLine,
#endif // !LLVM_3_0
flags, flags,
isOptimized, llvmFunction); isOptimized, llvmFunction);
AssertPos(currentPos, diSubprogram.Verify()); AssertPos(currentPos, diSubprogram.Verify());
@@ -1377,11 +1382,7 @@ FunctionEmitContext::MasksAllEqual(llvm::Value *v1, llvm::Value *v2) {
llvm::Value * llvm::Value *
FunctionEmitContext::GetStringPtr(const std::string &str) { FunctionEmitContext::GetStringPtr(const std::string &str) {
#ifdef LLVM_3_0
llvm::Constant *lstr = llvm::ConstantArray::get(*g->ctx, str);
#else
llvm::Constant *lstr = llvm::ConstantDataArray::getString(*g->ctx, str); llvm::Constant *lstr = llvm::ConstantDataArray::getString(*g->ctx, str);
#endif
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage; llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage;
llvm::Value *lstrPtr = new llvm::GlobalVariable(*m->module, lstr->getType(), llvm::Value *lstrPtr = new llvm::GlobalVariable(*m->module, lstr->getType(),
true /*isConst*/, true /*isConst*/,
@@ -1431,11 +1432,7 @@ FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) {
static llvm::Value * static llvm::Value *
lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) { lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
#ifdef LLVM_3_0
llvm::Constant *sConstant = llvm::ConstantArray::get(*g->ctx, s);
#else
llvm::Constant *sConstant = llvm::ConstantDataArray::getString(*g->ctx, s); llvm::Constant *sConstant = llvm::ConstantDataArray::getString(*g->ctx, s);
#endif
llvm::Value *sPtr = new llvm::GlobalVariable(*m->module, sConstant->getType(), llvm::Value *sPtr = new llvm::GlobalVariable(*m->module, sConstant->getType(),
true /* const */, true /* const */,
llvm::GlobalValue::InternalLinkage, llvm::GlobalValue::InternalLinkage,

7
ctx.h
View File

@@ -40,9 +40,14 @@
#include "ispc.h" #include "ispc.h"
#include <map> #include <map>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/InstrTypes.h> #include <llvm/InstrTypes.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #else
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#endif
#if defined(LLVM_3_1)
#include <llvm/Analysis/DebugInfo.h> #include <llvm/Analysis/DebugInfo.h>
#include <llvm/Analysis/DIBuilder.h> #include <llvm/Analysis/DIBuilder.h>
#else #else

View File

@@ -56,13 +56,23 @@
#include <list> #include <list>
#include <set> #include <set>
#include <stdio.h> #include <stdio.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Function.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/Instructions.h>
#include <llvm/Function.h>
#include <llvm/DerivedTypes.h> #include <llvm/DerivedTypes.h>
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Instructions.h>
#include <llvm/CallingConv.h> #include <llvm/CallingConv.h>
#else
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/CallingConv.h>
#endif
#include <llvm/ExecutionEngine/GenericValue.h> #include <llvm/ExecutionEngine/GenericValue.h>
#include <llvm/Support/InstIterator.h> #include <llvm/Support/InstIterator.h>

View File

@@ -46,12 +46,21 @@
#include "util.h" #include "util.h"
#include <stdio.h> #include <stdio.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#include <llvm/Intrinsics.h> #include <llvm/Intrinsics.h>
#include <llvm/DerivedTypes.h>
#else
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Intrinsics.h>
#include <llvm/IR/DerivedTypes.h>
#endif
#include <llvm/PassManager.h> #include <llvm/PassManager.h>
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
#include <llvm/Transforms/IPO.h> #include <llvm/Transforms/IPO.h>
@@ -301,10 +310,12 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// isn't worth the code bloat / overhead. // isn't worth the code bloat / overhead.
bool checkMask = (type->isTask == true) || bool checkMask = (type->isTask == true) ||
( (
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false) (function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
#else #elif defined(LLVM_3_2)
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false) (function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
#else // LLVM 3.3+
(function->getAttributes().getFnAttributes().hasAttribute(llvm::Attribute::AlwaysInline) == false)
#endif #endif
&& &&
costEstimate > CHECK_MASK_AT_FUNCTION_START_COST); costEstimate > CHECK_MASK_AT_FUNCTION_START_COST);
@@ -442,7 +453,7 @@ Function::GenerateIR() {
functionName += std::string("_") + g->target.GetISAString(); functionName += std::string("_") + g->target.GetISAString();
llvm::Function *appFunction = llvm::Function *appFunction =
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module); llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
appFunction->setDoesNotThrow(true); appFunction->setDoesNotThrow(true);
#else #else
appFunction->setDoesNotThrow(); appFunction->setDoesNotThrow();

View File

@@ -48,9 +48,16 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #include <llvm/Instructions.h>
#else
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Instructions.h>
#endif
#if defined(LLVM_3_1)
#include <llvm/Analysis/DebugInfo.h> #include <llvm/Analysis/DebugInfo.h>
#include <llvm/Analysis/DIBuilder.h> #include <llvm/Analysis/DIBuilder.h>
#else #else
@@ -58,13 +65,14 @@
#include <llvm/DIBuilder.h> #include <llvm/DIBuilder.h>
#endif #endif
#include <llvm/Support/Dwarf.h> #include <llvm/Support/Dwarf.h>
#include <llvm/Instructions.h>
#include <llvm/Target/TargetMachine.h> #include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h> #include <llvm/Target/TargetOptions.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
#include <llvm/Target/TargetData.h> #include <llvm/Target/TargetData.h>
#else #elif defined(LLVM_3_2)
#include <llvm/DataLayout.h> #include <llvm/DataLayout.h>
#else // LLVM 3.3+
#include <llvm/IR/DataLayout.h>
#endif #endif
#include <llvm/Support/TargetRegistry.h> #include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h> #include <llvm/Support/TargetSelect.h>
@@ -340,13 +348,10 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand"; t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
t->maskingIsFree = false; t->maskingIsFree = false;
t->maskBitCount = 32; t->maskBitCount = 32;
#if !defined(LLVM_3_0)
// LLVM 3.1+ only
t->hasHalf = true; t->hasHalf = true;
#if !defined(LLVM_3_1) #if !defined(LLVM_3_1)
// LLVM 3.2+ only // LLVM 3.2+ only
t->hasRand = true; t->hasRand = true;
#endif
#endif #endif
} }
else if (!strcasecmp(isa, "avx1.1-x2")) { else if (!strcasecmp(isa, "avx1.1-x2")) {
@@ -356,16 +361,12 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand"; t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
t->maskingIsFree = false; t->maskingIsFree = false;
t->maskBitCount = 32; t->maskBitCount = 32;
#if !defined(LLVM_3_0)
// LLVM 3.1+ only
t->hasHalf = true; t->hasHalf = true;
#if !defined(LLVM_3_1) #if !defined(LLVM_3_1)
// LLVM 3.2+ only // LLVM 3.2+ only
t->hasRand = true; t->hasRand = true;
#endif
#endif #endif
} }
#ifndef LLVM_3_0
else if (!strcasecmp(isa, "avx2")) { else if (!strcasecmp(isa, "avx2")) {
t->isa = Target::AVX2; t->isa = Target::AVX2;
t->nativeVectorWidth = 8; t->nativeVectorWidth = 8;
@@ -402,7 +403,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->hasGather = true; t->hasGather = true;
#endif #endif
} }
#endif // !LLVM_3_0
else { else {
fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n", fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n",
isa, SupportedTargetISAs()); isa, SupportedTargetISAs());
@@ -411,7 +411,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
if (!error) { if (!error) {
llvm::TargetMachine *targetMachine = t->GetTargetMachine(); llvm::TargetMachine *targetMachine = t->GetTargetMachine();
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
const llvm::TargetData *targetData = targetMachine->getTargetData(); const llvm::TargetData *targetData = targetMachine->getTargetData();
t->is32Bit = (targetData->getPointerSize() == 4); t->is32Bit = (targetData->getPointerSize() == 4);
#else #else
@@ -448,9 +448,7 @@ Target::SupportedTargetArchs() {
const char * const char *
Target::SupportedTargetISAs() { Target::SupportedTargetISAs() {
return "sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2" return "sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2"
#ifndef LLVM_3_0
", avx1.1, avx1.1-x2, avx2, avx2-x2" ", avx1.1, avx1.1-x2, avx2, avx2-x2"
#endif // !LLVM_3_0
", generic-1, generic-4, generic-8, generic-16, generic-32"; ", generic-1, generic-4, generic-8, generic-16, generic-32";
} }
@@ -459,11 +457,7 @@ std::string
Target::GetTripleString() const { Target::GetTripleString() const {
llvm::Triple triple; llvm::Triple triple;
// Start with the host triple as the default // Start with the host triple as the default
#ifdef LLVM_3_0
triple.setTriple(llvm::sys::getHostTriple());
#else
triple.setTriple(llvm::sys::getDefaultTargetTriple()); triple.setTriple(llvm::sys::getDefaultTargetTriple());
#endif
// And override the arch in the host triple based on what the user // And override the arch in the host triple based on what the user
// specified. Here we need to deal with the fact that LLVM uses one // specified. Here we need to deal with the fact that LLVM uses one
@@ -488,11 +482,6 @@ Target::GetTargetMachine() const {
llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ : llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ :
llvm::Reloc::Default; llvm::Reloc::Default;
#ifdef LLVM_3_0
std::string featuresString = attributes;
llvm::TargetMachine *targetMachine =
target->createTargetMachine(triple, cpu, featuresString, relocModel);
#else
std::string featuresString = attributes; std::string featuresString = attributes;
llvm::TargetOptions options; llvm::TargetOptions options;
#if !defined(LLVM_3_1) #if !defined(LLVM_3_1)
@@ -502,7 +491,6 @@ Target::GetTargetMachine() const {
llvm::TargetMachine *targetMachine = llvm::TargetMachine *targetMachine =
target->createTargetMachine(triple, cpu, featuresString, options, target->createTargetMachine(triple, cpu, featuresString, options,
relocModel); relocModel);
#endif // !LLVM_3_0
Assert(targetMachine != NULL); Assert(targetMachine != NULL);
targetMachine->setAsmVerbosityDefault(true); targetMachine->setAsmVerbosityDefault(true);
@@ -587,7 +575,7 @@ Target::SizeOf(llvm::Type *type,
"sizeof_int", insertAtEnd); "sizeof_int", insertAtEnd);
} }
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
const llvm::TargetData *td = GetTargetMachine()->getTargetData(); const llvm::TargetData *td = GetTargetMachine()->getTargetData();
Assert(td != NULL); Assert(td != NULL);
uint64_t bitSize = td->getTypeSizeInBits(type); uint64_t bitSize = td->getTypeSizeInBits(type);
@@ -634,7 +622,7 @@ Target::StructOffset(llvm::Type *type, int element,
return NULL; return NULL;
} }
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
const llvm::TargetData *td = GetTargetMachine()->getTargetData(); const llvm::TargetData *td = GetTargetMachine()->getTargetData();
Assert(td != NULL); Assert(td != NULL);
const llvm::StructLayout *sl = td->getStructLayout(structType); const llvm::StructLayout *sl = td->getStructLayout(structType);

4
ispc.h
View File

@@ -40,8 +40,8 @@
#define ISPC_VERSION "1.3.1dev" #define ISPC_VERSION "1.3.1dev"
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) #if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3)
#error "Only LLVM 3.0, 3.1, 3.2 and the 3.3 development branch are supported" #error "Only LLVM 3.1, 3.2 and the 3.3 development branch are supported"
#endif #endif
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)

View File

@@ -38,8 +38,13 @@
#include "llvmutil.h" #include "llvmutil.h"
#include "ispc.h" #include "ispc.h"
#include "type.h" #include "type.h"
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#include <llvm/BasicBlock.h> #include <llvm/BasicBlock.h>
#else
#include <llvm/IR/Instructions.h>
#include <llvm/IR/BasicBlock.h>
#endif
#include <set> #include <set>
#include <map> #include <map>
@@ -544,7 +549,7 @@ lValuesAreEqual(llvm::Value *v0, llvm::Value *v1,
llvm::CastInst *cast1 = llvm::dyn_cast<llvm::CastInst>(v1); llvm::CastInst *cast1 = llvm::dyn_cast<llvm::CastInst>(v1);
if (cast0 != NULL && cast1 != NULL) { if (cast0 != NULL && cast1 != NULL) {
if (cast0->getOpcode() != cast1->getOpcode()) if (cast0->getOpcode() != cast1->getOpcode())
return NULL; return false;
return lValuesAreEqual(cast0->getOperand(0), cast1->getOperand(0), return lValuesAreEqual(cast0->getOperand(0), cast1->getOperand(0),
seenPhi0, seenPhi1); seenPhi0, seenPhi1);
} }
@@ -655,9 +660,6 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) {
return true; return true;
} }
// Deal with the fact that LLVM3.1 and previous versions have different
// representations for vectors of constant ints...
#ifndef LLVM_3_0
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v); llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
if (cv == NULL) if (cv == NULL)
return false; return false;
@@ -665,20 +667,6 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) {
for (int i = 0; i < (int)cv->getNumElements(); ++i) for (int i = 0; i < (int)cv->getNumElements(); ++i)
ret[i] = cv->getElementAsInteger(i); ret[i] = cv->getElementAsInteger(i);
return true; return true;
#else
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v);
if (cv == NULL)
return false;
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
cv->getVectorElements(elements);
for (int i = 0; i < (int)vt->getNumElements(); ++i) {
llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[i]);
Assert(ci != NULL);
ret[i] = ci->getSExtValue();
}
return true;
#endif // !LLVM_3_0
} }
@@ -947,11 +935,9 @@ lVectorValuesAllEqual(llvm::Value *v, int vectorLength,
if (cv != NULL) if (cv != NULL)
return (cv->getSplatValue() != NULL); return (cv->getSplatValue() != NULL);
#ifndef LLVM_3_0
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v); llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
if (cdv != NULL) if (cdv != NULL)
return (cdv->getSplatValue() != NULL); return (cdv->getSplatValue() != NULL);
#endif
llvm::BinaryOperator *bop = llvm::dyn_cast<llvm::BinaryOperator>(v); llvm::BinaryOperator *bop = llvm::dyn_cast<llvm::BinaryOperator>(v);
if (bop != NULL) { if (bop != NULL) {
@@ -1101,22 +1087,13 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride,
elements. elements.
*/ */
static bool static bool
lVectorIsLinearConstantInts( lVectorIsLinearConstantInts(llvm::ConstantDataVector *cv,
#ifndef LLVM_3_0
llvm::ConstantDataVector *cv,
#else
llvm::ConstantVector *cv,
#endif
int vectorLength, int vectorLength,
int stride) { int stride) {
// Flatten the vector out into the elements array // Flatten the vector out into the elements array
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements; llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
#ifndef LLVM_3_0
for (int i = 0; i < (int)cv->getNumElements(); ++i) for (int i = 0; i < (int)cv->getNumElements(); ++i)
elements.push_back(cv->getElementAsConstant(i)); elements.push_back(cv->getElementAsConstant(i));
#else
cv->getVectorElements(elements);
#endif
Assert((int)elements.size() == vectorLength); Assert((int)elements.size() == vectorLength);
llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[0]); llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[0]);
@@ -1152,11 +1129,7 @@ lCheckMulForLinear(llvm::Value *op0, llvm::Value *op1, int vectorLength,
int stride, std::vector<llvm::PHINode *> &seenPhis) { int stride, std::vector<llvm::PHINode *> &seenPhis) {
// Is the first operand a constant integer value splatted across all of // Is the first operand a constant integer value splatted across all of
// the lanes? // the lanes?
#ifndef LLVM_3_0
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(op0); llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(op0);
#else
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(op0);
#endif
if (cv == NULL) if (cv == NULL)
return false; return false;
@@ -1226,11 +1199,7 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride,
std::vector<llvm::PHINode *> &seenPhis) { std::vector<llvm::PHINode *> &seenPhis) {
// First try the easy case: if the values are all just constant // First try the easy case: if the values are all just constant
// integers and have the expected stride between them, then we're done. // integers and have the expected stride between them, then we're done.
#ifndef LLVM_3_0
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v); llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
#else
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v);
#endif
if (cv != NULL) if (cv != NULL)
return lVectorIsLinearConstantInts(cv, vectorLength, stride); return lVectorIsLinearConstantInts(cv, vectorLength, stride);
@@ -1402,19 +1371,11 @@ lExtractFirstVectorElement(llvm::Value *v,
return llvm::Constant::getNullValue(vt->getElementType()); return llvm::Constant::getNullValue(vt->getElementType());
} }
if (llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v)) { if (llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v)) {
#ifndef LLVM_3_0
return cv->getOperand(0); return cv->getOperand(0);
#else
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
cv->getVectorElements(elements);
return elements[0];
#endif // !LLVM_3_0
} }
#ifndef LLVM_3_0
if (llvm::ConstantDataVector *cdv = if (llvm::ConstantDataVector *cdv =
llvm::dyn_cast<llvm::ConstantDataVector>(v)) llvm::dyn_cast<llvm::ConstantDataVector>(v))
return cdv->getElementAsConstant(0); return cdv->getElementAsConstant(0);
#endif // !LLVM_3_0
// Otherwise, all that we should have at this point is an instruction // Otherwise, all that we should have at this point is an instruction
// of some sort // of some sort

View File

@@ -38,10 +38,17 @@
#ifndef ISPC_LLVMUTIL_H #ifndef ISPC_LLVMUTIL_H
#define ISPC_LLVMUTIL_H 1 #define ISPC_LLVMUTIL_H 1
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h> #include <llvm/DerivedTypes.h>
#include <llvm/Constants.h> #include <llvm/Constants.h>
#else
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Constants.h>
#endif
namespace llvm { namespace llvm {
class PHINode; class PHINode;

View File

@@ -62,9 +62,7 @@ static void
lPrintVersion() { lPrintVersion() {
printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n", printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n",
ISPC_VERSION, BUILD_VERSION, BUILD_DATE, ISPC_VERSION, BUILD_VERSION, BUILD_DATE,
#if defined(LLVM_3_0) #if defined(LLVM_3_1)
"3.0"
#elif defined(LLVM_3_1)
"3.1" "3.1"
#elif defined(LLVM_3_2) #elif defined(LLVM_3_2)
"3.2" "3.2"

View File

@@ -64,12 +64,21 @@
#define strcasecmp stricmp #define strcasecmp stricmp
#endif #endif
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#include <llvm/Intrinsics.h> #include <llvm/Intrinsics.h>
#include <llvm/DerivedTypes.h>
#else
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Intrinsics.h>
#include <llvm/IR/DerivedTypes.h>
#endif
#include <llvm/PassManager.h> #include <llvm/PassManager.h>
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
#include <llvm/Transforms/IPO.h> #include <llvm/Transforms/IPO.h>
@@ -77,10 +86,14 @@
#include <llvm/Support/FileUtilities.h> #include <llvm/Support/FileUtilities.h>
#include <llvm/Target/TargetMachine.h> #include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h> #include <llvm/Target/TargetOptions.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
#include <llvm/Target/TargetData.h> #include <llvm/Target/TargetData.h>
#else #else
#if defined(LLVM_3_2)
#include <llvm/DataLayout.h> #include <llvm/DataLayout.h>
#else // LLVM 3.3+
#include <llvm/IR/DataLayout.h>
#endif
#include <llvm/TargetTransformInfo.h> #include <llvm/TargetTransformInfo.h>
#endif #endif
#include <llvm/Analysis/Verifier.h> #include <llvm/Analysis/Verifier.h>
@@ -136,7 +149,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
if (g->generateDebuggingSymbols == false) if (g->generateDebuggingSymbols == false)
return; return;
#ifndef LLVM_3_0
// loop over the compile units that contributed to the final module // loop over the compile units that contributed to the final module
if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) { if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) { for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) {
@@ -215,7 +227,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
} }
for (int i = 0; i < (int)toErase.size(); ++i) for (int i = 0; i < (int)toErase.size(); ++i)
module->eraseNamedMetadata(toErase[i]); module->eraseNamedMetadata(toErase[i]);
#endif // !LLVM_3_0
// Wrap up by running the LLVM pass to remove anything left that's // Wrap up by running the LLVM pass to remove anything left that's
// unused. // unused.
@@ -760,14 +771,14 @@ Module::AddFunctionDeclaration(const std::string &name,
if (storageClass != SC_EXTERN_C && if (storageClass != SC_EXTERN_C &&
!g->generateDebuggingSymbols && !g->generateDebuggingSymbols &&
isInline) isInline)
#if defined(LLVM_3_0) || defined(LLVM_3_1) #ifdef LLVM_3_2
function->addFnAttr(llvm::Attribute::AlwaysInline);
#else
function->addFnAttr(llvm::Attributes::AlwaysInline); function->addFnAttr(llvm::Attributes::AlwaysInline);
#else
function->addFnAttr(llvm::Attribute::AlwaysInline);
#endif #endif
if (functionType->isTask) if (functionType->isTask)
// This also applies transitively to members I think? // This also applies transitively to members I think?
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
function->setDoesNotAlias(1, true); function->setDoesNotAlias(1, true);
#else #else
function->setDoesNotAlias(1); function->setDoesNotAlias(1);
@@ -818,7 +829,7 @@ Module::AddFunctionDeclaration(const std::string &name,
// NOTE: LLVM indexes function parameters starting from 1. // NOTE: LLVM indexes function parameters starting from 1.
// This is unintuitive. // This is unintuitive.
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
function->setDoesNotAlias(i+1, true); function->setDoesNotAlias(i+1, true);
#else #else
function->setDoesNotAlias(i+1); function->setDoesNotAlias(i+1);
@@ -1045,7 +1056,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
} }
llvm::PassManager pm; llvm::PassManager pm;
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
if (const llvm::TargetData *td = targetMachine->getTargetData()) if (const llvm::TargetData *td = targetMachine->getTargetData())
pm.add(new llvm::TargetData(*td)); pm.add(new llvm::TargetData(*td));
else else
@@ -1059,13 +1070,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
llvm::formatted_raw_ostream fos(of->os()); llvm::formatted_raw_ostream fos(of->os());
#ifdef LLVM_3_0
llvm::CodeGenOpt::Level optLevel =
(g->opt.level > 0) ? llvm::CodeGenOpt::Aggressive : llvm::CodeGenOpt::None;
if (targetMachine->addPassesToEmitFile(pm, fos, fileType, optLevel)) {
#else
if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) { if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) {
#endif
fprintf(stderr, "Fatal error adding passes to emit object file!"); fprintf(stderr, "Fatal error adding passes to emit object file!");
exit(1); exit(1);
} }
@@ -1775,7 +1780,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
llvm::raw_fd_ostream stderrRaw(2, false); llvm::raw_fd_ostream stderrRaw(2, false);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
clang::TextDiagnosticPrinter *diagPrinter = clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions()); new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
#else #else
@@ -1784,7 +1789,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions); new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
#endif #endif
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs); llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
clang::DiagnosticsEngine *diagEngine = clang::DiagnosticsEngine *diagEngine =
new clang::DiagnosticsEngine(diagIDs, diagPrinter); new clang::DiagnosticsEngine(diagIDs, diagPrinter);
#else #else
@@ -1796,20 +1801,21 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
clang::TargetOptions &options = inst.getTargetOpts(); clang::TargetOptions &options = inst.getTargetOpts();
llvm::Triple triple(module->getTargetTriple()); llvm::Triple triple(module->getTargetTriple());
if (triple.getTriple().empty()) { if (triple.getTriple().empty()) {
#ifdef LLVM_3_0
triple.setTriple(llvm::sys::getHostTriple());
#else
triple.setTriple(llvm::sys::getDefaultTargetTriple()); triple.setTriple(llvm::sys::getDefaultTargetTriple());
#endif
} }
options.Triple = triple.getTriple(); options.Triple = triple.getTriple();
#if defined(LLVM_3_1) || defined(LLVM_3_2)
clang::TargetInfo *target = clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
#else // LLVM 3.3+
clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options);
#endif
inst.setTarget(target); inst.setTarget(target);
inst.createSourceManager(inst.getFileManager()); inst.createSourceManager(inst.getFileManager());
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
inst.InitializeSourceManager(infilename); inst.InitializeSourceManager(infilename);
#else #else
clang::FrontendInputFile inputFile(infilename, clang::IK_None); clang::FrontendInputFile inputFile(infilename, clang::IK_None);

58
opt.cpp
View File

@@ -48,15 +48,24 @@
#include <set> #include <set>
#include <llvm/Pass.h> #include <llvm/Pass.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Instructions.h>
#include <llvm/Intrinsics.h>
#include <llvm/Function.h>
#include <llvm/BasicBlock.h>
#include <llvm/Constants.h>
#else
#include <llvm/IR/Module.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Intrinsics.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h>
#endif
#include <llvm/PassManager.h> #include <llvm/PassManager.h>
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
#include <llvm/Assembly/PrintModulePass.h> #include <llvm/Assembly/PrintModulePass.h>
#include <llvm/Function.h>
#include <llvm/BasicBlock.h>
#include <llvm/Instructions.h>
#include <llvm/Intrinsics.h>
#include <llvm/Constants.h>
#include <llvm/Analysis/ConstantFolding.h> #include <llvm/Analysis/ConstantFolding.h>
#include <llvm/Target/TargetLibraryInfo.h> #include <llvm/Target/TargetLibraryInfo.h>
#include <llvm/ADT/Triple.h> #include <llvm/ADT/Triple.h>
@@ -64,16 +73,19 @@
#include <llvm/Transforms/IPO.h> #include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.h> #include <llvm/Transforms/Utils/BasicBlockUtils.h>
#include <llvm/Target/TargetOptions.h> #include <llvm/Target/TargetOptions.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
#include <llvm/Target/TargetData.h> #include <llvm/Target/TargetData.h>
#else #elif defined(LLVM_3_2)
#include <llvm/DataLayout.h> #include <llvm/DataLayout.h>
#else // LLVM 3.3+
#include <llvm/IR/DataLayout.h>
#include <llvm/TargetTransformInfo.h>
#endif #endif
#include <llvm/Target/TargetMachine.h> #include <llvm/Target/TargetMachine.h>
#include <llvm/Analysis/Verifier.h> #include <llvm/Analysis/Verifier.h>
#include <llvm/Analysis/Passes.h> #include <llvm/Analysis/Passes.h>
#include <llvm/Support/raw_ostream.h> #include <llvm/Support/raw_ostream.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
#include <llvm/Analysis/DebugInfo.h> #include <llvm/Analysis/DebugInfo.h>
#else #else
#include <llvm/DebugInfo.h> #include <llvm/DebugInfo.h>
@@ -311,7 +323,6 @@ lConstElementsToMask(const llvm::SmallVector<llvm::Constant *,
*/ */
static bool static bool
lGetMask(llvm::Value *factor, uint64_t *mask) { lGetMask(llvm::Value *factor, uint64_t *mask) {
#ifndef LLVM_3_0
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(factor); llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(factor);
if (cdv != NULL) { if (cdv != NULL) {
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements; llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
@@ -320,22 +331,17 @@ lGetMask(llvm::Value *factor, uint64_t *mask) {
*mask = lConstElementsToMask(elements); *mask = lConstElementsToMask(elements);
return true; return true;
} }
#endif
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(factor); llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(factor);
if (cv != NULL) { if (cv != NULL) {
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements; llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
#ifndef LLVM_3_0
for (int i = 0; i < (int)cv->getNumOperands(); ++i) { for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
llvm::Constant *c = llvm::Constant *c =
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i)); llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
if (c == NULL) if (c == NULL)
return NULL; return false;
elements.push_back(c); elements.push_back(c);
} }
#else
cv->getVectorElements(elements);
#endif
*mask = lConstElementsToMask(elements); *mask = lConstElementsToMask(elements);
return true; return true;
} }
@@ -408,7 +414,7 @@ Optimize(llvm::Module *module, int optLevel) {
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
optPM.add(targetLibraryInfo); optPM.add(targetLibraryInfo);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
optPM.add(new llvm::TargetData(module)); optPM.add(new llvm::TargetData(module));
#else #else
llvm::TargetMachine *targetMachine = g->target.GetTargetMachine(); llvm::TargetMachine *targetMachine = g->target.GetTargetMachine();
@@ -416,8 +422,13 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(new llvm::DataLayout(*dl)); optPM.add(new llvm::DataLayout(*dl));
else else
optPM.add(new llvm::DataLayout(module)); optPM.add(new llvm::DataLayout(module));
#ifdef LLVM_3_2
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(), optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
targetMachine->getVectorTargetTransformInfo())); targetMachine->getVectorTargetTransformInfo()));
#else // LLVM 3.3+
optPM.add(llvm::createNoTTIPass(targetMachine->getScalarTargetTransformInfo(),
targetMachine->getVectorTargetTransformInfo()));
#endif
#endif #endif
optPM.add(llvm::createIndVarSimplifyPass()); optPM.add(llvm::createIndVarSimplifyPass());
@@ -933,8 +944,6 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
restart: restart:
for (llvm::BasicBlock::iterator iter = bb.begin(), e = bb.end(); iter != e; ++iter) { for (llvm::BasicBlock::iterator iter = bb.begin(), e = bb.end(); iter != e; ++iter) {
// vector select wasn't available before 3.1...
#ifndef LLVM_3_0
llvm::SelectInst *selectInst = llvm::dyn_cast<llvm::SelectInst>(&*iter); llvm::SelectInst *selectInst = llvm::dyn_cast<llvm::SelectInst>(&*iter);
if (selectInst != NULL && selectInst->getType()->isVectorTy()) { if (selectInst != NULL && selectInst->getType()->isVectorTy()) {
llvm::Value *factor = selectInst->getOperand(0); llvm::Value *factor = selectInst->getOperand(0);
@@ -955,7 +964,6 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
goto restart; goto restart;
} }
} }
#endif // !LLVM_3_0
llvm::CallInst *callInst = llvm::dyn_cast<llvm::CallInst>(&*iter); llvm::CallInst *callInst = llvm::dyn_cast<llvm::CallInst>(&*iter);
if (callInst == NULL) if (callInst == NULL)
@@ -1168,7 +1176,6 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
// Indexing into global arrays can lead to this form, with // Indexing into global arrays can lead to this form, with
// ConstantVectors.. // ConstantVectors..
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements; llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
#ifndef LLVM_3_0
for (int i = 0; i < (int)cv->getNumOperands(); ++i) { for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
llvm::Constant *c = llvm::Constant *c =
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i)); llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
@@ -1176,9 +1183,6 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
return NULL; return NULL;
elements.push_back(c); elements.push_back(c);
} }
#else
cv->getVectorElements(elements);
#endif
llvm::Constant *delta[ISPC_MAX_NVEC]; llvm::Constant *delta[ISPC_MAX_NVEC];
for (unsigned int i = 0; i < elements.size(); ++i) { for (unsigned int i = 0; i < elements.size(); ++i) {
@@ -1263,9 +1267,7 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset,
llvm::Value **variableOffset, llvm::Value **variableOffset,
llvm::Instruction *insertBefore) { llvm::Instruction *insertBefore) {
if (llvm::isa<llvm::ConstantVector>(vec) || if (llvm::isa<llvm::ConstantVector>(vec) ||
#ifndef LLVM_3_0
llvm::isa<llvm::ConstantDataVector>(vec) || llvm::isa<llvm::ConstantDataVector>(vec) ||
#endif
llvm::isa<llvm::ConstantAggregateZero>(vec)) { llvm::isa<llvm::ConstantAggregateZero>(vec)) {
*constOffset = vec; *constOffset = vec;
*variableOffset = NULL; *variableOffset = NULL;
@@ -1388,12 +1390,8 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset,
*splat, if so). */ *splat, if so). */
static bool static bool
lIsIntegerSplat(llvm::Value *v, int *splat) { lIsIntegerSplat(llvm::Value *v, int *splat) {
#ifdef LLVM_3_0
llvm::ConstantVector *cvec = llvm::dyn_cast<llvm::ConstantVector>(v);
#else
llvm::ConstantDataVector *cvec = llvm::ConstantDataVector *cvec =
llvm::dyn_cast<llvm::ConstantDataVector>(v); llvm::dyn_cast<llvm::ConstantDataVector>(v);
#endif
if (cvec == NULL) if (cvec == NULL)
return false; return false;
@@ -1528,9 +1526,7 @@ lExtractUniforms(llvm::Value **vec, llvm::Instruction *insertBefore) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (llvm::isa<llvm::ConstantVector>(*vec) || if (llvm::isa<llvm::ConstantVector>(*vec) ||
#ifndef LLVM_3_0
llvm::isa<llvm::ConstantDataVector>(*vec) || llvm::isa<llvm::ConstantDataVector>(*vec) ||
#endif
llvm::isa<llvm::ConstantAggregateZero>(*vec)) llvm::isa<llvm::ConstantAggregateZero>(*vec))
return NULL; return NULL;

View File

@@ -83,7 +83,11 @@ struct ForeachDimension;
#include "util.h" #include "util.h"
#include <stdio.h> #include <stdio.h>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Constants.h> #include <llvm/Constants.h>
#else
#include <llvm/IR/Constants.h>
#endif
#define UNIMPLEMENTED \ #define UNIMPLEMENTED \
Error(yylloc, "Unimplemented parser functionality %s:%d", \ Error(yylloc, "Unimplemented parser functionality %s:%d", \

View File

@@ -48,14 +48,25 @@
#include <stdio.h> #include <stdio.h>
#include <map> #include <map>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Function.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/Instructions.h>
#include <llvm/Function.h>
#include <llvm/DerivedTypes.h> #include <llvm/DerivedTypes.h>
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Metadata.h> #include <llvm/Metadata.h>
#include <llvm/Instructions.h>
#include <llvm/CallingConv.h> #include <llvm/CallingConv.h>
#else
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Metadata.h>
#include <llvm/IR/CallingConv.h>
#endif
#include <llvm/Support/raw_ostream.h> #include <llvm/Support/raw_ostream.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -2304,14 +2315,14 @@ ForeachUniqueStmt::TypeCheck() {
Error(expr->pos, "Iteration domain type in \"foreach_tiled\" loop " Error(expr->pos, "Iteration domain type in \"foreach_tiled\" loop "
"must be \"varying\" type, not \"%s\".", "must be \"varying\" type, not \"%s\".",
type->GetString().c_str()); type->GetString().c_str());
return false; return NULL;
} }
if (Type::IsBasicType(type) == false) { if (Type::IsBasicType(type) == false) {
Error(expr->pos, "Iteration domain type in \"foreach_tiled\" loop " Error(expr->pos, "Iteration domain type in \"foreach_tiled\" loop "
"must be an atomic, pointer, or enum type, not \"%s\".", "must be an atomic, pointer, or enum type, not \"%s\".",
type->GetString().c_str()); type->GetString().c_str());
return false; return NULL;
} }
return this; return this;

View File

@@ -43,9 +43,14 @@
#include <stdio.h> #include <stdio.h>
#include <map> #include <map>
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Value.h> #include <llvm/Value.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) #else
#include <llvm/IR/Value.h>
#include <llvm/IR/Module.h>
#endif
#if defined(LLVM_3_1)
#include <llvm/Analysis/DebugInfo.h> #include <llvm/Analysis/DebugInfo.h>
#include <llvm/Analysis/DIBuilder.h> #include <llvm/Analysis/DIBuilder.h>
#else #else
@@ -815,7 +820,7 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
32 /* size in bits */, 32 /* size in bits */,
32 /* align in bits */, 32 /* align in bits */,
elementArray elementArray
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) #if !defined(LLVM_3_1)
, llvm::DIType() , llvm::DIType()
#endif #endif
); );
@@ -2621,7 +2626,7 @@ ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
} }
llvm::DIType diTargetType = targetType->GetDIType(scope); llvm::DIType diTargetType = targetType->GetDIType(scope);
#if defined(LLVM_3_0) || defined(LLVM_3_1) #if defined(LLVM_3_1)
return m->diBuilder->createReferenceType(diTargetType); return m->diBuilder->createReferenceType(diTargetType);
#else #else
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type, return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,

5
type.h
View File

@@ -40,8 +40,13 @@
#include "ispc.h" #include "ispc.h"
#include "util.h" #include "util.h"
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h> #include <llvm/DerivedTypes.h>
#else
#include <llvm/IR/Type.h>
#include <llvm/IR/DerivedTypes.h>
#endif
#include <llvm/ADT/SmallVector.h> #include <llvm/ADT/SmallVector.h>
class ConstExpr; class ConstExpr;