Skip to content

Commit 0afa3f5

Browse files
committed
New LLVM version macro
1 parent 0b62c28 commit 0afa3f5

20 files changed

+559
-448
lines changed

builtins.cpp

+22-19
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747

4848
#include <math.h>
4949
#include <stdlib.h>
50-
#if defined(LLVM_3_2)
50+
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
5151
#include <llvm/Attributes.h>
5252
#endif
53-
#if defined(LLVM_3_2)
53+
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
5454
#include <llvm/LLVMContext.h>
5555
#include <llvm/Module.h>
5656
#include <llvm/Type.h>
@@ -66,7 +66,7 @@
6666
#include <llvm/IR/Intrinsics.h>
6767
#include <llvm/IR/DerivedTypes.h>
6868
#endif
69-
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
69+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
7070
#include <llvm/Linker/Linker.h>
7171
#else
7272
#include <llvm/Linker.h>
@@ -784,13 +784,13 @@ void
784784
AddBitcodeToModule(const unsigned char *bitcode, int length,
785785
llvm::Module *module, SymbolTable *symbolTable, bool warn) {
786786
llvm::StringRef sb = llvm::StringRef((char *)bitcode, length);
787-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
787+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
788788
llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb);
789789
#else // LLVM 3.6+
790790
llvm::MemoryBufferRef bcBuf = llvm::MemoryBuffer::getMemBuffer(sb)->getMemBufferRef();
791791
#endif
792792

793-
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
793+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
794794
llvm::ErrorOr<llvm::Module *> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx);
795795
if (std::error_code EC = ModuleOrErr.getError())
796796
Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str());
@@ -850,7 +850,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
850850
// architecture and investigate what happened.
851851
// Generally we allow library DataLayout to be subset of module
852852
// DataLayout or library DataLayout to be empty.
853-
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
853+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
854854
if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(),
855855
bcModule->getDataLayoutStr())
856856
&& warn) {
@@ -880,7 +880,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
880880

881881
std::string(linkError);
882882
if (llvm::Linker::LinkModules(module, bcModule
883-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
883+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
884884
, llvm::Linker::DestroySource,
885885
&linkError))
886886
Error(SourcePos(), "Error linking stdlib bitcode: %s", linkError.c_str());
@@ -917,7 +917,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
917917
symbolTable->AddVariable(sym);
918918

919919
if (m->diBuilder != NULL) {
920-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
920+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
921921
llvm::DIFile file;
922922
llvm::DIType diType = sym->type->GetDIType(file);
923923
Assert(diType.Verify());
@@ -932,15 +932,15 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
932932
// have the DW_AT_artifical attribute. It's not clear if this
933933
// matters for anything though.
934934

935-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
935+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
936936
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
937937
name,
938938
file,
939939
0 /* line */,
940940
diType,
941941
true /* static */,
942942
sym->storagePtr);
943-
#elif defined(LLVM_3_6)
943+
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* i.e., 3.6 */
944944
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
945945
Assert(sym_const_storagePtr);
946946
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
@@ -965,10 +965,10 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
965965
true /* static */,
966966
sym_const_storagePtr);
967967
#endif
968-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
968+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
969969
Assert(var.Verify());
970970
#else // LLVM 3.7+
971-
//comming soon
971+
//coming soon
972972
#endif
973973
}
974974
}
@@ -984,7 +984,7 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module,
984984

985985
llvm::Function *func = module->getFunction(name);
986986
Assert(func != NULL); // it should be declared already...
987-
#if defined(LLVM_3_2)
987+
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
988988
func->addFnAttr(llvm::Attributes::AlwaysInline);
989989
#else // LLVM 3.3+
990990
func->addFnAttr(llvm::Attribute::AlwaysInline);
@@ -1019,7 +1019,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
10191019
symbolTable->AddVariable(sym);
10201020

10211021
if (m->diBuilder != NULL) {
1022-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
1022+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
10231023
llvm::DIFile file;
10241024
llvm::DIType diType = sym->type->GetDIType(file);
10251025
Assert(diType.Verify());
@@ -1030,10 +1030,13 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
10301030
llvm::DIType *diType = sym->type->GetDIType(file);
10311031
// Assert(diType.Verify());
10321032
#endif
1033-
#if defined(LLVM_3_6)// LLVM 3.6+
1033+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6
10341034
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
10351035
Assert(sym_const_storagePtr);
1036-
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
1036+
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
1037+
llvm::DIGlobalVariable var =
1038+
#endif
1039+
m->diBuilder->createGlobalVariable(
10371040
file,
10381041
sym->name.c_str(),
10391042
sym->name.c_str(),
@@ -1042,7 +1045,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
10421045
diType,
10431046
false /* static */,
10441047
sym_const_storagePtr);
1045-
#elif defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
1048+
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 /* && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 */
10461049
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
10471050
sym->name.c_str(),
10481051
file,
@@ -1063,10 +1066,10 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
10631066
false /* static */,
10641067
sym_const_storagePtr);
10651068
#endif
1066-
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
1069+
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
10671070
Assert(var.Verify());
10681071
#else // LLVM 3.7+
1069-
//comming soon
1072+
//coming soon
10701073
#endif
10711074
}
10721075
}

0 commit comments

Comments
 (0)