New LLVM version macro
This commit is contained in:
41
builtins.cpp
41
builtins.cpp
@@ -47,10 +47,10 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#include <llvm/Attributes.h>
|
#include <llvm/Attributes.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2)
|
#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>
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
#include <llvm/IR/Intrinsics.h>
|
#include <llvm/IR/Intrinsics.h>
|
||||||
#include <llvm/IR/DerivedTypes.h>
|
#include <llvm/IR/DerivedTypes.h>
|
||||||
#endif
|
#endif
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
|
||||||
#include <llvm/Linker/Linker.h>
|
#include <llvm/Linker/Linker.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/Linker.h>
|
#include <llvm/Linker.h>
|
||||||
@@ -784,13 +784,13 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
|
||||||
llvm::ErrorOr<llvm::Module *> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx);
|
llvm::ErrorOr<llvm::Module *> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx);
|
||||||
if (std::error_code EC = ModuleOrErr.getError())
|
if (std::error_code EC = ModuleOrErr.getError())
|
||||||
Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str());
|
Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str());
|
||||||
@@ -850,7 +850,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length,
|
|||||||
// architecture and investigate what happened.
|
// architecture and investigate what happened.
|
||||||
// Generally we allow library DataLayout to be subset of module
|
// Generally we allow library DataLayout to be subset of module
|
||||||
// DataLayout or library DataLayout to be empty.
|
// DataLayout or library DataLayout to be empty.
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
|
||||||
if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(),
|
if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(),
|
||||||
bcModule->getDataLayoutStr())
|
bcModule->getDataLayoutStr())
|
||||||
&& warn) {
|
&& warn) {
|
||||||
@@ -880,7 +880,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
, 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 +917,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 +932,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
|
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
|
||||||
name,
|
name,
|
||||||
file,
|
file,
|
||||||
@@ -940,7 +940,7 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
|
|||||||
diType,
|
diType,
|
||||||
true /* static */,
|
true /* static */,
|
||||||
sym->storagePtr);
|
sym->storagePtr);
|
||||||
#elif defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* i.e., 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,10 +965,10 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
|
|||||||
true /* static */,
|
true /* static */,
|
||||||
sym_const_storagePtr);
|
sym_const_storagePtr);
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
Assert(var.Verify());
|
Assert(var.Verify());
|
||||||
#else // LLVM 3.7+
|
#else // LLVM 3.7+
|
||||||
//comming soon
|
//coming soon
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -984,7 +984,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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
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 +1019,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
|
|||||||
symbolTable->AddVariable(sym);
|
symbolTable->AddVariable(sym);
|
||||||
|
|
||||||
if (m->diBuilder != NULL) {
|
if (m->diBuilder != NULL) {
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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,10 +1030,13 @@ 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 defined(LLVM_3_6)// LLVM 3.6+
|
#if ISPC_LLVM_VERSION >= ISPC_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(
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
|
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(),
|
||||||
@@ -1042,7 +1045,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
|
|||||||
diType,
|
diType,
|
||||||
false /* static */,
|
false /* static */,
|
||||||
sym_const_storagePtr);
|
sym_const_storagePtr);
|
||||||
#elif defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 /* && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 */
|
||||||
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
|
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
|
||||||
sym->name.c_str(),
|
sym->name.c_str(),
|
||||||
file,
|
file,
|
||||||
@@ -1063,10 +1066,10 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
|
|||||||
false /* static */,
|
false /* static */,
|
||||||
sym_const_storagePtr);
|
sym_const_storagePtr);
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
Assert(var.Verify());
|
Assert(var.Verify());
|
||||||
#else // LLVM 3.7+
|
#else // LLVM 3.7+
|
||||||
//comming soon
|
//coming soon
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
225
cbackend.cpp
225
cbackend.cpp
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "llvmutil.h"
|
#include "llvmutil.h"
|
||||||
|
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/CallingConv.h"
|
#include "llvm/CallingConv.h"
|
||||||
@@ -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
|
#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,29 +52,29 @@
|
|||||||
#include "llvm/IR/InlineAsm.h"
|
#include "llvm/IR/InlineAsm.h"
|
||||||
#endif
|
#endif
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* <= 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 defined(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 defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */
|
||||||
#include "llvm/Support/InstIterator.h"
|
#include "llvm/Support/InstIterator.h"
|
||||||
#else
|
#else /* 3.5+ */
|
||||||
#include "llvm/IR/InstIterator.h"
|
#include "llvm/IR/InstIterator.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
#include "llvm/Analysis/FindUsedTypes.h"
|
#include "llvm/Analysis/FindUsedTypes.h"
|
||||||
#endif
|
#endif
|
||||||
#include "llvm/Analysis/LoopInfo.h"
|
#include "llvm/Analysis/LoopInfo.h"
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_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/CallSite.h"
|
#include "llvm/IR/CallSite.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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#elif defined (LLVM_3_3) || defined (LLVM_3_4)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
namespace constant_scanner {
|
namespace constant_scanner {
|
||||||
class constant_iterator : public std::iterator<std::forward_iterator_tag,
|
class constant_iterator : public std::iterator<std::forward_iterator_tag,
|
||||||
const llvm::Constant, ptrdiff_t> {
|
const llvm::Constant, ptrdiff_t> {
|
||||||
llvm::const_inst_iterator InstI; // Method instruction iterator
|
llvm::const_inst_iterator InstI; // Method instruction iterator
|
||||||
unsigned OpIdx; // Operand index
|
unsigned OpIdx; // Operand index
|
||||||
|
|
||||||
bool isAtConstant() const {
|
bool isAtConstant() const {
|
||||||
@@ -206,7 +206,7 @@ namespace {
|
|||||||
// To avoid walking constant expressions multiple times and other IR
|
// To avoid walking constant expressions multiple times and other IR
|
||||||
// objects, we keep several helper maps.
|
// objects, we keep several helper maps.
|
||||||
llvm::DenseSet<const llvm::Value*> VisitedConstants;
|
llvm::DenseSet<const llvm::Value*> VisitedConstants;
|
||||||
#if !defined (LLVM_3_2) && !defined (LLVM_3_3) && !defined (LLVM_3_4) && !defined (LLVM_3_5)// LLVN 3.6++
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
|
||||||
llvm::DenseSet<const llvm::Metadata*> VisitedMDNodes;
|
llvm::DenseSet<const llvm::Metadata*> VisitedMDNodes;
|
||||||
#endif
|
#endif
|
||||||
llvm::DenseSet<llvm::Type*> VisitedTypes;
|
llvm::DenseSet<llvm::Type*> VisitedTypes;
|
||||||
@@ -312,12 +312,12 @@ 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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 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;
|
||||||
}
|
}
|
||||||
#else // LLVN 3.6++
|
#else /* LLVN 3.6+ */
|
||||||
if (const llvm::MetadataAsValue *MV = llvm::dyn_cast<llvm::MetadataAsValue>(V)) {
|
if (const llvm::MetadataAsValue *MV = llvm::dyn_cast<llvm::MetadataAsValue>(V)) {
|
||||||
incorporateMDNode(MV->getMetadata());
|
incorporateMDNode(MV->getMetadata());
|
||||||
return;
|
return;
|
||||||
@@ -339,7 +339,7 @@ namespace {
|
|||||||
incorporateValue(*I);
|
incorporateValue(*I);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 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
|
||||||
|
|
||||||
@@ -519,9 +519,9 @@ namespace {
|
|||||||
bool isSigned = false,
|
bool isSigned = false,
|
||||||
const std::string &VariableName = "",
|
const std::string &VariableName = "",
|
||||||
bool IgnoreName = false,
|
bool IgnoreName = false,
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
|
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
const llvm::AttributeSet &PAL = llvm::AttributeSet()
|
const llvm::AttributeSet &PAL = llvm::AttributeSet()
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
@@ -530,9 +530,9 @@ namespace {
|
|||||||
const std::string &NameSoFar = "");
|
const std::string &NameSoFar = "");
|
||||||
|
|
||||||
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
const llvm::AttrListPtr &PAL,
|
const llvm::AttrListPtr &PAL,
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
const llvm::AttributeSet &PAL,
|
const llvm::AttributeSet &PAL,
|
||||||
#endif
|
#endif
|
||||||
llvm::PointerType *Ty);
|
llvm::PointerType *Ty);
|
||||||
@@ -610,7 +610,7 @@ namespace {
|
|||||||
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
|
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // 3.5+
|
||||||
// This instruction returns a struct on LLVM older than 3.4, and can not be inlined
|
// This instruction returns a struct on LLVM older than 3.4, and can not be inlined
|
||||||
if (llvm::isa<llvm::AtomicCmpXchgInst>(I))
|
if (llvm::isa<llvm::AtomicCmpXchgInst>(I))
|
||||||
return false;
|
return false;
|
||||||
@@ -628,7 +628,7 @@ namespace {
|
|||||||
// Must not be used in inline asm, extractelement, or shufflevector.
|
// Must not be used in inline asm, extractelement, or shufflevector.
|
||||||
if (I.hasOneUse()) {
|
if (I.hasOneUse()) {
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // 3.5+
|
||||||
const llvm::Instruction &User = llvm::cast<llvm::Instruction>(*I.user_back());
|
const llvm::Instruction &User = llvm::cast<llvm::Instruction>(*I.user_back());
|
||||||
#else
|
#else
|
||||||
const llvm::Instruction &User = llvm::cast<llvm::Instruction>(*I.use_back());
|
const llvm::Instruction &User = llvm::cast<llvm::Instruction>(*I.use_back());
|
||||||
@@ -640,7 +640,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only inline instruction it if it's use is in the same BB as the inst.
|
// Only inline instruction it if it's use is in the same BB as the inst.
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // 3.5+
|
||||||
return I.getParent() == llvm::cast<llvm::Instruction>(I.user_back())->getParent();
|
return I.getParent() == llvm::cast<llvm::Instruction>(I.user_back())->getParent();
|
||||||
#else
|
#else
|
||||||
return I.getParent() == llvm::cast<llvm::Instruction>(I.use_back())->getParent();
|
return I.getParent() == llvm::cast<llvm::Instruction>(I.use_back())->getParent();
|
||||||
@@ -776,9 +776,9 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) {
|
|||||||
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
|
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
|
||||||
/// print it as "Struct (*)(...)", for struct return functions.
|
/// print it as "Struct (*)(...)", for struct return functions.
|
||||||
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
const llvm::AttrListPtr &PAL,
|
const llvm::AttrListPtr &PAL,
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
const llvm::AttributeSet &PAL,
|
const llvm::AttributeSet &PAL,
|
||||||
#endif
|
#endif
|
||||||
llvm::PointerType *TheTy) {
|
llvm::PointerType *TheTy) {
|
||||||
@@ -795,18 +795,18 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
|||||||
if (PrintedType)
|
if (PrintedType)
|
||||||
FunctionInnards << ", ";
|
FunctionInnards << ", ";
|
||||||
llvm::Type *ArgTy = *I;
|
llvm::Type *ArgTy = *I;
|
||||||
#if defined(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
|
#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());
|
||||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||||
}
|
}
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(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
|
#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
|
||||||
"");
|
"");
|
||||||
@@ -821,9 +821,9 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
|||||||
}
|
}
|
||||||
FunctionInnards << ')';
|
FunctionInnards << ')';
|
||||||
printType(Out, RetTy,
|
printType(Out, RetTy,
|
||||||
#if defined(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
|
#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());
|
||||||
@@ -919,9 +919,9 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned,
|
|||||||
llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
||||||
bool isSigned, const std::string &NameSoFar,
|
bool isSigned, const std::string &NameSoFar,
|
||||||
bool IgnoreName,
|
bool IgnoreName,
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
const llvm::AttrListPtr &PAL
|
const llvm::AttrListPtr &PAL
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
const llvm::AttributeSet &PAL
|
const llvm::AttributeSet &PAL
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
@@ -941,9 +941,9 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
|||||||
for (llvm::FunctionType::param_iterator I = FTy->param_begin(),
|
for (llvm::FunctionType::param_iterator I = FTy->param_begin(),
|
||||||
E = FTy->param_end(); I != E; ++I) {
|
E = FTy->param_end(); I != E; ++I) {
|
||||||
llvm::Type *ArgTy = *I;
|
llvm::Type *ArgTy = *I;
|
||||||
#if defined(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
|
#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());
|
||||||
@@ -952,9 +952,9 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
|||||||
if (I != FTy->param_begin())
|
if (I != FTy->param_begin())
|
||||||
FunctionInnards << ", ";
|
FunctionInnards << ", ";
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(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
|
#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
|
||||||
"");
|
"");
|
||||||
@@ -969,9 +969,9 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
|||||||
}
|
}
|
||||||
FunctionInnards << ')';
|
FunctionInnards << ')';
|
||||||
printType(Out, FTy->getReturnType(),
|
printType(Out, FTy->getReturnType(),
|
||||||
#if defined(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
|
#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());
|
||||||
@@ -1585,7 +1585,8 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
|
|||||||
Out << CI->getZExtValue() << "ull";
|
Out << CI->getZExtValue() << "ull";
|
||||||
else if (Ty->getPrimitiveSizeInBits() > 64) {
|
else if (Ty->getPrimitiveSizeInBits() > 64) {
|
||||||
Out << "\"";
|
Out << "\"";
|
||||||
const uint64_t *Ptr64 = CPV->getUniqueInteger().getRawData();
|
//const uint64_t *Ptr64 = CPV->getUniqueInteger().getRawData();
|
||||||
|
const uint64_t *Ptr64 = CI->getValue().getRawData();
|
||||||
for (int i = 0; i < Ty->getPrimitiveSizeInBits(); i++) {
|
for (int i = 0; i < Ty->getPrimitiveSizeInBits(); i++) {
|
||||||
Out << ((Ptr64[i / (sizeof (uint64_t) * 8)] >> (i % (sizeof (uint64_t) * 8))) & 1);
|
Out << ((Ptr64[i / (sizeof (uint64_t) * 8)] >> (i % (sizeof (uint64_t) * 8))) & 1);
|
||||||
}
|
}
|
||||||
@@ -1956,9 +1957,9 @@ std::string CWriter::GetValueName(const llvm::Value *Operand) {
|
|||||||
|
|
||||||
// Resolve potential alias.
|
// Resolve potential alias.
|
||||||
if (const llvm::GlobalAlias *GA = llvm::dyn_cast<llvm::GlobalAlias>(Operand)) {
|
if (const llvm::GlobalAlias *GA = llvm::dyn_cast<llvm::GlobalAlias>(Operand)) {
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */
|
||||||
if (const llvm::Value *V = GA->getAliasee())
|
if (const llvm::Value *V = GA->getAliasee())
|
||||||
#else
|
#else /* <= LLVM 3.4 */
|
||||||
if (const llvm::Value *V = GA->resolveAliasedGlobal(false))
|
if (const llvm::Value *V = GA->resolveAliasedGlobal(false))
|
||||||
#endif
|
#endif
|
||||||
Operand = V;
|
Operand = V;
|
||||||
@@ -2332,7 +2333,7 @@ static SpecialGlobalClass getGlobalVariableClass(const llvm::GlobalVariable *GV)
|
|||||||
|
|
||||||
// Otherwise, if it is other metadata, don't print it. This catches things
|
// Otherwise, if it is other metadata, don't print it. This catches things
|
||||||
// like debug information.
|
// like debug information.
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* LLVM 3.5+ */
|
||||||
// Here we compare char *
|
// Here we compare char *
|
||||||
if (!strcmp(GV->getSection(), "llvm.metadata"))
|
if (!strcmp(GV->getSection(), "llvm.metadata"))
|
||||||
#else
|
#else
|
||||||
@@ -2390,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 !defined(LLVM_3_2) && !defined(LLVM_3_3)
|
#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);
|
||||||
@@ -2514,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#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())
|
||||||
@@ -2691,7 +2692,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
|
|||||||
|
|
||||||
if (I->hasLocalLinkage())
|
if (I->hasLocalLinkage())
|
||||||
Out << "static ";
|
Out << "static ";
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#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
|
||||||
@@ -3040,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // 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;
|
||||||
@@ -3051,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // 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;
|
||||||
@@ -3065,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // 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
|
||||||
@@ -3086,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // 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
|
||||||
@@ -3109,9 +3110,9 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
|||||||
|
|
||||||
// Loop over the arguments, printing them...
|
// Loop over the arguments, printing them...
|
||||||
llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType());
|
llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType());
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
const llvm::AttrListPtr &PAL = F->getAttributes();
|
const llvm::AttrListPtr &PAL = F->getAttributes();
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
const llvm::AttributeSet &PAL = F->getAttributes();
|
const llvm::AttributeSet &PAL = F->getAttributes();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3143,18 +3144,18 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
|||||||
else
|
else
|
||||||
ArgName = "";
|
ArgName = "";
|
||||||
llvm::Type *ArgTy = I->getType();
|
llvm::Type *ArgTy = I->getType();
|
||||||
#if defined(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
|
#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
|
||||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||||
ByValParams.insert(I);
|
ByValParams.insert(I);
|
||||||
}
|
}
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(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
|
#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
|
||||||
ArgName);
|
ArgName);
|
||||||
@@ -3178,18 +3179,18 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
|||||||
for (; I != E; ++I) {
|
for (; I != E; ++I) {
|
||||||
if (PrintedArg) FunctionInnards << ", ";
|
if (PrintedArg) FunctionInnards << ", ";
|
||||||
llvm::Type *ArgTy = *I;
|
llvm::Type *ArgTy = *I;
|
||||||
#if defined(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
|
#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());
|
||||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||||
}
|
}
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(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
|
#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
|
||||||
);
|
);
|
||||||
@@ -3224,9 +3225,9 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
|||||||
|
|
||||||
// Print out the return type and the signature built above.
|
// Print out the return type and the signature built above.
|
||||||
printType(Out, RetTy,
|
printType(Out, RetTy,
|
||||||
#if defined(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
|
#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());
|
||||||
@@ -3412,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // 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())))
|
||||||
@@ -3437,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // 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))
|
||||||
@@ -4079,9 +4080,9 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
|
|||||||
const char *BuiltinName = "";
|
const char *BuiltinName = "";
|
||||||
#define GET_GCC_BUILTIN_NAME
|
#define GET_GCC_BUILTIN_NAME
|
||||||
#define Intrinsic llvm::Intrinsic
|
#define Intrinsic llvm::Intrinsic
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
#include "llvm/IR/Intrinsics.gen"
|
#include "llvm/IR/Intrinsics.gen"
|
||||||
#endif
|
#endif
|
||||||
#undef Intrinsic
|
#undef Intrinsic
|
||||||
@@ -4092,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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#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));
|
||||||
@@ -4148,9 +4149,9 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
|
|||||||
|
|
||||||
// If this is a call to a struct-return function, assign to the first
|
// If this is a call to a struct-return function, assign to the first
|
||||||
// parameter instead of passing it to the call.
|
// parameter instead of passing it to the call.
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
const llvm::AttrListPtr &PAL = I.getAttributes();
|
const llvm::AttrListPtr &PAL = I.getAttributes();
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
const llvm::AttributeSet &PAL = I.getAttributes();
|
const llvm::AttributeSet &PAL = I.getAttributes();
|
||||||
#endif
|
#endif
|
||||||
bool hasByVal = I.hasByValArgument();
|
bool hasByVal = I.hasByValArgument();
|
||||||
@@ -4258,9 +4259,9 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
|
|||||||
(*AI)->getType() != FTy->getParamType(ArgNo)) {
|
(*AI)->getType() != FTy->getParamType(ArgNo)) {
|
||||||
Out << '(';
|
Out << '(';
|
||||||
printType(Out, FTy->getParamType(ArgNo),
|
printType(Out, FTy->getParamType(ArgNo),
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
|
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
@@ -4268,9 +4269,9 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
|
|||||||
}
|
}
|
||||||
// Check if the argument is expected to be passed by value.
|
// Check if the argument is expected to be passed by value.
|
||||||
if (I.paramHasAttr(ArgNo+1,
|
if (I.paramHasAttr(ArgNo+1,
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
llvm::Attributes::ByVal
|
llvm::Attributes::ByVal
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
llvm::Attribute::ByVal
|
llvm::Attribute::ByVal
|
||||||
#endif
|
#endif
|
||||||
)) {
|
)) {
|
||||||
@@ -4296,9 +4297,9 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID,
|
|||||||
const char *BuiltinName = "";
|
const char *BuiltinName = "";
|
||||||
#define GET_GCC_BUILTIN_NAME
|
#define GET_GCC_BUILTIN_NAME
|
||||||
#define Intrinsic llvm::Intrinsic
|
#define Intrinsic llvm::Intrinsic
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
#include "llvm/IR/Intrinsics.gen"
|
#include "llvm/IR/Intrinsics.gen"
|
||||||
#endif
|
#endif
|
||||||
#undef Intrinsic
|
#undef Intrinsic
|
||||||
@@ -4817,7 +4818,7 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) {
|
|||||||
|
|
||||||
void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
|
void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
|
||||||
Out << "(";
|
Out << "(";
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#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
|
||||||
@@ -4828,7 +4829,7 @@ void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
|
|||||||
Out << ", ";
|
Out << ", ";
|
||||||
writeOperand(ACXI.getNewValOperand());
|
writeOperand(ACXI.getNewValOperand());
|
||||||
Out << ")";
|
Out << ")";
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#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 << ")";
|
||||||
@@ -4932,7 +4933,11 @@ SmearCleanupPass::getShuffleSmearValue(llvm::Instruction* inst) const {
|
|||||||
// Check that the shuffle is a broadcast of the element of the first vector,
|
// Check that the shuffle is a broadcast of the element of the first vector,
|
||||||
// i.e. mask vector is vector with equal elements of expected size.
|
// i.e. mask vector is vector with equal elements of expected size.
|
||||||
if (!(mask &&
|
if (!(mask &&
|
||||||
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
|
(mask->isNullValue() || (shuffleInst->getMask()->getType()->isVectorTy() && llvm::dyn_cast<llvm::ConstantVector>(shuffleInst->getMask())->getSplatValue() != 0 ) ) &&
|
||||||
|
#else
|
||||||
(mask->isNullValue() || (shuffleInst->getMask()->getSplatValue() != 0))&&
|
(mask->isNullValue() || (shuffleInst->getMask()->getSplatValue() != 0))&&
|
||||||
|
#endif
|
||||||
llvm::dyn_cast<llvm::VectorType>(mask->getType())->getNumElements() == vectorWidth)) {
|
llvm::dyn_cast<llvm::VectorType>(mask->getType())->getNumElements() == vectorWidth)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -4973,8 +4978,14 @@ SmearCleanupPass::getShuffleSmearValue(llvm::Instruction* inst) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
llvm::Instruction *extractCall =
|
llvm::Instruction *extractCall =
|
||||||
llvm::ExtractElementInst::Create(shuffleInst->getOperand(0), mask->getSplatValue(),
|
llvm::ExtractElementInst::Create(shuffleInst->getOperand(0),
|
||||||
"__extract_element", inst);
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
|
// mask is of VectorType
|
||||||
|
llvm::dyn_cast<llvm::ConstantVector>(mask)->getSplatValue(),
|
||||||
|
#else
|
||||||
|
mask->getSplatValue(),
|
||||||
|
#endif
|
||||||
|
"__extract_element", inst);
|
||||||
return extractCall;
|
return extractCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5150,10 +5161,10 @@ public:
|
|||||||
notFunc =
|
notFunc =
|
||||||
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__not", mt, mt, NULL));
|
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__not", mt, mt, NULL));
|
||||||
assert(notFunc != NULL);
|
assert(notFunc != NULL);
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
notFunc->addFnAttr(llvm::Attributes::NoUnwind);
|
notFunc->addFnAttr(llvm::Attributes::NoUnwind);
|
||||||
notFunc->addFnAttr(llvm::Attributes::ReadNone);
|
notFunc->addFnAttr(llvm::Attributes::ReadNone);
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
notFunc->addFnAttr(llvm::Attribute::NoUnwind);
|
notFunc->addFnAttr(llvm::Attribute::NoUnwind);
|
||||||
notFunc->addFnAttr(llvm::Attribute::ReadNone);
|
notFunc->addFnAttr(llvm::Attribute::ReadNone);
|
||||||
#endif
|
#endif
|
||||||
@@ -5162,10 +5173,10 @@ public:
|
|||||||
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not1", mt, mt, mt,
|
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not1", mt, mt, mt,
|
||||||
NULL));
|
NULL));
|
||||||
assert(andNotFuncs[0] != NULL);
|
assert(andNotFuncs[0] != NULL);
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
andNotFuncs[0]->addFnAttr(llvm::Attributes::NoUnwind);
|
andNotFuncs[0]->addFnAttr(llvm::Attributes::NoUnwind);
|
||||||
andNotFuncs[0]->addFnAttr(llvm::Attributes::ReadNone);
|
andNotFuncs[0]->addFnAttr(llvm::Attributes::ReadNone);
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind);
|
andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind);
|
||||||
andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone);
|
andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone);
|
||||||
#endif
|
#endif
|
||||||
@@ -5173,10 +5184,10 @@ public:
|
|||||||
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not2", mt, mt, mt,
|
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not2", mt, mt, mt,
|
||||||
NULL));
|
NULL));
|
||||||
assert(andNotFuncs[1] != NULL);
|
assert(andNotFuncs[1] != NULL);
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
andNotFuncs[1]->addFnAttr(llvm::Attributes::NoUnwind);
|
andNotFuncs[1]->addFnAttr(llvm::Attributes::NoUnwind);
|
||||||
andNotFuncs[1]->addFnAttr(llvm::Attributes::ReadNone);
|
andNotFuncs[1]->addFnAttr(llvm::Attributes::ReadNone);
|
||||||
#else
|
#else /* LLVM 3.3+ */
|
||||||
andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind);
|
andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind);
|
||||||
andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone);
|
andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone);
|
||||||
#endif
|
#endif
|
||||||
@@ -5304,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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
|
||||||
@@ -5316,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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#else
|
#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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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);
|
||||||
@@ -5350,7 +5361,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth,
|
|||||||
pm.add(llvm::createDeadCodeEliminationPass()); // clean up after smear pass
|
pm.add(llvm::createDeadCodeEliminationPass()); // clean up after smear pass
|
||||||
//CO pm.add(llvm::createPrintModulePass(&fos));
|
//CO pm.add(llvm::createPrintModulePass(&fos));
|
||||||
pm.add(new CWriter(fos, includeName, vectorWidth));
|
pm.add(new CWriter(fos, includeName, vectorWidth));
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
// This interface is depricated for 3.3+
|
// This interface is depricated for 3.3+
|
||||||
pm.add(llvm::createGCInfoDeleter());
|
pm.add(llvm::createGCInfoDeleter());
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
124
ctx.cpp
124
ctx.cpp
@@ -46,7 +46,7 @@
|
|||||||
#include "sym.h"
|
#include "sym.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include <llvm/Metadata.h>
|
#include <llvm/Metadata.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
@@ -337,25 +337,27 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */
|
||||||
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
|
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
|
||||||
#elif defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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;
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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+ */
|
||||||
llvm::DIType *diSubprogramType = NULL;
|
llvm::DIType *diSubprogramType = NULL;
|
||||||
|
//llvm::MDType *diSubprogramType = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const FunctionType *functionType = function->GetType();
|
const FunctionType *functionType = function->GetType();
|
||||||
@@ -363,21 +365,22 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 3.2, 3.3 */
|
||||||
llvm::DIType diSubprogramType_n = diSubprogramType;
|
llvm::DIType diSubprogramType_n = diSubprogramType;
|
||||||
#elif defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
int flags = llvm::DIDescriptor::FlagPrototyped;
|
||||||
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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);
|
||||||
int flags = llvm::DIDescriptor::FlagPrototyped;
|
int flags = llvm::DIDescriptor::FlagPrototyped;
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
Assert(llvm::isa<llvm::DICompositeTypeBase>(diSubprogramType));
|
Assert(llvm::isa<llvm::DICompositeTypeBase>(diSubprogramType));
|
||||||
llvm::DISubroutineType *diSubprogramType_n =
|
llvm::DISubroutineType *diSubprogramType_n =
|
||||||
llvm::cast<llvm::DISubroutineType>(getDICompositeType(diSubprogramType));
|
llvm::cast<llvm::DISubroutineType>(getDICompositeType(diSubprogramType));
|
||||||
@@ -392,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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,
|
||||||
@@ -401,7 +404,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
|||||||
firstLine, flags,
|
firstLine, flags,
|
||||||
isOptimized, llvmFunction);
|
isOptimized, llvmFunction);
|
||||||
AssertPos(currentPos, diSubprogram.Verify());
|
AssertPos(currentPos, diSubprogram.Verify());
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
diSubprogram =
|
diSubprogram =
|
||||||
m->diBuilder->createFunction(diFile /* scope */, funSym->name,
|
m->diBuilder->createFunction(diFile /* scope */, funSym->name,
|
||||||
mangledName, diFile,
|
mangledName, diFile,
|
||||||
@@ -1610,9 +1613,9 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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),
|
||||||
sPtr, arrayRef, "sptr", bblock);
|
sPtr, arrayRef, "sptr", bblock);
|
||||||
#endif
|
#endif
|
||||||
@@ -1654,10 +1657,11 @@ FunctionEmitContext::GetDebugPos() const {
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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) {
|
||||||
|
//llvm::MDScope *scope) {
|
||||||
#endif
|
#endif
|
||||||
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(value);
|
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(value);
|
||||||
if (inst != NULL && m->diBuilder) {
|
if (inst != NULL && m->diBuilder) {
|
||||||
@@ -1668,9 +1672,9 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.2, 3.3, 3.4, 3.5, 3.6 */
|
||||||
*scope
|
*scope
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
scope
|
scope
|
||||||
#endif
|
#endif
|
||||||
: GetDIScope()));
|
: GetDIScope()));
|
||||||
@@ -1681,12 +1685,14 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::StartScope() {
|
FunctionEmitContext::StartScope() {
|
||||||
if (m->diBuilder != NULL) {
|
if (m->diBuilder != NULL) {
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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+ */
|
||||||
llvm::DIScope *parentScope;
|
llvm::DIScope *parentScope;
|
||||||
llvm::DILexicalBlock *lexicalBlock;
|
llvm::DILexicalBlock *lexicalBlock;
|
||||||
|
//llvm::MDScope *parentScope;
|
||||||
|
//llvm::MDLexicalBlock *lexicalBlock;
|
||||||
#endif
|
#endif
|
||||||
if (debugScopes.size() > 0)
|
if (debugScopes.size() > 0)
|
||||||
parentScope = debugScopes.back();
|
parentScope = debugScopes.back();
|
||||||
@@ -1696,7 +1702,7 @@ FunctionEmitContext::StartScope() {
|
|||||||
lexicalBlock =
|
lexicalBlock =
|
||||||
m->diBuilder->createLexicalBlock(parentScope, diFile,
|
m->diBuilder->createLexicalBlock(parentScope, diFile,
|
||||||
currentPos.first_line,
|
currentPos.first_line,
|
||||||
#if defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_5
|
||||||
// Revision 202736 in LLVM adds support of DWARF discriminator
|
// Revision 202736 in LLVM adds support of DWARF discriminator
|
||||||
// to the last argument and revision 202737 in clang adds 0
|
// to the last argument and revision 202737 in clang adds 0
|
||||||
// for the last argument by default.
|
// for the last argument by default.
|
||||||
@@ -1706,11 +1712,12 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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+ */
|
||||||
debugScopes.push_back(llvm::cast<llvm::DILexicalBlockBase>(lexicalBlock));
|
debugScopes.push_back(llvm::cast<llvm::DILexicalBlockBase>(lexicalBlock));
|
||||||
|
//debugScopes.push_back(llvm::cast<llvm::MDLexicalBlockBase>(lexicalBlock));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1725,10 +1732,11 @@ FunctionEmitContext::EndScope() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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*
|
||||||
|
//llvm::MDScope*
|
||||||
#endif
|
#endif
|
||||||
FunctionEmitContext::GetDIScope() const {
|
FunctionEmitContext::GetDIScope() const {
|
||||||
AssertPos(currentPos, debugScopes.size() > 0);
|
AssertPos(currentPos, debugScopes.size() > 0);
|
||||||
@@ -1741,15 +1749,18 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
|||||||
if (m->diBuilder == NULL)
|
if (m->diBuilder == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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());
|
||||||
llvm::DIVariable var =
|
llvm::DIVariable var =
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
llvm::DIScope *scope = GetDIScope();
|
llvm::DIScope *scope = GetDIScope();
|
||||||
llvm::DIType *diType = sym->type->GetDIType(scope);
|
llvm::DIType *diType = sym->type->GetDIType(scope);
|
||||||
llvm::DILocalVariable *var =
|
llvm::DILocalVariable *var =
|
||||||
|
//llvm::MDScope *scope = GetDIScope();
|
||||||
|
//llvm::MDType *diType = sym->type->GetDIType(scope);
|
||||||
|
//llvm::MDLocalVariable *var =
|
||||||
#endif
|
#endif
|
||||||
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
|
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
|
||||||
scope,
|
scope,
|
||||||
@@ -1758,16 +1769,16 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
|||||||
sym->pos.first_line,
|
sym->pos.first_line,
|
||||||
diType,
|
diType,
|
||||||
true /* preserve through opts */);
|
true /* preserve through opts */);
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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,
|
||||||
#if defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_6
|
||||||
m->diBuilder->createExpression(),
|
m->diBuilder->createExpression(),
|
||||||
#endif
|
#endif
|
||||||
bblock);
|
bblock);
|
||||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::Instruction *declareInst =
|
llvm::Instruction *declareInst =
|
||||||
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
||||||
m->diBuilder->createExpression(),
|
m->diBuilder->createExpression(),
|
||||||
@@ -1785,15 +1796,18 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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());
|
||||||
llvm::DIVariable var =
|
llvm::DIVariable var =
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
llvm::DIScope *scope = diSubprogram;
|
llvm::DIScope *scope = diSubprogram;
|
||||||
llvm::DIType *diType = sym->type->GetDIType(scope);
|
llvm::DIType *diType = sym->type->GetDIType(scope);
|
||||||
llvm::DILocalVariable *var =
|
llvm::DILocalVariable *var =
|
||||||
|
//llvm::MDScope *scope = diSubprogram;
|
||||||
|
//llvm::MDType *diType = sym->type->GetDIType(scope);
|
||||||
|
//llvm::MDLocalVariable *var =
|
||||||
#endif
|
#endif
|
||||||
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_arg_variable,
|
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_arg_variable,
|
||||||
scope,
|
scope,
|
||||||
@@ -1804,16 +1818,16 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
|
|||||||
true /* preserve through opts */,
|
true /* preserve through opts */,
|
||||||
flags,
|
flags,
|
||||||
argNum + 1);
|
argNum + 1);
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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,
|
||||||
#if defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_6
|
||||||
m->diBuilder->createExpression(),
|
m->diBuilder->createExpression(),
|
||||||
#endif
|
#endif
|
||||||
bblock);
|
bblock);
|
||||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::Instruction *declareInst =
|
llvm::Instruction *declareInst =
|
||||||
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
||||||
m->diBuilder->createExpression(),
|
m->diBuilder->createExpression(),
|
||||||
@@ -2430,11 +2444,11 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::Instruction *inst =
|
llvm::Instruction *inst =
|
||||||
llvm::GetElementPtrInst::Create(PTYPE(basePtr),
|
llvm::GetElementPtrInst::Create(PTYPE(basePtr),
|
||||||
basePtr, arrayRef,
|
basePtr, arrayRef,
|
||||||
@@ -2497,11 +2511,11 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::Instruction *inst =
|
llvm::Instruction *inst =
|
||||||
llvm::GetElementPtrInst::Create(PTYPE(basePtr),
|
llvm::GetElementPtrInst::Create(PTYPE(basePtr),
|
||||||
basePtr, arrayRef,
|
basePtr, arrayRef,
|
||||||
@@ -2598,11 +2612,11 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
resultPtr =
|
resultPtr =
|
||||||
llvm::GetElementPtrInst::Create(PTYPE(basePtr), basePtr, arrayRef,
|
llvm::GetElementPtrInst::Create(PTYPE(basePtr), basePtr, arrayRef,
|
||||||
name ? name : "struct_offset", bblock);
|
name ? name : "struct_offset", bblock);
|
||||||
@@ -2909,41 +2923,41 @@ 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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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);
|
||||||
#endif
|
#endif
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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));
|
||||||
#endif
|
#endif
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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));
|
||||||
#endif
|
#endif
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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));
|
||||||
#endif
|
#endif
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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));
|
||||||
#endif
|
#endif
|
||||||
md = llvm::MDNode::get(*g->ctx, last_column);
|
md = llvm::MDNode::get(*g->ctx, last_column);
|
||||||
@@ -3577,7 +3591,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType,
|
|||||||
// alias analysis.
|
// alias analysis.
|
||||||
// TODO: what other attributes needs to be copied?
|
// TODO: what other attributes needs to be copied?
|
||||||
// TODO: do the same for varing path.
|
// TODO: do the same for varing path.
|
||||||
#if !defined (LLVM_3_2) // LLVM 3.3+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 // LLVM 3.3+
|
||||||
llvm::CallInst *cc = llvm::dyn_cast<llvm::CallInst>(ci);
|
llvm::CallInst *cc = llvm::dyn_cast<llvm::CallInst>(ci);
|
||||||
if (cc &&
|
if (cc &&
|
||||||
cc->getCalledFunction() &&
|
cc->getCalledFunction() &&
|
||||||
|
|||||||
21
ctx.h
21
ctx.h
@@ -40,19 +40,19 @@
|
|||||||
|
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#include <llvm/InstrTypes.h>
|
#include <llvm/InstrTypes.h>
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#else
|
#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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5
|
||||||
#include <llvm/IR/DebugInfo.h>
|
|
||||||
#include <llvm/IR/DIBuilder.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/DebugInfo.h>
|
#include <llvm/DebugInfo.h>
|
||||||
#include <llvm/DIBuilder.h>
|
#include <llvm/DIBuilder.h>
|
||||||
|
#else /* >= 3.5 */
|
||||||
|
#include <llvm/IR/DebugInfo.h>
|
||||||
|
#include <llvm/IR/DIBuilder.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct CFInfo;
|
struct CFInfo;
|
||||||
@@ -352,10 +352,11 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIScope *scope = NULL);
|
llvm::DIScope *scope = NULL);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::DIScope *scope = NULL);
|
llvm::DIScope *scope = NULL);
|
||||||
|
//llvm::MDScope *scope = NULL );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Inform the debugging information generation code that a new scope
|
/** Inform the debugging information generation code that a new scope
|
||||||
@@ -368,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIScope GetDIScope() const;
|
llvm::DIScope GetDIScope() const;
|
||||||
#else // LLVM 3.7++
|
#else // LLVM 3.7++
|
||||||
llvm::DIScope *GetDIScope() const;
|
llvm::DIScope *GetDIScope() const;
|
||||||
@@ -683,7 +684,7 @@ private:
|
|||||||
emitted. */
|
emitted. */
|
||||||
std::vector<CFInfo *> controlFlowInfo;
|
std::vector<CFInfo *> controlFlowInfo;
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
/** 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;
|
||||||
|
|||||||
4
expr.cpp
4
expr.cpp
@@ -56,7 +56,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(LLVM_3_2)
|
#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>
|
||||||
@@ -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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */
|
||||||
#include <llvm/IR/InstIterator.h>
|
#include <llvm/IR/InstIterator.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/Support/InstIterator.h>
|
#include <llvm/Support/InstIterator.h>
|
||||||
|
|||||||
34
func.cpp
34
func.cpp
@@ -46,7 +46,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* < 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 !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 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,11 +360,19 @@ 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+ */
|
||||||
|
llvm::SmallVector<llvm::Metadata*, 3> av;
|
||||||
|
av.push_back(llvm::ValueAsMetadata::get(function));
|
||||||
|
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
||||||
|
av.push_back(llvm::ConstantAsMetadata::get(LLVMInt32(1)));
|
||||||
|
annotations->addOperand(llvm::MDNode::get(*g->ctx, llvm::ArrayRef<llvm::Metadata*>(av)));
|
||||||
|
#else
|
||||||
llvm::SmallVector<llvm::Value*, 3> av;
|
llvm::SmallVector<llvm::Value*, 3> av;
|
||||||
av.push_back(function);
|
av.push_back(function);
|
||||||
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
||||||
av.push_back(LLVMInt32(1));
|
av.push_back(LLVMInt32(1));
|
||||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* ISPC_NVPTX_ENABLED */
|
#endif /* ISPC_NVPTX_ENABLED */
|
||||||
}
|
}
|
||||||
@@ -384,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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 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
|
||||||
&&
|
&&
|
||||||
@@ -569,11 +577,21 @@ 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+ */
|
||||||
|
|
||||||
|
llvm::SmallVector<llvm::Metadata*, 3> av;
|
||||||
|
av.push_back(llvm::ValueAsMetadata::get(function));
|
||||||
|
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
||||||
|
av.push_back(llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1)));
|
||||||
|
annotations->addOperand(llvm::MDNode::get(*g->ctx, llvm::ArrayRef<llvm::Metadata*>(av)));
|
||||||
|
#else
|
||||||
llvm::SmallVector<llvm::Value*, 3> av;
|
llvm::SmallVector<llvm::Value*, 3> av;
|
||||||
av.push_back(appFunction);
|
av.push_back(function);
|
||||||
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
av.push_back(llvm::MDString::get(*g->ctx, "kernel"));
|
||||||
av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1));
|
av.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(*g->ctx,32), 1));
|
||||||
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
annotations->addOperand(llvm::MDNode::get(*g->ctx, av));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* ISPC_NVPTX_ENABLED */
|
#endif /* ISPC_NVPTX_ENABLED */
|
||||||
}
|
}
|
||||||
|
|||||||
89
ispc.cpp
89
ispc.cpp
@@ -50,22 +50,22 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include <llvm/LLVMContext.h>
|
#include <llvm/LLVMContext.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#else
|
#else /* 3.3+ */
|
||||||
#include <llvm/IR/LLVMContext.h>
|
#include <llvm/IR/LLVMContext.h>
|
||||||
#include <llvm/IR/Module.h>
|
#include <llvm/IR/Module.h>
|
||||||
#include <llvm/IR/Instructions.h>
|
#include <llvm/IR/Instructions.h>
|
||||||
#endif
|
#endif
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
|
||||||
#include <llvm/Target/TargetSubtargetInfo.h>
|
#include <llvm/Target/TargetSubtargetInfo.h>
|
||||||
#if !defined(LLVM_3_6) // LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
#include <llvm/Target/TargetLowering.h>
|
#include <llvm/Target/TargetLowering.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
|
||||||
#include <llvm/IR/DebugInfo.h>
|
#include <llvm/IR/DebugInfo.h>
|
||||||
#include <llvm/IR/DIBuilder.h>
|
#include <llvm/IR/DIBuilder.h>
|
||||||
#else // LLVM 3.2, 3.3, 3.4
|
#else // LLVM 3.2, 3.3, 3.4
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
#include <llvm/Target/TargetMachine.h>
|
#include <llvm/Target/TargetMachine.h>
|
||||||
#include <llvm/Target/TargetOptions.h>
|
#include <llvm/Target/TargetOptions.h>
|
||||||
#if defined(LLVM_3_2)
|
#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>
|
||||||
@@ -233,17 +233,17 @@ typedef enum {
|
|||||||
// Haswell. Supports AVX 2.
|
// Haswell. Supports AVX 2.
|
||||||
CPU_Haswell,
|
CPU_Haswell,
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
|
||||||
// Broadwell. Supports AVX 2 + ADX/RDSEED/SMAP.
|
// Broadwell. Supports AVX 2 + ADX/RDSEED/SMAP.
|
||||||
CPU_Broadwell,
|
CPU_Broadwell,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
// KNL. Supports AVX512.
|
// KNL. Supports AVX512.
|
||||||
CPU_KNL,
|
CPU_KNL,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+
|
||||||
// Late Atom-like design. Supports SSE 4.2 + POPCNT/LZCNT.
|
// Late Atom-like design. Supports SSE 4.2 + POPCNT/LZCNT.
|
||||||
CPU_Silvermont,
|
CPU_Silvermont,
|
||||||
#endif
|
#endif
|
||||||
@@ -302,7 +302,7 @@ public:
|
|||||||
|
|
||||||
names[CPU_Penryn].push_back("penryn");
|
names[CPU_Penryn].push_back("penryn");
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 // LLVM 3.4+
|
||||||
names[CPU_Silvermont].push_back("slm");
|
names[CPU_Silvermont].push_back("slm");
|
||||||
names[CPU_Silvermont].push_back("silvermont");
|
names[CPU_Silvermont].push_back("silvermont");
|
||||||
#endif
|
#endif
|
||||||
@@ -319,11 +319,11 @@ public:
|
|||||||
names[CPU_Haswell].push_back("core-avx2");
|
names[CPU_Haswell].push_back("core-avx2");
|
||||||
names[CPU_Haswell].push_back("haswell");
|
names[CPU_Haswell].push_back("haswell");
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6 // LLVM 3.6+
|
||||||
names[CPU_Broadwell].push_back("broadwell");
|
names[CPU_Broadwell].push_back("broadwell");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
names[CPU_KNL].push_back("knl");
|
names[CPU_KNL].push_back("knl");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -338,24 +338,24 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) // LLVM 3.4+
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4 // LLVM 3.2 or 3.3
|
||||||
#define CPU_Silvermont CPU_Nehalem
|
#define CPU_Silvermont CPU_Nehalem
|
||||||
#else
|
#else /* LLVM 3.4+ */
|
||||||
compat[CPU_Silvermont] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn,
|
compat[CPU_Silvermont] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn,
|
||||||
CPU_Core2, CPU_Nehalem, CPU_Silvermont,
|
CPU_Core2, CPU_Nehalem, CPU_Silvermont,
|
||||||
CPU_None);
|
CPU_None);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
compat[CPU_KNL] = Set(CPU_KNL, CPU_Generic, CPU_Bonnell, CPU_Penryn,
|
compat[CPU_KNL] = Set(CPU_KNL, CPU_Generic, CPU_Bonnell, CPU_Penryn,
|
||||||
CPU_Core2, CPU_Nehalem, CPU_Silvermont,
|
CPU_Core2, CPU_Nehalem, CPU_Silvermont,
|
||||||
CPU_SandyBridge, CPU_IvyBridge,
|
CPU_SandyBridge, CPU_IvyBridge,
|
||||||
CPU_Haswell, CPU_Broadwell, CPU_None);
|
CPU_Haswell, CPU_Broadwell, CPU_None);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) // LLVM 3.6+
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // LLVM 3.2, 3.3, 3.4 or 3.5
|
||||||
#define CPU_Broadwell CPU_Haswell
|
#define CPU_Broadwell CPU_Haswell
|
||||||
#else
|
#else /* LLVM 3.6+ */
|
||||||
compat[CPU_Broadwell] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn,
|
compat[CPU_Broadwell] = Set(CPU_Generic, CPU_Bonnell, CPU_Penryn,
|
||||||
CPU_Core2, CPU_Nehalem, CPU_Silvermont,
|
CPU_Core2, CPU_Nehalem, CPU_Silvermont,
|
||||||
CPU_SandyBridge, CPU_IvyBridge,
|
CPU_SandyBridge, CPU_IvyBridge,
|
||||||
@@ -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 !defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 /* ! 3.2 */
|
||||||
m_tf_attributes(NULL),
|
m_tf_attributes(NULL),
|
||||||
#endif
|
#endif
|
||||||
m_nativeVectorWidth(-1),
|
m_nativeVectorWidth(-1),
|
||||||
@@ -507,13 +507,13 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
case CPU_KNL:
|
case CPU_KNL:
|
||||||
isa = "avx512knl-i32x16";
|
isa = "avx512knl-i32x16";
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6
|
||||||
case CPU_Broadwell:
|
case CPU_Broadwell:
|
||||||
#endif
|
#endif
|
||||||
case CPU_Haswell:
|
case CPU_Haswell:
|
||||||
@@ -531,7 +531,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
|
|||||||
// Penryn is here because ISPC does not use SSE 4.2
|
// Penryn is here because ISPC does not use SSE 4.2
|
||||||
case CPU_Penryn:
|
case CPU_Penryn:
|
||||||
case CPU_Nehalem:
|
case CPU_Nehalem:
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4
|
||||||
case CPU_Silvermont:
|
case CPU_Silvermont:
|
||||||
#endif
|
#endif
|
||||||
isa = "sse4-i32x4";
|
isa = "sse4-i32x4";
|
||||||
@@ -569,7 +569,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
|
|||||||
|
|
||||||
// Make sure the target architecture is a known one; print an error
|
// Make sure the target architecture is a known one; print an error
|
||||||
// with the valid ones otherwise.
|
// with the valid ones otherwise.
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) // 3.7 +
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
for (llvm::TargetRegistry::iterator iter = llvm::TargetRegistry::targets().begin();
|
for (llvm::TargetRegistry::iterator iter = llvm::TargetRegistry::targets().begin();
|
||||||
iter != llvm::TargetRegistry::targets().end(); ++iter) {
|
iter != llvm::TargetRegistry::targets().end(); ++iter) {
|
||||||
#else
|
#else
|
||||||
@@ -584,7 +584,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
|
|||||||
if (this->m_target == NULL) {
|
if (this->m_target == NULL) {
|
||||||
fprintf(stderr, "Invalid architecture \"%s\"\nOptions: ", arch);
|
fprintf(stderr, "Invalid architecture \"%s\"\nOptions: ", arch);
|
||||||
llvm::TargetRegistry::iterator iter;
|
llvm::TargetRegistry::iterator iter;
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) // 3.7 +
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
for (iter = llvm::TargetRegistry::targets().begin();
|
for (iter = llvm::TargetRegistry::targets().begin();
|
||||||
iter != llvm::TargetRegistry::targets().end(); ++iter)
|
iter != llvm::TargetRegistry::targets().end(); ++iter)
|
||||||
#else
|
#else
|
||||||
@@ -891,7 +891,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
|
|||||||
this->m_hasGather = true;
|
this->m_hasGather = true;
|
||||||
CPUfromISA = CPU_Haswell;
|
CPUfromISA = CPU_Haswell;
|
||||||
}
|
}
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
else if (!strcasecmp(isa, "avx512knl-i32x16")) {
|
else if (!strcasecmp(isa, "avx512knl-i32x16")) {
|
||||||
this->m_isa = Target::KNL_AVX512;
|
this->m_isa = Target::KNL_AVX512;
|
||||||
this->m_nativeVectorWidth = 16;
|
this->m_nativeVectorWidth = 16;
|
||||||
@@ -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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
#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,18 +1034,17 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
m_targetMachine->setAsmVerbosityDefault(true);
|
m_targetMachine->setAsmVerbosityDefault(true);
|
||||||
#else
|
#else /* LLVM 3.7+ */
|
||||||
m_targetMachine->Options.MCOptions.AsmVerbose = true;
|
m_targetMachine->Options.MCOptions.AsmVerbose = true;
|
||||||
#endif
|
#endif
|
||||||
// Initialize TargetData/DataLayout in 3 steps.
|
// Initialize TargetData/DataLayout in 3 steps.
|
||||||
// 1. Get default data layout first
|
// 1. Get default data layout first
|
||||||
std::string dl_string;
|
std::string dl_string;
|
||||||
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_6
|
||||||
#if defined(LLVM_3_6)
|
|
||||||
dl_string = m_targetMachine->getSubtargetImpl()->getDataLayout()->getStringRepresentation();
|
dl_string = m_targetMachine->getSubtargetImpl()->getDataLayout()->getStringRepresentation();
|
||||||
#else // LLVM 3.5- and LLVM 3.7+
|
#else // LLVM 3.5- or LLVM 3.7+
|
||||||
dl_string = m_targetMachine->getDataLayout()->getStringRepresentation();
|
dl_string = m_targetMachine->getDataLayout()->getStringRepresentation();
|
||||||
#endif
|
#endif
|
||||||
// 2. Adjust for generic
|
// 2. Adjust for generic
|
||||||
@@ -1076,7 +1075,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
|
|||||||
|
|
||||||
this->m_is32Bit = (getDataLayout()->getPointerSize() == 4);
|
this->m_is32Bit = (getDataLayout()->getPointerSize() == 4);
|
||||||
|
|
||||||
#if !defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3
|
||||||
// This is LLVM 3.3+ feature.
|
// This is LLVM 3.3+ feature.
|
||||||
// Initialize target-specific "target-feature" attribute.
|
// Initialize target-specific "target-feature" attribute.
|
||||||
if (!m_attributes.empty()) {
|
if (!m_attributes.empty()) {
|
||||||
@@ -1135,11 +1134,11 @@ Target::SupportedTargets() {
|
|||||||
"avx1-i32x8, avx1-i32x16, avx1-i64x4, "
|
"avx1-i32x8, avx1-i32x16, avx1-i64x4, "
|
||||||
"avx1.1-i32x8, avx1.1-i32x16, avx1.1-i64x4, "
|
"avx1.1-i32x8, avx1.1-i32x16, avx1.1-i64x4, "
|
||||||
"avx2-i32x8, avx2-i32x16, avx2-i64x4, "
|
"avx2-i32x8, avx2-i32x16, avx2-i64x4, "
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
"avx512knl-i32x16, "
|
"avx512knl-i32x16, "
|
||||||
#endif
|
#endif
|
||||||
"generic-x1, generic-x4, generic-x8, generic-x16, "
|
"generic-x1, generic-x4, generic-x8, generic-x16, "
|
||||||
"generic-x32, generic-x64, *-generic-x16"
|
"generic-x32, generic-x64, *-generic-x16, "
|
||||||
#ifdef ISPC_ARM_ENABLED
|
#ifdef ISPC_ARM_ENABLED
|
||||||
", neon-i8x16, neon-i16x8, neon-i32x4"
|
", neon-i8x16, neon-i16x8, neon-i32x4"
|
||||||
#endif
|
#endif
|
||||||
@@ -1208,7 +1207,7 @@ Target::ISAToString(ISA isa) {
|
|||||||
return "avx11";
|
return "avx11";
|
||||||
case Target::AVX2:
|
case Target::AVX2:
|
||||||
return "avx2";
|
return "avx2";
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
case Target::KNL_AVX512:
|
case Target::KNL_AVX512:
|
||||||
return "avx512knl-i32x16";
|
return "avx512knl-i32x16";
|
||||||
#endif
|
#endif
|
||||||
@@ -1256,7 +1255,7 @@ Target::ISAToTargetString(ISA isa) {
|
|||||||
return "avx1.1-i32x8";
|
return "avx1.1-i32x8";
|
||||||
case Target::AVX2:
|
case Target::AVX2:
|
||||||
return "avx2-i32x8";
|
return "avx2-i32x8";
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6)// LLVM 3.7+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+
|
||||||
case Target::KNL_AVX512:
|
case Target::KNL_AVX512:
|
||||||
return "avx512knl-i32x16";
|
return "avx512knl-i32x16";
|
||||||
#endif
|
#endif
|
||||||
@@ -1325,11 +1324,11 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::Instruction *gep =
|
llvm::Instruction *gep =
|
||||||
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep",
|
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "sizeof_gep",
|
||||||
insertAtEnd);
|
insertAtEnd);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::Instruction *gep =
|
llvm::Instruction *gep =
|
||||||
llvm::GetElementPtrInst::Create(PTYPE(voidPtr), voidPtr,
|
llvm::GetElementPtrInst::Create(PTYPE(voidPtr), voidPtr,
|
||||||
arrayRef, "sizeof_gep",
|
arrayRef, "sizeof_gep",
|
||||||
@@ -1363,11 +1362,11 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::Instruction *gep =
|
llvm::Instruction *gep =
|
||||||
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep",
|
llvm::GetElementPtrInst::Create(voidPtr, arrayRef, "offset_gep",
|
||||||
insertAtEnd);
|
insertAtEnd);
|
||||||
#else // LLVM 3.7++
|
#else /* LLVM 3.7+ */
|
||||||
llvm::Instruction *gep =
|
llvm::Instruction *gep =
|
||||||
llvm::GetElementPtrInst::Create(PTYPE(voidPtr), voidPtr,
|
llvm::GetElementPtrInst::Create(PTYPE(voidPtr), voidPtr,
|
||||||
arrayRef, "offset_gep",
|
arrayRef, "offset_gep",
|
||||||
@@ -1399,7 +1398,7 @@ Target::StructOffset(llvm::Type *type, int element,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Target::markFuncWithTargetAttr(llvm::Function* func) {
|
void Target::markFuncWithTargetAttr(llvm::Function* func) {
|
||||||
#if !defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3
|
||||||
if (m_tf_attributes) {
|
if (m_tf_attributes) {
|
||||||
func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes);
|
func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes);
|
||||||
}
|
}
|
||||||
@@ -1484,19 +1483,21 @@ SourcePos::SourcePos(const char *n, int fl, int fc, int ll, int lc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIFile
|
llvm::DIFile
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
llvm::DIFile*
|
llvm::DIFile*
|
||||||
|
//llvm::MDFile*
|
||||||
#endif
|
#endif
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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+ */
|
||||||
llvm::DIFile *ret = m->diBuilder->createFile(filename, directory);
|
llvm::DIFile *ret = m->diBuilder->createFile(filename, directory);
|
||||||
|
//llvm::MDFile *ret = m->diBuilder->createFile(filename, directory);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
12
ispc.h
12
ispc.h
@@ -38,9 +38,9 @@
|
|||||||
#ifndef ISPC_H
|
#ifndef ISPC_H
|
||||||
#define ISPC_H
|
#define ISPC_H
|
||||||
|
|
||||||
#define ISPC_VERSION "1.8.3dev"
|
#include "ispc_version.h"
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) && !defined(LLVM_3_7)
|
#if ISPC_LLVM_VERSION < OLDEST_SUPPORTED_LLVM || ISPC_LLVM_VERSION > LATEST_SUPPORTED_LLVM
|
||||||
#error "Only LLVM 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 development branch are supported"
|
#error "Only LLVM 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 development branch are supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ namespace llvm {
|
|||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
class Type;
|
class Type;
|
||||||
class Value;
|
class Value;
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
class DIFile;
|
class DIFile;
|
||||||
class DIType;
|
class DIType;
|
||||||
class DIDescriptor;
|
class DIDescriptor;
|
||||||
@@ -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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
/** 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
|
||||||
@@ -259,7 +259,7 @@ public:
|
|||||||
|
|
||||||
// Note the same name of method for 3.1 and 3.2+, this allows
|
// Note the same name of method for 3.1 and 3.2+, this allows
|
||||||
// to reduce number ifdefs on client side.
|
// to reduce number ifdefs on client side.
|
||||||
llvm::DataLayout *getDataLayout() const {return m_dataLayout;}
|
const llvm::DataLayout *getDataLayout() const {return m_dataLayout;}
|
||||||
|
|
||||||
/** Reports if Target object has valid state. */
|
/** Reports if Target object has valid state. */
|
||||||
bool isValid() const {return m_valid;}
|
bool isValid() const {return m_valid;}
|
||||||
@@ -344,7 +344,7 @@ private:
|
|||||||
/** Target-specific attribute string to pass along to the LLVM backend */
|
/** Target-specific attribute string to pass along to the LLVM backend */
|
||||||
std::string m_attributes;
|
std::string m_attributes;
|
||||||
|
|
||||||
#if !defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3
|
||||||
/** Target-specific LLVM attribute, which has to be attached to every
|
/** Target-specific LLVM attribute, which has to be attached to every
|
||||||
function to ensure that it is generated for correct target architecture.
|
function to ensure that it is generated for correct target architecture.
|
||||||
This is requirement was introduced in LLVM 3.3 */
|
This is requirement was introduced in LLVM 3.3 */
|
||||||
|
|||||||
64
ispc_version.h
Normal file
64
ispc_version.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2015, Intel Corporation
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of Intel Corporation nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
||||||
|
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file ispc_version.h
|
||||||
|
@brief defines the ISPC version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ISPC_VERSION_H
|
||||||
|
#define ISPC_VERSION_H
|
||||||
|
|
||||||
|
#define ISPC_VERSION "1.8.3dev"
|
||||||
|
#include "llvm/Config/llvm-config.h"
|
||||||
|
|
||||||
|
#define ISPC_LLVM_VERSION ( LLVM_VERSION_MAJOR * 10000 + LLVM_VERSION_MINOR * 100 )
|
||||||
|
|
||||||
|
#define ISPC_LLVM_3_2 30200
|
||||||
|
#define ISPC_LLVM_3_3 30300
|
||||||
|
#define ISPC_LLVM_3_4 30400
|
||||||
|
#define ISPC_LLVM_3_5 30500
|
||||||
|
#define ISPC_LLVM_3_6 30600
|
||||||
|
#define ISPC_LLVM_3_7 30700
|
||||||
|
|
||||||
|
#define OLDEST_SUPPORTED_LLVM ISPC_LLVM_3_2
|
||||||
|
#define LATEST_SUPPORTED_LLVM ISPC_LLVM_3_7
|
||||||
|
|
||||||
|
#ifdef __ispc__xstr
|
||||||
|
#undef __ispc__xstr
|
||||||
|
#endif
|
||||||
|
#define __ispc__xstr(s) __ispc__str(s)
|
||||||
|
#define __ispc__str(s) #s
|
||||||
|
|
||||||
|
#define ISPC_LLVM_VERSION_STRING __ispc__xstr(LLVM_VERSION_MAJOR) "." __ispc__xstr(LLVM_VERSION_MINOR)
|
||||||
|
|
||||||
|
#endif // ISPC_VERSION_H
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
#include "llvmutil.h"
|
#include "llvmutil.h"
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#include <llvm/BasicBlock.h>
|
#include <llvm/BasicBlock.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -38,12 +38,13 @@
|
|||||||
#ifndef ISPC_LLVMUTIL_H
|
#ifndef ISPC_LLVMUTIL_H
|
||||||
#define ISPC_LLVMUTIL_H 1
|
#define ISPC_LLVMUTIL_H 1
|
||||||
|
|
||||||
#if defined(LLVM_3_2)
|
#include "ispc_version.h"
|
||||||
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#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
|
#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>
|
||||||
|
|||||||
20
main.cpp
20
main.cpp
@@ -62,21 +62,7 @@ static void
|
|||||||
lPrintVersion() {
|
lPrintVersion() {
|
||||||
printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n",
|
printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n",
|
||||||
ISPC_VERSION, BUILD_VERSION, BUILD_DATE,
|
ISPC_VERSION, BUILD_VERSION, BUILD_DATE,
|
||||||
#if defined(LLVM_3_2)
|
ISPC_LLVM_VERSION_STRING
|
||||||
"3.2"
|
|
||||||
#elif defined(LLVM_3_3)
|
|
||||||
"3.3"
|
|
||||||
#elif defined(LLVM_3_4)
|
|
||||||
"3.4"
|
|
||||||
#elif defined(LLVM_3_5)
|
|
||||||
"3.5"
|
|
||||||
#elif defined(LLVM_3_6)
|
|
||||||
"3.6"
|
|
||||||
#elif defined(LLVM_3_7)
|
|
||||||
"3.7"
|
|
||||||
#else
|
|
||||||
#error "Unhandled LLVM version"
|
|
||||||
#endif
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +159,7 @@ devUsage(int ret) {
|
|||||||
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 defined(LLVM_3_4) || defined(LLVM_3_5) // only 3.4 and 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");
|
||||||
@@ -570,7 +556,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 defined(LLVM_3_4) || defined(LLVM_3_5) // only 3.4 and 3.5
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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="));
|
||||||
}
|
}
|
||||||
|
|||||||
131
module.cpp
131
module.cpp
@@ -66,8 +66,7 @@
|
|||||||
#include <io.h>
|
#include <io.h>
|
||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#if defined(LLVM_3_2)
|
|
||||||
#include <llvm/LLVMContext.h>
|
#include <llvm/LLVMContext.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#include <llvm/Type.h>
|
#include <llvm/Type.h>
|
||||||
@@ -85,16 +84,16 @@
|
|||||||
#include <llvm/IR/Intrinsics.h>
|
#include <llvm/IR/Intrinsics.h>
|
||||||
#include <llvm/IR/DerivedTypes.h>
|
#include <llvm/IR/DerivedTypes.h>
|
||||||
#ifdef ISPC_NVPTX_ENABLED
|
#ifdef ISPC_NVPTX_ENABLED
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */
|
||||||
#include <llvm/IR/AssemblyAnnotationWriter.h>
|
#include <llvm/IR/AssemblyAnnotationWriter.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/Assembly/AssemblyAnnotationWriter.h>
|
#include <llvm/Assembly/AssemblyAnnotationWriter.h>
|
||||||
#endif
|
#endif
|
||||||
#endif /* ISPC_NVPTX_ENABLED */
|
#endif /* ISPC_NVPTX_ENABLED */
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
#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>
|
||||||
@@ -103,14 +102,14 @@
|
|||||||
#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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include <llvm/DataLayout.h>
|
#include <llvm/DataLayout.h>
|
||||||
#include <llvm/TargetTransformInfo.h>
|
#include <llvm/TargetTransformInfo.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
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_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/InstIterator.h>
|
#include <llvm/IR/InstIterator.h>
|
||||||
@@ -170,9 +169,9 @@ static void
|
|||||||
lStripUnusedDebugInfo(llvm::Module *module) {
|
lStripUnusedDebugInfo(llvm::Module *module) {
|
||||||
if (g->generateDebuggingSymbols == false)
|
if (g->generateDebuggingSymbols == false)
|
||||||
return;
|
return;
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* <= 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
|
||||||
@@ -191,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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* <= 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();
|
||||||
@@ -206,9 +205,11 @@ 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::MDScope *scope = dloc->getScope();
|
||||||
node = dloc->getInlinedAt();
|
node = dloc->getInlinedAt();
|
||||||
// now following a chain of nested scopes
|
// now following a chain of nested scopes
|
||||||
while (!0) {
|
while (!0) {
|
||||||
@@ -232,36 +233,38 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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) {
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
llvm::DICompileUnit *cu = llvm::cast<llvm::DICompileUnit>(cuNode);
|
llvm::DICompileUnit *cu = llvm::cast<llvm::DICompileUnit>(cuNode);
|
||||||
llvm::DISubprogramArray subprograms = cu->getSubprograms();
|
llvm::DISubprogramArray subprograms = cu->getSubprograms();
|
||||||
|
//llvm::MDCompileUnit *cu = llvm::cast<llvm::MDCompileUnit>(cuNode);
|
||||||
|
//llvm::MDSubprogramArray subprograms = cu->getSubprograms();
|
||||||
if (subprograms.size() == 0) {
|
if (subprograms.size() == 0) {
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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+ */
|
||||||
std::set<llvm::Metadata *> SPset;
|
std::set<llvm::Metadata *> SPset;
|
||||||
std::vector<llvm::Metadata *> usedSubprograms;
|
std::vector<llvm::Metadata *> usedSubprograms;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// determine what functions of those extracted belong to the unit
|
// determine what functions of those extracted belong to the unit
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
SPset.insert(subprograms->getOperand(j));
|
SPset.insert(subprograms->getOperand(j));
|
||||||
#elif defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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
|
||||||
|
|
||||||
@@ -271,9 +274,9 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
(int)subprograms.getNumElements());
|
(int)subprograms.getNumElements());
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
(int)subprograms.size());
|
(int)subprograms.size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -296,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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 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);
|
||||||
@@ -314,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 defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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);
|
||||||
@@ -328,8 +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);
|
||||||
#else // LLVM 3.6+
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 3.6 */
|
||||||
#if defined(LLVM_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)
|
||||||
@@ -340,8 +342,9 @@ 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();
|
||||||
Assert(nodeSPs.size() == subprograms.size());
|
Assert(nodeSPs.size() == subprograms.size());
|
||||||
for (int i = 0; i < (int)nodeSPs.size(); ++i)
|
for (int i = 0; i < (int)nodeSPs.size(); ++i)
|
||||||
Assert(nodeSPs [i] == subprograms [i]);
|
Assert(nodeSPs [i] == subprograms [i]);
|
||||||
@@ -350,7 +353,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
|
|||||||
// confidence...
|
// confidence...
|
||||||
cu->replaceSubprograms(llvm::MDTuple::get(cu->getContext(),
|
cu->replaceSubprograms(llvm::MDTuple::get(cu->getContext(),
|
||||||
llvm::ArrayRef<llvm::Metadata *>(usedSubprograms)));
|
llvm::ArrayRef<llvm::Metadata *>(usedSubprograms)));
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -418,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 !defined(LLVM_3_2) && !defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 /* 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 */
|
||||||
@@ -698,7 +700,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (diBuilder) {
|
if (diBuilder) {
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 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,
|
||||||
@@ -707,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 defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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);
|
||||||
@@ -720,8 +722,9 @@ 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::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);
|
||||||
diBuilder->createGlobalVariable(
|
diBuilder->createGlobalVariable(
|
||||||
@@ -734,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
Assert(var.Verify());
|
Assert(var.Verify());
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
//comming soon
|
//comming soon
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1159,7 +1162,7 @@ Module::writeOutput(OutputType outputType, const char *outFileName,
|
|||||||
if (diBuilder && (outputType != Header) && (outputType != Deps))
|
if (diBuilder && (outputType != Header) && (outputType != Deps))
|
||||||
lStripUnusedDebugInfo(module);
|
lStripUnusedDebugInfo(module);
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 /* 3.4+ */
|
||||||
// In LLVM_3_4 after r195494 and r195504 revisions we should pass
|
// In LLVM_3_4 after r195494 and r195504 revisions we should pass
|
||||||
// "Debug Info Version" constant to the module. LLVM will ignore
|
// "Debug Info Version" constant to the module. LLVM will ignore
|
||||||
// our Debug Info metadata without it.
|
// our Debug Info metadata without it.
|
||||||
@@ -1393,7 +1396,7 @@ Module::writeBitcode(llvm::Module *module, const char *outFileName) {
|
|||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
llvm::raw_string_ostream out(s);
|
llvm::raw_string_ostream out(s);
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */
|
||||||
std::unique_ptr<llvm::AssemblyAnnotationWriter> Annotator;
|
std::unique_ptr<llvm::AssemblyAnnotationWriter> Annotator;
|
||||||
#else
|
#else
|
||||||
llvm::OwningPtr<llvm::AssemblyAnnotationWriter> Annotator;
|
llvm::OwningPtr<llvm::AssemblyAnnotationWriter> Annotator;
|
||||||
@@ -1406,7 +1409,7 @@ Module::writeBitcode(llvm::Module *module, const char *outFileName) {
|
|||||||
input.push_back(s);
|
input.push_back(s);
|
||||||
output = input;
|
output = input;
|
||||||
|
|
||||||
#if !(defined(LLVM_3_1) || defined(LLVM_3_2))
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 /* 3.3+ */
|
||||||
/* do not fix attributed with LLVM 3.2, everything is fine there */
|
/* do not fix attributed with LLVM 3.2, everything is fine there */
|
||||||
lFixAttributes(input,output);
|
lFixAttributes(input,output);
|
||||||
#endif
|
#endif
|
||||||
@@ -1442,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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4 /* 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 defined(LLVM_3_4)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 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
|
#else /* 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
if (error.size()) {
|
if (error.size()) {
|
||||||
#else // LLVM 3.6+
|
#else /* LLVM 3.6+ */
|
||||||
if (error) {
|
if (error) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1471,25 +1474,25 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 3.2, 3.3, 3.4 */
|
||||||
pm.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
pm.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
||||||
#elif defined(LLVM_3_5)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6 /* 3.5 */
|
||||||
pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
|
pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
|
||||||
#elif defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7 /* 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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)) {
|
||||||
@@ -1578,7 +1581,7 @@ lEmitStructDecl(const StructType *st, std::vector<const StructType *> *emittedSt
|
|||||||
char sSOA[48];
|
char sSOA[48];
|
||||||
bool pack, needsAlign = false;
|
bool pack, needsAlign = false;
|
||||||
llvm::Type *stype = st->LLVMType(g->ctx);
|
llvm::Type *stype = st->LLVMType(g->ctx);
|
||||||
llvm::DataLayout *DL = g->target->getDataLayout();
|
const llvm::DataLayout *DL = g->target->getDataLayout();
|
||||||
|
|
||||||
if (!(pack = llvm::dyn_cast<llvm::StructType>(stype)->isPacked()))
|
if (!(pack = llvm::dyn_cast<llvm::StructType>(stype)->isPacked()))
|
||||||
for (int i = 0; !needsAlign && (i < st->GetElementCount()); ++i) {
|
for (int i = 0; !needsAlign && (i < st->GetElementCount()); ++i) {
|
||||||
@@ -2431,9 +2434,9 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
|
|
||||||
inst.setDiagnostics(diagEngine);
|
inst.setDiagnostics(diagEngine);
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 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
|
||||||
@@ -2443,19 +2446,19 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3 /* 3.2 */
|
||||||
clang::TargetInfo *target =
|
clang::TargetInfo *target =
|
||||||
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
|
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
|
||||||
#elif defined(LLVM_3_3) || defined(LLVM_3_4)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_5 /* 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
|
||||||
@@ -2469,7 +2472,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
// track the source file position by handling them ourselves.
|
// track the source file position by handling them ourselves.
|
||||||
inst.getPreprocessorOutputOpts().ShowComments = 1;
|
inst.getPreprocessorOutputOpts().ShowComments = 1;
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) // LLVM 3.3+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 // LLVM 3.3+
|
||||||
inst.getPreprocessorOutputOpts().ShowCPP = 1;
|
inst.getPreprocessorOutputOpts().ShowCPP = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2481,7 +2484,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
headerOpts.Verbose = 1;
|
headerOpts.Verbose = 1;
|
||||||
for (int i = 0; i < (int)g->includePath.size(); ++i) {
|
for (int i = 0; i < (int)g->includePath.size(); ++i) {
|
||||||
headerOpts.AddPath(g->includePath[i], clang::frontend::Angled,
|
headerOpts.AddPath(g->includePath[i], clang::frontend::Angled,
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
true /* is user supplied */,
|
true /* is user supplied */,
|
||||||
#endif
|
#endif
|
||||||
false /* not a framework */,
|
false /* not a framework */,
|
||||||
@@ -2560,7 +2563,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
|
|
||||||
inst.getLangOpts().LineComment = 1;
|
inst.getLangOpts().LineComment = 1;
|
||||||
|
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 /* 3.5+ */
|
||||||
inst.createPreprocessor(clang::TU_Complete);
|
inst.createPreprocessor(clang::TU_Complete);
|
||||||
#else
|
#else
|
||||||
inst.createPreprocessor();
|
inst.createPreprocessor();
|
||||||
@@ -2905,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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());
|
||||||
|
|||||||
11
module.h
11
module.h
@@ -41,10 +41,9 @@
|
|||||||
|
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include "ast.h"
|
#include "ast.h"
|
||||||
#if defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5
|
||||||
#include <llvm/DebugInfo.h>
|
#include <llvm/DebugInfo.h>
|
||||||
#endif
|
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_5
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
|
||||||
#include <llvm/IR/DebugInfo.h>
|
#include <llvm/IR/DebugInfo.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -161,10 +160,10 @@ public:
|
|||||||
/** The diBuilder manages generating debugging information */
|
/** The diBuilder manages generating debugging information */
|
||||||
llvm::DIBuilder *diBuilder;
|
llvm::DIBuilder *diBuilder;
|
||||||
|
|
||||||
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DICompileUnit diCompileUnit;
|
llvm::DICompileUnit diCompileUnit;
|
||||||
#elif !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.7++
|
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7
|
||||||
llvm::DICompileUnit *diCompileUnit;
|
llvm::DICompileUnit* diCompileUnit;
|
||||||
#endif // LLVM_3_4+
|
#endif // LLVM_3_4+
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
82
opt.cpp
82
opt.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <llvm/Pass.h>
|
#include <llvm/Pass.h>
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#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
|
#else /* >= 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>
|
||||||
@@ -69,30 +69,30 @@
|
|||||||
#include <llvm/IR/InlineAsm.h>
|
#include <llvm/IR/InlineAsm.h>
|
||||||
#endif /* ISPC_NVPTX_ENABLED */
|
#endif /* ISPC_NVPTX_ENABLED */
|
||||||
#endif
|
#endif
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#else // LLVM 3.7+
|
#else /* >= 3.7 */
|
||||||
#include "llvm/IR/LegacyPassManager.h"
|
#include "llvm/IR/LegacyPassManager.h"
|
||||||
#endif
|
#endif
|
||||||
#include <llvm/PassRegistry.h>
|
#include <llvm/PassRegistry.h>
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 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/PatternMatch.h>
|
#include <llvm/IR/PatternMatch.h>
|
||||||
#include <llvm/IR/DebugInfo.h>
|
#include <llvm/IR/DebugInfo.h>
|
||||||
#else
|
#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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
#include <llvm/Target/TargetLibraryInfo.h>
|
#include <llvm/Target/TargetLibraryInfo.h>
|
||||||
#else // LLVM 3.7+
|
#else /* >= 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 defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#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
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
#include <llvm/Analysis/Passes.h>
|
#include <llvm/Analysis/Passes.h>
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_6
|
||||||
#include <llvm/IR/IntrinsicInst.h>
|
#include <llvm/IR/IntrinsicInst.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef ISPC_IS_LINUX
|
#ifdef ISPC_IS_LINUX
|
||||||
@@ -238,33 +238,33 @@ 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 defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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));
|
||||||
#endif
|
#endif
|
||||||
Assert(first_lnum);
|
Assert(first_lnum);
|
||||||
|
|
||||||
llvm::ConstantInt *first_colnum =
|
llvm::ConstantInt *first_colnum =
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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));
|
||||||
#endif
|
#endif
|
||||||
Assert(first_column);
|
Assert(first_column);
|
||||||
|
|
||||||
llvm::ConstantInt *last_lnum =
|
llvm::ConstantInt *last_lnum =
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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));
|
||||||
#endif
|
#endif
|
||||||
Assert(last_lnum);
|
Assert(last_lnum);
|
||||||
|
|
||||||
llvm::ConstantInt *last_colnum =
|
llvm::ConstantInt *last_colnum =
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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));
|
||||||
#endif
|
#endif
|
||||||
Assert(last_column);
|
Assert(last_column);
|
||||||
@@ -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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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,15 +466,15 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::PassManager PM;
|
llvm::PassManager PM;
|
||||||
#else // LLVM 3.7+
|
#else /* LLVM 3.7+ */
|
||||||
llvm::legacy::PassManager PM;
|
llvm::legacy::PassManager PM;
|
||||||
#endif
|
#endif
|
||||||
int number;
|
int number;
|
||||||
@@ -500,7 +500,7 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) {
|
|||||||
PM.add(CreateDebugPass(buf));
|
PM.add(CreateDebugPass(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LLVM_3_4) || defined(LLVM_3_5) // only 3.4 and 3.5
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_4 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6 // 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_5
|
||||||
optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
||||||
#elif defined(LLVM_3_5)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
|
optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout()));
|
||||||
#elif defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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();
|
||||||
|
|
||||||
#ifdef LLVM_3_2
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
|
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
|
||||||
targetMachine->getVectorTargetTransformInfo()));
|
targetMachine->getVectorTargetTransformInfo()));
|
||||||
#elif defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) // LLVM 3.3 - 3.6
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4
|
||||||
// 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 defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_2 && ISPC_LLVM_VERSION < ISPC_LLVM_3_4
|
||||||
// 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 !defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION > ISPC_LLVM_3_2
|
||||||
|
|
||||||
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 !defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION > ISPC_LLVM_3_2
|
||||||
if (!builtinCall)
|
if (!builtinCall)
|
||||||
builtinCall = lMatchAvgUpUInt8(inst);
|
builtinCall = lMatchAvgUpUInt8(inst);
|
||||||
if (!builtinCall)
|
if (!builtinCall)
|
||||||
@@ -5471,9 +5471,7 @@ llvm::Instruction* FixBooleanSelectPass::fixSelect(llvm::SelectInst* sel, llvm::
|
|||||||
bool
|
bool
|
||||||
FixBooleanSelectPass::runOnFunction(llvm::Function &F) {
|
FixBooleanSelectPass::runOnFunction(llvm::Function &F) {
|
||||||
bool modifiedAny = false;
|
bool modifiedAny = false;
|
||||||
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_3 // LLVM 3.3 only
|
||||||
// LLVM 3.3 only
|
|
||||||
#if defined(LLVM_3_3)
|
|
||||||
|
|
||||||
// Don't optimize generic targets.
|
// Don't optimize generic targets.
|
||||||
if (g->target->getISA() == Target::GENERIC) {
|
if (g->target->getISA() == Target::GENERIC) {
|
||||||
|
|||||||
2
parse.yy
2
parse.yy
@@ -83,7 +83,7 @@ struct ForeachDimension;
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#include <llvm/Constants.h>
|
#include <llvm/Constants.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/IR/Constants.h>
|
#include <llvm/IR/Constants.h>
|
||||||
|
|||||||
10
stmt.cpp
10
stmt.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#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,11 @@ 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
|
||||||
value = llvm::GetElementPtrInst::Create(value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock());
|
value = llvm::GetElementPtrInst::Create(value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock());
|
||||||
|
#else
|
||||||
|
value = llvm::GetElementPtrInst::Create(NULL, value, offset, "gep2gen_offset", ctx->GetCurrentBasicBlock());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert arrElTy* to elTy* */
|
/* convert arrElTy* to elTy* */
|
||||||
@@ -1535,7 +1539,11 @@ 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
|
||||||
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
|
||||||
|
llvm::Instruction* ptr_arrayidx = llvm::GetElementPtrInst::Create(NULL, globalDelta, ptr_arrayidx_indices, "arrayidx", ctx->GetCurrentBasicBlock());
|
||||||
|
#endif
|
||||||
llvm::LoadInst* int8_39 = new llvm::LoadInst(ptr_arrayidx, "", false, ctx->GetCurrentBasicBlock());
|
llvm::LoadInst* int8_39 = new llvm::LoadInst(ptr_arrayidx, "", false, ctx->GetCurrentBasicBlock());
|
||||||
llvm::Value * int32_39 = ctx->ZExtInst(int8_39, LLVMTypes::Int32Type);
|
llvm::Value * int32_39 = ctx->ZExtInst(int8_39, LLVMTypes::Int32Type);
|
||||||
|
|
||||||
|
|||||||
104
type.cpp
104
type.cpp
@@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
#include <llvm/Value.h>
|
#include <llvm/Value.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/IR/Value.h>
|
#include <llvm/IR/Value.h>
|
||||||
#include <llvm/IR/Module.h>
|
#include <llvm/IR/Module.h>
|
||||||
#endif
|
#endif
|
||||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_5 // LLVM 3.5+
|
||||||
#include <llvm/IR/DebugInfo.h>
|
#include <llvm/IR/DebugInfo.h>
|
||||||
#include <llvm/IR/DIBuilder.h>
|
#include <llvm/IR/DIBuilder.h>
|
||||||
#else
|
#else
|
||||||
@@ -79,12 +79,13 @@ 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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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) {
|
||||||
#endif
|
#endif
|
||||||
#ifdef LLVM_3_2
|
|
||||||
|
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_2
|
||||||
int lowerBound = 0, upperBound = count-1;
|
int lowerBound = 0, upperBound = count-1;
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
@@ -94,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 defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, count);
|
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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);
|
||||||
@@ -106,7 +107,7 @@ static llvm::DIType *lCreateDIArray(llvm::DIType *eltType, int count) {
|
|||||||
#endif
|
#endif
|
||||||
subs.push_back(sub);
|
subs.push_back(sub);
|
||||||
|
|
||||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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();
|
||||||
@@ -525,7 +526,7 @@ AtomicType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 {
|
||||||
@@ -535,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
#else //LLVM 3.7++
|
#else //LLVM 3.7++
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -586,7 +587,7 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
#else //LLVM 3.7++
|
#else //LLVM 3.7++
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -594,21 +595,23 @@ llvm::DIType *AtomicType::GetDIType(llvm::DIScope *scope) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (variability == Variability::Varying) {
|
else if (variability == Variability::Varying) {
|
||||||
#ifdef LLVM_3_2
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
|
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
|
||||||
#elif defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5)
|
#elif ISPC_LLVM_VERSION >= ISPC_VERSION_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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 defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_VERSION_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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();
|
||||||
#else // LLVM 3.7++
|
#elif ISPC_LLVM_VERSION >= ISPC_VERSION_3_7 // 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::MDType *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();
|
||||||
#endif
|
#endif
|
||||||
@@ -844,13 +847,13 @@ EnumType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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;
|
||||||
@@ -860,7 +863,7 @@ 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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
llvm::Value *descriptor =
|
llvm::Value *descriptor =
|
||||||
#else // LLVM 3.6++
|
#else // LLVM 3.6++
|
||||||
llvm::Metadata *descriptor =
|
llvm::Metadata *descriptor =
|
||||||
@@ -868,7 +871,7 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
|
|||||||
m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue);
|
m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue);
|
||||||
enumeratorDescriptors.push_back(descriptor);
|
enumeratorDescriptors.push_back(descriptor);
|
||||||
}
|
}
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIArray elementArray =
|
llvm::DIArray elementArray =
|
||||||
m->diBuilder->getOrCreateArray(enumeratorDescriptors);
|
m->diBuilder->getOrCreateArray(enumeratorDescriptors);
|
||||||
llvm::DIFile diFile = pos.GetDIFile();
|
llvm::DIFile diFile = pos.GetDIFile();
|
||||||
@@ -891,19 +894,20 @@ llvm::DIType *EnumType::GetDIType(llvm::DIScope *scope) const {
|
|||||||
case Variability::Uniform:
|
case Variability::Uniform:
|
||||||
return diType;
|
return diType;
|
||||||
case Variability::Varying: {
|
case Variability::Varying: {
|
||||||
#ifdef LLVM_3_2
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
|
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
|
||||||
#elif defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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 defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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();
|
||||||
#else // 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);
|
||||||
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();
|
||||||
#endif
|
#endif
|
||||||
@@ -914,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
#else //LLVM 3.7++
|
#else //LLVM 3.7++
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1252,7 +1256,7 @@ PointerType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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);
|
||||||
@@ -1275,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIType eltType =
|
llvm::DIType eltType =
|
||||||
#else //LLVM 3.7++
|
#else //LLVM 3.7++
|
||||||
llvm::DIDerivedType *eltType =
|
llvm::DIDerivedType *eltType =
|
||||||
@@ -1289,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
#else //LLVM 3.7++
|
#else //LLVM 3.7++
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1567,7 +1571,7 @@ ArrayType::TotalElementCount() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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);
|
||||||
@@ -1816,16 +1820,16 @@ VectorType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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
|
||||||
#ifdef LLVM_3_2
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
|
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
|
||||||
#elif defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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);
|
||||||
@@ -1834,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 defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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();
|
||||||
@@ -1855,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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
#else // LLVM 3.7++
|
#else // LLVM 3.7++
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -2259,13 +2263,13 @@ StructType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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;
|
||||||
@@ -2274,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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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();
|
||||||
@@ -2296,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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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++
|
||||||
@@ -2316,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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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++
|
||||||
@@ -2331,9 +2335,9 @@ 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 defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIType(), // DerivedFrom
|
llvm::DIType(), // DerivedFrom
|
||||||
#elif !defined(LLVM_3_2) // LLVM 3.7++
|
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
elements);
|
elements);
|
||||||
@@ -2564,7 +2568,7 @@ UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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;
|
||||||
@@ -2581,9 +2585,9 @@ llvm::DIType *UndefinedStructType::GetDIType(llvm::DIScope *scope) const {
|
|||||||
0, // Size
|
0, // Size
|
||||||
0, // Align
|
0, // Align
|
||||||
0, // Flags
|
0, // Flags
|
||||||
#if defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_3 && ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DIType(), // DerivedFrom
|
llvm::DIType(), // DerivedFrom
|
||||||
#elif !defined(LLVM_3_2) // LLVM 3.7++
|
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7++
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
elements);
|
elements);
|
||||||
@@ -2838,7 +2842,7 @@ ReferenceType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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);
|
||||||
@@ -3117,13 +3121,13 @@ FunctionType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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;
|
||||||
@@ -3133,22 +3137,22 @@ 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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_4
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
#elif defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_6
|
||||||
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 defined(LLVM_3_6)
|
#elif ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
llvm::DITypeArray retArgTypesArray =
|
llvm::DITypeArray retArgTypesArray =
|
||||||
m->diBuilder->getOrCreateTypeArray(retArgTypes);
|
m->diBuilder->getOrCreateTypeArray(retArgTypes);
|
||||||
llvm::DIType diType =
|
llvm::DIType diType =
|
||||||
|
|||||||
24
type.h
24
type.h
@@ -40,10 +40,10 @@
|
|||||||
|
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#include <llvm/Type.h>
|
#include <llvm/Type.h>
|
||||||
#include <llvm/DerivedTypes.h>
|
#include <llvm/DerivedTypes.h>
|
||||||
#else
|
#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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
/** 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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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 defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_7
|
||||||
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;
|
||||||
|
|||||||
2
util.cpp
2
util.cpp
@@ -65,7 +65,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#if defined(LLVM_3_2)
|
#if ISPC_LLVM_VERSION < ISPC_LLVM_3_3
|
||||||
#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>
|
||||||
|
|||||||
Reference in New Issue
Block a user