From ee1fe3aa9fb1aa9f9d2ca21ee70d3f7e6438f341 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 3 May 2012 08:25:25 -0700 Subject: [PATCH] Update build to handle existence of LLVM 3.2 dev branch. We now compile with LLVM 3.0, 3.1, and 3.2svn. --- Makefile | 12 +++---- cbackend.cpp | 44 ++++++++++++------------- ctx.cpp | 12 +++---- ispc.cpp | 91 +++++++++++++--------------------------------------- ispc.h | 4 +-- llvmutil.cpp | 22 ++++++------- main.cpp | 4 ++- module.cpp | 11 ++----- opt.cpp | 20 ++++++------ 9 files changed, 85 insertions(+), 135 deletions(-) diff --git a/Makefile b/Makefile index e9422564..ca55a734 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,12 @@ else endif ARCH_TYPE = $(shell arch) -ifeq ($(shell $(LLVM_CONFIG) --version), 3.1svn) +ifeq ($(shell $(LLVM_CONFIG) --version), 3.0) + LLVM_LIBS=$(shell $(LLVM_CONFIG) --libs) +else LLVM_LIBS=-lLLVMAsmParser -lLLVMInstrumentation -lLLVMLinker \ -lLLVMArchive -lLLVMBitReader -lLLVMDebugInfo -lLLVMJIT -lLLVMipo \ - -lLLVMBitWriter -lLLVMTableGen \ + -lLLVMBitWriter -lLLVMTableGen \ -lLLVMX86Disassembler -lLLVMX86CodeGen -lLLVMSelectionDAG \ -lLLVMAsmPrinter -lLLVMX86AsmParser -lLLVMX86Desc -lLLVMX86Info \ -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCDisassembler -lLLVMMCParser \ @@ -30,15 +32,13 @@ ifeq ($(shell $(LLVM_CONFIG) --version), 3.1svn) -lLLVMipa -lLLVMAnalysis -lLLVMMCJIT -lLLVMRuntimeDyld \ -lLLVMExecutionEngine -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore \ -lLLVMSupport -else - LLVM_LIBS=$(shell $(LLVM_CONFIG) --libs) endif CLANG=clang CLANG_LIBS = -lclangFrontend -lclangDriver \ -lclangSerialization -lclangParse -lclangSema \ -lclangAnalysis -lclangAST -lclangLex -lclangBasic -ifeq ($(shell $(LLVM_CONFIG) --version), 3.1svn) +ifneq ($(shell $(LLVM_CONFIG) --version), 3.0) CLANG_LIBS += -lclangEdit endif @@ -54,7 +54,7 @@ ifeq ($(ARCH_OS2),Msys) endif LLVM_CXXFLAGS=$(shell $(LLVM_CONFIG) --cppflags) -LLVM_VERSION=LLVM_$(shell $(LLVM_CONFIG) --version | sed s/\\./_/) +LLVM_VERSION=LLVM_$(shell $(LLVM_CONFIG) --version | sed -e s/\\./_/ -e s/svn//) LLVM_VERSION_DEF=-D$(LLVM_VERSION) BUILD_DATE=$(shell date +%Y%m%d) diff --git a/cbackend.cpp b/cbackend.cpp index 0522fd85..e932dff2 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -361,7 +361,7 @@ namespace { bool printConstExprCast(const ConstantExpr *CE, bool Static); void printConstantArray(ConstantArray *CPA, bool Static); void printConstantVector(ConstantVector *CV, bool Static); -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 void printConstantDataSequential(ConstantDataSequential *CDS, bool Static); #endif @@ -438,11 +438,11 @@ namespace { void visitInvokeInst(InvokeInst &I) { llvm_unreachable("Lowerinvoke pass didn't work!"); } -#if !defined(LLVM_3_1) && !defined(LLVM_3_1svn) +#ifdef LLVM_3_0 void visitUnwindInst(UnwindInst &I) { llvm_unreachable("Lowerinvoke pass didn't work!"); } -#endif // !LLVM_3_1svn +#endif // LLVM_3_0 void visitResumeInst(ResumeInst &I) { llvm_unreachable("DwarfEHPrepare pass didn't work!"); } @@ -802,7 +802,7 @@ raw_ostream &CWriter::printType(raw_ostream &Out, Type *Ty, } void CWriter::printConstantArray(ConstantArray *CPA, bool Static) { -#ifndef LLVM_3_1svn +#ifdef LLVM_3_0 Type *ETy = CPA->getType()->getElementType(); // MMP: this looks like a bug: both sides of the || are the same bool isString = ETy == Type::getInt8Ty(CPA->getContext()); @@ -855,7 +855,7 @@ void CWriter::printConstantArray(ConstantArray *CPA, bool Static) { Out << "\""; return; } -#endif // !LLVM_3_1 +#endif // LLVM_3_0 printConstant(cast(CPA->getOperand(0)), Static); for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) { @@ -872,7 +872,7 @@ void CWriter::printConstantVector(ConstantVector *CP, bool Static) { } } -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 void CWriter::printConstantDataSequential(ConstantDataSequential *CDS, bool Static) { // As a special case, print the array as a string if it is an array of @@ -929,9 +929,9 @@ void CWriter::printConstantDataSequential(ConstantDataSequential *CDS, } } } -#endif // LLVM_3_1svn +#endif // !LLVM_3_0 -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 static inline std::string ftostr(const APFloat& V) { std::string Buf; if (&V.getSemantics() == &APFloat::IEEEdouble) { @@ -943,7 +943,7 @@ static inline std::string ftostr(const APFloat& V) { } return ""; // error } -#endif // LLVM_3_1svn +#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 @@ -1432,11 +1432,11 @@ void CWriter::printConstant(Constant *CPV, bool Static) { } if (ConstantArray *CA = dyn_cast(CPV)) { printConstantArray(CA, Static); -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 } else if (ConstantDataSequential *CDS = dyn_cast(CPV)) { printConstantDataSequential(CDS, Static); -#endif // LLVM_3_1svn +#endif // !LLVM_3_0 } else { assert(isa(CPV) || isa(CPV)); if (AT->getNumElements()) { @@ -1481,7 +1481,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) { Out << ")"; } } -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 else if (ConstantDataVector *CDV = dyn_cast(CPV)) { llvm::Constant *splatValue = CDV->getSplatValue(); if (splatValue != NULL && smearFunc != NULL) { @@ -1496,7 +1496,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) { Out << ")"; } } -#endif +#endif // !LLVM_3_0 else { assert(isa(CPV)); Constant *CZ = Constant::getNullValue(VT->getElementType()); @@ -2898,17 +2898,17 @@ void CWriter::visitSwitchInst(SwitchInst &SI) { printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2); Out << ";\n"; -#ifdef LLVM_3_1svn - for (SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) { - ConstantInt* CaseVal = i.getCaseValue(); - BasicBlock* Succ = i.getCaseSuccessor(); -#else +#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) { ConstantInt* CaseVal = SI.getCaseValue(i); BasicBlock* Succ = SI.getSuccessor(i); -#endif // LLVM_3_1svn +#else + for (SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) { + ConstantInt* CaseVal = i.getCaseValue(); + BasicBlock* Succ = i.getCaseSuccessor(); +#endif // !LLVM_3_0 Out << " case "; writeOperand(CaseVal); Out << ":\n"; @@ -3806,10 +3806,10 @@ std::string CWriter::InterpretASMConstraint(InlineAsm::ConstraintInfo& c) { const MCAsmInfo *TargetAsm; std::string Triple = TheModule->getTargetTriple(); if (Triple.empty()) -#if defined(LLVM_3_1) || defined(LLVM_3_1svn) - Triple = llvm::sys::getDefaultTargetTriple(); -#else +#ifdef LLVM_3_0 Triple = llvm::sys::getHostTriple(); +#else + Triple = llvm::sys::getDefaultTargetTriple(); #endif std::string E; diff --git a/ctx.cpp b/ctx.cpp index 1d0c834b..5d9ed434 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -1314,10 +1314,10 @@ FunctionEmitContext::MasksAllEqual(llvm::Value *v1, llvm::Value *v2) { llvm::Value * FunctionEmitContext::GetStringPtr(const std::string &str) { -#ifdef LLVM_3_1svn - llvm::Constant *lstr = llvm::ConstantDataArray::getString(*g->ctx, str); -#else +#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(), @@ -1368,10 +1368,10 @@ FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) { static llvm::Value * lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) { -#ifdef LLVM_3_1svn - llvm::Constant *sConstant = llvm::ConstantDataArray::getString(*g->ctx, s); -#else +#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 */, diff --git a/ispc.cpp b/ispc.cpp index 2fcf27ff..bd832825 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -54,14 +54,8 @@ #include #include #include -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) - #include - #include -#else - #include - #include - #include -#endif +#include +#include #include Globals *g; @@ -114,10 +108,7 @@ lGetSystemISA() { static const char *supportedCPUs[] = { - "atom", "penryn", "core2", "corei7", -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) - "corei7-avx" -#endif + "atom", "penryn", "core2", "corei7", "corei7-avx" }; @@ -128,14 +119,11 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, if (cpu != NULL) { // If a CPU was specified explicitly, try to pick the best // possible ISA based on that. -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) if (!strcmp(cpu, "sandybridge") || !strcmp(cpu, "corei7-avx")) isa = "avx"; - else -#endif - if (!strcmp(cpu, "corei7") || - !strcmp(cpu, "penryn")) + else if (!strcmp(cpu, "corei7") || + !strcmp(cpu, "penryn")) isa = "sse4"; else isa = "sse2"; @@ -277,7 +265,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->allOffMaskIsSafe = false; t->maskBitCount = 32; } -#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; @@ -296,8 +283,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->allOffMaskIsSafe = false; t->maskBitCount = 32; } -#endif // LLVM 3.0+ -#if defined(LLVM_3_1svn) +#ifndef LLVM_3_0 else if (!strcasecmp(isa, "avx2")) { t->isa = Target::AVX2; t->nativeVectorWidth = 8; @@ -316,7 +302,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->allOffMaskIsSafe = false; t->maskBitCount = 32; } -#endif // LLVM 3.1 +#endif // !LLVM_3_0 else { fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n", isa, SupportedTargetISAs()); @@ -354,13 +340,10 @@ Target::SupportedTargetArchs() { const char * Target::SupportedTargetISAs() { - return "sse2, sse2-x2, sse4, sse4-x2" -#ifndef LLVM_2_9 - ", avx, avx-x2" -#endif // !LLVM_2_9 -#ifdef LLVM_3_1svn + return "sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2" +#ifndef LLVM_3_0 ", avx2, avx2-x2" -#endif // LLVM_3_1svn +#endif // !LLVM_3_0 ", generic-4, generic-8, generic-16, generic-1"; } @@ -369,10 +352,10 @@ std::string Target::GetTripleString() const { llvm::Triple triple; // Start with the host triple as the default -#if defined(LLVM_3_1) || defined(LLVM_3_1svn) - triple.setTriple(llvm::sys::getDefaultTargetTriple()); -#else +#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 @@ -398,37 +381,17 @@ Target::GetTargetMachine() const { llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ : llvm::Reloc::Default; -#if defined(LLVM_3_1svn) - std::string featuresString = attributes; - llvm::TargetOptions options; -#if 0 - // This was breaking e.g. round() on SSE2, where the code we want to - // run wants to do: - // x += 0x1.0p23f; - // x -= 0x1.0p23f; - // But then LLVM was optimizing this away... - if (g->opt.fastMath == true) - options.UnsafeFPMath = 1; -#endif - llvm::TargetMachine *targetMachine = - target->createTargetMachine(triple, cpu, featuresString, options, - relocModel); -#elif defined(LLVM_3_0) +#ifdef LLVM_3_0 std::string featuresString = attributes; llvm::TargetMachine *targetMachine = target->createTargetMachine(triple, cpu, featuresString, relocModel); -#else // LLVM 2.9 -#ifdef ISPC_IS_APPLE - relocModel = llvm::Reloc::PIC_; -#endif // ISPC_IS_APPLE - std::string featuresString = cpu + std::string(",") + attributes; +#else + std::string featuresString = attributes; + llvm::TargetOptions options; llvm::TargetMachine *targetMachine = - target->createTargetMachine(triple, featuresString); -#ifndef ISPC_IS_WINDOWS - targetMachine->setRelocationModel(relocModel); -#endif // !ISPC_IS_WINDOWS -#endif // LLVM_2_9 - + target->createTargetMachine(triple, cpu, featuresString, options, + relocModel); +#endif // !LLVM_3_0 Assert(targetMachine != NULL); targetMachine->setAsmVerbosityDefault(true); @@ -498,16 +461,11 @@ Target::SizeOf(llvm::Type *type, llvm::Value *index[1] = { LLVMInt32(1) }; llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) llvm::ArrayRef arrayRef(&index[0], &index[1]); llvm::Instruction *gep = llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep", insertAtEnd); -#else - llvm::Instruction *gep = - llvm::GetElementPtrInst::Create(voidPtr, &index[0], &index[1], - "sizeof_gep", insertAtEnd); -#endif + if (is32Bit || g->opt.force32BitAddressing) return new llvm::PtrToIntInst(gep, LLVMTypes::Int32Type, "sizeof_int", insertAtEnd); @@ -536,16 +494,11 @@ Target::StructOffset(llvm::Type *type, int element, llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(element) }; llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); -#if defined(LLVM_3_0) || defined(LLVM_3_0svn) || defined(LLVM_3_1svn) llvm::ArrayRef arrayRef(&indices[0], &indices[2]); llvm::Instruction *gep = llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep", insertAtEnd); -#else - llvm::Instruction *gep = - llvm::GetElementPtrInst::Create(voidPtr, &indices[0], &indices[2], - "offset_gep", insertAtEnd); -#endif + if (is32Bit || g->opt.force32BitAddressing) return new llvm::PtrToIntInst(gep, LLVMTypes::Int32Type, "offset_int", insertAtEnd); diff --git a/ispc.h b/ispc.h index c4c5c405..d0d0c3f7 100644 --- a/ispc.h +++ b/ispc.h @@ -40,8 +40,8 @@ #define ISPC_VERSION "1.2.3dev" -#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" +#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2) +#error "Only LLVM 3.0, 3.1, and the 3.2 development branch are supported" #endif #if defined(_WIN32) || defined(_WIN64) diff --git a/llvmutil.cpp b/llvmutil.cpp index e21a0b12..cc8ac5af 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -657,7 +657,7 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) { // Deal with the fact that LLVM3.1 and previous versions have different // representations for vectors of constant ints... -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::ConstantDataVector *cv = llvm::dyn_cast(v); if (cv == NULL) return false; @@ -678,7 +678,7 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) { ret[i] = ci->getSExtValue(); } return true; -#endif // LLVM_3_1svn +#endif // !LLVM_3_0 } @@ -947,7 +947,7 @@ lVectorValuesAllEqual(llvm::Value *v, int vectorLength, if (cv != NULL) return (cv->getSplatValue() != NULL); -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::ConstantDataVector *cdv = llvm::dyn_cast(v); if (cdv != NULL) return (cdv->getSplatValue() != NULL); @@ -1102,7 +1102,7 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride, */ static bool lVectorIsLinearConstantInts( -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::ConstantDataVector *cv, #else llvm::ConstantVector *cv, @@ -1111,7 +1111,7 @@ lVectorIsLinearConstantInts( int stride) { // Flatten the vector out into the elements array llvm::SmallVector elements; -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 for (int i = 0; i < (int)cv->getNumElements(); ++i) elements.push_back(cv->getElementAsConstant(i)); #else @@ -1152,7 +1152,7 @@ lCheckMulForLinear(llvm::Value *op0, llvm::Value *op1, int vectorLength, int stride, std::vector &seenPhis) { // Is the first operand a constant integer value splatted across all of // the lanes? -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::ConstantDataVector *cv = llvm::dyn_cast(op0); #else llvm::ConstantVector *cv = llvm::dyn_cast(op0); @@ -1226,7 +1226,7 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride, std::vector &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. -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::ConstantDataVector *cv = llvm::dyn_cast(v); #else llvm::ConstantVector *cv = llvm::dyn_cast(v); @@ -1403,19 +1403,19 @@ lExtractFirstVectorElement(llvm::Value *v, return llvm::ConstantInt::get(vt->getElementType(), 0); } if (llvm::ConstantVector *cv = llvm::dyn_cast(v)) { -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 return cv->getOperand(0); #else llvm::SmallVector elements; cv->getVectorElements(elements); return elements[0]; -#endif // LLVM_3_1 +#endif // !LLVM_3_0 } -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 if (llvm::ConstantDataVector *cdv = llvm::dyn_cast(v)) return cdv->getElementAsConstant(0); -#endif // LLVM_3_1 +#endif // !LLVM_3_0 // Otherwise, all that we should have at this point is an instruction // of some sort diff --git a/main.cpp b/main.cpp index a98a35bb..417c1c3c 100644 --- a/main.cpp +++ b/main.cpp @@ -62,8 +62,10 @@ lPrintVersion() { ISPC_VERSION, BUILD_VERSION, BUILD_DATE, #if defined(LLVM_3_0) "3.0" -#elif defined(LLVM_3_1) || defined(LLVM_3_1svn) +#elif defined(LLVM_3_1) "3.1" +#elif defined(LLVM_3_2) + "3.2" #else #error "Unhandled LLVM version" #endif diff --git a/module.cpp b/module.cpp index 17df7b86..41eeb412 100644 --- a/module.cpp +++ b/module.cpp @@ -271,11 +271,6 @@ extern void yy_delete_buffer(YY_BUFFER_STATE); int Module::CompileFile() { -#ifndef LLVM_3_1svn - if (g->opt.fastMath == true) - llvm::UnsafeFPMath = true; -#endif // !LLVM_3_1svn - extern void ParserInit(); ParserInit(); @@ -1286,10 +1281,10 @@ Module::execPreprocessor(const char* infilename, llvm::raw_string_ostream* ostre clang::TargetOptions &options = inst.getTargetOpts(); llvm::Triple triple(module->getTargetTriple()); if (triple.getTriple().empty()) { -#if defined(LLVM_3_1) || defined(LLVM_3_1svn) - triple.setTriple(llvm::sys::getDefaultTargetTriple()); -#else +#ifdef LLVM_3_0 triple.setTriple(llvm::sys::getHostTriple()); +#else + triple.setTriple(llvm::sys::getDefaultTargetTriple()); #endif } options.Triple = triple.getTriple(); diff --git a/opt.cpp b/opt.cpp index 644a83dc..34cdab0f 100644 --- a/opt.cpp +++ b/opt.cpp @@ -656,7 +656,7 @@ lGetMask(llvm::Value *factor) { "known and all bits on". */ Assert(g->target.vectorWidth < 32); -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::ConstantDataVector *cdv = llvm::dyn_cast(factor); if (cdv != NULL) { llvm::SmallVector elements; @@ -669,7 +669,7 @@ lGetMask(llvm::Value *factor) { llvm::ConstantVector *cv = llvm::dyn_cast(factor); if (cv != NULL) { llvm::SmallVector elements; - #ifdef LLVM_3_1svn +#ifndef LLVM_3_0 for (int i = 0; i < (int)cv->getNumOperands(); ++i) { llvm::Constant *c = llvm::dyn_cast(cv->getOperand(i)); @@ -945,7 +945,7 @@ 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... -#if defined(LLVM_3_1svn) +#ifndef LLVM_3_0 llvm::SelectInst *selectInst = llvm::dyn_cast(&*iter); if (selectInst != NULL && selectInst->getType()->isVectorTy()) { llvm::Value *factor = selectInst->getOperand(0); @@ -966,7 +966,7 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) { goto restart; } } -#endif // LLVM_3_1svn +#endif // !LLVM_3_0 llvm::CallInst *callInst = llvm::dyn_cast(&*iter); if (callInst == NULL) @@ -1179,7 +1179,7 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets, // Indexing into global arrays can lead to this form, with // ConstantVectors.. llvm::SmallVector elements; - #ifdef LLVM_3_1svn +#ifndef LLVM_3_0 for (int i = 0; i < (int)cv->getNumOperands(); ++i) { llvm::Constant *c = llvm::dyn_cast(cv->getOperand(i)); @@ -1274,7 +1274,7 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset, llvm::Value **variableOffset, llvm::Instruction *insertBefore) { if (llvm::isa(vec) || -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::isa(vec) || #endif llvm::isa(vec)) { @@ -1399,11 +1399,11 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset, *splat, if so). */ static bool lIsIntegerSplat(llvm::Value *v, int *splat) { -#ifdef LLVM_3_1svn +#ifdef LLVM_3_0 + llvm::ConstantVector *cvec = llvm::dyn_cast(v); +#else llvm::ConstantDataVector *cvec = llvm::dyn_cast(v); -#else - llvm::ConstantVector *cvec = llvm::dyn_cast(v); #endif if (cvec == NULL) return false; @@ -1539,7 +1539,7 @@ lExtractUniforms(llvm::Value **vec, llvm::Instruction *insertBefore) { fprintf(stderr, "\n"); if (llvm::isa(*vec) || -#ifdef LLVM_3_1svn +#ifndef LLVM_3_0 llvm::isa(*vec) || #endif llvm::isa(*vec))