From 074cbc2716474614f6c8baab0188ff65e068cc4f Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 19 Oct 2011 14:01:19 -0700 Subject: [PATCH] Fix #ifdefs to catch LLVM 3.1svn now as well --- builtins.cpp | 2 +- ctx.cpp | 14 +++++++------- ispc.cpp | 12 ++++++------ ispc.h | 2 +- ispc_test.cpp | 6 +++--- main.cpp | 4 ++-- module.cpp | 8 ++++---- opt.cpp | 32 ++++++++++++++++---------------- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index 33551632..50ec269b 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -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)) diff --git a/ctx.cpp b/ctx.cpp index fe0c2953..653c666c 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -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 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 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 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 argArrayRef(&args[0], &args[2]); llvm::Instruction *ci = llvm::CallInst::Create(func, argArrayRef, name ? name : "", diff --git a/ispc.cpp b/ispc.cpp index 3a3d3751..fce7af14 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -52,7 +52,7 @@ #include #include #include -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) +#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) #include #include #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); diff --git a/ispc.h b/ispc.h index fed84bda..4461e76e 100644 --- a/ispc.h +++ b/ispc.h @@ -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 diff --git a/ispc_test.cpp b/ispc_test.cpp index 385e7dc2..a72081c4 100644 --- a/ispc_test.cpp +++ b/ispc_test.cpp @@ -74,7 +74,7 @@ extern "C" { #include #include #include -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) +#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) #include #include #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 diff --git a/main.cpp b/main.cpp index 72ec1355..02646aff 100644 --- a/main.cpp +++ b/main.cpp @@ -41,7 +41,7 @@ #include #include #include -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) +#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) #include #include #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 diff --git a/module.cpp b/module.cpp index d58c7349..ee8078b0 100644 --- a/module.cpp +++ b/module.cpp @@ -566,7 +566,7 @@ Module::AddFunctionDefinition(Symbol *sym, const std::vector &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 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); diff --git a/opt.cpp b/opt.cpp index 1d9d9caa..ca242870 100644 --- a/opt.cpp +++ b/opt.cpp @@ -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 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 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 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 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 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 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 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 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 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 argArray(&args[0], &args[3]); llvm::Instruction *newCall = llvm::CallInst::Create(scatterInfo->maskedStoreFunc, argArray,