Remove support for building with LLVM 3.1
This commit is contained in:
@@ -49,8 +49,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#if defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Attributes.h>
|
#include <llvm/Attributes.h>
|
||||||
#endif
|
|
||||||
#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>
|
||||||
|
|||||||
@@ -31,9 +31,7 @@
|
|||||||
|
|
||||||
include(`target-avx-x2.ll')
|
include(`target-avx-x2.ll')
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
|
rdrand_definition()
|
||||||
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
|
|
||||||
`rdrand_definition()')
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; int min/max
|
;; int min/max
|
||||||
|
|||||||
@@ -31,9 +31,7 @@
|
|||||||
|
|
||||||
include(`target-avx.ll')
|
include(`target-avx.ll')
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
|
rdrand_definition()
|
||||||
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
|
|
||||||
`rdrand_definition()')
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; int min/max
|
;; int min/max
|
||||||
|
|||||||
@@ -29,15 +29,11 @@
|
|||||||
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `',
|
define(`HAVE_GATHER', `1')
|
||||||
LLVM_VERSION, `LLVM_3_1', `',
|
|
||||||
`define(`HAVE_GATHER', `1')')
|
|
||||||
|
|
||||||
include(`target-avx-x2.ll')
|
include(`target-avx-x2.ll')
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
|
rdrand_definition()
|
||||||
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
|
|
||||||
`rdrand_definition()')
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; int min/max
|
;; int min/max
|
||||||
@@ -176,21 +172,6 @@ define(`assemble_4s', `
|
|||||||
assemble_8s($1, $2, $2_1, $2_2)
|
assemble_8s($1, $2, $2_1, $2_2)
|
||||||
')
|
')
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `
|
|
||||||
gen_gather_factored(i8)
|
|
||||||
gen_gather_factored(i16)
|
|
||||||
gen_gather_factored(i32)
|
|
||||||
gen_gather_factored(float)
|
|
||||||
gen_gather_factored(i64)
|
|
||||||
gen_gather_factored(double)',
|
|
||||||
LLVM_VERSION, `LLVM_3_1', `
|
|
||||||
gen_gather_factored(i8)
|
|
||||||
gen_gather_factored(i16)
|
|
||||||
gen_gather_factored(i32)
|
|
||||||
gen_gather_factored(float)
|
|
||||||
gen_gather_factored(i64)
|
|
||||||
gen_gather_factored(double)', `
|
|
||||||
|
|
||||||
gen_gather(i8)
|
gen_gather(i8)
|
||||||
gen_gather(i16)
|
gen_gather(i16)
|
||||||
|
|
||||||
@@ -557,5 +538,3 @@ define <16 x double> @__gather64_double(<16 x i64> %ptrs,
|
|||||||
|
|
||||||
ret <16 x double> %v
|
ret <16 x double> %v
|
||||||
}
|
}
|
||||||
|
|
||||||
')
|
|
||||||
|
|||||||
@@ -29,15 +29,11 @@
|
|||||||
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `',
|
define(`HAVE_GATHER', `1')
|
||||||
LLVM_VERSION, `LLVM_3_1', `',
|
|
||||||
`define(`HAVE_GATHER', `1')')
|
|
||||||
|
|
||||||
include(`target-avx.ll')
|
include(`target-avx.ll')
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()',
|
rdrand_definition()
|
||||||
LLVM_VERSION, `LLVM_3_1', `rdrand_decls()',
|
|
||||||
`rdrand_definition()')
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; int min/max
|
;; int min/max
|
||||||
@@ -123,21 +119,6 @@ define(`extract_4s', `
|
|||||||
%$2_2 = shufflevector <8 x $1> %$2, <8 x $1> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
|
%$2_2 = shufflevector <8 x $1> %$2, <8 x $1> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
|
||||||
')
|
')
|
||||||
|
|
||||||
ifelse(LLVM_VERSION, `LLVM_3_0', `
|
|
||||||
gen_gather_factored(i8)
|
|
||||||
gen_gather_factored(i16)
|
|
||||||
gen_gather_factored(i32)
|
|
||||||
gen_gather_factored(float)
|
|
||||||
gen_gather_factored(i64)
|
|
||||||
gen_gather_factored(double)',
|
|
||||||
LLVM_VERSION, `LLVM_3_1', `
|
|
||||||
gen_gather_factored(i8)
|
|
||||||
gen_gather_factored(i16)
|
|
||||||
gen_gather_factored(i32)
|
|
||||||
gen_gather_factored(float)
|
|
||||||
gen_gather_factored(i64)
|
|
||||||
gen_gather_factored(double)', `
|
|
||||||
|
|
||||||
gen_gather(i8)
|
gen_gather(i8)
|
||||||
gen_gather(i16)
|
gen_gather(i16)
|
||||||
|
|
||||||
@@ -429,5 +410,3 @@ define <8 x double> @__gather64_double(<8 x i64> %ptrs,
|
|||||||
|
|
||||||
ret <8 x double> %v
|
ret <8 x double> %v
|
||||||
}
|
}
|
||||||
|
|
||||||
')
|
|
||||||
|
|||||||
115
cbackend.cpp
115
cbackend.cpp
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "llvmutil.h"
|
#include "llvmutil.h"
|
||||||
|
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if 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"
|
||||||
@@ -38,6 +38,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"
|
||||||
|
#include "llvm/TypeFinder.h"
|
||||||
#else
|
#else
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
@@ -47,16 +48,10 @@
|
|||||||
#include "llvm/IR/Intrinsics.h"
|
#include "llvm/IR/Intrinsics.h"
|
||||||
#include "llvm/IR/IntrinsicInst.h"
|
#include "llvm/IR/IntrinsicInst.h"
|
||||||
#include "llvm/IR/InlineAsm.h"
|
#include "llvm/IR/InlineAsm.h"
|
||||||
|
#include "llvm/IR/TypeFinder.h"
|
||||||
#endif
|
#endif
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
#if defined(LLVM_3_2)
|
|
||||||
#include "llvm/TypeFinder.h"
|
|
||||||
#else // LLVM_3_3 +
|
|
||||||
#include "llvm/IR/TypeFinder.h"
|
|
||||||
#endif
|
|
||||||
#endif // LLVM_3_2 +
|
|
||||||
#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"
|
||||||
@@ -76,9 +71,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_1)
|
#if defined(LLVM_3_2)
|
||||||
#include "llvm/Target/TargetData.h"
|
|
||||||
#elif defined(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"
|
||||||
@@ -88,7 +81,7 @@
|
|||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include "llvm/Support/InstVisitor.h"
|
#include "llvm/Support/InstVisitor.h"
|
||||||
#else // LLVM 3.3+
|
#else // LLVM 3.3+
|
||||||
#include "llvm/InstVisitor.h"
|
#include "llvm/InstVisitor.h"
|
||||||
@@ -258,14 +251,10 @@ 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_1)
|
|
||||||
const llvm::TargetData* TD;
|
|
||||||
#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
|
||||||
// lots of ifdefs in the below since the new DataLayout and the old
|
// lots of ifdefs in the below since the new DataLayout and the old
|
||||||
// TargetData have generally similar interfaces...
|
// TargetData have generally similar interfaces...
|
||||||
const llvm::DataLayout* TD;
|
const llvm::DataLayout* TD;
|
||||||
#endif
|
|
||||||
|
|
||||||
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
|
std::map<const llvm::ConstantFP *, unsigned> FPConstantMap;
|
||||||
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
|
std::map<const llvm::ConstantDataVector *, unsigned> VectorConstantMap;
|
||||||
@@ -352,7 +341,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_1) || defined(LLVM_3_2)
|
#if 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()
|
||||||
@@ -363,7 +352,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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL,
|
const llvm::AttrListPtr &PAL,
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL,
|
const llvm::AttributeSet &PAL,
|
||||||
@@ -586,7 +575,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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL,
|
const llvm::AttrListPtr &PAL,
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL,
|
const llvm::AttributeSet &PAL,
|
||||||
@@ -605,20 +594,16 @@ 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_1)
|
#if defined(LLVM_3_2)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
#else
|
#else
|
||||||
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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
|
||||||
@@ -635,9 +620,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
|||||||
}
|
}
|
||||||
FunctionInnards << ')';
|
FunctionInnards << ')';
|
||||||
printType(Out, RetTy,
|
printType(Out, RetTy,
|
||||||
#if defined(LLVM_3_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
|
||||||
@@ -737,7 +720,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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
const llvm::AttrListPtr &PAL
|
const llvm::AttrListPtr &PAL
|
||||||
#else
|
#else
|
||||||
const llvm::AttributeSet &PAL
|
const llvm::AttributeSet &PAL
|
||||||
@@ -759,9 +742,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_1)
|
#if defined(LLVM_3_2)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
#else
|
#else
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
|
||||||
@@ -772,9 +753,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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
|
||||||
@@ -791,9 +770,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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
|
||||||
@@ -1972,11 +1949,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_1)
|
|
||||||
const llvm::TargetData *TD) {
|
|
||||||
#else
|
|
||||||
const llvm::DataLayout *TD) {
|
const llvm::DataLayout *TD) {
|
||||||
#endif
|
|
||||||
// We output GCC specific attributes to preserve 'linkonce'ness on globals.
|
// We output GCC specific attributes to preserve 'linkonce'ness on globals.
|
||||||
// If we aren't being compiled with GCC, just drop these attributes.
|
// If we aren't being compiled with GCC, just drop these attributes.
|
||||||
Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n"
|
Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n"
|
||||||
@@ -2169,11 +2142,7 @@ bool CWriter::doInitialization(llvm::Module &M) {
|
|||||||
// Initialize
|
// Initialize
|
||||||
TheModule = &M;
|
TheModule = &M;
|
||||||
|
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
TD = new llvm::TargetData(&M);
|
|
||||||
#else
|
|
||||||
TD = new llvm::DataLayout(&M);
|
TD = new llvm::DataLayout(&M);
|
||||||
#endif
|
|
||||||
IL = new llvm::IntrinsicLowering(*TD);
|
IL = new llvm::IntrinsicLowering(*TD);
|
||||||
IL->AddPrototypes(M);
|
IL->AddPrototypes(M);
|
||||||
|
|
||||||
@@ -2656,15 +2625,11 @@ 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_1)
|
|
||||||
TheModule->findUsedStructTypes(StructTypes);
|
|
||||||
#else
|
|
||||||
llvm::TypeFinder typeFinder;
|
llvm::TypeFinder typeFinder;
|
||||||
typeFinder.run(*TheModule, false);
|
typeFinder.run(*TheModule, false);
|
||||||
for (llvm::TypeFinder::iterator iter = typeFinder.begin();
|
for (llvm::TypeFinder::iterator iter = typeFinder.begin();
|
||||||
iter != typeFinder.end(); ++iter)
|
iter != typeFinder.end(); ++iter)
|
||||||
StructTypes.push_back(*iter);
|
StructTypes.push_back(*iter);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get all of the array types used in the module
|
// Get all of the array types used in the module
|
||||||
std::vector<llvm::ArrayType*> ArrayTypes;
|
std::vector<llvm::ArrayType*> ArrayTypes;
|
||||||
@@ -2785,7 +2750,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_1) || defined(LLVM_3_2)
|
#if 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();
|
||||||
@@ -2819,20 +2784,16 @@ 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_1)
|
#if defined(LLVM_3_2)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
#else
|
#else
|
||||||
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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt),
|
||||||
@@ -2858,9 +2819,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_1)
|
#if defined(LLVM_3_2)
|
||||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||||
#else
|
#else
|
||||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
|
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) {
|
||||||
@@ -2869,9 +2828,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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
|
PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
|
||||||
@@ -2908,9 +2865,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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
|
PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt),
|
||||||
@@ -3712,7 +3667,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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#else
|
#else
|
||||||
#include "llvm/IR/Intrinsics.gen"
|
#include "llvm/IR/Intrinsics.gen"
|
||||||
@@ -3777,7 +3732,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_1) || defined(LLVM_3_2)
|
#if 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();
|
||||||
@@ -3865,9 +3820,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_1)
|
#if defined(LLVM_3_2)
|
||||||
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt)
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
||||||
#else
|
#else
|
||||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
|
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt)
|
||||||
@@ -3905,7 +3858,7 @@ 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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include "llvm/Intrinsics.gen"
|
#include "llvm/Intrinsics.gen"
|
||||||
#else
|
#else
|
||||||
#include "llvm/IR/Intrinsics.gen"
|
#include "llvm/IR/Intrinsics.gen"
|
||||||
@@ -4555,13 +4508,8 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
|
|||||||
smearType, NULL);
|
smearType, 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_1)
|
|
||||||
smearFunc->setDoesNotThrow(true);
|
|
||||||
smearFunc->setDoesNotAccessMemory(true);
|
|
||||||
#else
|
|
||||||
smearFunc->setDoesNotThrow();
|
smearFunc->setDoesNotThrow();
|
||||||
smearFunc->setDoesNotAccessMemory();
|
smearFunc->setDoesNotAccessMemory();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(smearFunc != NULL);
|
assert(smearFunc != NULL);
|
||||||
@@ -4703,13 +4651,8 @@ 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_1)
|
|
||||||
andCmpFunc->setDoesNotThrow(true);
|
|
||||||
andCmpFunc->setDoesNotAccessMemory(true);
|
|
||||||
#else
|
|
||||||
andCmpFunc->setDoesNotThrow();
|
andCmpFunc->setDoesNotThrow();
|
||||||
andCmpFunc->setDoesNotAccessMemory();
|
andCmpFunc->setDoesNotAccessMemory();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the function call to the *_and_mask function; the
|
// Set up the function call to the *_and_mask function; the
|
||||||
@@ -4914,7 +4857,7 @@ 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_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if defined(LLVM_3_2) || defined(LLVM_3_3)
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#else
|
#else
|
||||||
llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None;
|
llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None;
|
||||||
@@ -4939,7 +4882,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_1) || defined(LLVM_3_2)
|
#if defined(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
|
||||||
|
|||||||
4
ctx.cpp
4
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_1) || defined(LLVM_3_2)
|
#if 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>
|
||||||
@@ -3312,7 +3312,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_1) && !defined (LLVM_3_2) // LLVM 3.3+
|
#if !defined (LLVM_3_2) // 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() &&
|
||||||
|
|||||||
11
ctx.h
11
ctx.h
@@ -40,20 +40,15 @@
|
|||||||
|
|
||||||
#include "ispc.h"
|
#include "ispc.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if 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_1)
|
#include <llvm/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/DIBuilder.h>
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/DebugInfo.h>
|
|
||||||
#include <llvm/DIBuilder.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct CFInfo;
|
struct CFInfo;
|
||||||
|
|
||||||
|
|||||||
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_1) || defined(LLVM_3_2)
|
#if 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>
|
||||||
|
|||||||
10
func.cpp
10
func.cpp
@@ -46,7 +46,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(LLVM_3_1) || defined(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>
|
||||||
@@ -310,9 +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_1)
|
#if defined(LLVM_3_2)
|
||||||
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
|
|
||||||
#elif defined(LLVM_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)
|
||||||
@@ -453,11 +451,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_1)
|
|
||||||
appFunction->setDoesNotThrow(true);
|
|
||||||
#else
|
|
||||||
appFunction->setDoesNotThrow();
|
appFunction->setDoesNotThrow();
|
||||||
#endif
|
|
||||||
|
|
||||||
g->target->markFuncWithTargetAttr(appFunction);
|
g->target->markFuncWithTargetAttr(appFunction);
|
||||||
|
|
||||||
|
|||||||
68
ispc.cpp
68
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_1) || defined(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/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
@@ -57,19 +57,12 @@
|
|||||||
#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_1)
|
#include <llvm/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/DIBuilder.h>
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/DebugInfo.h>
|
|
||||||
#include <llvm/DIBuilder.h>
|
|
||||||
#endif
|
|
||||||
#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_1)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Target/TargetData.h>
|
|
||||||
#elif defined(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>
|
||||||
@@ -145,27 +138,20 @@ static const char *supportedCPUs[] = {
|
|||||||
// cortex-a9 and a15. We should be able to handle any of them that also
|
// cortex-a9 and a15. We should be able to handle any of them that also
|
||||||
// have NEON support.
|
// have NEON support.
|
||||||
"cortex-a9", "cortex-a15",
|
"cortex-a9", "cortex-a15",
|
||||||
"atom", "penryn", "core2", "corei7", "corei7-avx"
|
"atom", "penryn", "core2", "corei7", "corei7-avx", "core-avx-i", "core-avx2"
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
, "core-avx-i", "core-avx2"
|
|
||||||
#endif // LLVM 3.2+
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
||||||
m_target(NULL),
|
m_target(NULL),
|
||||||
m_targetMachine(NULL),
|
m_targetMachine(NULL),
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
m_targetData(NULL),
|
|
||||||
#else
|
|
||||||
m_dataLayout(NULL),
|
m_dataLayout(NULL),
|
||||||
#endif
|
|
||||||
m_valid(false),
|
m_valid(false),
|
||||||
m_isa(SSE2),
|
m_isa(SSE2),
|
||||||
m_arch(""),
|
m_arch(""),
|
||||||
m_is32Bit(true),
|
m_is32Bit(true),
|
||||||
m_cpu(""),
|
m_cpu(""),
|
||||||
m_attributes(""),
|
m_attributes(""),
|
||||||
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
#if !defined(LLVM_3_2)
|
||||||
m_tf_attributes(NULL),
|
m_tf_attributes(NULL),
|
||||||
#endif
|
#endif
|
||||||
m_nativeVectorWidth(-1),
|
m_nativeVectorWidth(-1),
|
||||||
@@ -407,10 +393,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
this->m_maskingIsFree = false;
|
this->m_maskingIsFree = false;
|
||||||
this->m_maskBitCount = 32;
|
this->m_maskBitCount = 32;
|
||||||
this->m_hasHalf = true;
|
this->m_hasHalf = true;
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
// LLVM 3.2+ only
|
|
||||||
this->m_hasRand = true;
|
this->m_hasRand = true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(isa, "avx1.1-x2")) {
|
else if (!strcasecmp(isa, "avx1.1-x2")) {
|
||||||
this->m_isa = Target::AVX11;
|
this->m_isa = Target::AVX11;
|
||||||
@@ -420,46 +403,29 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
this->m_maskingIsFree = false;
|
this->m_maskingIsFree = false;
|
||||||
this->m_maskBitCount = 32;
|
this->m_maskBitCount = 32;
|
||||||
this->m_hasHalf = true;
|
this->m_hasHalf = true;
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
// LLVM 3.2+ only
|
|
||||||
this->m_hasRand = true;
|
this->m_hasRand = true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(isa, "avx2")) {
|
else if (!strcasecmp(isa, "avx2")) {
|
||||||
this->m_isa = Target::AVX2;
|
this->m_isa = Target::AVX2;
|
||||||
this->m_nativeVectorWidth = 8;
|
this->m_nativeVectorWidth = 8;
|
||||||
this->m_vectorWidth = 8;
|
this->m_vectorWidth = 8;
|
||||||
this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand"
|
this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand,+fma";
|
||||||
#ifndef LLVM_3_1
|
|
||||||
",+fma"
|
|
||||||
#endif // !LLVM_3_1
|
|
||||||
;
|
|
||||||
this->m_maskingIsFree = false;
|
this->m_maskingIsFree = false;
|
||||||
this->m_maskBitCount = 32;
|
this->m_maskBitCount = 32;
|
||||||
this->m_hasHalf = true;
|
this->m_hasHalf = true;
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
// LLVM 3.2+ only
|
|
||||||
this->m_hasRand = true;
|
this->m_hasRand = true;
|
||||||
this->m_hasGather = true;
|
this->m_hasGather = true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(isa, "avx2-x2")) {
|
else if (!strcasecmp(isa, "avx2-x2")) {
|
||||||
this->m_isa = Target::AVX2;
|
this->m_isa = Target::AVX2;
|
||||||
this->m_nativeVectorWidth = 16;
|
this->m_nativeVectorWidth = 16;
|
||||||
this->m_vectorWidth = 16;
|
this->m_vectorWidth = 16;
|
||||||
this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand"
|
this->m_attributes = "+avx2,+popcnt,+cmov,+f16c,+rdrand,+fma";
|
||||||
#ifndef LLVM_3_1
|
|
||||||
",+fma"
|
|
||||||
#endif // !LLVM_3_1
|
|
||||||
;
|
|
||||||
this->m_maskingIsFree = false;
|
this->m_maskingIsFree = false;
|
||||||
this->m_maskBitCount = 32;
|
this->m_maskBitCount = 32;
|
||||||
this->m_hasHalf = true;
|
this->m_hasHalf = true;
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
// LLVM 3.2+ only
|
|
||||||
this->m_hasRand = true;
|
this->m_hasRand = true;
|
||||||
this->m_hasGather = true;
|
this->m_hasGather = true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(isa, "neon-8")) {
|
else if (!strcasecmp(isa, "neon-8")) {
|
||||||
this->m_isa = Target::NEON8;
|
this->m_isa = Target::NEON8;
|
||||||
@@ -505,10 +471,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
if (m_isa == Target::NEON8 || m_isa == Target::NEON16 ||
|
if (m_isa == Target::NEON8 || m_isa == Target::NEON16 ||
|
||||||
m_isa == Target::NEON32)
|
m_isa == Target::NEON32)
|
||||||
options.FloatABIType = llvm::FloatABI::Hard;
|
options.FloatABIType = llvm::FloatABI::Hard;
|
||||||
#if !defined(LLVM_3_1)
|
|
||||||
if (g->opt.disableFMA == false)
|
if (g->opt.disableFMA == false)
|
||||||
options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
|
options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
|
||||||
#endif // !LLVM_3_1
|
|
||||||
|
|
||||||
#ifdef ISPC_IS_WINDOWS
|
#ifdef ISPC_IS_WINDOWS
|
||||||
if (strcmp("x86", arch) == 0) {
|
if (strcmp("x86", arch) == 0) {
|
||||||
@@ -526,12 +490,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
|
|
||||||
// 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 defined(LLVM_3_1)
|
m_targetMachine->getDataLayout()->getStringRepresentation();
|
||||||
dl_string = m_targetMachine->getTargetData()->getStringRepresentation();
|
|
||||||
#else
|
|
||||||
dl_string = m_targetMachine->getDataLayout()->getStringRepresentation();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 2. Adjust for generic
|
// 2. Adjust for generic
|
||||||
if (m_isa == Target::GENERIC) {
|
if (m_isa == Target::GENERIC) {
|
||||||
@@ -546,11 +506,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. Finally set member data
|
// 3. Finally set member data
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
m_targetData = new llvm::TargetData(dl_string);
|
|
||||||
#else
|
|
||||||
m_dataLayout = new llvm::DataLayout(dl_string);
|
m_dataLayout = new llvm::DataLayout(dl_string);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set is32Bit
|
// Set is32Bit
|
||||||
// This indicates if we are compiling for 32 bit platform
|
// This indicates if we are compiling for 32 bit platform
|
||||||
@@ -558,7 +514,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) :
|
|||||||
// FIXME: all generic targets are handled as 64 bit, which is incorrect.
|
// FIXME: all generic targets are handled as 64 bit, which is incorrect.
|
||||||
this->m_is32Bit = (getDataLayout()->getPointerSize() == 4);
|
this->m_is32Bit = (getDataLayout()->getPointerSize() == 4);
|
||||||
|
|
||||||
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
#if !defined(LLVM_3_2)
|
||||||
// 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()) {
|
||||||
@@ -772,7 +728,7 @@ Target::StructOffset(llvm::Type *type, int element,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Target::markFuncWithTargetAttr(llvm::Function* func) {
|
void Target::markFuncWithTargetAttr(llvm::Function* func) {
|
||||||
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
#if !defined(LLVM_3_2)
|
||||||
if (m_tf_attributes) {
|
if (m_tf_attributes) {
|
||||||
func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes);
|
func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes);
|
||||||
}
|
}
|
||||||
|
|||||||
18
ispc.h
18
ispc.h
@@ -40,8 +40,8 @@
|
|||||||
|
|
||||||
#define ISPC_VERSION "1.4.5dev"
|
#define ISPC_VERSION "1.4.5dev"
|
||||||
|
|
||||||
#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
|
||||||
#error "Only LLVM 3.1, 3.2, 3.3 and the 3.4 development branch are supported"
|
#error "Only LLVM 3.2, 3.3 and the 3.4 development branch are supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
@@ -72,11 +72,7 @@ namespace llvm {
|
|||||||
class BasicBlock;
|
class BasicBlock;
|
||||||
class Constant;
|
class Constant;
|
||||||
class ConstantValue;
|
class ConstantValue;
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
class TargetData;
|
|
||||||
#else
|
|
||||||
class DataLayout;
|
class DataLayout;
|
||||||
#endif
|
|
||||||
class DIBuilder;
|
class DIBuilder;
|
||||||
class DIDescriptor;
|
class DIDescriptor;
|
||||||
class DIFile;
|
class DIFile;
|
||||||
@@ -226,11 +222,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.
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
llvm::TargetData *getDataLayout() const {return m_targetData;}
|
|
||||||
#else
|
|
||||||
llvm::DataLayout *getDataLayout() const {return m_dataLayout;}
|
llvm::DataLayout *getDataLayout() const {return m_dataLayout;}
|
||||||
#endif
|
|
||||||
|
|
||||||
/** 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;}
|
||||||
@@ -278,11 +270,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
llvm::TargetMachine *m_targetMachine;
|
llvm::TargetMachine *m_targetMachine;
|
||||||
|
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
llvm::TargetData *m_targetData;
|
|
||||||
#else
|
|
||||||
llvm::DataLayout *m_dataLayout;
|
llvm::DataLayout *m_dataLayout;
|
||||||
#endif
|
|
||||||
|
|
||||||
/** flag to report invalid state after construction
|
/** flag to report invalid state after construction
|
||||||
(due to bad parameters passed to constructor). */
|
(due to bad parameters passed to constructor). */
|
||||||
@@ -303,7 +291,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_1) && !defined(LLVM_3_2)
|
#if !defined(LLVM_3_2)
|
||||||
/** 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 */
|
||||||
|
|||||||
@@ -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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Instructions.h>
|
#include <llvm/Instructions.h>
|
||||||
#include <llvm/BasicBlock.h>
|
#include <llvm/BasicBlock.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -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_1) || defined(LLVM_3_2)
|
#if 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_1)
|
#if defined(LLVM_3_2)
|
||||||
"3.1"
|
|
||||||
#elif defined(LLVM_3_2)
|
|
||||||
"3.2"
|
"3.2"
|
||||||
#elif defined(LLVM_3_3)
|
#elif defined(LLVM_3_3)
|
||||||
"3.3"
|
"3.3"
|
||||||
|
|||||||
47
module.cpp
47
module.cpp
@@ -64,7 +64,7 @@
|
|||||||
#define strcasecmp stricmp
|
#define strcasecmp stricmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LLVM_3_1) || defined(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>
|
||||||
@@ -86,9 +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_1)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Target/TargetData.h>
|
|
||||||
#elif defined(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+
|
||||||
@@ -202,7 +200,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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_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);
|
||||||
@@ -797,11 +795,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_1)
|
|
||||||
function->setDoesNotAlias(1, true);
|
|
||||||
#else // LLVM 3.2+
|
|
||||||
function->setDoesNotAlias(1);
|
function->setDoesNotAlias(1);
|
||||||
#endif
|
|
||||||
|
|
||||||
g->target->markFuncWithTargetAttr(function);
|
g->target->markFuncWithTargetAttr(function);
|
||||||
|
|
||||||
@@ -850,12 +844,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_1)
|
|
||||||
function->setDoesNotAlias(i+1, true);
|
|
||||||
#else
|
|
||||||
function->setDoesNotAlias(i+1);
|
function->setDoesNotAlias(i+1);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
int align = 4 * RoundUpPow2(g->target->nativeVectorWidth);
|
int align = 4 * RoundUpPow2(g->target->nativeVectorWidth);
|
||||||
function->addAttribute(i+1, llvm::Attribute::constructAlignmentFromInt(align));
|
function->addAttribute(i+1, llvm::Attribute::constructAlignmentFromInt(align));
|
||||||
@@ -1067,7 +1056,7 @@ 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_1) || defined(LLVM_3_2) || defined(LLVM_3_3)
|
#if defined(LLVM_3_2) || defined(LLVM_3_3)
|
||||||
unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0;
|
unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0;
|
||||||
#else
|
#else
|
||||||
llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary :
|
llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary :
|
||||||
@@ -1082,11 +1071,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine,
|
|||||||
}
|
}
|
||||||
|
|
||||||
llvm::PassManager pm;
|
llvm::PassManager pm;
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
pm.add(new llvm::TargetData(*g->target->getDataLayout()));
|
|
||||||
#else
|
|
||||||
pm.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
pm.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
||||||
#endif
|
|
||||||
|
|
||||||
llvm::formatted_raw_ostream fos(of->os());
|
llvm::formatted_raw_ostream fos(of->os());
|
||||||
|
|
||||||
@@ -1800,22 +1785,12 @@ 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_1)
|
|
||||||
clang::TextDiagnosticPrinter *diagPrinter =
|
|
||||||
new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions());
|
|
||||||
#else
|
|
||||||
clang::DiagnosticOptions *diagOptions = new clang::DiagnosticOptions();
|
clang::DiagnosticOptions *diagOptions = new clang::DiagnosticOptions();
|
||||||
clang::TextDiagnosticPrinter *diagPrinter =
|
clang::TextDiagnosticPrinter *diagPrinter =
|
||||||
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
|
new clang::TextDiagnosticPrinter(stderrRaw, diagOptions);
|
||||||
#endif
|
|
||||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
|
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(new clang::DiagnosticIDs);
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
clang::DiagnosticsEngine *diagEngine =
|
|
||||||
new clang::DiagnosticsEngine(diagIDs, diagPrinter);
|
|
||||||
#else
|
|
||||||
clang::DiagnosticsEngine *diagEngine =
|
clang::DiagnosticsEngine *diagEngine =
|
||||||
new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter);
|
new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter);
|
||||||
#endif
|
|
||||||
inst.setDiagnostics(diagEngine);
|
inst.setDiagnostics(diagEngine);
|
||||||
|
|
||||||
clang::TargetOptions &options = inst.getTargetOpts();
|
clang::TargetOptions &options = inst.getTargetOpts();
|
||||||
@@ -1825,7 +1800,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
}
|
}
|
||||||
options.Triple = triple.getTriple();
|
options.Triple = triple.getTriple();
|
||||||
|
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if 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+
|
||||||
@@ -1835,18 +1810,14 @@ 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_1)
|
|
||||||
inst.InitializeSourceManager(infilename);
|
|
||||||
#else
|
|
||||||
clang::FrontendInputFile inputFile(infilename, clang::IK_None);
|
clang::FrontendInputFile inputFile(infilename, clang::IK_None);
|
||||||
inst.InitializeSourceManager(inputFile);
|
inst.InitializeSourceManager(inputFile);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Don't remove comments in the preprocessor, so that we can accurately
|
// Don't remove comments in the preprocessor, so that we can accurately
|
||||||
// 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_1) && !defined(LLVM_3_2) // LLVM 3.3+
|
#if !defined(LLVM_3_2) // LLVM 3.3+
|
||||||
inst.getPreprocessorOutputOpts().ShowCPP = 1;
|
inst.getPreprocessorOutputOpts().ShowCPP = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1858,7 +1829,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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
true /* is user supplied */,
|
true /* is user supplied */,
|
||||||
#endif
|
#endif
|
||||||
false /* not a framework */,
|
false /* not a framework */,
|
||||||
@@ -1913,11 +1884,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
inst.getLangOpts().BCPLComment = 1;
|
|
||||||
#else
|
|
||||||
inst.getLangOpts().LineComment = 1;
|
inst.getLangOpts().LineComment = 1;
|
||||||
#endif
|
|
||||||
inst.createPreprocessor();
|
inst.createPreprocessor();
|
||||||
|
|
||||||
diagPrinter->BeginSourceFile(inst.getLangOpts(), &inst.getPreprocessor());
|
diagPrinter->BeginSourceFile(inst.getLangOpts(), &inst.getPreprocessor());
|
||||||
|
|||||||
22
opt.cpp
22
opt.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <llvm/Pass.h>
|
#include <llvm/Pass.h>
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if 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,9 +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_1)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Target/TargetData.h>
|
|
||||||
#elif defined(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>
|
||||||
@@ -85,11 +83,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_1)
|
#include <llvm/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/DebugInfo.h>
|
|
||||||
#endif
|
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
#ifdef ISPC_IS_LINUX
|
#ifdef ISPC_IS_LINUX
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
@@ -415,18 +409,14 @@ Optimize(llvm::Module *module, int optLevel) {
|
|||||||
optPM.add(targetLibraryInfo);
|
optPM.add(targetLibraryInfo);
|
||||||
|
|
||||||
|
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
optPM.add(new llvm::TargetData(*g->target->getDataLayout()));
|
|
||||||
#else
|
|
||||||
optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
optPM.add(new llvm::DataLayout(*g->target->getDataLayout()));
|
||||||
|
|
||||||
llvm::TargetMachine *targetMachine = g->target->GetTargetMachine();
|
llvm::TargetMachine *targetMachine = g->target->GetTargetMachine();
|
||||||
#ifdef LLVM_3_2
|
#ifdef LLVM_3_2
|
||||||
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
|
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
|
||||||
targetMachine->getVectorTargetTransformInfo()));
|
targetMachine->getVectorTargetTransformInfo()));
|
||||||
#else // LLVM 3.3+
|
#else // LLVM 3.3+
|
||||||
targetMachine->addAnalysisPasses(optPM);
|
targetMachine->addAnalysisPasses(optPM);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
optPM.add(llvm::createIndVarSimplifyPass());
|
optPM.add(llvm::createIndVarSimplifyPass());
|
||||||
@@ -505,7 +495,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 defined(LLVM_3_2) || defined(LLVM_3_3)
|
||||||
// Starting from 3.4 this functionality was moved to
|
// Starting from 3.4 this functionality was moved to
|
||||||
// InstructionCombiningPass. See r184459 for details.
|
// InstructionCombiningPass. See r184459 for details.
|
||||||
optPM.add(llvm::createSimplifyLibCallsPass());
|
optPM.add(llvm::createSimplifyLibCallsPass());
|
||||||
|
|||||||
2
stmt.cpp
2
stmt.cpp
@@ -48,7 +48,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if 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>
|
||||||
|
|||||||
26
type.cpp
26
type.cpp
@@ -43,20 +43,15 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#if defined(LLVM_3_1) || defined(LLVM_3_2)
|
#if 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_1)
|
#include <llvm/DebugInfo.h>
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/DIBuilder.h>
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/DebugInfo.h>
|
|
||||||
#include <llvm/DIBuilder.h>
|
|
||||||
#endif
|
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -819,11 +814,8 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
m->diBuilder->createEnumerationType(scope, name, diFile, pos.first_line,
|
m->diBuilder->createEnumerationType(scope, name, diFile, pos.first_line,
|
||||||
32 /* size in bits */,
|
32 /* size in bits */,
|
||||||
32 /* align in bits */,
|
32 /* align in bits */,
|
||||||
elementArray
|
elementArray,
|
||||||
#if !defined(LLVM_3_1)
|
llvm::DIType());
|
||||||
, llvm::DIType()
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
switch (variability.type) {
|
switch (variability.type) {
|
||||||
@@ -2139,7 +2131,7 @@ StructType::GetDIType(llvm::DIDescriptor 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_1) && !defined(LLVM_3_2)
|
#if !defined(LLVM_3_2)
|
||||||
llvm::DIType(), // DerivedFrom
|
llvm::DIType(), // DerivedFrom
|
||||||
#endif
|
#endif
|
||||||
elements);
|
elements);
|
||||||
@@ -2382,7 +2374,7 @@ UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
0, // Size
|
0, // Size
|
||||||
0, // Align
|
0, // Align
|
||||||
0, // Flags
|
0, // Flags
|
||||||
#if !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
#if !defined(LLVM_3_2)
|
||||||
llvm::DIType(), // DerivedFrom
|
llvm::DIType(), // DerivedFrom
|
||||||
#endif
|
#endif
|
||||||
elements);
|
elements);
|
||||||
@@ -2645,12 +2637,8 @@ ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIType diTargetType = targetType->GetDIType(scope);
|
llvm::DIType diTargetType = targetType->GetDIType(scope);
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
return m->diBuilder->createReferenceType(diTargetType);
|
|
||||||
#else
|
|
||||||
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,
|
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,
|
||||||
diTargetType);
|
diTargetType);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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_1) || defined(LLVM_3_2)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Type.h>
|
#include <llvm/Type.h>
|
||||||
#include <llvm/DerivedTypes.h>
|
#include <llvm/DerivedTypes.h>
|
||||||
#else
|
#else
|
||||||
|
|||||||
9
util.cpp
9
util.cpp
@@ -65,9 +65,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#if defined(LLVM_3_1)
|
#if defined(LLVM_3_2)
|
||||||
#include <llvm/Target/TargetData.h>
|
|
||||||
#elif defined(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>
|
||||||
@@ -616,13 +614,8 @@ VerifyDataLayoutCompatibility(const std::string &module_dl,
|
|||||||
// which contradic: f80:128:128 followed by f80:32:32. This is a bug, but
|
// which contradic: f80:128:128 followed by f80:32:32. This is a bug, but
|
||||||
// correct thing to do is to interpret this exactly how LLVM would treat it,
|
// correct thing to do is to interpret this exactly how LLVM would treat it,
|
||||||
// so we create a DataLayout class and take its string representation.
|
// so we create a DataLayout class and take its string representation.
|
||||||
#if defined(LLVM_3_1)
|
|
||||||
llvm::TargetData d1(module_dl);
|
|
||||||
llvm::TargetData d2(lib_dl);
|
|
||||||
#else // LLVM 3.2+
|
|
||||||
llvm::DataLayout d1(module_dl);
|
llvm::DataLayout d1(module_dl);
|
||||||
llvm::DataLayout d2(lib_dl);
|
llvm::DataLayout d2(lib_dl);
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string module_dl_canonic = d1.getStringRepresentation();
|
std::string module_dl_canonic = d1.getStringRepresentation();
|
||||||
std::string lib_dl_canonic = d2.getStringRepresentation();
|
std::string lib_dl_canonic = d2.getStringRepresentation();
|
||||||
|
|||||||
Reference in New Issue
Block a user