Remove support for building with LLVM 3.0
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
#if defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Attributes.h>
|
#include <llvm/Attributes.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || 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>
|
||||||
|
|||||||
155
cbackend.cpp
155
cbackend.cpp
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "llvmutil.h"
|
#include "llvmutil.h"
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(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"
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1)
|
#if !defined(LLVM_3_1)
|
||||||
#include "llvm/TypeFinder.h"
|
#include "llvm/TypeFinder.h"
|
||||||
#endif // LLVM_3_2 +
|
#endif // LLVM_3_2 +
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
#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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
#include "llvm/DataLayout.h"
|
#include "llvm/DataLayout.h"
|
||||||
@@ -248,7 +248,7 @@ namespace {
|
|||||||
const llvm::MCRegisterInfo *MRI;
|
const llvm::MCRegisterInfo *MRI;
|
||||||
const llvm::MCObjectFileInfo *MOFI;
|
const llvm::MCObjectFileInfo *MOFI;
|
||||||
llvm::MCContext *TCtx;
|
llvm::MCContext *TCtx;
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
const llvm::TargetData* TD;
|
const llvm::TargetData* TD;
|
||||||
#else
|
#else
|
||||||
// FIXME: it's ugly to have the name be "TD" here, but it saves us
|
// FIXME: it's ugly to have the name be "TD" here, but it saves us
|
||||||
@@ -258,10 +258,8 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
|
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
|
||||||
#ifndef LLVM_3_0
|
|
||||||
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
|
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
|
||||||
unsigned VectorConstantIndex;
|
unsigned VectorConstantIndex;
|
||||||
#endif // !LLVM_3_0
|
|
||||||
std::set<llvm::Function*> intrinsicPrototypesAlreadyGenerated;
|
std::set<llvm::Function*> intrinsicPrototypesAlreadyGenerated;
|
||||||
std::set<const llvm::Argument*> ByValParams;
|
std::set<const llvm::Argument*> ByValParams;
|
||||||
unsigned FPCounter;
|
unsigned FPCounter;
|
||||||
@@ -288,9 +286,7 @@ namespace {
|
|||||||
vectorWidth(vecwidth) {
|
vectorWidth(vecwidth) {
|
||||||
initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry());
|
initializeLoopInfoPass(*llvm::PassRegistry::getPassRegistry());
|
||||||
FPCounter = 0;
|
FPCounter = 0;
|
||||||
#ifndef LLVM_3_0
|
|
||||||
VectorConstantIndex = 0;
|
VectorConstantIndex = 0;
|
||||||
#endif // !LLVM_3_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const char *getPassName() const { return "C backend"; }
|
virtual const char *getPassName() const { return "C backend"; }
|
||||||
@@ -334,9 +330,7 @@ namespace {
|
|||||||
delete MRI;
|
delete MRI;
|
||||||
delete MOFI;
|
delete MOFI;
|
||||||
FPConstantMap.clear();
|
FPConstantMap.clear();
|
||||||
#ifndef LLVM_3_0
|
|
||||||
VectorConstantMap.clear();
|
VectorConstantMap.clear();
|
||||||
#endif // !LLVM_3_0
|
|
||||||
ByValParams.clear();
|
ByValParams.clear();
|
||||||
intrinsicPrototypesAlreadyGenerated.clear();
|
intrinsicPrototypesAlreadyGenerated.clear();
|
||||||
UnnamedStructIDs.clear();
|
UnnamedStructIDs.clear();
|
||||||
@@ -348,7 +342,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
|
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL = llvm::AttributeSet()
|
const llvm::AttributeSet &PAL = llvm::AttributeSet()
|
||||||
@@ -359,7 +353,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL,
|
const llvm::AttrListPtr &PAL,
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL,
|
const llvm::AttributeSet &PAL,
|
||||||
@@ -417,9 +411,7 @@ namespace {
|
|||||||
bool printConstExprCast(const llvm::ConstantExpr *CE, bool Static);
|
bool printConstExprCast(const llvm::ConstantExpr *CE, bool Static);
|
||||||
void printConstantArray(llvm::ConstantArray *CPA, bool Static);
|
void printConstantArray(llvm::ConstantArray *CPA, bool Static);
|
||||||
void printConstantVector(llvm::ConstantVector *CV, bool Static);
|
void printConstantVector(llvm::ConstantVector *CV, bool Static);
|
||||||
#ifndef LLVM_3_0
|
|
||||||
void printConstantDataSequential(llvm::ConstantDataSequential *CDS, bool Static);
|
void printConstantDataSequential(llvm::ConstantDataSequential *CDS, bool Static);
|
||||||
#endif
|
|
||||||
|
|
||||||
/// isAddressExposed - Return true if the specified value's name needs to
|
/// isAddressExposed - Return true if the specified value's name needs to
|
||||||
/// have its address taken in order to get a C value of the correct type.
|
/// have its address taken in order to get a C value of the correct type.
|
||||||
@@ -494,11 +486,6 @@ namespace {
|
|||||||
void visitInvokeInst(llvm::InvokeInst &I) {
|
void visitInvokeInst(llvm::InvokeInst &I) {
|
||||||
llvm_unreachable("Lowerinvoke pass didn't work!");
|
llvm_unreachable("Lowerinvoke pass didn't work!");
|
||||||
}
|
}
|
||||||
#ifdef LLVM_3_0
|
|
||||||
void visitUnwindInst(llvm::UnwindInst &I) {
|
|
||||||
llvm_unreachable("Lowerinvoke pass didn't work!");
|
|
||||||
}
|
|
||||||
#endif // LLVM_3_0
|
|
||||||
void visitResumeInst(llvm::ResumeInst &I) {
|
void visitResumeInst(llvm::ResumeInst &I) {
|
||||||
llvm_unreachable("DwarfEHPrepare pass didn't work!");
|
llvm_unreachable("DwarfEHPrepare pass didn't work!");
|
||||||
}
|
}
|
||||||
@@ -589,7 +576,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL,
|
const llvm::AttrListPtr &PAL,
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL,
|
const llvm::AttributeSet &PAL,
|
||||||
@@ -608,7 +595,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
@@ -619,7 +606,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
|||||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||||
}
|
}
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||||
@@ -638,7 +625,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
|||||||
}
|
}
|
||||||
FunctionInnards << ')';
|
FunctionInnards << ')';
|
||||||
printType(Out, RetTy,
|
printType(Out, RetTy,
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||||
@@ -740,7 +727,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL
|
const llvm::AttrListPtr &PAL
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL
|
const llvm::AttributeSet &PAL
|
||||||
@@ -762,7 +749,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
@@ -775,7 +762,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||||
@@ -794,7 +781,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||||
@@ -909,61 +896,6 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CWriter::printConstantArray(llvm::ConstantArray *CPA, bool Static) {
|
void CWriter::printConstantArray(llvm::ConstantArray *CPA, bool Static) {
|
||||||
#ifdef LLVM_3_0
|
|
||||||
llvm::Type *ETy = CPA->getType()->getElementType();
|
|
||||||
// MMP: this looks like a bug: both sides of the || are the same
|
|
||||||
bool isString = ETy == llvm::Type::getInt8Ty(CPA->getContext());
|
|
||||||
|
|
||||||
// Make sure the last character is a null char, as automatically added by C
|
|
||||||
if (isString && (CPA->getNumOperands() == 0 ||
|
|
||||||
!llvm::cast<llvm::Constant>(*(CPA->op_end()-1))->isNullValue()))
|
|
||||||
isString = false;
|
|
||||||
|
|
||||||
if (isString) {
|
|
||||||
Out << "\"";
|
|
||||||
// Keep track of whether the last number was a hexadecimal escape.
|
|
||||||
bool LastWasHex = false;
|
|
||||||
|
|
||||||
// Do not include the last character, which we know is null
|
|
||||||
for (unsigned i = 0, e = CPA->getNumOperands()-1; i != e; ++i) {
|
|
||||||
unsigned char C = (unsigned char)(llvm::cast<llvm::ConstantInt>(CPA->getOperand(i))->getZExtValue());
|
|
||||||
|
|
||||||
// Print it out literally if it is a printable character. The only thing
|
|
||||||
// to be careful about is when the last letter output was a hex escape
|
|
||||||
// code, in which case we have to be careful not to print out hex digits
|
|
||||||
// explicitly (the C compiler thinks it is a continuation of the previous
|
|
||||||
// character, sheesh...)
|
|
||||||
//
|
|
||||||
if (isprint(C) && (!LastWasHex || !isxdigit(C))) {
|
|
||||||
LastWasHex = false;
|
|
||||||
if (C == '"' || C == '\\')
|
|
||||||
Out << "\\" << (char)C;
|
|
||||||
else
|
|
||||||
Out << (char)C;
|
|
||||||
} else {
|
|
||||||
LastWasHex = false;
|
|
||||||
switch (C) {
|
|
||||||
case '\n': Out << "\\n"; break;
|
|
||||||
case '\t': Out << "\\t"; break;
|
|
||||||
case '\r': Out << "\\r"; break;
|
|
||||||
case '\v': Out << "\\v"; break;
|
|
||||||
case '\a': Out << "\\a"; break;
|
|
||||||
case '\"': Out << "\\\""; break;
|
|
||||||
case '\'': Out << "\\\'"; break;
|
|
||||||
default:
|
|
||||||
Out << "\\x";
|
|
||||||
Out << (char)(( C/16 < 10) ? ( C/16 +'0') : ( C/16 -10+'A'));
|
|
||||||
Out << (char)(((C&15) < 10) ? ((C&15)+'0') : ((C&15)-10+'A'));
|
|
||||||
LastWasHex = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Out << "\"";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif // LLVM_3_0
|
|
||||||
|
|
||||||
printConstant(llvm::cast<llvm::Constant>(CPA->getOperand(0)), Static);
|
printConstant(llvm::cast<llvm::Constant>(CPA->getOperand(0)), Static);
|
||||||
for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) {
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
@@ -979,7 +911,6 @@ void CWriter::printConstantVector(llvm::ConstantVector *CP, bool Static) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS,
|
void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS,
|
||||||
bool Static) {
|
bool Static) {
|
||||||
// As a special case, print the array as a string if it is an array of
|
// As a special case, print the array as a string if it is an array of
|
||||||
@@ -1036,9 +967,7 @@ void CWriter::printConstantDataSequential(llvm::ConstantDataSequential *CDS,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !LLVM_3_0
|
|
||||||
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
static inline std::string ftostr(const llvm::APFloat& V) {
|
static inline std::string ftostr(const llvm::APFloat& V) {
|
||||||
std::string Buf;
|
std::string Buf;
|
||||||
if (&V.getSemantics() == &llvm::APFloat::IEEEdouble) {
|
if (&V.getSemantics() == &llvm::APFloat::IEEEdouble) {
|
||||||
@@ -1050,7 +979,6 @@ static inline std::string ftostr(const llvm::APFloat& V) {
|
|||||||
}
|
}
|
||||||
return "<unknown format in ftostr>"; // error
|
return "<unknown format in ftostr>"; // error
|
||||||
}
|
}
|
||||||
#endif // !LLVM_3_0
|
|
||||||
|
|
||||||
// isFPCSafeToPrint - Returns true if we may assume that CFP may be written out
|
// isFPCSafeToPrint - Returns true if we may assume that CFP may be written out
|
||||||
// textually as a double (rather than as a reference to a stack-allocated
|
// textually as a double (rather than as a reference to a stack-allocated
|
||||||
@@ -1554,11 +1482,9 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
|
|||||||
}
|
}
|
||||||
if (llvm::ConstantArray *CA = llvm::dyn_cast<llvm::ConstantArray>(CPV)) {
|
if (llvm::ConstantArray *CA = llvm::dyn_cast<llvm::ConstantArray>(CPV)) {
|
||||||
printConstantArray(CA, Static);
|
printConstantArray(CA, Static);
|
||||||
#ifndef LLVM_3_0
|
|
||||||
} else if (llvm::ConstantDataSequential *CDS =
|
} else if (llvm::ConstantDataSequential *CDS =
|
||||||
llvm::dyn_cast<llvm::ConstantDataSequential>(CPV)) {
|
llvm::dyn_cast<llvm::ConstantDataSequential>(CPV)) {
|
||||||
printConstantDataSequential(CDS, Static);
|
printConstantDataSequential(CDS, Static);
|
||||||
#endif // !LLVM_3_0
|
|
||||||
} else {
|
} else {
|
||||||
assert(llvm::isa<llvm::ConstantAggregateZero>(CPV) || llvm::isa<llvm::UndefValue>(CPV));
|
assert(llvm::isa<llvm::ConstantAggregateZero>(CPV) || llvm::isa<llvm::UndefValue>(CPV));
|
||||||
if (AT->getNumElements()) {
|
if (AT->getNumElements()) {
|
||||||
@@ -1613,8 +1539,6 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
|
|||||||
Out << ")";
|
Out << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef LLVM_3_0
|
|
||||||
// LLVM 3.1 and beyond have a different representation of constant vectors..
|
|
||||||
else if (llvm::ConstantDataVector *CDV =
|
else if (llvm::ConstantDataVector *CDV =
|
||||||
llvm::dyn_cast<llvm::ConstantDataVector>(CPV)) {
|
llvm::dyn_cast<llvm::ConstantDataVector>(CPV)) {
|
||||||
llvm::Constant *splatValue = CDV->getSplatValue();
|
llvm::Constant *splatValue = CDV->getSplatValue();
|
||||||
@@ -1646,7 +1570,6 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) {
|
|||||||
Out << ")";
|
Out << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !LLVM_3_0
|
|
||||||
else {
|
else {
|
||||||
llvm::report_fatal_error("Unexpected vector type");
|
llvm::report_fatal_error("Unexpected vector type");
|
||||||
}
|
}
|
||||||
@@ -2039,7 +1962,7 @@ void CWriter::writeOperandWithCast(llvm::Value* Operand, const llvm::ICmpInst &C
|
|||||||
// directives to cater to specific compilers as need be.
|
// directives to cater to specific compilers as need be.
|
||||||
//
|
//
|
||||||
static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out,
|
static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out,
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
const llvm::TargetData *TD) {
|
const llvm::TargetData *TD) {
|
||||||
#else
|
#else
|
||||||
const llvm::DataLayout *TD) {
|
const llvm::DataLayout *TD) {
|
||||||
@@ -2229,7 +2152,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
|
|||||||
// Initialize
|
// Initialize
|
||||||
TheModule = &M;
|
TheModule = &M;
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
TD = new llvm::TargetData(&M);
|
TD = new llvm::TargetData(&M);
|
||||||
#else
|
#else
|
||||||
TD = new llvm::DataLayout(&M);
|
TD = new llvm::DataLayout(&M);
|
||||||
@@ -2662,12 +2585,6 @@ void CWriter::printFloatingPointConstants(const llvm::Constant *C) {
|
|||||||
// loads to get their values, rather than tediously inserting the
|
// loads to get their values, rather than tediously inserting the
|
||||||
// individual values into the vector.
|
// individual values into the vector.
|
||||||
void CWriter::printVectorConstants(llvm::Function &F) {
|
void CWriter::printVectorConstants(llvm::Function &F) {
|
||||||
// LLVM 3.1 and beyond have a different representation of constant
|
|
||||||
// vectors than before--here we will only do this for 3.1 and later, as
|
|
||||||
// the separate code path isn't worth the trouble. This will hurt
|
|
||||||
// performance with 3.0 builds, though they should still generate
|
|
||||||
// correct code.
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
for (llvm::constant_iterator I = constant_begin(&F), E = constant_end(&F);
|
for (llvm::constant_iterator I = constant_begin(&F), E = constant_end(&F);
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
const llvm::ConstantDataVector *CDV = llvm::dyn_cast<llvm::ConstantDataVector>(*I);
|
const llvm::ConstantDataVector *CDV = llvm::dyn_cast<llvm::ConstantDataVector>(*I);
|
||||||
@@ -2695,7 +2612,6 @@ void CWriter::printVectorConstants(llvm::Function &F) {
|
|||||||
VectorConstantMap[CDV] = VectorConstantIndex++;
|
VectorConstantMap[CDV] = VectorConstantIndex++;
|
||||||
}
|
}
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
#endif // !LLVM_3_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printSymbolTable - Run through symbol table looking for type names. If a
|
/// printSymbolTable - Run through symbol table looking for type names. If a
|
||||||
@@ -2712,7 +2628,7 @@ void CWriter::printModuleTypes() {
|
|||||||
|
|
||||||
// Get all of the struct types used in the module.
|
// Get all of the struct types used in the module.
|
||||||
std::vector<llvm::StructType*> StructTypes;
|
std::vector<llvm::StructType*> StructTypes;
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
TheModule->findUsedStructTypes(StructTypes);
|
TheModule->findUsedStructTypes(StructTypes);
|
||||||
#else
|
#else
|
||||||
llvm::TypeFinder typeFinder;
|
llvm::TypeFinder typeFinder;
|
||||||
@@ -2841,7 +2757,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL = F->getAttributes();
|
const llvm::AttrListPtr &PAL = F->getAttributes();
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL = F->getAttributes();
|
const llvm::AttributeSet &PAL = F->getAttributes();
|
||||||
@@ -2875,7 +2791,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
@@ -2886,7 +2802,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
|||||||
ByValParams.insert(I);
|
ByValParams.insert(I);
|
||||||
}
|
}
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||||
@@ -2914,7 +2830,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
@@ -2925,7 +2841,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
|||||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||||
}
|
}
|
||||||
printType(FunctionInnards, ArgTy,
|
printType(FunctionInnards, ArgTy,
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
|
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
|
||||||
@@ -2964,7 +2880,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||||
@@ -3145,17 +3061,9 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) {
|
|||||||
printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
|
printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
|
||||||
Out << ";\n";
|
Out << ";\n";
|
||||||
|
|
||||||
#ifdef LLVM_3_0
|
|
||||||
// Skip the first item since that's the default case.
|
|
||||||
unsigned NumCases = SI.getNumCases();
|
|
||||||
for (unsigned i = 1; i < NumCases; ++i) {
|
|
||||||
llvm::ConstantInt* CaseVal = SI.getCaseValue(i);
|
|
||||||
llvm::BasicBlock* Succ = SI.getSuccessor(i);
|
|
||||||
#else
|
|
||||||
for (llvm::SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) {
|
for (llvm::SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) {
|
||||||
llvm::ConstantInt* CaseVal = i.getCaseValue();
|
llvm::ConstantInt* CaseVal = i.getCaseValue();
|
||||||
llvm::BasicBlock* Succ = i.getCaseSuccessor();
|
llvm::BasicBlock* Succ = i.getCaseSuccessor();
|
||||||
#endif // !LLVM_3_0
|
|
||||||
Out << " case ";
|
Out << " case ";
|
||||||
writeOperand(CaseVal);
|
writeOperand(CaseVal);
|
||||||
Out << ":\n";
|
Out << ":\n";
|
||||||
@@ -3776,7 +3684,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#else
|
#else
|
||||||
#include "llvm/IR/Intrinsics.gen"
|
#include "llvm/IR/Intrinsics.gen"
|
||||||
@@ -3841,7 +3749,7 @@ 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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL = I.getAttributes();
|
const llvm::AttrListPtr &PAL = I.getAttributes();
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL = I.getAttributes();
|
const llvm::AttributeSet &PAL = I.getAttributes();
|
||||||
@@ -3922,7 +3830,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt)
|
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt)
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
||||||
@@ -3958,12 +3866,9 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID,
|
|||||||
// If this is an intrinsic that directly corresponds to a GCC
|
// If this is an intrinsic that directly corresponds to a GCC
|
||||||
// builtin, we emit it here.
|
// builtin, we emit it here.
|
||||||
const char *BuiltinName = "";
|
const char *BuiltinName = "";
|
||||||
#ifdef LLVM_3_0
|
|
||||||
llvm::Function *F = I.getCalledFunction();
|
|
||||||
#endif // LLVM_3_0
|
|
||||||
#define GET_GCC_BUILTIN_NAME
|
#define GET_GCC_BUILTIN_NAME
|
||||||
#define Intrinsic llvm::Intrinsic
|
#define Intrinsic llvm::Intrinsic
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#else
|
#else
|
||||||
#include "llvm/IR/Intrinsics.gen"
|
#include "llvm/IR/Intrinsics.gen"
|
||||||
@@ -4548,7 +4453,7 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
matchType, NULL);
|
matchType, NULL);
|
||||||
smearFunc = llvm::dyn_cast<llvm::Function>(sf);
|
smearFunc = llvm::dyn_cast<llvm::Function>(sf);
|
||||||
assert(smearFunc != NULL);
|
assert(smearFunc != NULL);
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
smearFunc->setDoesNotThrow(true);
|
smearFunc->setDoesNotThrow(true);
|
||||||
smearFunc->setDoesNotAccessMemory(true);
|
smearFunc->setDoesNotAccessMemory(true);
|
||||||
#else
|
#else
|
||||||
@@ -4699,7 +4604,7 @@ AndCmpCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
LLVMTypes::MaskType, NULL);
|
LLVMTypes::MaskType, NULL);
|
||||||
andCmpFunc = llvm::dyn_cast<llvm::Function>(acf);
|
andCmpFunc = llvm::dyn_cast<llvm::Function>(acf);
|
||||||
Assert(andCmpFunc != NULL);
|
Assert(andCmpFunc != NULL);
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
andCmpFunc->setDoesNotThrow(true);
|
andCmpFunc->setDoesNotThrow(true);
|
||||||
andCmpFunc->setDoesNotAccessMemory(true);
|
andCmpFunc->setDoesNotAccessMemory(true);
|
||||||
#else
|
#else
|
||||||
@@ -4807,14 +4712,12 @@ lIsAllTrue(llvm::Value *v) {
|
|||||||
ci->isOne());
|
ci->isOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
if (llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v)) {
|
if (llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v)) {
|
||||||
llvm::ConstantInt *ci;
|
llvm::ConstantInt *ci;
|
||||||
return (cdv->getSplatValue() != NULL &&
|
return (cdv->getSplatValue() != NULL &&
|
||||||
(ci = llvm::dyn_cast<llvm::ConstantInt>(cdv->getSplatValue())) != NULL &&
|
(ci = llvm::dyn_cast<llvm::ConstantInt>(cdv->getSplatValue())) != NULL &&
|
||||||
ci->isOne());
|
ci->isOne());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
12
ctx.cpp
12
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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(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>
|
||||||
@@ -358,9 +358,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
|||||||
mangledName, diFile,
|
mangledName, diFile,
|
||||||
firstLine, diSubprogramType,
|
firstLine, diSubprogramType,
|
||||||
isStatic, true, /* is defn */
|
isStatic, true, /* is defn */
|
||||||
#ifndef LLVM_3_0
|
|
||||||
firstLine,
|
firstLine,
|
||||||
#endif // !LLVM_3_0
|
|
||||||
flags,
|
flags,
|
||||||
isOptimized, llvmFunction);
|
isOptimized, llvmFunction);
|
||||||
AssertPos(currentPos, diSubprogram.Verify());
|
AssertPos(currentPos, diSubprogram.Verify());
|
||||||
@@ -1384,11 +1382,7 @@ FunctionEmitContext::MasksAllEqual(llvm::Value *v1, llvm::Value *v2) {
|
|||||||
|
|
||||||
llvm::Value *
|
llvm::Value *
|
||||||
FunctionEmitContext::GetStringPtr(const std::string &str) {
|
FunctionEmitContext::GetStringPtr(const std::string &str) {
|
||||||
#ifdef LLVM_3_0
|
|
||||||
llvm::Constant *lstr = llvm::ConstantArray::get(*g->ctx, str);
|
|
||||||
#else
|
|
||||||
llvm::Constant *lstr = llvm::ConstantDataArray::getString(*g->ctx, str);
|
llvm::Constant *lstr = llvm::ConstantDataArray::getString(*g->ctx, str);
|
||||||
#endif
|
|
||||||
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage;
|
llvm::GlobalValue::LinkageTypes linkage = llvm::GlobalValue::InternalLinkage;
|
||||||
llvm::Value *lstrPtr = new llvm::GlobalVariable(*m->module, lstr->getType(),
|
llvm::Value *lstrPtr = new llvm::GlobalVariable(*m->module, lstr->getType(),
|
||||||
true /*isConst*/,
|
true /*isConst*/,
|
||||||
@@ -1438,11 +1432,7 @@ FunctionEmitContext::I1VecToBoolVec(llvm::Value *b) {
|
|||||||
|
|
||||||
static llvm::Value *
|
static llvm::Value *
|
||||||
lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
|
lGetStringAsValue(llvm::BasicBlock *bblock, const char *s) {
|
||||||
#ifdef LLVM_3_0
|
|
||||||
llvm::Constant *sConstant = llvm::ConstantArray::get(*g->ctx, s);
|
|
||||||
#else
|
|
||||||
llvm::Constant *sConstant = llvm::ConstantDataArray::getString(*g->ctx, s);
|
llvm::Constant *sConstant = llvm::ConstantDataArray::getString(*g->ctx, s);
|
||||||
#endif
|
|
||||||
llvm::Value *sPtr = new llvm::GlobalVariable(*m->module, sConstant->getType(),
|
llvm::Value *sPtr = new llvm::GlobalVariable(*m->module, sConstant->getType(),
|
||||||
true /* const */,
|
true /* const */,
|
||||||
llvm::GlobalValue::InternalLinkage,
|
llvm::GlobalValue::InternalLinkage,
|
||||||
|
|||||||
4
ctx.h
4
ctx.h
@@ -40,14 +40,14 @@
|
|||||||
|
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include <llvm/InstrTypes.h>
|
#include <llvm/InstrTypes.h>
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#else
|
#else
|
||||||
#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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
#include <llvm/Analysis/DIBuilder.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
2
expr.cpp
2
expr.cpp
@@ -56,7 +56,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(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>
|
||||||
|
|||||||
6
func.cpp
6
func.cpp
@@ -46,7 +46,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || 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>
|
||||||
@@ -310,7 +310,7 @@ 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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
|
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
|
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
|
||||||
@@ -453,7 +453,7 @@ Function::GenerateIR() {
|
|||||||
functionName += std::string("_") + g->target.GetISAString();
|
functionName += std::string("_") + g->target.GetISAString();
|
||||||
llvm::Function *appFunction =
|
llvm::Function *appFunction =
|
||||||
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
|
llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module);
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
appFunction->setDoesNotThrow(true);
|
appFunction->setDoesNotThrow(true);
|
||||||
#else
|
#else
|
||||||
appFunction->setDoesNotThrow();
|
appFunction->setDoesNotThrow();
|
||||||
|
|||||||
32
ispc.cpp
32
ispc.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(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>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
#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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
#include <llvm/Analysis/DIBuilder.h>
|
||||||
#else
|
#else
|
||||||
@@ -67,7 +67,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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Target/TargetData.h>
|
#include <llvm/Target/TargetData.h>
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
#include <llvm/DataLayout.h>
|
#include <llvm/DataLayout.h>
|
||||||
@@ -348,13 +348,10 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
|||||||
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
|
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
|
||||||
t->maskingIsFree = false;
|
t->maskingIsFree = false;
|
||||||
t->maskBitCount = 32;
|
t->maskBitCount = 32;
|
||||||
#if !defined(LLVM_3_0)
|
|
||||||
// LLVM 3.1+ only
|
|
||||||
t->hasHalf = true;
|
t->hasHalf = true;
|
||||||
#if !defined(LLVM_3_1)
|
#if !defined(LLVM_3_1)
|
||||||
// LLVM 3.2+ only
|
// LLVM 3.2+ only
|
||||||
t->hasRand = true;
|
t->hasRand = true;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(isa, "avx1.1-x2")) {
|
else if (!strcasecmp(isa, "avx1.1-x2")) {
|
||||||
@@ -364,16 +361,12 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
|||||||
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
|
t->attributes = "+avx,+popcnt,+cmov,+f16c,+rdrand";
|
||||||
t->maskingIsFree = false;
|
t->maskingIsFree = false;
|
||||||
t->maskBitCount = 32;
|
t->maskBitCount = 32;
|
||||||
#if !defined(LLVM_3_0)
|
|
||||||
// LLVM 3.1+ only
|
|
||||||
t->hasHalf = true;
|
t->hasHalf = true;
|
||||||
#if !defined(LLVM_3_1)
|
#if !defined(LLVM_3_1)
|
||||||
// LLVM 3.2+ only
|
// LLVM 3.2+ only
|
||||||
t->hasRand = true;
|
t->hasRand = true;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifndef LLVM_3_0
|
|
||||||
else if (!strcasecmp(isa, "avx2")) {
|
else if (!strcasecmp(isa, "avx2")) {
|
||||||
t->isa = Target::AVX2;
|
t->isa = Target::AVX2;
|
||||||
t->nativeVectorWidth = 8;
|
t->nativeVectorWidth = 8;
|
||||||
@@ -410,7 +403,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
|||||||
t->hasGather = true;
|
t->hasGather = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // !LLVM_3_0
|
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n",
|
fprintf(stderr, "Target ISA \"%s\" is unknown. Choices are: %s\n",
|
||||||
isa, SupportedTargetISAs());
|
isa, SupportedTargetISAs());
|
||||||
@@ -419,7 +411,7 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa,
|
|||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
llvm::TargetMachine *targetMachine = t->GetTargetMachine();
|
llvm::TargetMachine *targetMachine = t->GetTargetMachine();
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
const llvm::TargetData *targetData = targetMachine->getTargetData();
|
const llvm::TargetData *targetData = targetMachine->getTargetData();
|
||||||
t->is32Bit = (targetData->getPointerSize() == 4);
|
t->is32Bit = (targetData->getPointerSize() == 4);
|
||||||
#else
|
#else
|
||||||
@@ -456,9 +448,7 @@ Target::SupportedTargetArchs() {
|
|||||||
const char *
|
const char *
|
||||||
Target::SupportedTargetISAs() {
|
Target::SupportedTargetISAs() {
|
||||||
return "sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2"
|
return "sse2, sse2-x2, sse4, sse4-x2, avx, avx-x2"
|
||||||
#ifndef LLVM_3_0
|
|
||||||
", avx1.1, avx1.1-x2, avx2, avx2-x2"
|
", avx1.1, avx1.1-x2, avx2, avx2-x2"
|
||||||
#endif // !LLVM_3_0
|
|
||||||
", generic-1, generic-4, generic-8, generic-16, generic-32";
|
", generic-1, generic-4, generic-8, generic-16, generic-32";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,11 +457,7 @@ std::string
|
|||||||
Target::GetTripleString() const {
|
Target::GetTripleString() const {
|
||||||
llvm::Triple triple;
|
llvm::Triple triple;
|
||||||
// Start with the host triple as the default
|
// Start with the host triple as the default
|
||||||
#ifdef LLVM_3_0
|
|
||||||
triple.setTriple(llvm::sys::getHostTriple());
|
|
||||||
#else
|
|
||||||
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
||||||
#endif
|
|
||||||
|
|
||||||
// And override the arch in the host triple based on what the user
|
// And override the arch in the host triple based on what the user
|
||||||
// specified. Here we need to deal with the fact that LLVM uses one
|
// specified. Here we need to deal with the fact that LLVM uses one
|
||||||
@@ -496,11 +482,6 @@ Target::GetTargetMachine() const {
|
|||||||
|
|
||||||
llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ :
|
llvm::Reloc::Model relocModel = generatePIC ? llvm::Reloc::PIC_ :
|
||||||
llvm::Reloc::Default;
|
llvm::Reloc::Default;
|
||||||
#ifdef LLVM_3_0
|
|
||||||
std::string featuresString = attributes;
|
|
||||||
llvm::TargetMachine *targetMachine =
|
|
||||||
target->createTargetMachine(triple, cpu, featuresString, relocModel);
|
|
||||||
#else
|
|
||||||
std::string featuresString = attributes;
|
std::string featuresString = attributes;
|
||||||
llvm::TargetOptions options;
|
llvm::TargetOptions options;
|
||||||
#if !defined(LLVM_3_1)
|
#if !defined(LLVM_3_1)
|
||||||
@@ -510,7 +491,6 @@ Target::GetTargetMachine() const {
|
|||||||
llvm::TargetMachine *targetMachine =
|
llvm::TargetMachine *targetMachine =
|
||||||
target->createTargetMachine(triple, cpu, featuresString, options,
|
target->createTargetMachine(triple, cpu, featuresString, options,
|
||||||
relocModel);
|
relocModel);
|
||||||
#endif // !LLVM_3_0
|
|
||||||
Assert(targetMachine != NULL);
|
Assert(targetMachine != NULL);
|
||||||
|
|
||||||
targetMachine->setAsmVerbosityDefault(true);
|
targetMachine->setAsmVerbosityDefault(true);
|
||||||
@@ -595,7 +575,7 @@ Target::SizeOf(llvm::Type *type,
|
|||||||
"sizeof_int", insertAtEnd);
|
"sizeof_int", insertAtEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
const llvm::TargetData *td = GetTargetMachine()->getTargetData();
|
const llvm::TargetData *td = GetTargetMachine()->getTargetData();
|
||||||
Assert(td != NULL);
|
Assert(td != NULL);
|
||||||
uint64_t bitSize = td->getTypeSizeInBits(type);
|
uint64_t bitSize = td->getTypeSizeInBits(type);
|
||||||
@@ -642,7 +622,7 @@ Target::StructOffset(llvm::Type *type, int element,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
const llvm::TargetData *td = GetTargetMachine()->getTargetData();
|
const llvm::TargetData *td = GetTargetMachine()->getTargetData();
|
||||||
Assert(td != NULL);
|
Assert(td != NULL);
|
||||||
const llvm::StructLayout *sl = td->getStructLayout(structType);
|
const llvm::StructLayout *sl = td->getStructLayout(structType);
|
||||||
|
|||||||
4
ispc.h
4
ispc.h
@@ -40,8 +40,8 @@
|
|||||||
|
|
||||||
#define ISPC_VERSION "1.3.1dev"
|
#define ISPC_VERSION "1.3.1dev"
|
||||||
|
|
||||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3)
|
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3)
|
||||||
#error "Only LLVM 3.0, 3.1, 3.2 and the 3.3 development branch are supported"
|
#error "Only LLVM 3.1, 3.2 and the 3.3 development branch are supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|||||||
48
llvmutil.cpp
48
llvmutil.cpp
@@ -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_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#include <llvm/BasicBlock.h>
|
#include <llvm/BasicBlock.h>
|
||||||
#else
|
#else
|
||||||
@@ -660,9 +660,6 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deal with the fact that LLVM3.1 and previous versions have different
|
|
||||||
// representations for vectors of constant ints...
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
||||||
if (cv == NULL)
|
if (cv == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -670,20 +667,6 @@ LLVMExtractVectorInts(llvm::Value *v, int64_t ret[], int *nElts) {
|
|||||||
for (int i = 0; i < (int)cv->getNumElements(); ++i)
|
for (int i = 0; i < (int)cv->getNumElements(); ++i)
|
||||||
ret[i] = cv->getElementAsInteger(i);
|
ret[i] = cv->getElementAsInteger(i);
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v);
|
|
||||||
if (cv == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
|
||||||
cv->getVectorElements(elements);
|
|
||||||
for (int i = 0; i < (int)vt->getNumElements(); ++i) {
|
|
||||||
llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[i]);
|
|
||||||
Assert(ci != NULL);
|
|
||||||
ret[i] = ci->getSExtValue();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
#endif // !LLVM_3_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -952,11 +935,9 @@ lVectorValuesAllEqual(llvm::Value *v, int vectorLength,
|
|||||||
if (cv != NULL)
|
if (cv != NULL)
|
||||||
return (cv->getSplatValue() != NULL);
|
return (cv->getSplatValue() != NULL);
|
||||||
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
||||||
if (cdv != NULL)
|
if (cdv != NULL)
|
||||||
return (cdv->getSplatValue() != NULL);
|
return (cdv->getSplatValue() != NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
llvm::BinaryOperator *bop = llvm::dyn_cast<llvm::BinaryOperator>(v);
|
llvm::BinaryOperator *bop = llvm::dyn_cast<llvm::BinaryOperator>(v);
|
||||||
if (bop != NULL) {
|
if (bop != NULL) {
|
||||||
@@ -1106,22 +1087,13 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride,
|
|||||||
elements.
|
elements.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
lVectorIsLinearConstantInts(
|
lVectorIsLinearConstantInts(llvm::ConstantDataVector *cv,
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::ConstantDataVector *cv,
|
|
||||||
#else
|
|
||||||
llvm::ConstantVector *cv,
|
|
||||||
#endif
|
|
||||||
int vectorLength,
|
int vectorLength,
|
||||||
int stride) {
|
int stride) {
|
||||||
// Flatten the vector out into the elements array
|
// Flatten the vector out into the elements array
|
||||||
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
||||||
#ifndef LLVM_3_0
|
|
||||||
for (int i = 0; i < (int)cv->getNumElements(); ++i)
|
for (int i = 0; i < (int)cv->getNumElements(); ++i)
|
||||||
elements.push_back(cv->getElementAsConstant(i));
|
elements.push_back(cv->getElementAsConstant(i));
|
||||||
#else
|
|
||||||
cv->getVectorElements(elements);
|
|
||||||
#endif
|
|
||||||
Assert((int)elements.size() == vectorLength);
|
Assert((int)elements.size() == vectorLength);
|
||||||
|
|
||||||
llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[0]);
|
llvm::ConstantInt *ci = llvm::dyn_cast<llvm::ConstantInt>(elements[0]);
|
||||||
@@ -1157,11 +1129,7 @@ lCheckMulForLinear(llvm::Value *op0, llvm::Value *op1, int vectorLength,
|
|||||||
int stride, std::vector<llvm::PHINode *> &seenPhis) {
|
int stride, std::vector<llvm::PHINode *> &seenPhis) {
|
||||||
// Is the first operand a constant integer value splatted across all of
|
// Is the first operand a constant integer value splatted across all of
|
||||||
// the lanes?
|
// the lanes?
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(op0);
|
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(op0);
|
||||||
#else
|
|
||||||
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(op0);
|
|
||||||
#endif
|
|
||||||
if (cv == NULL)
|
if (cv == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1231,11 +1199,7 @@ lVectorIsLinear(llvm::Value *v, int vectorLength, int stride,
|
|||||||
std::vector<llvm::PHINode *> &seenPhis) {
|
std::vector<llvm::PHINode *> &seenPhis) {
|
||||||
// First try the easy case: if the values are all just constant
|
// First try the easy case: if the values are all just constant
|
||||||
// integers and have the expected stride between them, then we're done.
|
// integers and have the expected stride between them, then we're done.
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
llvm::ConstantDataVector *cv = llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
||||||
#else
|
|
||||||
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v);
|
|
||||||
#endif
|
|
||||||
if (cv != NULL)
|
if (cv != NULL)
|
||||||
return lVectorIsLinearConstantInts(cv, vectorLength, stride);
|
return lVectorIsLinearConstantInts(cv, vectorLength, stride);
|
||||||
|
|
||||||
@@ -1407,19 +1371,11 @@ lExtractFirstVectorElement(llvm::Value *v,
|
|||||||
return llvm::Constant::getNullValue(vt->getElementType());
|
return llvm::Constant::getNullValue(vt->getElementType());
|
||||||
}
|
}
|
||||||
if (llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v)) {
|
if (llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(v)) {
|
||||||
#ifndef LLVM_3_0
|
|
||||||
return cv->getOperand(0);
|
return cv->getOperand(0);
|
||||||
#else
|
|
||||||
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
|
||||||
cv->getVectorElements(elements);
|
|
||||||
return elements[0];
|
|
||||||
#endif // !LLVM_3_0
|
|
||||||
}
|
}
|
||||||
#ifndef LLVM_3_0
|
|
||||||
if (llvm::ConstantDataVector *cdv =
|
if (llvm::ConstantDataVector *cdv =
|
||||||
llvm::dyn_cast<llvm::ConstantDataVector>(v))
|
llvm::dyn_cast<llvm::ConstantDataVector>(v))
|
||||||
return cdv->getElementAsConstant(0);
|
return cdv->getElementAsConstant(0);
|
||||||
#endif // !LLVM_3_0
|
|
||||||
|
|
||||||
// Otherwise, all that we should have at this point is an instruction
|
// Otherwise, all that we should have at this point is an instruction
|
||||||
// of some sort
|
// of some sort
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#ifndef ISPC_LLVMUTIL_H
|
#ifndef ISPC_LLVMUTIL_H
|
||||||
#define ISPC_LLVMUTIL_H 1
|
#define ISPC_LLVMUTIL_H 1
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include <llvm/LLVMContext.h>
|
#include <llvm/LLVMContext.h>
|
||||||
#include <llvm/Type.h>
|
#include <llvm/Type.h>
|
||||||
#include <llvm/DerivedTypes.h>
|
#include <llvm/DerivedTypes.h>
|
||||||
|
|||||||
4
main.cpp
4
main.cpp
@@ -62,9 +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_0)
|
#if defined(LLVM_3_1)
|
||||||
"3.0"
|
|
||||||
#elif defined(LLVM_3_1)
|
|
||||||
"3.1"
|
"3.1"
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
"3.2"
|
"3.2"
|
||||||
|
|||||||
30
module.cpp
30
module.cpp
@@ -64,7 +64,7 @@
|
|||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || 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>
|
||||||
@@ -86,7 +86,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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Target/TargetData.h>
|
#include <llvm/Target/TargetData.h>
|
||||||
#else
|
#else
|
||||||
#if defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
@@ -149,7 +149,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
|
|||||||
if (g->generateDebuggingSymbols == false)
|
if (g->generateDebuggingSymbols == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
// loop over the compile units that contributed to the final module
|
// loop over the compile units that contributed to the final 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) {
|
||||||
@@ -228,7 +227,6 @@ lStripUnusedDebugInfo(llvm::Module *module) {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < (int)toErase.size(); ++i)
|
for (int i = 0; i < (int)toErase.size(); ++i)
|
||||||
module->eraseNamedMetadata(toErase[i]);
|
module->eraseNamedMetadata(toErase[i]);
|
||||||
#endif // !LLVM_3_0
|
|
||||||
|
|
||||||
// Wrap up by running the LLVM pass to remove anything left that's
|
// Wrap up by running the LLVM pass to remove anything left that's
|
||||||
// unused.
|
// unused.
|
||||||
@@ -780,7 +778,7 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
#endif
|
#endif
|
||||||
if (functionType->isTask)
|
if (functionType->isTask)
|
||||||
// This also applies transitively to members I think?
|
// This also applies transitively to members I think?
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
function->setDoesNotAlias(1, true);
|
function->setDoesNotAlias(1, true);
|
||||||
#else
|
#else
|
||||||
function->setDoesNotAlias(1);
|
function->setDoesNotAlias(1);
|
||||||
@@ -826,7 +824,7 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
|
|
||||||
// NOTE: LLVM indexes function parameters starting from 1.
|
// NOTE: LLVM indexes function parameters starting from 1.
|
||||||
// This is unintuitive.
|
// This is unintuitive.
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
function->setDoesNotAlias(i+1, true);
|
function->setDoesNotAlias(i+1, true);
|
||||||
#else
|
#else
|
||||||
function->setDoesNotAlias(i+1);
|
function->setDoesNotAlias(i+1);
|
||||||
@@ -1053,7 +1051,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
|
|||||||
}
|
}
|
||||||
|
|
||||||
llvm::PassManager pm;
|
llvm::PassManager pm;
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
if (const llvm::TargetData *td = targetMachine->getTargetData())
|
if (const llvm::TargetData *td = targetMachine->getTargetData())
|
||||||
pm.add(new llvm::TargetData(*td));
|
pm.add(new llvm::TargetData(*td));
|
||||||
else
|
else
|
||||||
@@ -1067,13 +1065,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
|
|||||||
|
|
||||||
llvm::formatted_raw_ostream fos(of->os());
|
llvm::formatted_raw_ostream fos(of->os());
|
||||||
|
|
||||||
#ifdef LLVM_3_0
|
|
||||||
llvm::CodeGenOpt::Level optLevel =
|
|
||||||
(g->opt.level > 0) ? llvm::CodeGenOpt::Aggressive : llvm::CodeGenOpt::None;
|
|
||||||
if (targetMachine->addPassesToEmitFile(pm, fos, fileType, optLevel)) {
|
|
||||||
#else
|
|
||||||
if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) {
|
if (targetMachine->addPassesToEmitFile(pm, fos, fileType)) {
|
||||||
#endif
|
|
||||||
fprintf(stderr, "Fatal error adding passes to emit object file!");
|
fprintf(stderr, "Fatal error adding passes to emit object file!");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -1783,7 +1775,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
|
|
||||||
llvm::raw_fd_ostream stderrRaw(2, false);
|
llvm::raw_fd_ostream stderrRaw(2, false);
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
clang::TextDiagnosticPrinter *diagPrinter =
|
clang::TextDiagnosticPrinter *diagPrinter =
|
||||||
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
|
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
|
||||||
#else
|
#else
|
||||||
@@ -1792,7 +1784,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
|
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
|
||||||
#endif
|
#endif
|
||||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
|
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
clang::DiagnosticsEngine *diagEngine =
|
clang::DiagnosticsEngine *diagEngine =
|
||||||
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
|
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
|
||||||
#else
|
#else
|
||||||
@@ -1804,15 +1796,11 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
clang::TargetOptions &options = inst.getTargetOpts();
|
clang::TargetOptions &options = inst.getTargetOpts();
|
||||||
llvm::Triple triple(module->getTargetTriple());
|
llvm::Triple triple(module->getTargetTriple());
|
||||||
if (triple.getTriple().empty()) {
|
if (triple.getTriple().empty()) {
|
||||||
#ifdef LLVM_3_0
|
|
||||||
triple.setTriple(llvm::sys::getHostTriple());
|
|
||||||
#else
|
|
||||||
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
triple.setTriple(llvm::sys::getDefaultTargetTriple());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
options.Triple = triple.getTriple();
|
options.Triple = triple.getTriple();
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
clang::TargetInfo *target =
|
clang::TargetInfo *target =
|
||||||
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
|
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
|
||||||
#else // LLVM 3.3+
|
#else // LLVM 3.3+
|
||||||
@@ -1822,7 +1810,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
|
|
||||||
inst.setTarget(target);
|
inst.setTarget(target);
|
||||||
inst.createSourceManager(inst.getFileManager());
|
inst.createSourceManager(inst.getFileManager());
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
inst.InitializeSourceManager(infilename);
|
inst.InitializeSourceManager(infilename);
|
||||||
#else
|
#else
|
||||||
clang::FrontendInputFile inputFile(infilename, clang::IK_None);
|
clang::FrontendInputFile inputFile(infilename, clang::IK_None);
|
||||||
|
|||||||
29
opt.cpp
29
opt.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <llvm/Pass.h>
|
#include <llvm/Pass.h>
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#include <llvm/Intrinsics.h>
|
#include <llvm/Intrinsics.h>
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
#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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Target/TargetData.h>
|
#include <llvm/Target/TargetData.h>
|
||||||
#elif defined(LLVM_3_2)
|
#elif defined(LLVM_3_2)
|
||||||
#include <llvm/DataLayout.h>
|
#include <llvm/DataLayout.h>
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
#include <llvm/Analysis/Verifier.h>
|
#include <llvm/Analysis/Verifier.h>
|
||||||
#include <llvm/Analysis/Passes.h>
|
#include <llvm/Analysis/Passes.h>
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#else
|
#else
|
||||||
#include <llvm/DebugInfo.h>
|
#include <llvm/DebugInfo.h>
|
||||||
@@ -323,7 +323,6 @@ lConstElementsToMask(const llvm::SmallVector<llvm::Constant *,
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
lGetMask(llvm::Value *factor, uint64_t *mask) {
|
lGetMask(llvm::Value *factor, uint64_t *mask) {
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(factor);
|
llvm::ConstantDataVector *cdv = llvm::dyn_cast<llvm::ConstantDataVector>(factor);
|
||||||
if (cdv != NULL) {
|
if (cdv != NULL) {
|
||||||
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
||||||
@@ -332,12 +331,10 @@ lGetMask(llvm::Value *factor, uint64_t *mask) {
|
|||||||
*mask = lConstElementsToMask(elements);
|
*mask = lConstElementsToMask(elements);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(factor);
|
llvm::ConstantVector *cv = llvm::dyn_cast<llvm::ConstantVector>(factor);
|
||||||
if (cv != NULL) {
|
if (cv != NULL) {
|
||||||
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
||||||
#ifndef LLVM_3_0
|
|
||||||
for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
|
for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
|
||||||
llvm::Constant *c =
|
llvm::Constant *c =
|
||||||
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
|
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
|
||||||
@@ -345,9 +342,6 @@ lGetMask(llvm::Value *factor, uint64_t *mask) {
|
|||||||
return false;
|
return false;
|
||||||
elements.push_back(c);
|
elements.push_back(c);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
cv->getVectorElements(elements);
|
|
||||||
#endif
|
|
||||||
*mask = lConstElementsToMask(elements);
|
*mask = lConstElementsToMask(elements);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -420,7 +414,7 @@ Optimize(llvm::Module *module, int optLevel) {
|
|||||||
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
|
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
|
||||||
optPM.add(targetLibraryInfo);
|
optPM.add(targetLibraryInfo);
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
optPM.add(new llvm::TargetData(module));
|
optPM.add(new llvm::TargetData(module));
|
||||||
#else
|
#else
|
||||||
llvm::TargetMachine *targetMachine = g->target.GetTargetMachine();
|
llvm::TargetMachine *targetMachine = g->target.GetTargetMachine();
|
||||||
@@ -950,8 +944,6 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
|
|
||||||
restart:
|
restart:
|
||||||
for (llvm::BasicBlock::iterator iter = bb.begin(), e = bb.end(); iter != e; ++iter) {
|
for (llvm::BasicBlock::iterator iter = bb.begin(), e = bb.end(); iter != e; ++iter) {
|
||||||
// vector select wasn't available before 3.1...
|
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::SelectInst *selectInst = llvm::dyn_cast<llvm::SelectInst>(&*iter);
|
llvm::SelectInst *selectInst = llvm::dyn_cast<llvm::SelectInst>(&*iter);
|
||||||
if (selectInst != NULL && selectInst->getType()->isVectorTy()) {
|
if (selectInst != NULL && selectInst->getType()->isVectorTy()) {
|
||||||
llvm::Value *factor = selectInst->getOperand(0);
|
llvm::Value *factor = selectInst->getOperand(0);
|
||||||
@@ -972,7 +964,6 @@ VSelMovmskOpt::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !LLVM_3_0
|
|
||||||
|
|
||||||
llvm::CallInst *callInst = llvm::dyn_cast<llvm::CallInst>(&*iter);
|
llvm::CallInst *callInst = llvm::dyn_cast<llvm::CallInst>(&*iter);
|
||||||
if (callInst == NULL)
|
if (callInst == NULL)
|
||||||
@@ -1185,7 +1176,6 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
|
|||||||
// Indexing into global arrays can lead to this form, with
|
// Indexing into global arrays can lead to this form, with
|
||||||
// ConstantVectors..
|
// ConstantVectors..
|
||||||
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
llvm::SmallVector<llvm::Constant *, ISPC_MAX_NVEC> elements;
|
||||||
#ifndef LLVM_3_0
|
|
||||||
for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
|
for (int i = 0; i < (int)cv->getNumOperands(); ++i) {
|
||||||
llvm::Constant *c =
|
llvm::Constant *c =
|
||||||
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
|
llvm::dyn_cast<llvm::Constant>(cv->getOperand(i));
|
||||||
@@ -1193,9 +1183,6 @@ lGetBasePtrAndOffsets(llvm::Value *ptrs, llvm::Value **offsets,
|
|||||||
return NULL;
|
return NULL;
|
||||||
elements.push_back(c);
|
elements.push_back(c);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
cv->getVectorElements(elements);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
llvm::Constant *delta[ISPC_MAX_NVEC];
|
llvm::Constant *delta[ISPC_MAX_NVEC];
|
||||||
for (unsigned int i = 0; i < elements.size(); ++i) {
|
for (unsigned int i = 0; i < elements.size(); ++i) {
|
||||||
@@ -1280,9 +1267,7 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset,
|
|||||||
llvm::Value **variableOffset,
|
llvm::Value **variableOffset,
|
||||||
llvm::Instruction *insertBefore) {
|
llvm::Instruction *insertBefore) {
|
||||||
if (llvm::isa<llvm::ConstantVector>(vec) ||
|
if (llvm::isa<llvm::ConstantVector>(vec) ||
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::isa<llvm::ConstantDataVector>(vec) ||
|
llvm::isa<llvm::ConstantDataVector>(vec) ||
|
||||||
#endif
|
|
||||||
llvm::isa<llvm::ConstantAggregateZero>(vec)) {
|
llvm::isa<llvm::ConstantAggregateZero>(vec)) {
|
||||||
*constOffset = vec;
|
*constOffset = vec;
|
||||||
*variableOffset = NULL;
|
*variableOffset = NULL;
|
||||||
@@ -1405,12 +1390,8 @@ lExtractConstantOffset(llvm::Value *vec, llvm::Value **constOffset,
|
|||||||
*splat, if so). */
|
*splat, if so). */
|
||||||
static bool
|
static bool
|
||||||
lIsIntegerSplat(llvm::Value *v, int *splat) {
|
lIsIntegerSplat(llvm::Value *v, int *splat) {
|
||||||
#ifdef LLVM_3_0
|
|
||||||
llvm::ConstantVector *cvec = llvm::dyn_cast<llvm::ConstantVector>(v);
|
|
||||||
#else
|
|
||||||
llvm::ConstantDataVector *cvec =
|
llvm::ConstantDataVector *cvec =
|
||||||
llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
llvm::dyn_cast<llvm::ConstantDataVector>(v);
|
||||||
#endif
|
|
||||||
if (cvec == NULL)
|
if (cvec == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1545,9 +1526,7 @@ lExtractUniforms(llvm::Value **vec, llvm::Instruction *insertBefore) {
|
|||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
if (llvm::isa<llvm::ConstantVector>(*vec) ||
|
if (llvm::isa<llvm::ConstantVector>(*vec) ||
|
||||||
#ifndef LLVM_3_0
|
|
||||||
llvm::isa<llvm::ConstantDataVector>(*vec) ||
|
llvm::isa<llvm::ConstantDataVector>(*vec) ||
|
||||||
#endif
|
|
||||||
llvm::isa<llvm::ConstantAggregateZero>(*vec))
|
llvm::isa<llvm::ConstantAggregateZero>(*vec))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
6
parse.yy
6
parse.yy
@@ -83,10 +83,10 @@ struct ForeachDimension;
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include <llvm/IR/Constants.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/Constants.h>
|
#include <llvm/Constants.h>
|
||||||
|
#else
|
||||||
|
#include <llvm/IR/Constants.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UNIMPLEMENTED \
|
#define UNIMPLEMENTED \
|
||||||
|
|||||||
2
stmt.cpp
2
stmt.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(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>
|
||||||
|
|||||||
8
type.cpp
8
type.cpp
@@ -43,14 +43,14 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(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_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
#include <llvm/Analysis/DIBuilder.h>
|
||||||
#else
|
#else
|
||||||
@@ -820,7 +820,7 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
32 /* size in bits */,
|
32 /* size in bits */,
|
||||||
32 /* align in bits */,
|
32 /* align in bits */,
|
||||||
elementArray
|
elementArray
|
||||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1)
|
#if !defined(LLVM_3_1)
|
||||||
, llvm::DIType()
|
, llvm::DIType()
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
@@ -2626,7 +2626,7 @@ ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType diTargetType = targetType->GetDIType(scope);
|
llvm::DIType diTargetType = targetType->GetDIType(scope);
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
#if defined(LLVM_3_1)
|
||||||
return m->diBuilder->createReferenceType(diTargetType);
|
return m->diBuilder->createReferenceType(diTargetType);
|
||||||
#else
|
#else
|
||||||
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,
|
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,
|
||||||
|
|||||||
2
type.h
2
type.h
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||||
#include <llvm/Type.h>
|
#include <llvm/Type.h>
|
||||||
#include <llvm/DerivedTypes.h>
|
#include <llvm/DerivedTypes.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user