Fix #ifdefs to catch LLVM 3.1svn now as well

This commit is contained in:
Matt Pharr
2011-10-19 14:01:19 -07:00
parent 114cb5b5c7
commit 074cbc2716
8 changed files with 40 additions and 40 deletions

View File

@@ -366,7 +366,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)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Linker::DestroySource,
#endif // LLVM_3_0
&linkError))

14
ctx.cpp
View File

@@ -808,7 +808,7 @@ FunctionEmitContext::SizeOf(LLVM_TYPE_CONST llvm::Type *ty) {
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(ty, 0);
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
llvm::Value *index[1] = { LLVMInt32(1) };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, arrayRef,
"offset_ptr", bblock);
@@ -830,7 +830,7 @@ 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)
#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
@@ -1316,7 +1316,7 @@ 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)
#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,
@@ -1843,7 +1843,7 @@ 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)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
count,
#endif // LLVM_3_0
name ? name : "phi", bblock);
@@ -1877,7 +1877,7 @@ FunctionEmitContext::CallInst(llvm::Function *func,
return NULL;
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Instruction *ci =
llvm::CallInst::Create(func, args, name ? name : "", bblock);
#else
@@ -1898,7 +1898,7 @@ FunctionEmitContext::CallInst(llvm::Function *func, llvm::Value *arg,
return NULL;
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::Instruction *ci =
llvm::CallInst::Create(func, arg, name ? name : "", bblock);
#else
@@ -1921,7 +1921,7 @@ FunctionEmitContext::CallInst(llvm::Function *func, llvm::Value *arg0,
}
llvm::Value *args[] = { arg0, arg1 };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> argArrayRef(&args[0], &args[2]);
llvm::Instruction *ci =
llvm::CallInst::Create(func, argArrayRef, name ? name : "",

View File

@@ -52,7 +52,7 @@
#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h>
#include <llvm/Target/TargetData.h>
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#else
@@ -85,7 +85,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
if (isa == NULL) {
if (!strcasecmp(cpu, "atom"))
isa = "sse2";
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
else if (!strcasecmp(cpu, "sandybridge") ||
!strcasecmp(cpu, "corei7-avx"))
isa = "avx";
@@ -147,7 +147,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
t->vectorWidth = 8;
t->attributes = "+sse,+sse2,+sse3,+sse41,-sse42,-sse4a,+ssse3,-popcnt,+cmov";
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
else if (!strcasecmp(isa, "avx")) {
t->isa = Target::AVX;
t->nativeVectorWidth = 8;
@@ -180,7 +180,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
const char *
Target::SupportedTargetCPUs() {
return "atom, barcelona, core2, corei7, "
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
"corei7-avx, "
#endif
"istanbul, nocona, penryn, "
@@ -200,7 +200,7 @@ Target::SupportedTargetArchs() {
const char *
Target::SupportedTargetISAs() {
return "sse2, sse2-x2, sse4, sse4-x2"
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
", avx, avx-x2"
#endif
;
@@ -236,7 +236,7 @@ Target::GetTargetMachine() const {
llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ :
llvm::Reloc::Default;
#if defined(LLVM_3_0svn) || defined(LLVM_3_0)
#if defined(LLVM_3_0svn) || defined(LLVM_3_1svn) || defined(LLVM_3_0)
std::string featuresString = attributes;
llvm::TargetMachine *targetMachine =
target->createTargetMachine(triple, cpu, featuresString, relocModel);

2
ispc.h
View File

@@ -76,7 +76,7 @@ namespace llvm {
}
// llvm::Type *s are no longer const in llvm 3.0
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
#define LLVM_TYPE_CONST
#else
#define LLVM_TYPE_CONST const

View File

@@ -74,7 +74,7 @@ extern "C" {
#include <llvm/DerivedTypes.h>
#include <llvm/Instructions.h>
#include <llvm/ExecutionEngine/ExecutionEngine.h>
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#else
@@ -182,7 +182,7 @@ static bool lRunTest(const char *fn) {
}
std::string eeError;
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::EngineBuilder engineBuilder(module);
engineBuilder.setErrorStr(&eeError);
engineBuilder.setEngineKind(llvm::EngineKind::JIT);
@@ -361,7 +361,7 @@ static bool lRunTest(const char *fn) {
int main(int argc, char *argv[]) {
llvm::InitializeNativeTarget();
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
LLVMLinkInJIT();
#endif

View File

@@ -41,7 +41,7 @@
#include <stdlib.h>
#include <llvm/Support/PrettyStackTrace.h>
#include <llvm/Support/Signals.h>
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#else
@@ -172,7 +172,7 @@ int main(int Argc, char *Argv[]) {
LLVMInitializeX86AsmPrinter();
LLVMInitializeX86AsmParser();
LLVMInitializeX86Disassembler();
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
LLVMInitializeX86TargetMC();
#endif

View File

@@ -566,7 +566,7 @@ Module::AddFunctionDefinition(Symbol *sym, const std::vector<Symbol *> &args,
bool
Module::writeOutput(OutputType outputType, const char *outFileName) {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
if (diBuilder != NULL && outputType != Header)
diBuilder->finalize();
#endif // LLVM_3_0
@@ -1099,7 +1099,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_0svn)
#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);
@@ -1450,7 +1450,7 @@ 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)
#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(),
@@ -1459,7 +1459,7 @@ lCreateDispatchFunction(llvm::Module *module, llvm::Function *setISAFunc,
llvm::ReturnInst::Create(*g->ctx, callBBlock);
}
else {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#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);

32
opt.cpp
View File

@@ -189,7 +189,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(targetLibraryInfo);
optPM.add(new llvm::TargetData(module));
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
optPM.add(llvm::createIndVarSimplifyPass());
#endif
@@ -419,7 +419,7 @@ 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)
#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);
@@ -430,7 +430,7 @@ IntrinsicsOpt::IntrinsicsOpt()
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)
#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));
@@ -522,7 +522,7 @@ lIsUndef(llvm::Value *value) {
bool
IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#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 =
@@ -605,7 +605,7 @@ IntrinsicsOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
goto restart;
}
}
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#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);
@@ -827,7 +827,7 @@ lSizeOf(LLVM_TYPE_CONST llvm::Type *type, llvm::Instruction *insertBefore) {
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(type, 0);
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
llvm::Value *index[1] = { LLVMInt32(1) };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, arrayRef,
"offset_ptr", insertBefore);
@@ -859,7 +859,7 @@ lStructOffset(LLVM_TYPE_CONST llvm::Type *type, uint64_t member,
LLVM_TYPE_CONST llvm::Type *ptrType = llvm::PointerType::get(type, 0);
llvm::Value *nullPtr = llvm::Constant::getNullValue(ptrType);
llvm::Value *index[2] = { LLVMInt32(0), LLVMInt32((int32_t)member) };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[2]);
llvm::Value *poffset = llvm::GetElementPtrInst::Create(nullPtr, arrayRef,
"member_ptr", insertBefore);
@@ -1274,7 +1274,7 @@ GatherScatterFlattenOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
// the instruction isn't inserted into a basic block and that
// way we can then call ReplaceInstWithInst().
llvm::Value *newArgs[3] = { basePtr, offsetVector, mask };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&newArgs[0], &newArgs[3]);
llvm::Instruction *newCall =
llvm::CallInst::Create(info->baseOffsetsFunc, newArgArray,
@@ -1295,7 +1295,7 @@ GatherScatterFlattenOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
// base+offsets instruction. See above for why passing NULL
// for the Instruction * is intended.
llvm::Value *newArgs[4] = { basePtr, offsetVector, rvalue, mask };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&newArgs[0], &newArgs[4]);
llvm::Instruction *newCall =
llvm::CallInst::Create(info->baseOffsetsFunc, newArgArray, "",
@@ -1550,7 +1550,7 @@ LowerMaskedStorePass::runOnBasicBlock(llvm::BasicBlock &bb) {
// replace the __pseudo_* one with it.
llvm::Function *fms = doBlend ? info->blendFunc : info->maskedStoreFunc;
llvm::Value *args[3] = { lvalue, rvalue, mask };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[3]);
llvm::Instruction *inst = llvm::CallInst::Create(fms, newArgArray, "",
callInst);
@@ -1898,7 +1898,7 @@ lScalarizeVector(llvm::Value *vec, llvm::Value **scalarizedVector,
// get them into the map<> before making recursive calls to
// lScalarizeVector.
for (int i = 0; i < vectorLength; ++i) {
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
scalarizedVector[i] =
llvm::PHINode::Create(eltType, numIncoming, "phi", phi);
#else
@@ -2492,7 +2492,7 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
new llvm::BitCastInst(base, LLVMTypes::VoidPointerType,
"base2i8", callInst);
lCopyMetadata(basei8, callInst);
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[1]);
llvm::Value *ptr =
llvm::GetElementPtrInst::Create(basei8, arrayRef, "ptr", callInst);
@@ -2512,7 +2512,7 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
// be invalid in that case).
Debug(pos, "Transformed gather to scalar load and broadcast!");
llvm::Value *args[2] = { ptr, mask };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> newArgArray(&args[0], &args[2]);
llvm::Instruction *newCall =
llvm::CallInst::Create(gatherInfo->loadBroadcastFunc, newArgArray,
@@ -2563,7 +2563,7 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
llvm::Value *basei8 =
new llvm::BitCastInst(base, LLVMTypes::VoidPointerType, "base2i8", callInst);
lCopyMetadata(basei8, callInst);
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[1]);
llvm::Value *ptr =
llvm::GetElementPtrInst::Create(basei8, arrayRef, "ptr", callInst);
@@ -2577,7 +2577,7 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
if (gatherInfo != NULL) {
Debug(pos, "Transformed gather to unaligned vector load!");
llvm::Value *args[2] = { ptr, mask };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> argArray(&args[0], &args[2]);
llvm::Instruction *newCall =
llvm::CallInst::Create(gatherInfo->loadMaskedFunc, argArray,
@@ -2597,7 +2597,7 @@ GSImprovementsPass::runOnBasicBlock(llvm::BasicBlock &bb) {
callInst);
llvm::Value *args[3] = { ptr, rvalue, mask };
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn)
llvm::ArrayRef<llvm::Value *> argArray(&args[0], &args[3]);
llvm::Instruction *newCall =
llvm::CallInst::Create(scatterInfo->maskedStoreFunc, argArray,