Remove support for building with LLVM 3.0

This commit is contained in:
Matt Pharr
2013-01-06 12:27:53 -08:00
parent 81dbd504aa
commit 0bf1320a32
17 changed files with 74 additions and 280 deletions

View File

@@ -50,7 +50,7 @@
#if defined(LLVM_3_2)
#include <llvm/Attributes.h>
#endif
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Type.h>

View File

@@ -29,7 +29,7 @@
#include "llvmutil.h"
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/CallingConv.h"
@@ -50,7 +50,7 @@
#endif
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#if !defined(LLVM_3_0) && !defined(LLVM_3_1)
#if !defined(LLVM_3_1)
#include "llvm/TypeFinder.h"
#endif // LLVM_3_2 +
#include "llvm/ADT/StringExtras.h"
@@ -72,7 +72,7 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.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"
#elif defined(LLVM_3_2)
#include "llvm/DataLayout.h"
@@ -248,7 +248,7 @@ namespace {
const llvm::MCRegisterInfo *MRI;
const llvm::MCObjectFileInfo *MOFI;
llvm::MCContext *TCtx;
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
const llvm::TargetData* TD;
#else
// FIXME: it's ugly to have the name be "TD" here, but it saves us
@@ -258,10 +258,8 @@ namespace {
#endif
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
#ifndef LLVM_3_0
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
unsigned VectorConstantIndex;
#endif // !LLVM_3_0
std::set<llvm::Function*> intrinsicPrototypesAlreadyGenerated;
std::set<const llvm::Argument*> ByValParams;
unsigned FPCounter;
@@ -288,9 +286,7 @@ namespace {
vectorWidth(vecwidth) {
initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry());
FPCounter = 0;
#ifndef LLVM_3_0
VectorConstantIndex = 0;
#endif // !LLVM_3_0
}
virtual const char *getPassName() const { return "C backend"; }
@@ -334,9 +330,7 @@ namespace {
delete MRI;
delete MOFI;
FPConstantMap.clear();
#ifndef LLVM_3_0
VectorConstantMap.clear();
#endif // !LLVM_3_0
ByValParams.clear();
intrinsicPrototypesAlreadyGenerated.clear();
UnnamedStructIDs.clear();
@@ -348,7 +342,7 @@ namespace {
bool isSigned = false,
const std::string &VariableName = "",
bool IgnoreName = false,
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
#else
const llvm::AttributeSet &PAL = llvm::AttributeSet()
@@ -359,7 +353,7 @@ namespace {
const std::string &NameSoFar = "");
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL,
#else
const llvm::AttributeSet &PAL,
@@ -417,9 +411,7 @@ namespace {
bool printConstExprCast(const llvm::ConstantExpr *CE, bool Static);
void printConstantArray(llvm::ConstantArray *CPA, bool Static);
void printConstantVector(llvm::ConstantVector *CV, bool Static);
#ifndef LLVM_3_0
void printConstantDataSequential(llvm::ConstantDataSequential *CDS, bool Static);
#endif
/// 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.
@@ -494,11 +486,6 @@ namespace {
void visitInvokeInst(llvm::InvokeInst &I) {
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) {
llvm_unreachable("DwarfEHPrepare pass didn't work!");
}
@@ -589,7 +576,7 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) {
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
/// print it as "Struct (*)(...)", for struct return functions.
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL,
#else
const llvm::AttributeSet &PAL,
@@ -608,7 +595,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
if (PrintedType)
FunctionInnards << ", ";
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)) {
#elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
@@ -619,7 +606,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
}
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
@@ -638,7 +625,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
}
FunctionInnards << ')';
printType(Out, RetTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
@@ -740,7 +727,7 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned,
llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
bool isSigned, const std::string &NameSoFar,
bool IgnoreName,
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL
#else
const llvm::AttributeSet &PAL
@@ -762,7 +749,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
for (llvm::FunctionType::param_iterator I = FTy->param_begin(),
E = FTy->param_end(); I != E; ++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)) {
#elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
@@ -775,7 +762,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
if (I != FTy->param_begin())
FunctionInnards << ", ";
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
@@ -794,7 +781,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
}
FunctionInnards << ')';
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),
#elif defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
@@ -909,61 +896,6 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
}
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);
for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) {
Out << ", ";
@@ -979,7 +911,6 @@ void CWriter::printConstantVector(llvm::ConstantVector *CP, bool Static) {
}
}
#ifndef LLVM_3_0
void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS,
bool Static) {
// As a special case, print the array as a string if it is an array of
@@ -1036,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) {
std::string Buf;
if (&V.getSemantics() == &llvm::APFloat::IEEEdouble) {
@@ -1050,7 +979,6 @@ static inline std::string ftostr(const llvm::APFloat& V) {
}
return "<unknown format in ftostr>"; // error
}
#endif // !LLVM_3_0
// 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
@@ -1554,11 +1482,9 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
}
if (llvm::ConstantArray *CA = llvm::dyn_cast<llvm::ConstantArray>(CPV)) {
printConstantArray(CA, Static);
#ifndef LLVM_3_0
} else if (llvm::ConstantDataSequential *CDS =
llvm::dyn_cast<llvm::ConstantDataSequential>(CPV)) {
printConstantDataSequential(CDS, Static);
#endif // !LLVM_3_0
} else {
assert(llvm::isa<llvm::ConstantAggregateZero>(CPV) || llvm::isa<llvm::UndefValue>(CPV));
if (AT->getNumElements()) {
@@ -1613,8 +1539,6 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
Out << ")";
}
}
#ifndef LLVM_3_0
// LLVM 3.1 and beyond have a different representation of constant vectors..
else if (llvm::ConstantDataVector *CDV =
llvm::dyn_cast<llvm::ConstantDataVector>(CPV)) {
llvm::Constant *splatValue = CDV->getSplatValue();
@@ -1646,7 +1570,6 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
Out << ")";
}
}
#endif // !LLVM_3_0
else {
llvm::report_fatal_error("Unexpected vector type");
}
@@ -2039,7 +1962,7 @@ void CWriter::writeOperandWithCast(llvm::Value* Operand, const llvm::ICmpInst &C
// directives to cater to specific compilers as need be.
//
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) {
#else
const llvm::DataLayout *TD) {
@@ -2229,7 +2152,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
// Initialize
TheModule = &M;
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
TD = new llvm::TargetData(&M);
#else
TD = new llvm::DataLayout(&M);
@@ -2662,12 +2585,6 @@ void CWriter::printFloatingPointConstants(const llvm::Constant *C) {
// loads to get their values, rather than tediously inserting the
// individual values into the vector.
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);
I != E; ++I) {
const llvm::ConstantDataVector *CDV = llvm::dyn_cast<llvm::ConstantDataVector>(*I);
@@ -2695,7 +2612,6 @@ void CWriter::printVectorConstants(llvm::Function &F) {
VectorConstantMap[CDV] = VectorConstantIndex++;
}
Out << "\n";
#endif // !LLVM_3_0
}
/// printSymbolTable - Run through symbol table looking for type names. If a
@@ -2712,7 +2628,7 @@ void CWriter::printModuleTypes() {
// Get all of the struct types used in the module.
std::vector<llvm::StructType*> StructTypes;
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
TheModule->findUsedStructTypes(StructTypes);
#else
llvm::TypeFinder typeFinder;
@@ -2841,7 +2757,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
// Loop over the arguments, printing them...
llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType());
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = F->getAttributes();
#else
const llvm::AttributeSet &PAL = F->getAttributes();
@@ -2875,7 +2791,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
else
ArgName = "";
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)) {
#elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
@@ -2886,7 +2802,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
ByValParams.insert(I);
}
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
@@ -2914,7 +2830,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
for (; I != E; ++I) {
if (PrintedArg) FunctionInnards << ", ";
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)) {
#elif defined(LLVM_3_2)
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
@@ -2925,7 +2841,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
}
printType(FunctionInnards, ArgTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
#elif defined(LLVM_3_2)
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
@@ -2964,7 +2880,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
// Print out the return type and the signature built above.
printType(Out, RetTy,
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
#elif defined(LLVM_3_2)
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
@@ -3145,17 +3061,9 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) {
printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
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::BasicBlock* Succ = i.getCaseSuccessor();
#endif // !LLVM_3_0
Out << " case ";
writeOperand(CaseVal);
Out << ":\n";
@@ -3776,7 +3684,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
const char *BuiltinName = "";
#define GET_GCC_BUILTIN_NAME
#define Intrinsic llvm::Intrinsic
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include "llvm/Intrinsics.gen"
#else
#include "llvm/IR/Intrinsics.gen"
@@ -3841,7 +3749,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
// If this is a call to a struct-return function, assign to the first
// parameter instead of passing it to the call.
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
const llvm::AttrListPtr &PAL = I.getAttributes();
#else
const llvm::AttributeSet &PAL = I.getAttributes();
@@ -3922,7 +3830,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
(*AI)->getType() != FTy->getParamType(ArgNo)) {
Out << '(';
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)
#elif defined(LLVM_3_2)
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
@@ -3958,12 +3866,9 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID,
// If this is an intrinsic that directly corresponds to a GCC
// builtin, we emit it here.
const char *BuiltinName = "";
#ifdef LLVM_3_0
llvm::Function *F = I.getCalledFunction();
#endif // LLVM_3_0
#define GET_GCC_BUILTIN_NAME
#define Intrinsic llvm::Intrinsic
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include "llvm/Intrinsics.gen"
#else
#include "llvm/IR/Intrinsics.gen"
@@ -4548,7 +4453,7 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
matchType, NULL);
smearFunc = llvm::dyn_cast<llvm::Function>(sf);
assert(smearFunc != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
smearFunc->setDoesNotThrow(true);
smearFunc->setDoesNotAccessMemory(true);
#else
@@ -4699,7 +4604,7 @@ AndCmpCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
LLVMTypes::MaskType, NULL);
andCmpFunc = llvm::dyn_cast<llvm::Function>(acf);
Assert(andCmpFunc != NULL);
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
andCmpFunc->setDoesNotThrow(true);
andCmpFunc->setDoesNotAccessMemory(true);
#else
@@ -4807,14 +4712,12 @@ lIsAllTrue(llvm::Value *v) {
ci->isOne());
}
#ifndef LLVM_3_0
if (llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v)) {
llvm::ConstantInt *ci;
return (cdv->getSplatValue() != NULL &&
(ci = llvm::dyn_cast<llvm::ConstantInt>(cdv->getSplatValue())) != NULL &&
ci->isOne());
}
#endif
return false;
}

12
ctx.cpp
View File

@@ -46,7 +46,7 @@
#include "sym.h"
#include <map>
#include <llvm/Support/Dwarf.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Metadata.h>
#include <llvm/Module.h>
#include <llvm/Instructions.h>
@@ -358,9 +358,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
mangledName, diFile,
firstLine, diSubprogramType,
isStatic, true, /* is defn */
#ifndef LLVM_3_0
firstLine,
#endif // !LLVM_3_0
flags,
isOptimized, llvmFunction);
AssertPos(currentPos, diSubprogram.Verify());
@@ -1384,11 +1382,7 @@ FunctionEmitContext::MasksAllEqual(llvm::Value *v1, llvm::Value *v2) {
llvm::Value *
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);
#endif
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage;
llvm::Value *lstrPtr = new llvm::GlobalVariable(*m->module, lstr->getType(),
true /*isConst*/,
@@ -1438,11 +1432,7 @@ FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) {
static llvm::Value *
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);
#endif
llvm::Value *sPtr = new llvm::GlobalVariable(*m->module, sConstant->getType(),
true /* const */,
llvm::GlobalValue::InternalLinkage,

4
ctx.h
View File

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

View File

@@ -56,7 +56,7 @@
#include <list>
#include <set>
#include <stdio.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Module.h>
#include <llvm/Type.h>
#include <llvm/Instructions.h>

View File

@@ -46,7 +46,7 @@
#include "util.h"
#include <stdio.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Type.h>
@@ -310,7 +310,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// isn't worth the code bloat / overhead.
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)
#elif defined(LLVM_3_2)
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
@@ -453,7 +453,7 @@ Function::GenerateIR() {
functionName += std::string("_") + g->target.GetISAString();
llvm::Function *appFunction =
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);
#else
appFunction->setDoesNotThrow();

View File

@@ -48,7 +48,7 @@
#include <sys/types.h>
#include <unistd.h>
#endif
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Instructions.h>
@@ -57,7 +57,7 @@
#include <llvm/IR/Module.h>
#include <llvm/IR/Instructions.h>
#endif
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
#include <llvm/Analysis/DebugInfo.h>
#include <llvm/Analysis/DIBuilder.h>
#else
@@ -67,7 +67,7 @@
#include <llvm/Support/Dwarf.h>
#include <llvm/Target/TargetMachine.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>
#elif defined(LLVM_3_2)
#include <llvm/DataLayout.h>
@@ -348,13 +348,10 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
t->maskingIsFree = false;
t->maskBitCount = 32;
#if !defined(LLVM_3_0)
// LLVM 3.1+ only
t->hasHalf = true;
#if !defined(LLVM_3_1)
#if !defined(LLVM_3_1)
// LLVM 3.2+ only
t->hasRand = true;
#endif
#endif
}
else if (!strcasecmp(isa, "avx1.1-x2")) {
@@ -364,16 +361,12 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
t->maskingIsFree = false;
t->maskBitCount = 32;
#if !defined(LLVM_3_0)
// LLVM 3.1+ only
t->hasHalf = true;
#if !defined(LLVM_3_1)
#if !defined(LLVM_3_1)
// LLVM 3.2+ only
t->hasRand = true;
#endif
#endif
}
#ifndef LLVM_3_0
else if (!strcasecmp(isa, "avx2")) {
t->isa = Target::AVX2;
t->nativeVectorWidth = 8;
@@ -410,7 +403,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->hasGather = true;
#endif
}
#endif // !LLVM_3_0
else {
fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n",
isa, SupportedTargetISAs());
@@ -419,7 +411,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
if (!error) {
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();
t->is32Bit = (targetData->getPointerSize() == 4);
#else
@@ -456,9 +448,7 @@ Target::SupportedTargetArchs() {
const char *
Target::SupportedTargetISAs() {
return "sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2"
#ifndef LLVM_3_0
", avx1.1, avx1.1-x2, avx2, avx2-x2"
#endif // !LLVM_3_0
", generic-1, generic-4, generic-8, generic-16, generic-32";
}
@@ -467,11 +457,7 @@ std::string
Target::GetTripleString() const {
llvm::Triple triple;
// Start with the host triple as the default
#ifdef LLVM_3_0
triple.setTriple(llvm::sys::getHostTriple());
#else
triple.setTriple(llvm::sys::getDefaultTargetTriple());
#endif
// 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
@@ -496,11 +482,6 @@ Target::GetTargetMachine() const {
llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ :
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;
llvm::TargetOptions options;
#if !defined(LLVM_3_1)
@@ -510,7 +491,6 @@ Target::GetTargetMachine() const {
llvm::TargetMachine *targetMachine =
target->createTargetMachine(triple, cpu, featuresString, options,
relocModel);
#endif // !LLVM_3_0
Assert(targetMachine != NULL);
targetMachine->setAsmVerbosityDefault(true);
@@ -595,7 +575,7 @@ Target::SizeOf(llvm::Type *type,
"sizeof_int", insertAtEnd);
}
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
const llvm::TargetData *td = GetTargetMachine()->getTargetData();
Assert(td != NULL);
uint64_t bitSize = td->getTypeSizeInBits(type);
@@ -642,7 +622,7 @@ Target::StructOffset(llvm::Type *type, int element,
return NULL;
}
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
const llvm::TargetData *td = GetTargetMachine()->getTargetData();
Assert(td != NULL);
const llvm::StructLayout *sl = td->getStructLayout(structType);

4
ispc.h
View File

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

View File

@@ -38,7 +38,7 @@
#include "llvmutil.h"
#include "ispc.h"
#include "type.h"
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Instructions.h>
#include <llvm/BasicBlock.h>
#else
@@ -660,9 +660,6 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) {
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);
if (cv == NULL)
return false;
@@ -670,20 +667,6 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) {
for (int i = 0; i < (int)cv->getNumElements(); ++i)
ret[i] = cv->getElementAsInteger(i);
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
}
@@ -952,11 +935,9 @@ lVectorValuesAllEqual(llvm::Value *v, int vectorLength,
if (cv != NULL)
return (cv->getSplatValue() != NULL);
#ifndef LLVM_3_0
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
if (cdv != NULL)
return (cdv->getSplatValue() != NULL);
#endif
llvm::BinaryOperator *bop = llvm::dyn_cast<llvm::BinaryOperator>(v);
if (bop != NULL) {
@@ -1106,22 +1087,13 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride,
elements.
*/
static bool
lVectorIsLinearConstantInts(
#ifndef LLVM_3_0
llvm::ConstantDataVector *cv,
#else
llvm::ConstantVector *cv,
#endif
lVectorIsLinearConstantInts(llvm::ConstantDataVector *cv,
int vectorLength,
int stride) {
// Flatten the vector out into the elements array
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
#ifndef LLVM_3_0
for (int i = 0; i < (int)cv->getNumElements(); ++i)
elements.push_back(cv->getElementAsConstant(i));
#else
cv->getVectorElements(elements);
#endif
Assert((int)elements.size() == vectorLength);
llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[0]);
@@ -1157,11 +1129,7 @@ lCheckMulForLinear(llvm::Value *op0, llvm::Value *op1, int vectorLength,
int stride, std::vector<llvm::PHINode *> &seenPhis) {
// Is the first operand a constant integer value splatted across all of
// the lanes?
#ifndef LLVM_3_0
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(op0);
#else
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(op0);
#endif
if (cv == NULL)
return false;
@@ -1231,11 +1199,7 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride,
std::vector<llvm::PHINode *> &seenPhis) {
// First try the easy case: if the values are all just constant
// 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);
#else
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v);
#endif
if (cv != NULL)
return lVectorIsLinearConstantInts(cv, vectorLength, stride);
@@ -1407,19 +1371,11 @@ lExtractFirstVectorElement(llvm::Value *v,
return llvm::Constant::getNullValue(vt->getElementType());
}
if (llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v)) {
#ifndef LLVM_3_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 =
llvm::dyn_cast<llvm::ConstantDataVector>(v))
return cdv->getElementAsConstant(0);
#endif // !LLVM_3_0
// Otherwise, all that we should have at this point is an instruction
// of some sort

View File

@@ -38,7 +38,7 @@
#ifndef ISPC_LLVMUTIL_H
#define ISPC_LLVMUTIL_H 1
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Type.h>
#include <llvm/DerivedTypes.h>

View File

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

View File

@@ -64,7 +64,7 @@
#define strcasecmp stricmp
#endif
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#include <llvm/Type.h>
@@ -86,7 +86,7 @@
#include <llvm/Support/FileUtilities.h>
#include <llvm/Target/TargetMachine.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>
#else
#if defined(LLVM_3_2)
@@ -149,7 +149,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
if (g->generateDebuggingSymbols == false)
return;
#ifndef LLVM_3_0
// loop over the compile units that contributed to the final module
if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) {
@@ -228,7 +227,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
}
for (int i = 0; i < (int)toErase.size(); ++i)
module->eraseNamedMetadata(toErase[i]);
#endif // !LLVM_3_0
// Wrap up by running the LLVM pass to remove anything left that's
// unused.
@@ -780,7 +778,7 @@ Module::AddFunctionDeclaration(const std::string &name,
#endif
if (functionType->isTask)
// 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);
#else
function->setDoesNotAlias(1);
@@ -826,7 +824,7 @@ Module::AddFunctionDeclaration(const std::string &name,
// NOTE: LLVM indexes function parameters starting from 1.
// This is unintuitive.
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
function->setDoesNotAlias(i+1, true);
#else
function->setDoesNotAlias(i+1);
@@ -1053,7 +1051,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
}
llvm::PassManager pm;
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
if (const llvm::TargetData *td = targetMachine->getTargetData())
pm.add(new llvm::TargetData(*td));
else
@@ -1067,13 +1065,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
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)) {
#endif
fprintf(stderr, "Fatal error adding passes to emit object file!");
exit(1);
}
@@ -1783,7 +1775,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
llvm::raw_fd_ostream stderrRaw(2, false);
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
#else
@@ -1792,7 +1784,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
#endif
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 =
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
#else
@@ -1804,15 +1796,11 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
clang::TargetOptions &options = inst.getTargetOpts();
llvm::Triple triple(module->getTargetTriple());
if (triple.getTriple().empty()) {
#ifdef LLVM_3_0
triple.setTriple(llvm::sys::getHostTriple());
#else
triple.setTriple(llvm::sys::getDefaultTargetTriple());
#endif
}
options.Triple = triple.getTriple();
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
#else // LLVM 3.3+
@@ -1822,7 +1810,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
inst.setTarget(target);
inst.createSourceManager(inst.getFileManager());
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
inst.InitializeSourceManager(infilename);
#else
clang::FrontendInputFile inputFile(infilename, clang::IK_None);

29
opt.cpp
View File

@@ -48,7 +48,7 @@
#include <set>
#include <llvm/Pass.h>
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Module.h>
#include <llvm/Instructions.h>
#include <llvm/Intrinsics.h>
@@ -73,7 +73,7 @@
#include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.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>
#elif defined(LLVM_3_2)
#include <llvm/DataLayout.h>
@@ -85,7 +85,7 @@
#include <llvm/Analysis/Verifier.h>
#include <llvm/Analysis/Passes.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>
#else
#include <llvm/DebugInfo.h>
@@ -323,7 +323,6 @@ lConstElementsToMask(const llvm::SmallVector<llvm::Constant *,
*/
static bool
lGetMask(llvm::Value *factor, uint64_t *mask) {
#ifndef LLVM_3_0
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(factor);
if (cdv != NULL) {
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
@@ -332,12 +331,10 @@ lGetMask(llvm::Value *factor, uint64_t *mask) {
*mask = lConstElementsToMask(elements);
return true;
}
#endif
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(factor);
if (cv != NULL) {
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
#ifndef LLVM_3_0
for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
llvm::Constant *c =
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
@@ -345,9 +342,6 @@ lGetMask(llvm::Value *factor, uint64_t *mask) {
return false;
elements.push_back(c);
}
#else
cv->getVectorElements(elements);
#endif
*mask = lConstElementsToMask(elements);
return true;
}
@@ -420,7 +414,7 @@ Optimize(llvm::Module *module, int optLevel) {
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
optPM.add(targetLibraryInfo);
#if defined(LLVM_3_0) || defined(LLVM_3_1)
#if defined(LLVM_3_1)
optPM.add(new llvm::TargetData(module));
#else
llvm::TargetMachine *targetMachine = g->target.GetTargetMachine();
@@ -950,8 +944,6 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
restart:
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);
if (selectInst != NULL && selectInst->getType()->isVectorTy()) {
llvm::Value *factor = selectInst->getOperand(0);
@@ -972,7 +964,6 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
goto restart;
}
}
#endif // !LLVM_3_0
llvm::CallInst *callInst = llvm::dyn_cast<llvm::CallInst>(&*iter);
if (callInst == NULL)
@@ -1185,7 +1176,6 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
// Indexing into global arrays can lead to this form, with
// ConstantVectors..
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
#ifndef LLVM_3_0
for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
llvm::Constant *c =
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
@@ -1193,9 +1183,6 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
return NULL;
elements.push_back(c);
}
#else
cv->getVectorElements(elements);
#endif
llvm::Constant *delta[ISPC_MAX_NVEC];
for (unsigned int i = 0; i < elements.size(); ++i) {
@@ -1280,9 +1267,7 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset,
llvm::Value **variableOffset,
llvm::Instruction *insertBefore) {
if (llvm::isa<llvm::ConstantVector>(vec) ||
#ifndef LLVM_3_0
llvm::isa<llvm::ConstantDataVector>(vec) ||
#endif
llvm::isa<llvm::ConstantAggregateZero>(vec)) {
*constOffset = vec;
*variableOffset = NULL;
@@ -1405,12 +1390,8 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset,
*splat, if so). */
static bool
lIsIntegerSplat(llvm::Value *v, int *splat) {
#ifdef LLVM_3_0
llvm::ConstantVector *cvec = llvm::dyn_cast<llvm::ConstantVector>(v);
#else
llvm::ConstantDataVector *cvec =
llvm::dyn_cast<llvm::ConstantDataVector>(v);
#endif
if (cvec == NULL)
return false;
@@ -1545,9 +1526,7 @@ lExtractUniforms(llvm::Value **vec, llvm::Instruction *insertBefore) {
fprintf(stderr, "\n");
if (llvm::isa<llvm::ConstantVector>(*vec) ||
#ifndef LLVM_3_0
llvm::isa<llvm::ConstantDataVector>(*vec) ||
#endif
llvm::isa<llvm::ConstantAggregateZero>(*vec))
return NULL;

View File

@@ -83,10 +83,10 @@ struct ForeachDimension;
#include "util.h"
#include <stdio.h>
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2)
#include <llvm/IR/Constants.h>
#else
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Constants.h>
#else
#include <llvm/IR/Constants.h>
#endif
#define UNIMPLEMENTED \

View File

@@ -48,7 +48,7 @@
#include <stdio.h>
#include <map>
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Module.h>
#include <llvm/Type.h>
#include <llvm/Instructions.h>

View File

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

2
type.h
View File

@@ -40,7 +40,7 @@
#include "ispc.h"
#include "util.h"
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
#if defined(LLVM_3_1) || defined(LLVM_3_2)
#include <llvm/Type.h>
#include <llvm/DerivedTypes.h>
#else