Remove support for building with LLVM 2.9.

A forthcoming change uses some features of LLVM 3.0's new type
system, and it's not worth back-porting this to also all work
with LLVM 2.9.
This commit is contained in:
Matt Pharr
2012-04-15 20:08:51 -07:00
parent 17b7148300
commit 098c4910de
12 changed files with 9 additions and 228 deletions

View File

@@ -620,9 +620,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
std::string(linkError);
if (llvm::Linker::LinkModules(module, bcModule,
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Linker::DestroySource,
#endif // LLVM_3_0
&linkError))
Error(SourcePos(), "Error linking stdlib bitcode: %s", linkError.c_str());
lSetInternalFunctions(module);

View File

@@ -12,10 +12,6 @@
//
//===----------------------------------------------------------------------===//
#ifdef LLVM_2_9
#warning "The C++ backend isn't supported when building with LLVM 2.9"
#else
#include <stdio.h>
#ifndef _MSC_VER
@@ -4462,5 +4458,3 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth,
return true;
}
#endif // LLVM_2_9

34
ctx.cpp
View File

@@ -1359,13 +1359,8 @@ lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
llvm::GlobalValue::InternalLinkage,
sConstant, s);
llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock);
#else
return llvm::GetElementPtrInst::Create(sPtr, &indices[0], &indices[2],
"sptr", bblock);
#endif
}
@@ -2067,16 +2062,10 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
// The easy case: both the base pointer and the indices are
// uniform, so just emit the regular LLVM GEP instruction
llvm::Value *ind[1] = { index };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&ind[0], &ind[1]);
llvm::Instruction *inst =
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
name ? name : "gep", bblock);
#else
llvm::Instruction *inst =
llvm::GetElementPtrInst::Create(basePtr, &ind[0], &ind[1],
name ? name : "gep", bblock);
#endif
AddDebugPos(inst);
return inst;
}
@@ -2133,16 +2122,10 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
// The easy case: both the base pointer and the indices are
// uniform, so just emit the regular LLVM GEP instruction
llvm::Value *indices[2] = { index0, index1 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
llvm::Instruction *inst =
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
name ? name : "gep", bblock);
#else
llvm::Instruction *inst =
llvm::GetElementPtrInst::Create(basePtr, &indices[0], &indices[2],
name ? name : "gep", bblock);
#endif
AddDebugPos(inst);
return inst;
}
@@ -2222,16 +2205,10 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
if (ptrType == NULL || ptrType->IsUniformType()) {
// If the pointer is uniform, we can use the regular LLVM GEP.
llvm::Value *offsets[2] = { LLVMInt32(0), LLVMInt32(elementNum) };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&offsets[0], &offsets[2]);
resultPtr =
llvm::GetElementPtrInst::Create(basePtr, arrayRef,
name ? name : "struct_offset", bblock);
#else
resultPtr =
llvm::GetElementPtrInst::Create(basePtr, &offsets[0], &offsets[2],
name ? name : "struct_offset", bblock);
#endif
}
else {
// Otherwise do the math to find the offset and add it to the given
@@ -3014,10 +2991,7 @@ FunctionEmitContext::InsertInst(llvm::Value *v, llvm::Value *eltVal, int elt,
llvm::PHINode *
FunctionEmitContext::PhiNode(LLVM_TYPE_CONST llvm::Type *type, int count,
const char *name) {
llvm::PHINode *pn = llvm::PHINode::Create(type,
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
count,
#endif // LLVM_3_0
llvm::PHINode *pn = llvm::PHINode::Create(type, count,
name ? name : "phi", bblock);
AddDebugPos(pn);
return pn;
@@ -3086,14 +3060,8 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
if (llvm::isa<LLVM_TYPE_CONST llvm::VectorType>(func->getType()) == false) {
// Regular 'uniform' function call--just one function or function
// pointer, so just emit the IR directly.
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Instruction *ci =
llvm::CallInst::Create(func, argVals, name ? name : "", bblock);
#else
llvm::Instruction *ci =
llvm::CallInst::Create(func, argVals.begin(), argVals.end(),
name ? name : "", bblock);
#endif
AddDebugPos(ci);
return ci;
}

View File

@@ -3701,14 +3701,10 @@ ExprList::GetConstant(const Type *type) const {
}
if (dynamic_cast<const StructType *>(type) != NULL) {
#if defined(LLVM_2_9)
return llvm::ConstantStruct::get(*g->ctx, cv, false);
#else
LLVM_TYPE_CONST llvm::StructType *llvmStructType =
llvm::dyn_cast<LLVM_TYPE_CONST llvm::StructType>(collectionType->LLVMType(g->ctx));
Assert(llvmStructType != NULL);
return llvm::ConstantStruct::get(llvmStructType, cv);
#endif
}
else {
LLVM_TYPE_CONST llvm::Type *lt = type->LLVMType(g->ctx);

4
ispc.h
View File

@@ -40,8 +40,8 @@
#define ISPC_VERSION "1.2.2dev"
#if !defined(LLVM_2_9) && !defined(LLVM_3_0) && !defined(LLVM_3_0svn) && !defined(LLVM_3_1svn)
#error "Only LLVM 2.9, 3.0, and the 3.1 development branch are supported"
#if !defined(LLVM_3_0) && !defined(LLVM_3_0svn) && !defined(LLVM_3_1svn)
#error "Only LLVM 3.0, and the 3.1 development branch are supported"
#endif
#if defined(_WIN32) || defined(_WIN64)

View File

@@ -1443,11 +1443,8 @@ lExtractFirstVectorElement(llvm::Value *v, llvm::Instruction *insertBefore,
llvm::Instruction *phiInsertPos = phi->getParent()->begin();
llvm::PHINode *scalarPhi =
llvm::PHINode::Create(vt->getElementType(),
#ifndef LLVM_2_9
phi->getNumIncomingValues(),
#endif // !LLVM_2_9
newName,
phiInsertPos);
newName, phiInsertPos);
phiMap[phi] = scalarPhi;
for (unsigned i = 0; i < phi->getNumIncomingValues(); ++i) {
@@ -1521,12 +1518,8 @@ LLVMShuffleVectors(llvm::Value *v1, llvm::Value *v2, int32_t shuf[],
shufVec.push_back(LLVMInt32(shuf[i]));
}
#ifndef LLVM_2_9
llvm::ArrayRef<llvm::Constant *> aref(&shufVec[0], &shufVec[shufSize]);
llvm::Value *vec = llvm::ConstantVector::get(aref);
#else // LLVM_2_9
llvm::Value *vec = llvm::ConstantVector::get(shufVec);
#endif
return new llvm::ShuffleVectorInst(v1, v2, vec, "shuffle", insertBefore);
}

View File

@@ -49,11 +49,7 @@ namespace llvm {
}
// llvm::Type *s are no longer const in llvm 3.0
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
#define LLVM_TYPE_CONST
#else
#define LLVM_TYPE_CONST const
#endif
/** This structure holds pointers to a variety of LLVM types; code

View File

@@ -45,14 +45,8 @@
#include <time.h>
#endif // ISPC_IS_WINDOWS
#include <llvm/Support/Signals.h>
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#else
#include <llvm/Target/TargetRegistry.h>
#include <llvm/Target/TargetSelect.h>
#include <llvm/Target/SubtargetFeature.h>
#endif
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#ifdef ISPC_IS_WINDOWS
#define strcasecmp stricmp
@@ -66,9 +60,7 @@ static void
lPrintVersion() {
printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n",
ISPC_VERSION, BUILD_VERSION, BUILD_DATE,
#ifdef LLVM_2_9
"2.9"
#elif defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0)
"3.0"
#elif defined(LLVM_3_1) || defined(LLVM_3_1svn)
"3.1"
@@ -93,9 +85,7 @@ usage(int ret) {
printf(" <cpu>={%s}\n", Target::SupportedTargetCPUs().c_str());
printf(" [-D<foo>]\t\t\t\t#define given value when running preprocessor\n");
printf(" [--emit-asm]\t\t\tGenerate assembly language file as output\n");
#ifndef LLVM_2_9
printf(" [--emit-c++]\t\t\tEmit a C++ source file as output\n");
#endif // !LLVM_2_9
printf(" [--emit-llvm]\t\t\tEmit LLVM bitode file as output\n");
printf(" [--emit-obj]\t\t\tGenerate object file file as output (default)\n");
printf(" [-g]\t\t\t\tGenerate debugging information\n");
@@ -220,9 +210,7 @@ int main(int Argc, char *Argv[]) {
LLVMInitializeX86AsmPrinter();
LLVMInitializeX86AsmParser();
LLVMInitializeX86Disassembler();
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
LLVMInitializeX86TargetMC();
#endif
char *file = NULL;
const char *headerFileName = NULL;
@@ -279,10 +267,8 @@ int main(int Argc, char *Argv[]) {
}
else if (!strcmp(argv[i], "--emit-asm"))
ot = Module::Asm;
#ifndef LLVM_2_9
else if (!strcmp(argv[i], "--emit-c++"))
ot = Module::CXX;
#endif // !LLVM_2_9
else if (!strcmp(argv[i], "--emit-llvm"))
ot = Module::Bitcode;
else if (!strcmp(argv[i], "--emit-obj"))

View File

@@ -706,10 +706,8 @@ Module::AddFunctionDefinition(const std::string &name, const FunctionType *type,
bool
Module::writeOutput(OutputType outputType, const char *outFileName,
const char *includeFileName) {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
if (diBuilder != NULL && outputType != Header)
diBuilder->finalize();
#endif // LLVM_3_0
// First, issue a warning if the output file suffix and the type of
// file being created seem to mismatch. This can help catch missing
@@ -731,14 +729,12 @@ Module::writeOutput(OutputType outputType, const char *outFileName,
if (strcasecmp(suffix, "o") && strcasecmp(suffix, "obj"))
fileType = "object";
break;
#ifndef LLVM_2_9
case CXX:
if (strcasecmp(suffix, "c") && strcasecmp(suffix, "cc") &&
strcasecmp(suffix, "c++") && strcasecmp(suffix, "cxx") &&
strcasecmp(suffix, "cpp"))
fileType = "c++";
break;
#endif // !LLVM_2_9
case Header:
if (strcasecmp(suffix, "h") && strcasecmp(suffix, "hh") &&
strcasecmp(suffix, "hpp"))
@@ -754,14 +750,12 @@ Module::writeOutput(OutputType outputType, const char *outFileName,
return writeHeader(outFileName);
else if (outputType == Bitcode)
return writeBitcode(module, outFileName);
#ifndef LLVM_2_9
else if (outputType == CXX) {
extern bool WriteCXXFile(llvm::Module *module, const char *fn,
int vectorWidth, const char *includeName);
return WriteCXXFile(module, outFileName, g->target.vectorWidth,
includeFileName);
}
#endif // !LLVM_2_9
else
return writeObjectFileOrAssembly(outputType, outFileName);
}
@@ -1172,18 +1166,12 @@ 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_0svn) || defined(LLVM_3_1svn)
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
clang::DiagnosticsEngine *diagEngine =
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
inst.setDiagnostics(diagEngine);
#else
clang::TextDiagnosticPrinter *diagPrinter =
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
inst.createDiagnostics(0, NULL, diagPrinter);
#endif
clang::TargetOptions &options = inst.getTargetOpts();
llvm::Triple triple(module->getTargetTriple());
@@ -1209,9 +1197,7 @@ Module::execPreprocessor(const char* infilename, llvm::raw_string_ostream* ostre
clang::HeaderSearchOptions &headerOpts = inst.getHeaderSearchOpts();
headerOpts.UseBuiltinIncludes = 0;
#ifndef LLVM_2_9
headerOpts.UseStandardSystemIncludes = 0;
#endif // !LLVM_2_9
headerOpts.UseStandardCXXIncludes = 0;
if (g->debugPrint)
headerOpts.Verbose = 1;
@@ -1549,24 +1535,13 @@ lCreateDispatchFunction(llvm::Module *module, llvm::Function *setISAFunc,
for (; argIter != dispatchFunc->arg_end(); ++argIter)
args.push_back(argIter);
if (voidReturn) {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::CallInst::Create(targetFuncs[i], args, "", callBBlock);
#else
llvm::CallInst::Create(targetFuncs[i], args.begin(), args.end(),
"", callBBlock);
#endif
llvm::ReturnInst::Create(*g->ctx, callBBlock);
}
else {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Value *retValue =
llvm::CallInst::Create(targetFuncs[i], args, "ret_value",
callBBlock);
#else
llvm::Value *retValue =
llvm::CallInst::Create(targetFuncs[i], args.begin(), args.end(),
"ret_value", callBBlock);
#endif
llvm::ReturnInst::Create(*g->ctx, retValue, callBBlock);
}
@@ -1664,13 +1639,11 @@ Module::CompileAndOutput(const char *srcFile, const char *arch, const char *cpu,
return errorCount > 0;
}
else {
#ifndef LLVM_2_9
if (outputType == CXX) {
Error(SourcePos(), "Illegal to specify more then one target when "
"compiling C++ output.");
return 1;
}
#endif // !LLVM_2_9
// The user supplied multiple targets
std::vector<std::string> targets = lExtractTargets(target);

View File

@@ -85,9 +85,7 @@ public:
enum OutputType { Asm, /** Generate text assembly language output */
Bitcode, /** Generate LLVM IR bitcode output */
Object, /** Generate a native object file */
#ifndef LLVM_2_9
CXX, /** Generate a C++ file */
#endif // !LLVM_2_9
Header /** Generate a C/C++ header file with
declarations of 'export'ed functions, global
variables, and the types used by them. */

88
opt.cpp
View File

@@ -59,9 +59,6 @@
#include <llvm/Constants.h>
#include <llvm/Analysis/ConstantFolding.h>
#include <llvm/Target/TargetLibraryInfo.h>
#ifdef LLVM_2_9
#include <llvm/Support/StandardPasses.h>
#endif // LLVM_2_9
#include <llvm/ADT/Triple.h>
#include <llvm/Transforms/Scalar.h>
#include <llvm/Transforms/IPO.h>
@@ -188,13 +185,8 @@ static llvm::Instruction *
lCallInst(llvm::Function *func, llvm::Value *arg0, llvm::Value *arg1,
const char *name, llvm::Instruction *insertBefore = NULL) {
llvm::Value *args[2] = { arg0, arg1 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[2]);
return llvm::CallInst::Create(func, newArgArray, name, insertBefore);
#else
return llvm::CallInst::Create(func, &args[0], &args[2],
name, insertBefore);
#endif
}
@@ -203,13 +195,8 @@ lCallInst(llvm::Function *func, llvm::Value *arg0, llvm::Value *arg1,
llvm::Value *arg2, const char *name,
llvm::Instruction *insertBefore = NULL) {
llvm::Value *args[3] = { arg0, arg1, arg2 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[3]);
return llvm::CallInst::Create(func, newArgArray, name, insertBefore);
#else
return llvm::CallInst::Create(func, &args[0], &args[3],
name, insertBefore);
#endif
}
@@ -219,13 +206,8 @@ lCallInst(llvm::Function *func, llvm::Value *arg0, llvm::Value *arg1,
llvm::Value *arg2, llvm::Value *arg3, const char *name,
llvm::Instruction *insertBefore = NULL) {
llvm::Value *args[4] = { arg0, arg1, arg2, arg3 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[4]);
return llvm::CallInst::Create(func, newArgArray, name, insertBefore);
#else
return llvm::CallInst::Create(func, &args[0], &args[4],
name, insertBefore);
#endif
}
#endif
@@ -234,28 +216,19 @@ lCallInst(llvm::Function *func, llvm::Value *arg0, llvm::Value *arg1,
llvm::Value *arg2, llvm::Value *arg3, llvm::Value *arg4,
const char *name, llvm::Instruction *insertBefore = NULL) {
llvm::Value *args[5] = { arg0, arg1, arg2, arg3, arg4 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[5]);
return llvm::CallInst::Create(func, newArgArray, name, insertBefore);
#else
return llvm::CallInst::Create(func, &args[0], &args[5],
name, insertBefore);
#endif
}
static llvm::Instruction *
lCallInst(llvm::Function *func, llvm::Value *arg0, llvm::Value *arg1,
llvm::Value *arg2, llvm::Value *arg3, llvm::Value *arg4,
llvm::Value *arg5, const char *name,
llvm::Instruction *insertBefore = NULL) {
llvm::Value *args[6] = { arg0, arg1, arg2, arg3, arg4, arg5 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[6]);
return llvm::CallInst::Create(func, newArgArray, name, insertBefore);
#else
return llvm::CallInst::Create(func, &args[0], &args[6],
name, insertBefore);
#endif
}
@@ -263,14 +236,9 @@ static llvm::Instruction *
lGEPInst(llvm::Value *ptr, llvm::Value *offset, const char *name,
llvm::Instruction *insertBefore) {
llvm::Value *index[1] = { offset };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
return llvm::GetElementPtrInst::Create(ptr, arrayRef, name,
insertBefore);
#else
return llvm::GetElementPtrInst::Create(ptr, &index[0], &index[1],
name, insertBefore);
#endif
}
@@ -295,9 +263,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(new llvm::TargetData(module));
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
optPM.add(llvm::createIndVarSimplifyPass());
#endif
if (optLevel == 0) {
// This is more or less the minimum set of optimizations that we
@@ -421,32 +387,6 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(CreateIntrinsicsOptPass());
optPM.add(CreateVSelMovmskOptPass());
#if defined(LLVM_2_9)
llvm::createStandardModulePasses(&optPM, 3,
false /* opt size */,
true /* unit at a time */,
g->opt.unrollLoops,
true /* simplify lib calls */,
false /* may have exceptions */,
llvm::createFunctionInliningPass());
llvm::createStandardLTOPasses(&optPM, true /* internalize pass */,
true /* inline once again */,
false /* verify after each pass */);
llvm::createStandardFunctionPasses(&optPM, 3);
optPM.add(CreateIsCompileTimeConstantPass(true));
optPM.add(CreateIntrinsicsOptPass());
optPM.add(CreateVSelMovmskOptPass());
llvm::createStandardModulePasses(&optPM, 3,
false /* opt size */,
true /* unit at a time */,
g->opt.unrollLoops,
true /* simplify lib calls */,
false /* may have exceptions */,
llvm::createFunctionInliningPass());
#else
funcPM.add(llvm::createTypeBasedAliasAnalysisPass());
funcPM.add(llvm::createBasicAliasAnalysisPass());
funcPM.add(llvm::createCFGSimplificationPass());
@@ -542,7 +482,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createStripDeadPrototypesPass());
optPM.add(llvm::createGlobalDCEPass());
optPM.add(llvm::createConstantMergePass());
#endif
optPM.add(CreateMakeInternalFuncsStaticPass());
optPM.add(llvm::createGlobalDCEPass());
}
@@ -633,22 +573,18 @@ IntrinsicsOpt::IntrinsicsOpt()
llvm::Intrinsic::getDeclaration(m->module, llvm::Intrinsic::x86_sse_movmsk_ps);
maskInstructions.push_back(sseMovmsk);
maskInstructions.push_back(m->module->getFunction("__movmsk"));
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Function *avxMovmsk =
llvm::Intrinsic::getDeclaration(m->module, llvm::Intrinsic::x86_avx_movmsk_ps_256);
Assert(avxMovmsk != NULL);
maskInstructions.push_back(avxMovmsk);
#endif
// And all of the blend instructions
blendInstructions.push_back(BlendInstruction(
llvm::Intrinsic::getDeclaration(m->module, llvm::Intrinsic::x86_sse41_blendvps),
0xf, 0, 1, 2));
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
blendInstructions.push_back(BlendInstruction(
llvm::Intrinsic::getDeclaration(m->module, llvm::Intrinsic::x86_avx_blendv_ps_256),
0xff, 0, 1, 2));
#endif
}
@@ -746,7 +682,6 @@ lIsUndef(llvm::Value *value) {
bool
IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Function *avxMaskedLoad32 =
llvm::Intrinsic::getDeclaration(m->module, llvm::Intrinsic::x86_avx_maskload_ps_256);
llvm::Function *avxMaskedLoad64 =
@@ -757,7 +692,6 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
llvm::Intrinsic::getDeclaration(m->module, llvm::Intrinsic::x86_avx_maskstore_pd_256);
Assert(avxMaskedLoad32 != NULL && avxMaskedStore32 != NULL);
Assert(avxMaskedLoad64 != NULL && avxMaskedStore64 != NULL);
#endif
bool modifiedAny = false;
restart:
@@ -829,7 +763,6 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
goto restart;
}
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
else if (callInst->getCalledFunction() == avxMaskedLoad32 ||
callInst->getCalledFunction() == avxMaskedLoad64) {
llvm::Value *factor = callInst->getArgOperand(1);
@@ -896,7 +829,6 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
goto restart;
}
}
#endif
}
return modifiedAny;
}
@@ -1132,11 +1064,7 @@ lExtractFromInserts(llvm::Value *v, unsigned int index) {
return NULL;
Assert(iv->hasIndices() && iv->getNumIndices() == 1);
#ifdef LLVM_2_9
if (*(iv->idx_begin()) == index)
#else
if (iv->getIndices()[0] == index)
#endif
return iv->getInsertedValueOperand();
else
return lExtractFromInserts(iv->getAggregateOperand(), index);
@@ -1253,24 +1181,16 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
}
Assert(base != NULL);
#ifdef LLVM_2_9
*offsets = llvm::ConstantVector::get(delta);
#else
llvm::ArrayRef<llvm::Constant *> deltas(&delta[0],
&delta[elements.size()]);
*offsets = llvm::ConstantVector::get(deltas);
#endif
return base;
}
llvm::ExtractValueInst *ev = llvm::dyn_cast<llvm::ExtractValueInst>(ptrs);
if (ev != NULL) {
Assert(ev->getNumIndices() == 1);
#ifdef LLVM_2_9
int index = *(ev->idx_begin());
#else
int index = ev->getIndices()[0];
#endif
ptrs = lExtractFromInserts(ev->getAggregateOperand(), index);
if (ptrs != NULL)
return lGetBasePtrAndOffsets(ptrs, offsets, insertBefore);
@@ -3415,13 +3335,9 @@ lCoalesceGathers(const std::vector<llvm::CallInst *> &coalesceGroup) {
memory. */
static bool
lInstructionMayWriteToMemory(llvm::Instruction *inst) {
#ifdef LLVM_2_9
if (llvm::isa<llvm::StoreInst>(inst))
#else
if (llvm::isa<llvm::StoreInst>(inst) ||
llvm::isa<llvm::AtomicRMWInst>(inst) ||
llvm::isa<llvm::AtomicCmpXchgInst>(inst))
#endif // !LLVM_2_9
// FIXME: we could be less conservative and try to allow stores if
// we are sure that the pointers don't overlap..
return true;

View File

@@ -81,11 +81,7 @@ lCreateDIArray(llvm::DIType eltType, int count) {
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(lowerBound, upperBound);
std::vector<llvm::Value *> subs;
subs.push_back(sub);
#ifdef LLVM_2_9
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(&subs[0], subs.size());
#else
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs);
#endif
uint64_t size = eltType.getSizeInBits() * count;
uint64_t align = eltType.getAlignInBits();
@@ -518,12 +514,7 @@ AtomicType::GetDIType(llvm::DIDescriptor scope) const {
else if (variability == Variability::Varying) {
llvm::DIType unifType = GetAsUniformType()->GetDIType(scope);
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target.vectorWidth-1);
#ifdef LLVM_2_9
llvm::Value *suba[] = { sub };
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(suba, 1);
#else
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
#endif // LLVM_2_9
uint64_t size = unifType.getSizeInBits() * g->target.vectorWidth;
uint64_t align = unifType.getAlignInBits() * g->target.vectorWidth;
return m->diBuilder->createVectorType(size, align, unifType, subArray);
@@ -767,14 +758,8 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue);
enumeratorDescriptors.push_back(descriptor);
}
#ifdef LLVM_2_9
llvm::DIArray elementArray =
m->diBuilder->getOrCreateArray(&enumeratorDescriptors[0],
enumeratorDescriptors.size());
#else
llvm::DIArray elementArray =
m->diBuilder->getOrCreateArray(enumeratorDescriptors);
#endif
llvm::DIFile diFile = pos.GetDIFile();
llvm::DIType diType =
@@ -789,12 +774,7 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
return diType;
case Variability::Varying: {
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target.vectorWidth-1);
#ifdef LLVM_2_9
llvm::Value *suba[] = { sub };
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(suba, 1);
#else
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
#endif // !LLVM_2_9
uint64_t size = diType.getSizeInBits() * g->target.vectorWidth;
uint64_t align = diType.getAlignInBits() * g->target.vectorWidth;
return m->diBuilder->createVectorType(size, align, diType, subArray);
@@ -1686,12 +1666,7 @@ llvm::DIType
VectorType::GetDIType(llvm::DIDescriptor scope) const {
llvm::DIType eltType = base->GetDIType(scope);
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
#ifdef LLVM_2_9
llvm::Value *subs[1] = { sub };
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs, 1);
#else
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
#endif
uint64_t sizeBits = eltType.getSizeInBits() * numElements;
@@ -1976,17 +1951,10 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
llvm::DIFile diFile = elementPositions[i].GetDIFile();
int line = elementPositions[i].first_line;
#ifdef LLVM_2_9
llvm::DIType fieldType =
m->diBuilder->createMemberType(elementNames[i], diFile, line,
eltSize, eltAlign, currentSize, 0,
eltType);
#else
llvm::DIType fieldType =
m->diBuilder->createMemberType(scope, elementNames[i], diFile,
line, eltSize, eltAlign,
currentSize, 0, eltType);
#endif // LLVM_2_9
elementLLVMTypes.push_back(fieldType);
currentSize += eltSize;
@@ -1997,12 +1965,7 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
if (currentSize > 0 && (currentSize % align))
currentSize += align - (currentSize % align);
#ifdef LLVM_2_9
llvm::DIArray elements = m->diBuilder->getOrCreateArray(&elementLLVMTypes[0],
elementLLVMTypes.size());
#else
llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes);
#endif
llvm::DIFile diFile = pos.GetDIFile();
return m->diBuilder->createStructType(scope, name, diFile, pos.first_line, currentSize,
align, 0, elements);