remove several redundant #if - clauses

This commit is contained in:
Anton Mitrokhin
2015-06-17 14:07:51 +03:00
parent 0afa3f5713
commit ebc47d00a1
19 changed files with 273 additions and 275 deletions

View File

@@ -47,10 +47,8 @@
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/Attributes.h> #include <llvm/Attributes.h>
#endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Type.h> #include <llvm/Type.h>
@@ -784,7 +782,7 @@ void
AddBitcodeToModule(const unsigned char *bitcode, int length, AddBitcodeToModule(const unsigned char *bitcode, int length,
llvm::Module *module, SymbolTable *symbolTable, bool warn) { llvm::Module *module, SymbolTable *symbolTable, bool warn) {
llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::StringRef sb = llvm::StringRef((char *)bitcode, length);
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb);
#else // LLVM 3.6+ #else // LLVM 3.6+
llvm::MemoryBufferRef bcBuf = llvm::MemoryBuffer::getMemBuffer(sb)->getMemBufferRef(); llvm::MemoryBufferRef bcBuf = llvm::MemoryBuffer::getMemBuffer(sb)->getMemBufferRef();
@@ -880,7 +878,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
std::string(linkError); std::string(linkError);
if (llvm::Linker::LinkModules(module, bcModule if (llvm::Linker::LinkModules(module, bcModule
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
, llvm::Linker::DestroySource, , llvm::Linker::DestroySource,
&linkError)) &linkError))
Error(SourcePos(), "Error linking stdlib bitcode: %s", linkError.c_str()); Error(SourcePos(), "Error linking stdlib bitcode: %s", linkError.c_str());
@@ -917,7 +915,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
symbolTable->AddVariable(sym); symbolTable->AddVariable(sym);
if (m->diBuilder != NULL) { if (m->diBuilder != NULL) {
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIFile file; llvm::DIFile file;
llvm::DIType diType = sym->type->GetDIType(file); llvm::DIType diType = sym->type->GetDIType(file);
Assert(diType.Verify()); Assert(diType.Verify());
@@ -932,7 +930,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
// have the DW_AT_artifical attribute. It's not clear if this // have the DW_AT_artifical attribute. It's not clear if this
// matters for anything though. // matters for anything though.
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
name, name,
file, file,
@@ -940,7 +938,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
diType, diType,
true /* static */, true /* static */,
sym->storagePtr); sym->storagePtr);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* i.e., 3.6 */ #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // LLVM 3.6
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
@@ -965,7 +963,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
true /* static */, true /* static */,
sym_const_storagePtr); sym_const_storagePtr);
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
Assert(var.Verify()); Assert(var.Verify());
#else // LLVM 3.7+ #else // LLVM 3.7+
//coming soon //coming soon
@@ -984,7 +982,7 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module,
llvm::Function *func = module->getFunction(name); llvm::Function *func = module->getFunction(name);
Assert(func != NULL); // it should be declared already... Assert(func != NULL); // it should be declared already...
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
func->addFnAttr(llvm::Attributes::AlwaysInline); func->addFnAttr(llvm::Attributes::AlwaysInline);
#else // LLVM 3.3+ #else // LLVM 3.3+
func->addFnAttr(llvm::Attribute::AlwaysInline); func->addFnAttr(llvm::Attribute::AlwaysInline);
@@ -1019,7 +1017,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
symbolTable->AddVariable(sym); symbolTable->AddVariable(sym);
if (m->diBuilder != NULL) { if (m->diBuilder != NULL) {
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIFile file; llvm::DIFile file;
llvm::DIType diType = sym->type->GetDIType(file); llvm::DIType diType = sym->type->GetDIType(file);
Assert(diType.Verify()); Assert(diType.Verify());
@@ -1030,13 +1028,10 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
llvm::DIType *diType = sym->type->GetDIType(file); llvm::DIType *diType = sym->type->GetDIType(file);
// Assert(diType.Verify()); // Assert(diType.Verify());
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // LLVM 3.6
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
llvm::DIGlobalVariable var =
#endif
m->diBuilder->createGlobalVariable(
file, file,
sym->name.c_str(), sym->name.c_str(),
sym->name.c_str(), sym->name.c_str(),
@@ -1045,7 +1040,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
diType, diType,
false /* static */, false /* static */,
sym_const_storagePtr); sym_const_storagePtr);
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 /* && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 */ #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
sym->name.c_str(), sym->name.c_str(),
file, file,
@@ -1053,7 +1048,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
diType, diType,
false /* static */, false /* static */,
sym->storagePtr); sym->storagePtr);
#else #else // LLVM 3.7+
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
m->diBuilder->createGlobalVariable( m->diBuilder->createGlobalVariable(
@@ -1065,8 +1060,8 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
diType, diType,
false /* static */, false /* static */,
sym_const_storagePtr); sym_const_storagePtr);
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
Assert(var.Verify()); Assert(var.Verify());
#else // LLVM 3.7+ #else // LLVM 3.7+
//coming soon //coming soon

View File

@@ -41,7 +41,7 @@
#include "llvm/Intrinsics.h" #include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h" #include "llvm/IntrinsicInst.h"
#include "llvm/InlineAsm.h" #include "llvm/InlineAsm.h"
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
#include "llvm/IR/Constants.h" #include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h" #include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/CallingConv.h" #include "llvm/IR/CallingConv.h"
@@ -52,25 +52,25 @@
#include "llvm/IR/InlineAsm.h" #include "llvm/IR/InlineAsm.h"
#endif #endif
#include "llvm/Pass.h" #include "llvm/Pass.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* <= 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
#endif #endif
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include "llvm/TypeFinder.h" #include "llvm/TypeFinder.h"
#else /* LLVM_3_3+ */ #else // LLVM_3_3+
#include "llvm/IR/TypeFinder.h" #include "llvm/IR/TypeFinder.h"
#endif #endif
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4
#include "llvm/Support/InstIterator.h" #include "llvm/Support/InstIterator.h"
#else /* 3.5+ */ #else // 3.5+
#include "llvm/IR/InstIterator.h" #include "llvm/IR/InstIterator.h"
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
#include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/FindUsedTypes.h"
#endif #endif
#include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopInfo.h"
@@ -100,18 +100,18 @@
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2
#include "llvm/DataLayout.h" #include "llvm/DataLayout.h"
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
#include "llvm/IR/DataLayout.h" #include "llvm/IR/DataLayout.h"
#endif #endif
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h" #include "llvm/Support/FormattedStream.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2
#include "llvm/Support/InstVisitor.h" #include "llvm/Support/InstVisitor.h"
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.3, 3.4 */ #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.3, 3.4
#include "llvm/InstVisitor.h" #include "llvm/InstVisitor.h"
#else /* LLVM 3.5+ */ #else // LLVM 3.5+
#include "llvm/IR/InstVisitor.h" #include "llvm/IR/InstVisitor.h"
#endif #endif
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
@@ -119,7 +119,7 @@
#include "llvm/Support/Host.h" #include "llvm/Support/Host.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4
#include "llvm/Config/config.h" #include "llvm/Config/config.h"
#endif #endif
@@ -312,7 +312,7 @@ namespace {
/// walked in other ways. GlobalValues, basic blocks, instructions, and /// walked in other ways. GlobalValues, basic blocks, instructions, and
/// inst operands are all explicitly enumerated. /// inst operands are all explicitly enumerated.
void incorporateValue(const llvm::Value *V) { void incorporateValue(const llvm::Value *V) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5
if (const llvm::MDNode *M = llvm::dyn_cast<llvm::MDNode>(V)) { if (const llvm::MDNode *M = llvm::dyn_cast<llvm::MDNode>(V)) {
incorporateMDNode(M); incorporateMDNode(M);
return; return;
@@ -339,7 +339,7 @@ namespace {
incorporateValue(*I); incorporateValue(*I);
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5
void incorporateMDNode(const llvm::MDNode *V) { void incorporateMDNode(const llvm::MDNode *V) {
// Already visited? // Already visited?
@@ -351,7 +351,7 @@ namespace {
if (llvm::Value *Op = V->getOperand(i)) if (llvm::Value *Op = V->getOperand(i))
incorporateValue(Op); incorporateValue(Op);
} }
#else /* LLVM 3.6+ */ #else // LLVM 3.6+
void incorporateMDNode(const llvm::Metadata *M) { void incorporateMDNode(const llvm::Metadata *M) {
// Already visited? // Already visited?
@@ -397,7 +397,7 @@ namespace {
public: public:
CBEMCAsmInfo() { CBEMCAsmInfo() {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4
GlobalPrefix = ""; GlobalPrefix = "";
#endif #endif
PrivateGlobalPrefix = ""; PrivateGlobalPrefix = "";
@@ -449,9 +449,9 @@ namespace {
OpaqueCounter(0), NextAnonValueNumber(0), OpaqueCounter(0), NextAnonValueNumber(0),
includeName(incname ? incname : "generic_defs.h"), includeName(incname ? incname : "generic_defs.h"),
vectorWidth(vecwidth) { vectorWidth(vecwidth) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6
initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry()); initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry());
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
initializeLoopInfoWrapperPassPass(*llvm::PassRegistry::getPassRegistry()); initializeLoopInfoWrapperPassPass(*llvm::PassRegistry::getPassRegistry());
#endif #endif
FPCounter = 0; FPCounter = 0;
@@ -461,9 +461,9 @@ namespace {
virtual const char *getPassName() const { return "C backend"; } virtual const char *getPassName() const { return "C backend"; }
void getAnalysisUsage(llvm::AnalysisUsage &AU) const { void getAnalysisUsage(llvm::AnalysisUsage &AU) const {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6
AU.addRequired<llvm::LoopInfo>(); AU.addRequired<llvm::LoopInfo>();
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
AU.addRequired<llvm::LoopInfoWrapperPass>(); AU.addRequired<llvm::LoopInfoWrapperPass>();
#endif #endif
AU.setPreservesAll(); AU.setPreservesAll();
@@ -477,9 +477,9 @@ namespace {
if (F.hasAvailableExternallyLinkage()) if (F.hasAvailableExternallyLinkage())
return false; return false;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6
LI = &getAnalysis<llvm::LoopInfo>(); LI = &getAnalysis<llvm::LoopInfo>();
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
LI = &getAnalysis<llvm::LoopInfoWrapperPass>().getLoopInfo(); LI = &getAnalysis<llvm::LoopInfoWrapperPass>().getLoopInfo();
#endif #endif
@@ -521,7 +521,7 @@ namespace {
bool IgnoreName = false, bool IgnoreName = false,
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
const llvm::AttrListPtr &PAL = llvm::AttrListPtr() const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
const llvm::AttributeSet &PAL = llvm::AttributeSet() const llvm::AttributeSet &PAL = llvm::AttributeSet()
#endif #endif
); );
@@ -532,7 +532,7 @@ namespace {
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out, void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
const llvm::AttrListPtr &PAL, const llvm::AttrListPtr &PAL,
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
const llvm::AttributeSet &PAL, const llvm::AttributeSet &PAL,
#endif #endif
llvm::PointerType *Ty); llvm::PointerType *Ty);
@@ -778,7 +778,7 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) {
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
const llvm::AttrListPtr &PAL, const llvm::AttrListPtr &PAL,
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
const llvm::AttributeSet &PAL, const llvm::AttributeSet &PAL,
#endif #endif
llvm::PointerType *TheTy) { llvm::PointerType *TheTy) {
@@ -797,7 +797,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
llvm::Type *ArgTy = *I; llvm::Type *ArgTy = *I;
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
#endif #endif
assert(ArgTy->isPointerTy()); assert(ArgTy->isPointerTy());
@@ -806,7 +806,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
printType(FunctionInnards, ArgTy, printType(FunctionInnards, ArgTy,
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
#endif #endif
""); "");
@@ -823,7 +823,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
printType(Out, RetTy, printType(Out, RetTy,
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
#endif #endif
FunctionInnards.str()); FunctionInnards.str());
@@ -2391,7 +2391,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
#endif #endif
TAsm = new CBEMCAsmInfo(); TAsm = new CBEMCAsmInfo();
MRI = new llvm::MCRegisterInfo(); MRI = new llvm::MCRegisterInfo();
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 /* LLVM 3.4+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+
TCtx = new llvm::MCContext(TAsm, MRI, NULL); TCtx = new llvm::MCContext(TAsm, MRI, NULL);
#else #else
TCtx = new llvm::MCContext(*TAsm, *MRI, NULL); TCtx = new llvm::MCContext(*TAsm, *MRI, NULL);
@@ -2515,7 +2515,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() || if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() ||
I->hasCommonLinkage()) I->hasCommonLinkage())
Out << "extern "; Out << "extern ";
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
else if (I->hasDLLImportStorageClass()) else if (I->hasDLLImportStorageClass())
#else #else
else if (I->hasDLLImportLinkage()) else if (I->hasDLLImportLinkage())
@@ -2692,7 +2692,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
if (I->hasLocalLinkage()) if (I->hasLocalLinkage())
Out << "static "; Out << "static ";
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) ";
else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) ";
#else #else
@@ -3041,7 +3041,7 @@ void CWriter::printContainedStructs(llvm::Type *Ty,
if (llvm::StructType *ST = llvm::dyn_cast<llvm::StructType>(Ty)) { if (llvm::StructType *ST = llvm::dyn_cast<llvm::StructType>(Ty)) {
// Check to see if we have already printed this struct. // Check to see if we have already printed this struct.
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* LLVM 3.6+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
if (!Printed.insert(Ty).second) return; if (!Printed.insert(Ty).second) return;
#else #else
if (!Printed.insert(Ty)) return; if (!Printed.insert(Ty)) return;
@@ -3052,7 +3052,7 @@ void CWriter::printContainedStructs(llvm::Type *Ty,
Out << ";\n\n"; Out << ";\n\n";
} }
if (llvm::ArrayType *AT = llvm::dyn_cast<llvm::ArrayType>(Ty)) { if (llvm::ArrayType *AT = llvm::dyn_cast<llvm::ArrayType>(Ty)) {
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* LLVM 3.6+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
if (!Printed.insert(Ty).second) return; if (!Printed.insert(Ty).second) return;
#else #else
if (!Printed.insert(Ty)) return; if (!Printed.insert(Ty)) return;
@@ -3066,7 +3066,7 @@ void CWriter::printContainedStructs(llvm::Type *Ty,
void CWriter::printContainedArrays(llvm::ArrayType *ATy, void CWriter::printContainedArrays(llvm::ArrayType *ATy,
llvm::SmallPtrSet<llvm::Type *, 16> &Printed) { llvm::SmallPtrSet<llvm::Type *, 16> &Printed) {
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* LLVM 3.6+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
if (!Printed.insert(ATy).second) if (!Printed.insert(ATy).second)
return; return;
#else #else
@@ -3087,7 +3087,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
bool isStructReturn = F->hasStructRetAttr(); bool isStructReturn = F->hasStructRetAttr();
if (F->hasLocalLinkage()) Out << "static "; if (F->hasLocalLinkage()) Out << "static ";
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) ";
if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) ";
#else #else
@@ -3413,7 +3413,7 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) {
printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printPHICopiesForSuccessor (SI.getParent(), Succ, 2);
printBranchToBlock(SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2);
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
if (llvm::Function::iterator(Succ) == std::next(llvm::Function::iterator(SI.getParent()))) if (llvm::Function::iterator(Succ) == std::next(llvm::Function::iterator(SI.getParent())))
#else #else
if (llvm::Function::iterator(Succ) == llvm::next(llvm::Function::iterator(SI.getParent()))) if (llvm::Function::iterator(Succ) == llvm::next(llvm::Function::iterator(SI.getParent())))
@@ -3438,7 +3438,7 @@ bool CWriter::isGotoCodeNecessary(llvm::BasicBlock *From, llvm::BasicBlock *To)
/// FIXME: This should be reenabled, but loop reordering safe!! /// FIXME: This should be reenabled, but loop reordering safe!!
return true; return true;
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To))
#else #else
if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To))
@@ -4093,7 +4093,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
// All other intrinsic calls we must lower. // All other intrinsic calls we must lower.
llvm::Instruction *Before = 0; llvm::Instruction *Before = 0;
if (CI != &BB->front()) if (CI != &BB->front())
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
Before = std::prev(llvm::BasicBlock::iterator(CI)); Before = std::prev(llvm::BasicBlock::iterator(CI));
#else #else
Before = prior(llvm::BasicBlock::iterator(CI)); Before = prior(llvm::BasicBlock::iterator(CI));
@@ -4818,7 +4818,7 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) {
void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
Out << "("; Out << "(";
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
printType(Out, ACXI.getType(), false); printType(Out, ACXI.getType(), false);
Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly
#endif #endif
@@ -4829,7 +4829,7 @@ void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
Out << ", "; Out << ", ";
writeOperand(ACXI.getNewValOperand()); writeOperand(ACXI.getNewValOperand());
Out << ")"; Out << ")";
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
Out << ", true /* There is no way to learn the value of this bit inside ISPC, so making it constant */)"; Out << ", true /* There is no way to learn the value of this bit inside ISPC, so making it constant */)";
#endif #endif
Out << ")"; Out << ")";
@@ -5315,9 +5315,9 @@ bool
WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth,
const char *includeName) { const char *includeName) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // 3.2, 3.3, 3.4, 3.5, 3.6
llvm::PassManager pm; llvm::PassManager pm;
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::legacy::PassManager pm; llvm::legacy::PassManager pm;
#endif #endif
#if 0 #if 0
@@ -5327,23 +5327,23 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth,
pm.add(new llvm::TargetData(module)); pm.add(new llvm::TargetData(module));
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // 3.2, 3.3
int flags = 0; int flags = 0;
#else /* LLVM 3.4+ */ #else // LLVM 3.4+
llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None; llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None;
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5
std::string error; std::string error;
#else /* LLVM 3.6+ */ #else // LLVM 3.6+
std::error_code error; std::error_code error;
#endif #endif
llvm::tool_output_file *of = new llvm::tool_output_file(fn, error, flags); llvm::tool_output_file *of = new llvm::tool_output_file(fn, error, flags);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5
if (error.size()) { if (error.size()) {
#else /* LLVM 3.6+ */ #else // LLVM 3.6+
if (error) { if (error) {
#endif #endif
fprintf(stderr, "Error opening output file \"%s\".\n", fn); fprintf(stderr, "Error opening output file \"%s\".\n", fn);

52
ctx.cpp
View File

@@ -337,22 +337,22 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
/* If debugging is enabled, tell the debug information emission /* If debugging is enabled, tell the debug information emission
code about this new function */ code about this new function */
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
diFile = funcStartPos.GetDIFile(); diFile = funcStartPos.GetDIFile();
AssertPos(currentPos, diFile.Verify()); AssertPos(currentPos, diFile.Verify());
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
diFile = funcStartPos.GetDIFile(); diFile = funcStartPos.GetDIFile();
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 /* 3.2, 3.3 */
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU()); llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.4, 3.5, 3.6 */ #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.4, 3.5, 3.6 */
llvm::DIScope scope = llvm::DIScope(m->diCompileUnit); llvm::DIScope scope = llvm::DIScope(m->diCompileUnit);
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::DIScope *scope = m->diCompileUnit; llvm::DIScope *scope = m->diCompileUnit;
//llvm::MDScope *scope = m->diCompileUnit; //llvm::MDScope *scope = m->diCompileUnit;
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::DIType diSubprogramType; llvm::DIType diSubprogramType;
AssertPos(currentPos, scope.Verify()); AssertPos(currentPos, scope.Verify());
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
@@ -365,17 +365,17 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
AssertPos(currentPos, m->errorCount > 0); AssertPos(currentPos, m->errorCount > 0);
else { else {
diSubprogramType = functionType->GetDIType(scope); diSubprogramType = functionType->GetDIType(scope);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
AssertPos(currentPos, diSubprogramType.Verify()); AssertPos(currentPos, diSubprogramType.Verify());
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
//comming soon //comming soon
#endif #endif
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 /* 3.2, 3.3 */
llvm::DIType diSubprogramType_n = diSubprogramType; llvm::DIType diSubprogramType_n = diSubprogramType;
int flags = llvm::DIDescriptor::FlagPrototyped; int flags = llvm::DIDescriptor::FlagPrototyped;
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.4, 3.5, 3.6 */ #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.4, 3.5, 3.6 */
Assert(diSubprogramType.isCompositeType()); Assert(diSubprogramType.isCompositeType());
llvm::DICompositeType diSubprogramType_n = llvm::DICompositeType diSubprogramType_n =
static_cast<llvm::DICompositeType>(diSubprogramType); static_cast<llvm::DICompositeType>(diSubprogramType);
@@ -395,7 +395,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
bool isOptimized = (g->opt.level > 0); bool isOptimized = (g->opt.level > 0);
int firstLine = funcStartPos.first_line; int firstLine = funcStartPos.first_line;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
diSubprogram = diSubprogram =
m->diBuilder->createFunction(diFile /* scope */, funSym->name, m->diBuilder->createFunction(diFile /* scope */, funSym->name,
mangledName, diFile, mangledName, diFile,
@@ -1613,7 +1613,7 @@ lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
sConstant, var_name.c_str()); sConstant, var_name.c_str());
llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) }; llvm::Value *indices[2] = { LLVMInt32(0), LLVMInt32(0) };
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]); llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock); return llvm::GetElementPtrInst::Create(sPtr, arrayRef, "sptr", bblock);
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
return llvm::GetElementPtrInst::Create(PTYPE(sPtr), return llvm::GetElementPtrInst::Create(PTYPE(sPtr),
@@ -1657,7 +1657,7 @@ FunctionEmitContext::GetDebugPos() const {
void void
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos, FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::DIScope *scope) { llvm::DIScope *scope) {
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::DIScope *scope) { llvm::DIScope *scope) {
@@ -1672,7 +1672,7 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
// for those functions // for those functions
inst->setDebugLoc(llvm::DebugLoc::get(p.first_line, p.first_column, inst->setDebugLoc(llvm::DebugLoc::get(p.first_line, p.first_column,
scope ? scope ?
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
*scope *scope
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
scope scope
@@ -1685,7 +1685,7 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
void void
FunctionEmitContext::StartScope() { FunctionEmitContext::StartScope() {
if (m->diBuilder != NULL) { if (m->diBuilder != NULL) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::DIScope parentScope; llvm::DIScope parentScope;
llvm::DILexicalBlock lexicalBlock; llvm::DILexicalBlock lexicalBlock;
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
@@ -1712,7 +1712,7 @@ FunctionEmitContext::StartScope() {
// as the last argument // as the last argument
currentPos.first_column); currentPos.first_column);
#endif // LLVM 3.2, 3.3, 3.4 and 3.6+ #endif // LLVM 3.2, 3.3, 3.4 and 3.6+
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
AssertPos(currentPos, lexicalBlock.Verify()); AssertPos(currentPos, lexicalBlock.Verify());
debugScopes.push_back(lexicalBlock); debugScopes.push_back(lexicalBlock);
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
@@ -1732,7 +1732,7 @@ FunctionEmitContext::EndScope() {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::DIScope llvm::DIScope
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::DIScope* llvm::DIScope*
@@ -1749,7 +1749,7 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
if (m->diBuilder == NULL) if (m->diBuilder == NULL)
return; return;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::DIScope scope = GetDIScope(); llvm::DIScope scope = GetDIScope();
llvm::DIType diType = sym->type->GetDIType(scope); llvm::DIType diType = sym->type->GetDIType(scope);
AssertPos(currentPos, diType.Verify()); AssertPos(currentPos, diType.Verify());
@@ -1769,7 +1769,7 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
sym->pos.first_line, sym->pos.first_line,
diType, diType,
true /* preserve through opts */); true /* preserve through opts */);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
AssertPos(currentPos, var.Verify()); AssertPos(currentPos, var.Verify());
llvm::Instruction *declareInst = llvm::Instruction *declareInst =
m->diBuilder->insertDeclare(sym->storagePtr, var, m->diBuilder->insertDeclare(sym->storagePtr, var,
@@ -1796,7 +1796,7 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
return; return;
int flags = 0; int flags = 0;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::DIScope scope = diSubprogram; llvm::DIScope scope = diSubprogram;
llvm::DIType diType = sym->type->GetDIType(scope); llvm::DIType diType = sym->type->GetDIType(scope);
AssertPos(currentPos, diType.Verify()); AssertPos(currentPos, diType.Verify());
@@ -1818,7 +1818,7 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
true /* preserve through opts */, true /* preserve through opts */,
flags, flags,
argNum + 1); argNum + 1);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
AssertPos(currentPos, var.Verify()); AssertPos(currentPos, var.Verify());
llvm::Instruction *declareInst = llvm::Instruction *declareInst =
m->diBuilder->insertDeclare(sym->storagePtr, var, m->diBuilder->insertDeclare(sym->storagePtr, var,
@@ -2444,7 +2444,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index,
// uniform, so just emit the regular LLVM GEP instruction // uniform, so just emit the regular LLVM GEP instruction
llvm::Value *ind[1] = { index }; llvm::Value *ind[1] = { index };
llvm::ArrayRef<llvm::Value *> arrayRef(&ind[0], &ind[1]); llvm::ArrayRef<llvm::Value *> arrayRef(&ind[0], &ind[1]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::Instruction *inst = llvm::Instruction *inst =
llvm::GetElementPtrInst::Create(basePtr, arrayRef, llvm::GetElementPtrInst::Create(basePtr, arrayRef,
name ? name : "gep", bblock); name ? name : "gep", bblock);
@@ -2511,7 +2511,7 @@ FunctionEmitContext::GetElementPtrInst(llvm::Value *basePtr, llvm::Value *index0
// uniform, so just emit the regular LLVM GEP instruction // uniform, so just emit the regular LLVM GEP instruction
llvm::Value *indices[2] = { index0, index1 }; llvm::Value *indices[2] = { index0, index1 };
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]); llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
llvm::Instruction *inst = llvm::Instruction *inst =
llvm::GetElementPtrInst::Create(basePtr, arrayRef, llvm::GetElementPtrInst::Create(basePtr, arrayRef,
name ? name : "gep", bblock); name ? name : "gep", bblock);
@@ -2612,7 +2612,7 @@ FunctionEmitContext::AddElementOffset(llvm::Value *fullBasePtr, int elementNum,
// If the pointer is uniform, we can use the regular LLVM GEP. // If the pointer is uniform, we can use the regular LLVM GEP.
llvm::Value *offsets[2] = { LLVMInt32(0), LLVMInt32(elementNum) }; llvm::Value *offsets[2] = { LLVMInt32(0), LLVMInt32(elementNum) };
llvm::ArrayRef<llvm::Value *> arrayRef(&offsets[0], &offsets[2]); llvm::ArrayRef<llvm::Value *> arrayRef(&offsets[0], &offsets[2]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
resultPtr = resultPtr =
llvm::GetElementPtrInst::Create(basePtr, arrayRef, llvm::GetElementPtrInst::Create(basePtr, arrayRef,
name ? name : "struct_offset", bblock); name ? name : "struct_offset", bblock);
@@ -2923,7 +2923,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) {
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(v); llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(v);
if (inst == NULL) if (inst == NULL)
return; return;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */
llvm::Value *str = llvm::MDString::get(*g->ctx, pos.name); llvm::Value *str = llvm::MDString::get(*g->ctx, pos.name);
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::MDString *str = llvm::MDString::get(*g->ctx, pos.name); llvm::MDString *str = llvm::MDString::get(*g->ctx, pos.name);
@@ -2931,7 +2931,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) {
llvm::MDNode *md = llvm::MDNode::get(*g->ctx, str); llvm::MDNode *md = llvm::MDNode::get(*g->ctx, str);
inst->setMetadata("filename", md); inst->setMetadata("filename", md);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */
llvm::Value *first_line = LLVMInt32(pos.first_line); llvm::Value *first_line = LLVMInt32(pos.first_line);
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::Metadata *first_line = llvm::ConstantAsMetadata::get(LLVMInt32(pos.first_line)); llvm::Metadata *first_line = llvm::ConstantAsMetadata::get(LLVMInt32(pos.first_line));
@@ -2939,7 +2939,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) {
md = llvm::MDNode::get(*g->ctx, first_line); md = llvm::MDNode::get(*g->ctx, first_line);
inst->setMetadata("first_line", md); inst->setMetadata("first_line", md);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */
llvm::Value *first_column = LLVMInt32(pos.first_column); llvm::Value *first_column = LLVMInt32(pos.first_column);
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::Metadata *first_column = llvm::ConstantAsMetadata::get(LLVMInt32(pos.first_column)); llvm::Metadata *first_column = llvm::ConstantAsMetadata::get(LLVMInt32(pos.first_column));
@@ -2947,7 +2947,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) {
md = llvm::MDNode::get(*g->ctx, first_column); md = llvm::MDNode::get(*g->ctx, first_column);
inst->setMetadata("first_column", md); inst->setMetadata("first_column", md);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */
llvm::Value *last_line = LLVMInt32(pos.last_line); llvm::Value *last_line = LLVMInt32(pos.last_line);
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::Metadata *last_line = llvm::ConstantAsMetadata::get(LLVMInt32(pos.last_line)); llvm::Metadata *last_line = llvm::ConstantAsMetadata::get(LLVMInt32(pos.last_line));
@@ -2955,7 +2955,7 @@ FunctionEmitContext::addGSMetadata(llvm::Value *v, SourcePos pos) {
md = llvm::MDNode::get(*g->ctx, last_line); md = llvm::MDNode::get(*g->ctx, last_line);
inst->setMetadata("last_line", md); inst->setMetadata("last_line", md);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4, 3.5 */
llvm::Value *last_column = LLVMInt32(pos.last_column); llvm::Value *last_column = LLVMInt32(pos.last_column);
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::Metadata *last_column = llvm::ConstantAsMetadata::get(LLVMInt32(pos.last_column)); llvm::Metadata *last_column = llvm::ConstantAsMetadata::get(LLVMInt32(pos.last_column));

14
ctx.h
View File

@@ -40,17 +40,17 @@
#include "ispc.h" #include "ispc.h"
#include <map> #include <map>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/InstrTypes.h> #include <llvm/InstrTypes.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#else /* >= 3.3 */ #else // 3.3+
#include <llvm/IR/InstrTypes.h> #include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h> #include <llvm/IR/Instructions.h>
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4
#include <llvm/DebugInfo.h> #include <llvm/DebugInfo.h>
#include <llvm/DIBuilder.h> #include <llvm/DIBuilder.h>
#else /* >= 3.5 */ #else // 3.5+
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
#include <llvm/IR/DIBuilder.h> #include <llvm/IR/DIBuilder.h>
#endif #endif
@@ -352,7 +352,7 @@ public:
Instructions stored using Value pointers; the code here returns Instructions stored using Value pointers; the code here returns
silently if it's not actually given an instruction. */ silently if it's not actually given an instruction. */
void AddDebugPos(llvm::Value *instruction, const SourcePos *pos = NULL, void AddDebugPos(llvm::Value *instruction, const SourcePos *pos = NULL,
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIScope *scope = NULL); llvm::DIScope *scope = NULL);
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::DIScope *scope = NULL); llvm::DIScope *scope = NULL);
@@ -369,7 +369,7 @@ public:
/** Returns the llvm::DIScope corresponding to the current program /** Returns the llvm::DIScope corresponding to the current program
scope. */ scope. */
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIScope GetDIScope() const; llvm::DIScope GetDIScope() const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIScope *GetDIScope() const; llvm::DIScope *GetDIScope() const;
@@ -684,7 +684,7 @@ private:
emitted. */ emitted. */
std::vector<CFInfo *> controlFlowInfo; std::vector<CFInfo *> controlFlowInfo;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
/** DIFile object corresponding to the source file where the current /** DIFile object corresponding to the source file where the current
function was defined (used for debugging info). */ function was defined (used for debugging info). */
llvm::DIFile diFile; llvm::DIFile diFile;

View File

@@ -74,7 +74,7 @@
#include <llvm/IR/CallingConv.h> #include <llvm/IR/CallingConv.h>
#endif #endif
#include <llvm/ExecutionEngine/GenericValue.h> #include <llvm/ExecutionEngine/GenericValue.h>
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
#include <llvm/IR/InstIterator.h> #include <llvm/IR/InstIterator.h>
#else #else
#include <llvm/Support/InstIterator.h> #include <llvm/Support/InstIterator.h>

View File

@@ -46,7 +46,7 @@
#include "util.h" #include "util.h"
#include <stdio.h> #include <stdio.h>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2
#ifdef ISPC_NVPTX_ENABLED #ifdef ISPC_NVPTX_ENABLED
#include <llvm/Metadata.h> #include <llvm/Metadata.h>
#endif /* ISPC_NVPTX_ENABLED */ #endif /* ISPC_NVPTX_ENABLED */
@@ -67,9 +67,9 @@
#include <llvm/IR/Intrinsics.h> #include <llvm/IR/Intrinsics.h>
#include <llvm/IR/DerivedTypes.h> #include <llvm/IR/DerivedTypes.h>
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
#endif #endif
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
@@ -78,7 +78,7 @@
#include <llvm/Support/FileUtilities.h> #include <llvm/Support/FileUtilities.h>
#include <llvm/Target/TargetMachine.h> #include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h> #include <llvm/Target/TargetOptions.h>
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
#include <llvm/IR/Verifier.h> #include <llvm/IR/Verifier.h>
#include <llvm/IR/IRPrintingPasses.h> #include <llvm/IR/IRPrintingPasses.h>
#include <llvm/IR/CFG.h> #include <llvm/IR/CFG.h>
@@ -360,7 +360,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
{ {
llvm::NamedMDNode* annotations = llvm::NamedMDNode* annotations =
m->module->getOrInsertNamedMetadata("nvvm.annotations"); m->module->getOrInsertNamedMetadata("nvvm.annotations");
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* 3.6+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
llvm::SmallVector<llvm::Metadata*, 3> av; llvm::SmallVector<llvm::Metadata*, 3> av;
av.push_back(llvm::ValueAsMetadata::get(function)); av.push_back(llvm::ValueAsMetadata::get(function));
av.push_back(llvm::MDString::get(*g->ctx, "kernel")); av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
@@ -392,9 +392,9 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
// isn't worth the code bloat / overhead. // isn't worth the code bloat / overhead.
bool checkMask = (type->isTask == true) || bool checkMask = (type->isTask == true) ||
( (
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false) (function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
(function->getAttributes().getFnAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::AlwaysInline) == false) (function->getAttributes().getFnAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::AlwaysInline) == false)
#endif #endif
&& &&
@@ -577,7 +577,7 @@ Function::GenerateIR() {
{ {
llvm::NamedMDNode* annotations = llvm::NamedMDNode* annotations =
m->module->getOrInsertNamedMetadata("nvvm.annotations"); m->module->getOrInsertNamedMetadata("nvvm.annotations");
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 /* 3.6+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
llvm::SmallVector<llvm::Metadata*, 3> av; llvm::SmallVector<llvm::Metadata*, 3> av;
av.push_back(llvm::ValueAsMetadata::get(function)); av.push_back(llvm::ValueAsMetadata::get(function));

View File

@@ -338,7 +338,7 @@ public:
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 // LLVM 3.2 or 3.3 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // LLVM 3.2 or 3.3
#define CPU_Silvermont CPU_Nehalem #define CPU_Silvermont CPU_Nehalem
#else /* LLVM 3.4+ */ #else /* LLVM 3.4+ */
compat[CPU_Silvermont] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn, compat[CPU_Silvermont] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn,
@@ -353,7 +353,7 @@ public:
CPU_Haswell, CPU_Broadwell, CPU_None); CPU_Haswell, CPU_Broadwell, CPU_None);
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // LLVM 3.2, 3.3, 3.4 or 3.5 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // LLVM 3.2, 3.3, 3.4 or 3.5
#define CPU_Broadwell CPU_Haswell #define CPU_Broadwell CPU_Haswell
#else /* LLVM 3.6+ */ #else /* LLVM 3.6+ */
compat[CPU_Broadwell] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn, compat[CPU_Broadwell] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn,
@@ -446,7 +446,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
m_is32Bit(true), m_is32Bit(true),
m_cpu(""), m_cpu(""),
m_attributes(""), m_attributes(""),
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 /* ! 3.2 */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3
m_tf_attributes(NULL), m_tf_attributes(NULL),
#endif #endif
m_nativeVectorWidth(-1), m_nativeVectorWidth(-1),
@@ -1020,7 +1020,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
#endif #endif
if (g->opt.disableFMA == false) if (g->opt.disableFMA == false)
options.AllowFPOpFusion = llvm::FPOpFusion::Fast; options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
#ifdef ISPC_IS_WINDOWS #ifdef ISPC_IS_WINDOWS
if (strcmp("x86", arch) == 0) { if (strcmp("x86", arch) == 0) {
// Workaround for issue #503 (LLVM issue 14646). // Workaround for issue #503 (LLVM issue 14646).
@@ -1034,7 +1034,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
relocModel); relocModel);
Assert(m_targetMachine != NULL); Assert(m_targetMachine != NULL);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
m_targetMachine->setAsmVerbosityDefault(true); m_targetMachine->setAsmVerbosityDefault(true);
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
m_targetMachine->Options.MCOptions.AsmVerbose = true; m_targetMachine->Options.MCOptions.AsmVerbose = true;
@@ -1324,7 +1324,7 @@ Target::SizeOf(llvm::Type *type,
llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::PointerType *ptrType = llvm::PointerType::get(type, 0);
llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType);
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]); llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::Instruction *gep = llvm::Instruction *gep =
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep", llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep",
insertAtEnd); insertAtEnd);
@@ -1362,7 +1362,7 @@ Target::StructOffset(llvm::Type *type, int element,
llvm::PointerType *ptrType = llvm::PointerType::get(type, 0); llvm::PointerType *ptrType = llvm::PointerType::get(type, 0);
llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType); llvm::Value *voidPtr = llvm::ConstantPointerNull::get(ptrType);
llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]); llvm::ArrayRef<llvm::Value *> arrayRef(&indices[0], &indices[2]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::Instruction *gep = llvm::Instruction *gep =
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep", llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep",
insertAtEnd); insertAtEnd);
@@ -1483,7 +1483,7 @@ SourcePos::SourcePos(const char *n, int fl, int fc, int ll, int lc) {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIFile llvm::DIFile
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::DIFile* llvm::DIFile*
@@ -1492,7 +1492,7 @@ llvm::DIFile*
SourcePos::GetDIFile() const { SourcePos::GetDIFile() const {
std::string directory, filename; std::string directory, filename;
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename); GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIFile ret = m->diBuilder->createFile(filename, directory); llvm::DIFile ret = m->diBuilder->createFile(filename, directory);
Assert(ret.Verify()); Assert(ret.Verify());
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */

6
ispc.h
View File

@@ -86,11 +86,11 @@ namespace llvm {
class TargetMachine; class TargetMachine;
class Type; class Type;
class Value; class Value;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
class DIFile; class DIFile;
class DIType; class DIType;
class DIDescriptor; class DIDescriptor;
#else // LLVM 3.7++ #else // LLVM 3.7+
class DIFile; class DIFile;
class DIType; class DIType;
class DIScope; class DIScope;
@@ -144,7 +144,7 @@ struct SourcePos {
/** Prints the filename and line/column range to standard output. */ /** Prints the filename and line/column range to standard output. */
void Print() const; void Print() const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
/** Returns a LLVM DIFile object that represents the SourcePos's file */ /** Returns a LLVM DIFile object that represents the SourcePos's file */
llvm::DIFile GetDIFile() const; llvm::DIFile GetDIFile() const;
#else #else

View File

@@ -61,4 +61,8 @@
#define ISPC_LLVM_VERSION_STRING __ispc__xstr(LLVM_VERSION_MAJOR) "." __ispc__xstr(LLVM_VERSION_MINOR) #define ISPC_LLVM_VERSION_STRING __ispc__xstr(LLVM_VERSION_MAJOR) "." __ispc__xstr(LLVM_VERSION_MINOR)
#if ISPC_LLVM_VERSION < OLDEST_SUPPORTED_LLVM || ISPC_LLVM_VERSION > LATEST_SUPPORTED_LLVM
#error "Unhandled LLVM version"
#endif
#endif // ISPC_VERSION_H #endif // ISPC_VERSION_H

View File

@@ -39,12 +39,12 @@
#define ISPC_LLVMUTIL_H 1 #define ISPC_LLVMUTIL_H 1
#include "ispc_version.h" #include "ispc_version.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/LLVMContext.h> #include <llvm/LLVMContext.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h> #include <llvm/DerivedTypes.h>
#include <llvm/Constants.h> #include <llvm/Constants.h>
#else /* >= 3.3 */ #else // 3.3+
#include <llvm/IR/LLVMContext.h> #include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Type.h> #include <llvm/IR/Type.h>
#include <llvm/IR/DerivedTypes.h> #include <llvm/IR/DerivedTypes.h>

View File

@@ -158,8 +158,7 @@ devUsage(int ret) {
printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n"); printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n");
printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n"); printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n");
printf(" [--debug-phase=<value>]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n"); printf(" [--debug-phase=<value>]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n");
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 || ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // 3.4, 3.5
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.4, 3.5 */
printf(" [--debug-ir=<value>]\t\tSet optimization phase to generate debugIR after it\n"); printf(" [--debug-ir=<value>]\t\tSet optimization phase to generate debugIR after it\n");
#endif #endif
printf(" [--off-phase=<value>]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n"); printf(" [--off-phase=<value>]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n");
@@ -556,7 +555,7 @@ int main(int Argc, char *Argv[]) {
g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase="));
} }
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.4, 3.5 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 || ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // 3.4, 3.5
else if (strncmp(argv[i], "--debug-ir=", 11) == 0) { else if (strncmp(argv[i], "--debug-ir=", 11) == 0) {
g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir=")); g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir="));
} }

View File

@@ -91,9 +91,9 @@
#endif #endif
#endif /* ISPC_NVPTX_ENABLED */ #endif /* ISPC_NVPTX_ENABLED */
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
#endif #endif
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
@@ -169,9 +169,9 @@ static void
lStripUnusedDebugInfo(llvm::Module *module) { lStripUnusedDebugInfo(llvm::Module *module) {
if (g->generateDebuggingSymbols == false) if (g->generateDebuggingSymbols == false)
return; return;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* <= 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // <= 3.5
std::set<llvm::Value *> SPall; std::set<llvm::Value *> SPall;
#else /* LLVM 3.6+ */ #else // LLVM 3.6+
std::set<llvm::Metadata *> SPall; std::set<llvm::Metadata *> SPall;
#endif #endif
// OK, now we are to determine which functions actually survived the // OK, now we are to determine which functions actually survived the
@@ -190,7 +190,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
while (node) { while (node) {
// get the scope of the current instruction`s location // get the scope of the current instruction`s location
// node becomes NULL if this was the original location // node becomes NULL if this was the original location
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* <= 3.6 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6 // <= 3.6
llvm::DILocation dloc(node); llvm::DILocation dloc(node);
llvm::DIScope scope = dloc.getScope(); llvm::DIScope scope = dloc.getScope();
node = dloc.getOrigLocation(); node = dloc.getOrigLocation();
@@ -205,7 +205,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
else break; else break;
} }
if (scope.isSubprogram()) { if (scope.isSubprogram()) {
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::DILocation *dloc = llvm::cast<llvm::DILocation>(node); llvm::DILocation *dloc = llvm::cast<llvm::DILocation>(node);
llvm::DIScope *scope = dloc->getScope(); llvm::DIScope *scope = dloc->getScope();
//llvm::MDLocation *dloc = llvm::cast<llvm::MDLocation>(node); //llvm::MDLocation *dloc = llvm::cast<llvm::MDLocation>(node);
@@ -233,7 +233,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) { if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) { for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) {
llvm::MDNode *cuNode = cuNodes->getOperand(i); llvm::MDNode *cuNode = cuNodes->getOperand(i);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DICompileUnit cu(cuNode); llvm::DICompileUnit cu(cuNode);
llvm::DIArray subprograms = cu.getSubprograms(); llvm::DIArray subprograms = cu.getSubprograms();
if (subprograms.getNumElements() == 0) { if (subprograms.getNumElements() == 0) {
@@ -246,7 +246,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
#endif #endif
continue; continue;
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
std::set<llvm::Value *> SPset; std::set<llvm::Value *> SPset;
std::vector<llvm::Value *> usedSubprograms; std::vector<llvm::Value *> usedSubprograms;
#else /* LLVM 3.6+ */ #else /* LLVM 3.6+ */
@@ -255,16 +255,16 @@ lStripUnusedDebugInfo(llvm::Module *module) {
#endif #endif
// determine what functions of those extracted belong to the unit // determine what functions of those extracted belong to the unit
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
for (unsigned j = 0, je = subprograms.getNumElements(); j != je; ++j) for (unsigned j = 0, je = subprograms.getNumElements(); j != je; ++j)
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
for (unsigned j = 0, je = subprograms.size(); j != je; ++j) for (unsigned j = 0, je = subprograms.size(); j != je; ++j)
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
SPset.insert(subprograms->getOperand(j)); SPset.insert(subprograms->getOperand(j));
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6
SPset.insert(subprograms.getElement(j)); SPset.insert(subprograms.getElement(j));
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
SPset.insert(subprograms [j]); SPset.insert(subprograms [j]);
#endif #endif
@@ -274,7 +274,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
Debug(SourcePos(), "%d / %d functions left in module with debug " Debug(SourcePos(), "%d / %d functions left in module with debug "
"info.", (int)usedSubprograms.size(), "info.", (int)usedSubprograms.size(),
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
(int)subprograms.getNumElements()); (int)subprograms.getNumElements());
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
(int)subprograms.size()); (int)subprograms.size());
@@ -299,7 +299,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
// stuff and remove it later on. Removing it is useful, as it // stuff and remove it later on. Removing it is useful, as it
// reduces size of the binary significantly (manyfold for small // reduces size of the binary significantly (manyfold for small
// programs). // programs).
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2
llvm::MDNode *nodeSPMD = llvm::MDNode *nodeSPMD =
llvm::dyn_cast<llvm::MDNode>(cuNode->getOperand(12)); llvm::dyn_cast<llvm::MDNode>(cuNode->getOperand(12));
Assert(nodeSPMD != NULL); Assert(nodeSPMD != NULL);
@@ -317,7 +317,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
llvm::MDNode *replNode = llvm::MDNode *replNode =
llvm::MDNode::get(*g->ctx, llvm::ArrayRef<llvm::Value *>(usedSubprogramsArray)); llvm::MDNode::get(*g->ctx, llvm::ArrayRef<llvm::Value *>(usedSubprogramsArray));
cuNode->replaceOperandWith(12, replNode); cuNode->replaceOperandWith(12, replNode);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.3, 3.4, 3.5 */ #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.3, 3.4, 3.5
llvm::MDNode *nodeSPMDArray = llvm::MDNode *nodeSPMDArray =
llvm::dyn_cast<llvm::MDNode>(cuNode->getOperand(9)); llvm::dyn_cast<llvm::MDNode>(cuNode->getOperand(9));
Assert(nodeSPMDArray != NULL); Assert(nodeSPMDArray != NULL);
@@ -331,7 +331,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
llvm::MDNode *replNode = llvm::MDNode *replNode =
m->diBuilder->getOrCreateArray(llvm::ArrayRef<llvm::Value *>(usedSubprograms)); m->diBuilder->getOrCreateArray(llvm::ArrayRef<llvm::Value *>(usedSubprograms));
cuNode->replaceOperandWith(9, replNode); cuNode->replaceOperandWith(9, replNode);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */ #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // 3.6
llvm::DIArray nodeSPs = cu.getSubprograms(); llvm::DIArray nodeSPs = cu.getSubprograms();
Assert(nodeSPs.getNumElements() == subprograms.getNumElements()); Assert(nodeSPs.getNumElements() == subprograms.getNumElements());
for (int i = 0; i < (int)nodeSPs.getNumElements(); ++i) for (int i = 0; i < (int)nodeSPs.getNumElements(); ++i)
@@ -342,7 +342,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
llvm::MDNode *replNode = llvm::MDNode::get(module->getContext(), llvm::MDNode *replNode = llvm::MDNode::get(module->getContext(),
llvm::ArrayRef<llvm::Metadata *>(usedSubprograms)); llvm::ArrayRef<llvm::Metadata *>(usedSubprograms));
cu.replaceSubprograms(llvm::DIArray(replNode)); cu.replaceSubprograms(llvm::DIArray(replNode));
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::DISubprogramArray nodeSPs = cu->getSubprograms(); llvm::DISubprogramArray nodeSPs = cu->getSubprograms();
//llvm::MDSubprogramArray nodeSPs = cu->getSubprograms(); //llvm::MDSubprogramArray nodeSPs = cu->getSubprograms();
Assert(nodeSPs.size() == subprograms.size()); Assert(nodeSPs.size() == subprograms.size());
@@ -420,7 +420,7 @@ Module::Module(const char *fn) {
sprintf(producerString, "ispc version %s (built on %s)", sprintf(producerString, "ispc version %s (built on %s)",
ISPC_VERSION, __DATE__); ISPC_VERSION, __DATE__);
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 /* 3.4+ */ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+
diCompileUnit = diCompileUnit =
#endif // LLVM_3_4+ #endif // LLVM_3_4+
diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */ diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */
@@ -700,7 +700,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
} }
if (diBuilder) { if (diBuilder) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.2, 3.3, 3.4, 3.5 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5 // 3.2, 3.3, 3.4, 3.5
llvm::DIFile file = pos.GetDIFile(); llvm::DIFile file = pos.GetDIFile();
llvm::DIGlobalVariable var = diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = diBuilder->createGlobalVariable(
name, name,
@@ -709,7 +709,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
sym->type->GetDIType(file), sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC), (sym->storageClass == SC_STATIC),
sym->storagePtr); sym->storagePtr);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */ #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // 3.6
llvm::DIFile file = pos.GetDIFile(); llvm::DIFile file = pos.GetDIFile();
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
@@ -722,7 +722,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
sym->type->GetDIType(file), sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC), (sym->storageClass == SC_STATIC),
sym_const_storagePtr); sym_const_storagePtr);
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::DIFile *file = pos.GetDIFile(); llvm::DIFile *file = pos.GetDIFile();
//llvm::MDFile *file = pos.GetDIFile(); //llvm::MDFile *file = pos.GetDIFile();
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
@@ -737,9 +737,9 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
(sym->storageClass == SC_STATIC), (sym->storageClass == SC_STATIC),
sym_const_storagePtr); sym_const_storagePtr);
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
Assert(var.Verify()); Assert(var.Verify());
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
//comming soon //comming soon
#endif #endif
} }
@@ -1445,28 +1445,28 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
llvm::TargetMachine::CodeGenFileType fileType = (outputType == Object) ? llvm::TargetMachine::CodeGenFileType fileType = (outputType == Object) ?
llvm::TargetMachine::CGFT_ObjectFile : llvm::TargetMachine::CGFT_AssemblyFile; llvm::TargetMachine::CGFT_ObjectFile : llvm::TargetMachine::CGFT_AssemblyFile;
bool binary = (fileType == llvm::TargetMachine::CGFT_ObjectFile); bool binary = (fileType == llvm::TargetMachine::CGFT_ObjectFile);
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3 // 3.2, 3.3
unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0; unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0;
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.4 */ #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_4 // 3.4
llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary : llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary :
llvm::sys::fs::F_None; llvm::sys::fs::F_None;
#else /* 3.5+ */ #else // LLVM 3.5+
llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_None : llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_None :
llvm::sys::fs::F_Text; llvm::sys::fs::F_Text;
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
std::string error; std::string error;
#else /* LLVM 3.6+ */ #else // LLVM 3.6+
std::error_code error; std::error_code error;
#endif #endif
llvm::tool_output_file *of = new llvm::tool_output_file(outFileName, error, flags); llvm::tool_output_file *of = new llvm::tool_output_file(outFileName, error, flags);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
if (error.size()) { if (error.size()) {
#else /* LLVM 3.6+ */ #else // LLVM 3.6+
if (error) { if (error) {
#endif #endif
@@ -1474,25 +1474,25 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
return false; return false;
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::PassManager pm; llvm::PassManager pm;
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::legacy::PassManager pm; llvm::legacy::PassManager pm;
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4
pm.add(new llvm::DataLayout(*g->target->getDataLayout())); pm.add(new llvm::DataLayout(*g->target->getDataLayout()));
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.5 */ #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // 3.5
pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */ #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6 // 3.6
llvm::DataLayoutPass *dlp= new llvm::DataLayoutPass(); llvm::DataLayoutPass *dlp= new llvm::DataLayoutPass();
dlp->doInitialization(*module); dlp->doInitialization(*module);
pm.add(dlp); pm.add(dlp);
#endif // LLVM 3.7+ doesn't have DataLayoutPass anymore. #endif // LLVM 3.7+ doesn't have DataLayoutPass anymore.
{ {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::formatted_raw_ostream fos(of->os()); llvm::formatted_raw_ostream fos(of->os());
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::raw_fd_ostream &fos(of->os()); llvm::raw_fd_ostream &fos(of->os());
#endif #endif
if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) { if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) {
@@ -2434,9 +2434,9 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
inst.setDiagnostics(diagEngine); inst.setDiagnostics(diagEngine);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4
clang::TargetOptions &options = inst.getTargetOpts(); clang::TargetOptions &options = inst.getTargetOpts();
#else /* LLVM 3.5+ */ #else // LLVM 3.5+
const std::shared_ptr< clang::TargetOptions > &options = const std::shared_ptr< clang::TargetOptions > &options =
std::make_shared< clang::TargetOptions >(inst.getTargetOpts()); std::make_shared< clang::TargetOptions >(inst.getTargetOpts());
#endif #endif
@@ -2446,19 +2446,19 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
triple.setTriple(llvm::sys::getDefaultTargetTriple()); triple.setTriple(llvm::sys::getDefaultTargetTriple());
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */ #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.2, 3.3, 3.4
options.Triple = triple.getTriple(); options.Triple = triple.getTriple();
#else /* LLVM 3.5+ */ #else // LLVM 3.5+
options->Triple = triple.getTriple(); options->Triple = triple.getTriple();
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */ #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2 // 3.2
clang::TargetInfo *target = clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.3, 3.4 */ #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_4 // 3.3, 3.4
clang::TargetInfo *target = clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options); clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options);
#else /* LLVM 3.5+ */ #else // LLVM 3.5+
clang::TargetInfo *target = clang::TargetInfo *target =
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
#endif #endif
@@ -2908,9 +2908,9 @@ static void lEmitDispatchModule(llvm::Module *module,
// Do some rudimentary cleanup of the final result and make sure that // Do some rudimentary cleanup of the final result and make sure that
// the module is all ok. // the module is all ok.
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::PassManager optPM; llvm::PassManager optPM;
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
llvm::legacy::PassManager optPM; llvm::legacy::PassManager optPM;
#endif #endif
optPM.add(llvm::createGlobalDCEPass()); optPM.add(llvm::createGlobalDCEPass());

View File

@@ -41,7 +41,7 @@
#include "ispc.h" #include "ispc.h"
#include "ast.h" #include "ast.h"
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_4
#include <llvm/DebugInfo.h> #include <llvm/DebugInfo.h>
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
@@ -160,7 +160,7 @@ public:
/** The diBuilder manages generating debugging information */ /** The diBuilder manages generating debugging information */
llvm::DIBuilder *diBuilder; llvm::DIBuilder *diBuilder;
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DICompileUnit diCompileUnit; llvm::DICompileUnit diCompileUnit;
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7
llvm::DICompileUnit* diCompileUnit; llvm::DICompileUnit* diCompileUnit;

60
opt.cpp
View File

@@ -48,7 +48,7 @@
#include <set> #include <set>
#include <llvm/Pass.h> #include <llvm/Pass.h>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
#include <llvm/Intrinsics.h> #include <llvm/Intrinsics.h>
@@ -58,7 +58,7 @@
#ifdef ISPC_NVPTX_ENABLED #ifdef ISPC_NVPTX_ENABLED
#include <llvm/InlineAsm.h> #include <llvm/InlineAsm.h>
#endif /* ISPC_NVPTX_ENABLED */ #endif /* ISPC_NVPTX_ENABLED */
#else /* >= 3.3 */ #else // LLVM 3.3+
#include <llvm/IR/Module.h> #include <llvm/IR/Module.h>
#include <llvm/IR/Instructions.h> #include <llvm/IR/Instructions.h>
#include <llvm/IR/Intrinsics.h> #include <llvm/IR/Intrinsics.h>
@@ -72,9 +72,9 @@
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+ #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+
#include <llvm/Transforms/Instrumentation.h> #include <llvm/Transforms/Instrumentation.h>
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#else /* >= 3.7 */ #else // LLVM 3.7+
#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/LegacyPassManager.h"
#endif #endif
#include <llvm/PassRegistry.h> #include <llvm/PassRegistry.h>
@@ -83,16 +83,16 @@
#include <llvm/IR/IRPrintingPasses.h> #include <llvm/IR/IRPrintingPasses.h>
#include <llvm/IR/PatternMatch.h> #include <llvm/IR/PatternMatch.h>
#include <llvm/IR/DebugInfo.h> #include <llvm/IR/DebugInfo.h>
#else /* < 3.5 */ #else // < 3.5
#include <llvm/Analysis/Verifier.h> #include <llvm/Analysis/Verifier.h>
#include <llvm/Assembly/PrintModulePass.h> #include <llvm/Assembly/PrintModulePass.h>
#include <llvm/Support/PatternMatch.h> #include <llvm/Support/PatternMatch.h>
#include <llvm/DebugInfo.h> #include <llvm/DebugInfo.h>
#endif #endif
#include <llvm/Analysis/ConstantFolding.h> #include <llvm/Analysis/ConstantFolding.h>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
#include <llvm/Target/TargetLibraryInfo.h> #include <llvm/Target/TargetLibraryInfo.h>
#else /* >= 3.7 */ #else // LLVM 3.7+
#include <llvm/Analysis/TargetLibraryInfo.h> #include <llvm/Analysis/TargetLibraryInfo.h>
#endif #endif
#include <llvm/ADT/Triple.h> #include <llvm/ADT/Triple.h>
@@ -101,9 +101,9 @@
#include <llvm/Transforms/IPO.h> #include <llvm/Transforms/IPO.h>
#include <llvm/Transforms/Utils/BasicBlockUtils.h> #include <llvm/Transforms/Utils/BasicBlockUtils.h>
#include <llvm/Target/TargetOptions.h> #include <llvm/Target/TargetOptions.h>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/DataLayout.h> #include <llvm/DataLayout.h>
#else /* LLVM 3.3+ */ #else // LLVM 3.3+
#include <llvm/IR/DataLayout.h> #include <llvm/IR/DataLayout.h>
#include <llvm/Analysis/TargetTransformInfo.h> #include <llvm/Analysis/TargetTransformInfo.h>
#endif #endif
@@ -238,7 +238,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) {
llvm::MDString *str = llvm::dyn_cast<llvm::MDString>(filename->getOperand(0)); llvm::MDString *str = llvm::dyn_cast<llvm::MDString>(filename->getOperand(0));
Assert(str); Assert(str);
llvm::ConstantInt *first_lnum = llvm::ConstantInt *first_lnum =
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::dyn_cast<llvm::ConstantInt>(first_line->getOperand(0)); llvm::dyn_cast<llvm::ConstantInt>(first_line->getOperand(0));
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::mdconst::extract<llvm::ConstantInt>(first_line->getOperand(0)); llvm::mdconst::extract<llvm::ConstantInt>(first_line->getOperand(0));
@@ -246,7 +246,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) {
Assert(first_lnum); Assert(first_lnum);
llvm::ConstantInt *first_colnum = llvm::ConstantInt *first_colnum =
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::dyn_cast<llvm::ConstantInt>(first_column->getOperand(0)); llvm::dyn_cast<llvm::ConstantInt>(first_column->getOperand(0));
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::mdconst::extract<llvm::ConstantInt>(first_column->getOperand(0)); llvm::mdconst::extract<llvm::ConstantInt>(first_column->getOperand(0));
@@ -254,7 +254,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) {
Assert(first_column); Assert(first_column);
llvm::ConstantInt *last_lnum = llvm::ConstantInt *last_lnum =
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::dyn_cast<llvm::ConstantInt>(last_line->getOperand(0)); llvm::dyn_cast<llvm::ConstantInt>(last_line->getOperand(0));
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::mdconst::extract<llvm::ConstantInt>(last_line->getOperand(0)); llvm::mdconst::extract<llvm::ConstantInt>(last_line->getOperand(0));
@@ -262,7 +262,7 @@ lGetSourcePosFromMetadata(const llvm::Instruction *inst, SourcePos *pos) {
Assert(last_lnum); Assert(last_lnum);
llvm::ConstantInt *last_colnum = llvm::ConstantInt *last_colnum =
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::dyn_cast<llvm::ConstantInt>(last_column->getOperand(0)); llvm::dyn_cast<llvm::ConstantInt>(last_column->getOperand(0));
#else /* LLVN 3.6+ */ #else /* LLVN 3.6+ */
llvm::mdconst::extract<llvm::ConstantInt>(last_column->getOperand(0)); llvm::mdconst::extract<llvm::ConstantInt>(last_column->getOperand(0));
@@ -330,10 +330,10 @@ lGEPInst(llvm::Value *ptr, llvm::Value *offset, const char *name,
llvm::Instruction *insertBefore) { llvm::Instruction *insertBefore) {
llvm::Value *index[1] = { offset }; llvm::Value *index[1] = { offset };
llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]); llvm::ArrayRef<llvm::Value *> arrayRef(&index[0], &index[1]);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::GetElementPtrInst::Create(ptr, arrayRef, name, return llvm::GetElementPtrInst::Create(ptr, arrayRef, name,
insertBefore); insertBefore);
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
return llvm::GetElementPtrInst::Create(PTYPE(ptr), ptr, arrayRef, return llvm::GetElementPtrInst::Create(PTYPE(ptr), ptr, arrayRef,
name, insertBefore); name, insertBefore);
#endif #endif
@@ -466,13 +466,13 @@ public:
DebugPassManager():number(0){} DebugPassManager():number(0){}
void add(llvm::Pass * P, int stage); void add(llvm::Pass * P, int stage);
bool run(llvm::Module& M) {return PM.run(M);} bool run(llvm::Module& M) {return PM.run(M);}
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::PassManager& getPM() {return PM;} llvm::PassManager& getPM() {return PM;}
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::legacy::PassManager& getPM() {return PM;} llvm::legacy::PassManager& getPM() {return PM;}
#endif #endif
private: private:
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::PassManager PM; llvm::PassManager PM;
#else /* LLVM 3.7+ */ #else /* LLVM 3.7+ */
llvm::legacy::PassManager PM; llvm::legacy::PassManager PM;
@@ -500,7 +500,7 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) {
PM.add(CreateDebugPass(buf)); PM.add(CreateDebugPass(buf));
} }
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // only 3.4 and 3.5 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_4 || ISPC_LLVM_VERSION == ISPC_LLVM_3_5 // only 3.4 and 3.5
if (g->debugIR == number) { if (g->debugIR == number) {
// adding generating of LLVM IR debug after optimization // adding generating of LLVM IR debug after optimization
char buf[100]; char buf[100];
@@ -521,19 +521,19 @@ Optimize(llvm::Module *module, int optLevel) {
DebugPassManager optPM; DebugPassManager optPM;
optPM.add(llvm::createVerifierPass(),0); optPM.add(llvm::createVerifierPass(),0);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::TargetLibraryInfo *targetLibraryInfo = llvm::TargetLibraryInfo *targetLibraryInfo =
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
optPM.add(targetLibraryInfo); optPM.add(targetLibraryInfo);
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
optPM.add(new llvm::TargetLibraryInfoWrapperPass(llvm::Triple(module->getTargetTriple()))); optPM.add(new llvm::TargetLibraryInfoWrapperPass(llvm::Triple(module->getTargetTriple())));
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_4
optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_5
optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6
llvm::DataLayoutPass *dlp= new llvm::DataLayoutPass(); llvm::DataLayoutPass *dlp= new llvm::DataLayoutPass();
dlp->doInitialization(*module); dlp->doInitialization(*module);
optPM.add(dlp); optPM.add(dlp);
@@ -541,12 +541,12 @@ Optimize(llvm::Module *module, int optLevel) {
llvm::TargetMachine *targetMachine = g->target->GetTargetMachine(); llvm::TargetMachine *targetMachine = g->target->GetTargetMachine();
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(), optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
targetMachine->getVectorTargetTransformInfo())); targetMachine->getVectorTargetTransformInfo()));
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
targetMachine->addAnalysisPasses(optPM.getPM()); targetMachine->addAnalysisPasses(optPM.getPM());
#else /* LLVM 3.7+ */ #else // LLVM 3.7+
optPM.getPM().add(createTargetTransformInfoWrapperPass(targetMachine->getTargetIRAnalysis())); optPM.getPM().add(createTargetTransformInfoWrapperPass(targetMachine->getTargetIRAnalysis()));
#endif #endif
@@ -660,7 +660,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createCFGSimplificationPass()); optPM.add(llvm::createCFGSimplificationPass());
optPM.add(llvm::createArgumentPromotionPass()); optPM.add(llvm::createArgumentPromotionPass());
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3
// Starting from 3.4 this functionality was moved to // Starting from 3.4 this functionality was moved to
// InstructionCombiningPass. See r184459 for details. // InstructionCombiningPass. See r184459 for details.
optPM.add(llvm::createSimplifyLibCallsPass(), 240); optPM.add(llvm::createSimplifyLibCallsPass(), 240);
@@ -810,7 +810,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createCFGSimplificationPass()); optPM.add(llvm::createCFGSimplificationPass());
optPM.add(llvm::createArgumentPromotionPass()); optPM.add(llvm::createArgumentPromotionPass());
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3
// Starting from 3.4 this functionality was moved to // Starting from 3.4 this functionality was moved to
// InstructionCombiningPass. See r184459 for details. // InstructionCombiningPass. See r184459 for details.
optPM.add(llvm::createSimplifyLibCallsPass()); optPM.add(llvm::createSimplifyLibCallsPass());
@@ -4924,7 +4924,7 @@ PeepholePass::PeepholePass()
: BasicBlockPass(ID) { : BasicBlockPass(ID) {
} }
#if ISPC_LLVM_VERSION > ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3
using namespace llvm::PatternMatch; using namespace llvm::PatternMatch;
@@ -5258,7 +5258,7 @@ PeepholePass::runOnBasicBlock(llvm::BasicBlock &bb) {
llvm::Instruction *inst = &*iter; llvm::Instruction *inst = &*iter;
llvm::Instruction *builtinCall = NULL; llvm::Instruction *builtinCall = NULL;
#if ISPC_LLVM_VERSION > ISPC_LLVM_3_2 #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3
if (!builtinCall) if (!builtinCall)
builtinCall = lMatchAvgUpUInt8(inst); builtinCall = lMatchAvgUpUInt8(inst);
if (!builtinCall) if (!builtinCall)

View File

@@ -83,7 +83,7 @@ struct ForeachDimension;
#include "util.h" #include "util.h"
#include <stdio.h> #include <stdio.h>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/Constants.h> #include <llvm/Constants.h>
#else #else
#include <llvm/IR/Constants.h> #include <llvm/IR/Constants.h>

View File

@@ -48,7 +48,7 @@
#include <stdio.h> #include <stdio.h>
#include <map> #include <map>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/Module.h> #include <llvm/Module.h>
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/Instructions.h> #include <llvm/Instructions.h>
@@ -190,7 +190,7 @@ static llvm::Value* lConvertToGenericPtr(FunctionEmitContext *ctx, llvm::Value *
llvm::Function *func_warp_index = m->module->getFunction("__warp_index"); llvm::Function *func_warp_index = m->module->getFunction("__warp_index");
llvm::Value *warpId = ctx->CallInst(func_warp_index, NULL, std::vector<llvm::Value*>(), "gep2gen_warp_index"); llvm::Value *warpId = ctx->CallInst(func_warp_index, NULL, std::vector<llvm::Value*>(), "gep2gen_warp_index");
llvm::Value *offset = ctx->BinaryOperator(llvm::Instruction::Mul, warpId, LLVMInt32(numEl), "gep2gen_offset"); llvm::Value *offset = ctx->BinaryOperator(llvm::Instruction::Mul, warpId, LLVMInt32(numEl), "gep2gen_offset");
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
value = llvm::GetElementPtrInst::Create(value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock()); value = llvm::GetElementPtrInst::Create(value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock());
#else #else
value = llvm::GetElementPtrInst::Create(NULL, value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock()); value = llvm::GetElementPtrInst::Create(NULL, value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock());
@@ -1539,7 +1539,7 @@ lUpdateVaryingCounter(int dim, int nDims, FunctionEmitContext *ctx,
ptr_arrayidx_indices.push_back(LLVMInt32(0)); ptr_arrayidx_indices.push_back(LLVMInt32(0));
ptr_arrayidx_indices.push_back(laneIdx); ptr_arrayidx_indices.push_back(laneIdx);
#if 1 #if 1
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock()); llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock());
#else #else
llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(NULL, globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock()); llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(NULL, globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock());

104
type.cpp
View File

@@ -79,7 +79,7 @@ lShouldPrintName(const std::string &name) {
/** Utility routine to create a llvm array type of the given number of /** Utility routine to create a llvm array type of the given number of
the given element type. */ the given element type. */
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
static llvm::DIType lCreateDIArray(llvm::DIType eltType, int count) { static llvm::DIType lCreateDIArray(llvm::DIType eltType, int count) {
#else // LLVM 3.7++ #else // LLVM 3.7++
static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) { static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) {
@@ -95,11 +95,11 @@ static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) {
} }
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(lowerBound, upperBound); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(lowerBound, upperBound);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, count); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, count);
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
std::vector<llvm::Value *> subs; std::vector<llvm::Value *> subs;
#else // LLVM 3.6++ #else // LLVM 3.6++
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, count); llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, count);
@@ -107,7 +107,7 @@ static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) {
#endif #endif
subs.push_back(sub); subs.push_back(sub);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs); llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs);
uint64_t size = eltType.getSizeInBits() * count; uint64_t size = eltType.getSizeInBits() * count;
uint64_t align = eltType.getAlignInBits(); uint64_t align = eltType.getAlignInBits();
@@ -526,7 +526,7 @@ AtomicType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType AtomicType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType AtomicType::GetDIType(llvm::DIDescriptor scope) const {
#else //LLVM 3.7++ #else //LLVM 3.7++
llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const { llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const {
@@ -536,7 +536,7 @@ llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const {
if (variability.type == Variability::Uniform) { if (variability.type == Variability::Uniform) {
switch (basicType) { switch (basicType) {
case TYPE_VOID: case TYPE_VOID:
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::DIType(); return llvm::DIType();
#else //LLVM 3.7++ #else //LLVM 3.7++
return NULL; return NULL;
@@ -587,27 +587,27 @@ llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const {
break; break;
default: default:
FATAL("unhandled basic type in AtomicType::GetDIType()"); FATAL("unhandled basic type in AtomicType::GetDIType()");
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::DIType(); return llvm::DIType();
#else //LLVM 3.7++ #else //LLVM 3.7+
return NULL; return NULL;
#endif #endif
} }
} }
else if (variability == Variability::Varying) { else if (variability == Variability::Varying) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
#elif ISPC_LLVM_VERSION >= ISPC_VERSION_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #elif ISPC_LLVM_VERSION > ISPC_VERSION_3_2 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth());
#else // LLVM 3.6++ #else // LLVM 3.6+
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth());
#endif #endif
#if ISPC_LLVM_VERSION >= ISPC_VERSION_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION > ISPC_VERSION_3_2 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
llvm::DIType unifType = GetAsUniformType()->GetDIType(scope); llvm::DIType unifType = GetAsUniformType()->GetDIType(scope);
uint64_t size = unifType.getSizeInBits() * g->target->getVectorWidth(); uint64_t size = unifType.getSizeInBits() * g->target->getVectorWidth();
uint64_t align = unifType.getAlignInBits() * g->target->getVectorWidth(); uint64_t align = unifType.getAlignInBits() * g->target->getVectorWidth();
#elif ISPC_LLVM_VERSION >= ISPC_VERSION_3_7 // LLVM 3.7+ #else // LLVM 3.7+
llvm::DINodeArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DINodeArray subArray = m->diBuilder->getOrCreateArray(sub);
llvm::DIType *unifType = GetAsUniformType()->GetDIType(scope); llvm::DIType *unifType = GetAsUniformType()->GetDIType(scope);
//llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub); //llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub);
@@ -847,15 +847,15 @@ EnumType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType EnumType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType EnumType::GetDIType(llvm::DIDescriptor scope) const {
#else // LLVM 3.7++ #else // LLVM 3.7+
llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const { llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
std::vector<llvm::Value *> enumeratorDescriptors; std::vector<llvm::Value *> enumeratorDescriptors;
#else // LLVM 3.6++ #else // LLVM 3.6+
std::vector<llvm::Metadata *> enumeratorDescriptors; std::vector<llvm::Metadata *> enumeratorDescriptors;
#endif #endif
for (unsigned int i = 0; i < enumerators.size(); ++i) { for (unsigned int i = 0; i < enumerators.size(); ++i) {
@@ -863,15 +863,15 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
Assert(enumerators[i]->constValue != NULL); Assert(enumerators[i]->constValue != NULL);
int count = enumerators[i]->constValue->GetValues(&enumeratorValue); int count = enumerators[i]->constValue->GetValues(&enumeratorValue);
Assert(count == 1); Assert(count == 1);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::Value *descriptor = llvm::Value *descriptor =
#else // LLVM 3.6++ #else // LLVM 3.6+
llvm::Metadata *descriptor = llvm::Metadata *descriptor =
#endif #endif
m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue); m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue);
enumeratorDescriptors.push_back(descriptor); enumeratorDescriptors.push_back(descriptor);
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIArray elementArray = llvm::DIArray elementArray =
m->diBuilder->getOrCreateArray(enumeratorDescriptors); m->diBuilder->getOrCreateArray(enumeratorDescriptors);
llvm::DIFile diFile = pos.GetDIFile(); llvm::DIFile diFile = pos.GetDIFile();
@@ -880,7 +880,7 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
32 /* size in bits */, 32 /* size in bits */,
32 /* align in bits */, 32 /* align in bits */,
elementArray, llvm::DIType()); elementArray, llvm::DIType());
#else // LLVM 3.7++ #else // LLVM 3.7+
llvm::DINodeArray elementArray = llvm::DINodeArray elementArray =
m->diBuilder->getOrCreateArray(enumeratorDescriptors); m->diBuilder->getOrCreateArray(enumeratorDescriptors);
llvm::DIFile *diFile = pos.GetDIFile(); llvm::DIFile *diFile = pos.GetDIFile();
@@ -894,18 +894,18 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
case Variability::Uniform: case Variability::Uniform:
return diType; return diType;
case Variability::Varying: { case Variability::Varying: {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth());
#else // LLVM 3.6++ #else // LLVM 3.6++
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()); llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth());
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
uint64_t size = diType.getSizeInBits() * g->target->getVectorWidth(); uint64_t size = diType.getSizeInBits() * g->target->getVectorWidth();
uint64_t align = diType.getAlignInBits() * g->target->getVectorWidth(); uint64_t align = diType.getAlignInBits() * g->target->getVectorWidth();
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++ #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
llvm::DINodeArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DINodeArray subArray = m->diBuilder->getOrCreateArray(sub);
//llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub); //llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub);
uint64_t size = diType->getSizeInBits() * g->target->getVectorWidth(); uint64_t size = diType->getSizeInBits() * g->target->getVectorWidth();
@@ -918,7 +918,7 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
} }
default: default:
FATAL("Unexpected variability in EnumType::GetDIType()"); FATAL("Unexpected variability in EnumType::GetDIType()");
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::DIType(); return llvm::DIType();
#else //LLVM 3.7++ #else //LLVM 3.7++
return NULL; return NULL;
@@ -1256,7 +1256,7 @@ PointerType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType PointerType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType PointerType::GetDIType(llvm::DIDescriptor scope) const {
if (baseType == NULL) { if (baseType == NULL) {
Assert(m->errorCount > 0); Assert(m->errorCount > 0);
@@ -1279,7 +1279,7 @@ llvm::DIType *PointerType::GetDIType(llvm::DIScope *scope) const {
ptrAlignBits); ptrAlignBits);
case Variability::Varying: { case Variability::Varying: {
// emit them as an array of pointers // emit them as an array of pointers
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType eltType = llvm::DIType eltType =
#else //LLVM 3.7++ #else //LLVM 3.7++
llvm::DIDerivedType *eltType = llvm::DIDerivedType *eltType =
@@ -1293,7 +1293,7 @@ llvm::DIType *PointerType::GetDIType(llvm::DIScope *scope) const {
} }
default: default:
FATAL("Unexpected variability in PointerType::GetDIType()"); FATAL("Unexpected variability in PointerType::GetDIType()");
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::DIType(); return llvm::DIType();
#else //LLVM 3.7++ #else //LLVM 3.7++
return NULL; return NULL;
@@ -1571,7 +1571,7 @@ ArrayType::TotalElementCount() const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType ArrayType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType ArrayType::GetDIType(llvm::DIDescriptor scope) const {
if (child == NULL) { if (child == NULL) {
Assert(m->errorCount > 0); Assert(m->errorCount > 0);
@@ -1820,16 +1820,16 @@ VectorType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType VectorType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType VectorType::GetDIType(llvm::DIDescriptor scope) const {
llvm::DIType eltType = base->GetDIType(scope); llvm::DIType eltType = base->GetDIType(scope);
#else //LLVM 3.7++ #else //LLVM 3.7++
llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const { llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const {
llvm::DIType *eltType = base->GetDIType(scope); llvm::DIType *eltType = base->GetDIType(scope);
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements); llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements);
#else // LLVM 3.6++ #else // LLVM 3.6++
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, numElements); llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, numElements);
@@ -1838,7 +1838,7 @@ llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const {
// vectors of varying types are already naturally aligned to the // vectors of varying types are already naturally aligned to the
// machine's vector width, but arrays of uniform types need to be // machine's vector width, but arrays of uniform types need to be
// explicitly aligned to the machines natural vector alignment. // explicitly aligned to the machines natural vector alignment.
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub); llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
uint64_t sizeBits = eltType.getSizeInBits() * numElements; uint64_t sizeBits = eltType.getSizeInBits() * numElements;
uint64_t align = eltType.getAlignInBits(); uint64_t align = eltType.getAlignInBits();
@@ -1859,7 +1859,7 @@ llvm::DIType *VectorType::GetDIType(llvm::DIScope *scope) const {
} }
else { else {
FATAL("Unexpected variability in VectorType::GetDIType()"); FATAL("Unexpected variability in VectorType::GetDIType()");
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::DIType(); return llvm::DIType();
#else // LLVM 3.7++ #else // LLVM 3.7++
return NULL; return NULL;
@@ -2263,13 +2263,13 @@ StructType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType StructType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType StructType::GetDIType(llvm::DIDescriptor scope) const {
#else //LLVM 3.7++ #else //LLVM 3.7++
llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const { llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const {
#endif #endif
uint64_t currentSize = 0, align = 0; uint64_t currentSize = 0, align = 0;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
std::vector<llvm::Value *> elementLLVMTypes; std::vector<llvm::Value *> elementLLVMTypes;
#else // LLVM 3.6++ #else // LLVM 3.6++
std::vector<llvm::Metadata *> elementLLVMTypes; std::vector<llvm::Metadata *> elementLLVMTypes;
@@ -2278,7 +2278,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const {
// alignment and size, using that to figure out its offset w.r.t. the // alignment and size, using that to figure out its offset w.r.t. the
// start of the structure. // start of the structure.
for (unsigned int i = 0; i < elementTypes.size(); ++i) { for (unsigned int i = 0; i < elementTypes.size(); ++i) {
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType eltType = GetElementType(i)->GetDIType(scope); llvm::DIType eltType = GetElementType(i)->GetDIType(scope);
uint64_t eltAlign = eltType.getAlignInBits(); uint64_t eltAlign = eltType.getAlignInBits();
uint64_t eltSize = eltType.getSizeInBits(); uint64_t eltSize = eltType.getSizeInBits();
@@ -2300,7 +2300,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const {
Assert((currentSize == 0) || (currentSize % eltAlign) == 0); Assert((currentSize == 0) || (currentSize % eltAlign) == 0);
int line = elementPositions[i].first_line; int line = elementPositions[i].first_line;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIFile diFile = elementPositions[i].GetDIFile(); llvm::DIFile diFile = elementPositions[i].GetDIFile();
llvm::DIType fieldType = llvm::DIType fieldType =
#else // LLVM 3.7++ #else // LLVM 3.7++
@@ -2320,7 +2320,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const {
if (currentSize > 0 && (currentSize % align)) if (currentSize > 0 && (currentSize % align))
currentSize += align - (currentSize % align); currentSize += align - (currentSize % align);
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes); llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes);
llvm::DIFile diFile = pos.GetDIFile(); llvm::DIFile diFile = pos.GetDIFile();
#else // LLVM 3.7++ #else // LLVM 3.7++
@@ -2335,7 +2335,7 @@ llvm::DIType *StructType::GetDIType(llvm::DIScope *scope) const {
currentSize, // Size in bits currentSize, // Size in bits
align, // Alignment in bits align, // Alignment in bits
0, // Flags 0, // Flags
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType(), // DerivedFrom llvm::DIType(), // DerivedFrom
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++ #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++
NULL, NULL,
@@ -2568,7 +2568,7 @@ UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
llvm::DIFile diFile = pos.GetDIFile(); llvm::DIFile diFile = pos.GetDIFile();
llvm::DIArray elements; llvm::DIArray elements;
@@ -2585,9 +2585,9 @@ llvm::DIType *UndefinedStructType::GetDIType(llvm::DIScope *scope) const {
0, // Size 0, // Size
0, // Align 0, // Align
0, // Flags 0, // Flags
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType(), // DerivedFrom llvm::DIType(), // DerivedFrom
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++ #elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
NULL, NULL,
#endif #endif
elements); elements);
@@ -2842,7 +2842,7 @@ ReferenceType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType ReferenceType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
if (targetType == NULL) { if (targetType == NULL) {
Assert(m->errorCount > 0); Assert(m->errorCount > 0);
@@ -3121,13 +3121,13 @@ FunctionType::LLVMType(llvm::LLVMContext *ctx) const {
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType FunctionType::GetDIType(llvm::DIDescriptor scope) const { llvm::DIType FunctionType::GetDIType(llvm::DIDescriptor scope) const {
#else //LLVM 3.7++ #else //LLVM 3.7++
llvm::DIType *FunctionType::GetDIType(llvm::DIScope *scope) const { llvm::DIType *FunctionType::GetDIType(llvm::DIScope *scope) const {
#endif #endif
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
std::vector<llvm::Value *> retArgTypes; std::vector<llvm::Value *> retArgTypes;
#else // LLVM 3.6++ #else // LLVM 3.6++
std::vector<llvm::Metadata *> retArgTypes; std::vector<llvm::Metadata *> retArgTypes;
@@ -3137,28 +3137,28 @@ llvm::DIType *FunctionType::GetDIType(llvm::DIScope *scope) const {
const Type *t = GetParameterType(i); const Type *t = GetParameterType(i);
if (t == NULL) if (t == NULL)
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_3
return llvm::DIType(); return llvm::DIType();
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #elif ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
return llvm::DICompositeType(); return llvm::DICompositeType();
#else // LLVM 3.7++ #else // LLVM 3.7++
return NULL; return NULL;
#endif #endif
retArgTypes.push_back(t->GetDIType(scope)); retArgTypes.push_back(t->GetDIType(scope));
} }
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_5
llvm::DIArray retArgTypesArray = llvm::DIArray retArgTypesArray =
m->diBuilder->getOrCreateArray(llvm::ArrayRef<llvm::Value *>(retArgTypes)); m->diBuilder->getOrCreateArray(llvm::ArrayRef<llvm::Value *>(retArgTypes));
llvm::DIType diType = llvm::DIType diType =
// FIXME: DIFile // FIXME: DIFile
m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray); m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray);
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #elif ISPC_LLVM_VERSION == ISPC_LLVM_3_6
llvm::DITypeArray retArgTypesArray = llvm::DITypeArray retArgTypesArray =
m->diBuilder->getOrCreateTypeArray(retArgTypes); m->diBuilder->getOrCreateTypeArray(retArgTypes);
llvm::DIType diType = llvm::DIType diType =
// FIXME: DIFile // FIXME: DIFile
m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray); m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray);
#else // LLVM 3.7++ #else // LLVM 3.7+
llvm::DITypeRefArray retArgTypesArray = llvm::DITypeRefArray retArgTypesArray =
m->diBuilder->getOrCreateTypeArray(retArgTypes); m->diBuilder->getOrCreateTypeArray(retArgTypes);
llvm::DIType *diType = llvm::DIType *diType =

24
type.h
View File

@@ -40,10 +40,10 @@
#include "ispc.h" #include "ispc.h"
#include "util.h" #include "util.h"
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/Type.h> #include <llvm/Type.h>
#include <llvm/DerivedTypes.h> #include <llvm/DerivedTypes.h>
#else /* >= 3.3 */ #else // >= 3.3
#include <llvm/IR/Type.h> #include <llvm/IR/Type.h>
#include <llvm/IR/DerivedTypes.h> #include <llvm/IR/DerivedTypes.h>
#endif #endif
@@ -222,7 +222,7 @@ public:
/** Returns the LLVM type corresponding to this ispc type */ /** Returns the LLVM type corresponding to this ispc type */
virtual llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0; virtual llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
/** Returns the DIType (LLVM's debugging information structure), /** Returns the DIType (LLVM's debugging information structure),
corresponding to this type. */ corresponding to this type. */
virtual llvm::DIType GetDIType(llvm::DIDescriptor scope) const = 0; virtual llvm::DIType GetDIType(llvm::DIDescriptor scope) const = 0;
@@ -317,7 +317,7 @@ public:
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -400,7 +400,7 @@ public:
const std::string &GetEnumName() const { return name; } const std::string &GetEnumName() const { return name; }
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -485,7 +485,7 @@ public:
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -591,7 +591,7 @@ public:
std::string Mangle() const; std::string Mangle() const;
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -663,7 +663,7 @@ public:
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -718,7 +718,7 @@ public:
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -810,7 +810,7 @@ public:
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -857,7 +857,7 @@ public:
std::string GetCDeclaration(const std::string &name) const; std::string GetCDeclaration(const std::string &name) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;
@@ -915,7 +915,7 @@ public:
std::string GetCDeclarationForDispatch(const std::string &fname) const; std::string GetCDeclarationForDispatch(const std::string &fname) const;
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const; llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 #if ISPC_LLVM_VERSION <= ISPC_LLVM_3_6
llvm::DIType GetDIType(llvm::DIDescriptor scope) const; llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
#else // LLVM 3.7++ #else // LLVM 3.7++
llvm::DIType *GetDIType(llvm::DIScope *scope) const; llvm::DIType *GetDIType(llvm::DIScope *scope) const;

View File

@@ -65,7 +65,7 @@
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 #if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
#include <llvm/DataLayout.h> #include <llvm/DataLayout.h>
#else // LLVM 3.3+ #else // LLVM 3.3+
#include <llvm/IR/DataLayout.h> #include <llvm/IR/DataLayout.h>