Fix build to work with LLVM top-of-tree again
This commit is contained in:
22
builtins.cpp
22
builtins.cpp
@@ -47,15 +47,25 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <llvm/LLVMContext.h>
|
||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1)
|
||||
#if defined(LLVM_3_2)
|
||||
#include <llvm/Attributes.h>
|
||||
#endif
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Intrinsics.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#else
|
||||
#include <llvm/IR/Attributes.h>
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/Intrinsics.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#endif
|
||||
#include <llvm/Linker.h>
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/ADT/Triple.h>
|
||||
@@ -700,10 +710,10 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module,
|
||||
|
||||
llvm::Function *func = module->getFunction(name);
|
||||
Assert(func != NULL); // it should be declared already...
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
func->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
#else
|
||||
#if defined(LLVM_3_2)
|
||||
func->addFnAttr(llvm::Attributes::AlwaysInline);
|
||||
#else
|
||||
func->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
#endif
|
||||
llvm::BasicBlock *bblock = llvm::BasicBlock::Create(*g->ctx, "entry", func, 0);
|
||||
llvm::ReturnInst::Create(*g->ctx, LLVMInt32(val), bblock);
|
||||
|
||||
140
cbackend.cpp
140
cbackend.cpp
@@ -29,16 +29,27 @@
|
||||
|
||||
#include "llvmutil.h"
|
||||
|
||||
#include "llvm/CallingConv.h"
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/CallingConv.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
#else
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/CallingConv.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/InlineAsm.h"
|
||||
#endif
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1)
|
||||
#include "llvm/TypeFinder.h"
|
||||
#endif // LLVM_3_2 +
|
||||
@@ -63,8 +74,10 @@
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
#include "llvm/DataLayout.h"
|
||||
#else // LLVM 3.3+
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#endif
|
||||
#include "llvm/Support/CallSite.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
@@ -335,13 +348,22 @@ namespace {
|
||||
bool isSigned = false,
|
||||
const std::string &VariableName = "",
|
||||
bool IgnoreName = false,
|
||||
const llvm::AttrListPtr &PAL = llvm::AttrListPtr());
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
const llvm::AttrListPtr &PAL = llvm::AttrListPtr()
|
||||
#else
|
||||
const llvm::AttributeSet &PAL = llvm::AttributeSet()
|
||||
#endif
|
||||
);
|
||||
llvm::raw_ostream &printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
||||
bool isSigned,
|
||||
const std::string &NameSoFar = "");
|
||||
|
||||
void printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
const llvm::AttrListPtr &PAL,
|
||||
#else
|
||||
const llvm::AttributeSet &PAL,
|
||||
#endif
|
||||
llvm::PointerType *Ty);
|
||||
|
||||
std::string getStructName(llvm::StructType *ST);
|
||||
@@ -567,7 +589,11 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) {
|
||||
/// return type, except, instead of printing the type as void (*)(Struct*, ...)
|
||||
/// print it as "Struct (*)(...)", for struct return functions.
|
||||
void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
const llvm::AttrListPtr &PAL,
|
||||
#else
|
||||
const llvm::AttributeSet &PAL,
|
||||
#endif
|
||||
llvm::PointerType *TheTy) {
|
||||
llvm::FunctionType *FTy = llvm::cast<llvm::FunctionType>(TheTy->getElementType());
|
||||
std::string tstr;
|
||||
@@ -584,8 +610,10 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||
llvm::Type *ArgTy = *I;
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||
#else
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
|
||||
#endif
|
||||
assert(ArgTy->isPointerTy());
|
||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||
@@ -593,8 +621,10 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||
printType(FunctionInnards, ArgTy,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||
#else
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt),
|
||||
#endif
|
||||
"");
|
||||
PrintedType = true;
|
||||
@@ -610,8 +640,10 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out,
|
||||
printType(Out, RetTy,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||
#else
|
||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt),
|
||||
#endif
|
||||
FunctionInnards.str());
|
||||
}
|
||||
@@ -707,7 +739,14 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned,
|
||||
//
|
||||
llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
||||
bool isSigned, const std::string &NameSoFar,
|
||||
bool IgnoreName, const llvm::AttrListPtr &PAL) {
|
||||
bool IgnoreName,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
const llvm::AttrListPtr &PAL
|
||||
#else
|
||||
const llvm::AttributeSet &PAL
|
||||
#endif
|
||||
) {
|
||||
|
||||
if (Ty->isPrimitiveType() || Ty->isIntegerTy() || Ty->isVectorTy()) {
|
||||
printSimpleType(Out, Ty, isSigned, NameSoFar);
|
||||
return Out;
|
||||
@@ -725,8 +764,10 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
||||
llvm::Type *ArgTy = *I;
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||
#else
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
|
||||
#endif
|
||||
assert(ArgTy->isPointerTy());
|
||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||
@@ -736,8 +777,10 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
||||
printType(FunctionInnards, ArgTy,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||
#else
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt),
|
||||
#endif
|
||||
"");
|
||||
++Idx;
|
||||
@@ -753,8 +796,10 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty,
|
||||
printType(Out, FTy->getReturnType(),
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||
#else
|
||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt),
|
||||
#endif
|
||||
FunctionInnards.str());
|
||||
return Out;
|
||||
@@ -2796,7 +2841,11 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
||||
|
||||
// Loop over the arguments, printing them...
|
||||
llvm::FunctionType *FT = llvm::cast<llvm::FunctionType>(F->getFunctionType());
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
const llvm::AttrListPtr &PAL = F->getAttributes();
|
||||
#else
|
||||
const llvm::AttributeSet &PAL = F->getAttributes();
|
||||
#endif
|
||||
|
||||
std::string tstr;
|
||||
llvm::raw_string_ostream FunctionInnards(tstr);
|
||||
@@ -2828,8 +2877,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
||||
llvm::Type *ArgTy = I->getType();
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||
#else
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
|
||||
#endif
|
||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||
ByValParams.insert(I);
|
||||
@@ -2837,8 +2888,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
||||
printType(FunctionInnards, ArgTy,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt),
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt),
|
||||
#else
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt),
|
||||
#endif
|
||||
ArgName);
|
||||
PrintedArg = true;
|
||||
@@ -2863,8 +2916,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
||||
llvm::Type *ArgTy = *I;
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) {
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) {
|
||||
#else
|
||||
if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::ByVal)) {
|
||||
#endif
|
||||
assert(ArgTy->isPointerTy());
|
||||
ArgTy = llvm::cast<llvm::PointerType>(ArgTy)->getElementType();
|
||||
@@ -2872,9 +2927,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
||||
printType(FunctionInnards, ArgTy,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt)
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt)
|
||||
|
||||
#else
|
||||
PAL.getParamAttributes(Idx).hasAttribute(llvm::Attribute::SExt)
|
||||
#endif
|
||||
);
|
||||
PrintedArg = true;
|
||||
@@ -2910,8 +2966,10 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) {
|
||||
printType(Out, RetTy,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt),
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt),
|
||||
#else
|
||||
PAL.getParamAttributes(0).hasAttribute(llvm::Attribute::SExt),
|
||||
#endif
|
||||
FunctionInnards.str());
|
||||
}
|
||||
@@ -3718,7 +3776,11 @@ void CWriter::lowerIntrinsics(llvm::Function &F) {
|
||||
const char *BuiltinName = "";
|
||||
#define GET_GCC_BUILTIN_NAME
|
||||
#define Intrinsic llvm::Intrinsic
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include "llvm/Intrinsics.gen"
|
||||
#else
|
||||
#include "llvm/IR/Intrinsics.gen"
|
||||
#endif
|
||||
#undef Intrinsic
|
||||
#undef GET_GCC_BUILTIN_NAME
|
||||
// If we handle it, don't lower it.
|
||||
@@ -3779,7 +3841,11 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
|
||||
|
||||
// If this is a call to a struct-return function, assign to the first
|
||||
// parameter instead of passing it to the call.
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
const llvm::AttrListPtr &PAL = I.getAttributes();
|
||||
#else
|
||||
const llvm::AttributeSet &PAL = I.getAttributes();
|
||||
#endif
|
||||
bool hasByVal = I.hasByValArgument();
|
||||
bool isStructRet = I.hasStructRetAttr();
|
||||
if (isStructRet) {
|
||||
@@ -3858,18 +3924,20 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
|
||||
printType(Out, FTy->getParamType(ArgNo),
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
/*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt)
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt)
|
||||
#else
|
||||
PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attribute::SExt)
|
||||
#endif
|
||||
);
|
||||
Out << ')';
|
||||
}
|
||||
// Check if the argument is expected to be passed by value.
|
||||
if (I.paramHasAttr(ArgNo+1,
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
llvm::Attribute::ByVal
|
||||
#else
|
||||
#if defined(LLVM_3_2)
|
||||
llvm::Attributes::ByVal
|
||||
#else
|
||||
llvm::Attribute::ByVal
|
||||
#endif
|
||||
))
|
||||
writeOperandDeref(*AI);
|
||||
@@ -3895,7 +3963,11 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID,
|
||||
#endif // LLVM_3_0
|
||||
#define GET_GCC_BUILTIN_NAME
|
||||
#define Intrinsic llvm::Intrinsic
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include "llvm/Intrinsics.gen"
|
||||
#else
|
||||
#include "llvm/IR/Intrinsics.gen"
|
||||
#endif
|
||||
#undef Intrinsic
|
||||
#undef GET_GCC_BUILTIN_NAME
|
||||
assert(BuiltinName[0] && "Unknown LLVM intrinsic!");
|
||||
@@ -4677,35 +4749,35 @@ public:
|
||||
notFunc =
|
||||
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__not", mt, mt, NULL));
|
||||
assert(notFunc != NULL);
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
notFunc->addFnAttr(llvm::Attribute::NoUnwind);
|
||||
notFunc->addFnAttr(llvm::Attribute::ReadNone);
|
||||
#else
|
||||
#if defined(LLVM_3_2)
|
||||
notFunc->addFnAttr(llvm::Attributes::NoUnwind);
|
||||
notFunc->addFnAttr(llvm::Attributes::ReadNone);
|
||||
#else
|
||||
notFunc->addFnAttr(llvm::Attribute::NoUnwind);
|
||||
notFunc->addFnAttr(llvm::Attribute::ReadNone);
|
||||
#endif
|
||||
|
||||
andNotFuncs[0] =
|
||||
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not1", mt, mt, mt,
|
||||
NULL));
|
||||
assert(andNotFuncs[0] != NULL);
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind);
|
||||
andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone);
|
||||
#else
|
||||
#if defined(LLVM_3_2)
|
||||
andNotFuncs[0]->addFnAttr(llvm::Attributes::NoUnwind);
|
||||
andNotFuncs[0]->addFnAttr(llvm::Attributes::ReadNone);
|
||||
#else
|
||||
andNotFuncs[0]->addFnAttr(llvm::Attribute::NoUnwind);
|
||||
andNotFuncs[0]->addFnAttr(llvm::Attribute::ReadNone);
|
||||
#endif
|
||||
andNotFuncs[1] =
|
||||
llvm::dyn_cast<llvm::Function>(m->getOrInsertFunction("__and_not2", mt, mt, mt,
|
||||
NULL));
|
||||
assert(andNotFuncs[1] != NULL);
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind);
|
||||
andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone);
|
||||
#else
|
||||
#if defined(LLVM_3_2)
|
||||
andNotFuncs[1]->addFnAttr(llvm::Attributes::NoUnwind);
|
||||
andNotFuncs[1]->addFnAttr(llvm::Attributes::ReadNone);
|
||||
#else
|
||||
andNotFuncs[1]->addFnAttr(llvm::Attribute::NoUnwind);
|
||||
andNotFuncs[1]->addFnAttr(llvm::Attribute::ReadNone);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
11
ctx.cpp
11
ctx.cpp
@@ -45,11 +45,18 @@
|
||||
#include "module.h"
|
||||
#include "sym.h"
|
||||
#include <map>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Support/Dwarf.h>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Metadata.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#else
|
||||
#include <llvm/IR/Metadata.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#endif
|
||||
|
||||
/** This is a small utility structure that records information related to one
|
||||
level of nested control flow. It's mostly used in correctly restoring
|
||||
|
||||
5
ctx.h
5
ctx.h
@@ -40,8 +40,13 @@
|
||||
|
||||
#include "ispc.h"
|
||||
#include <map>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/InstrTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#else
|
||||
#include <llvm/IR/InstrTypes.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#endif
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include <llvm/Analysis/DebugInfo.h>
|
||||
#include <llvm/Analysis/DIBuilder.h>
|
||||
|
||||
14
expr.cpp
14
expr.cpp
@@ -56,13 +56,23 @@
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <stdio.h>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Function.h>
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Function.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/CallingConv.h>
|
||||
#else
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/Function.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/CallingConv.h>
|
||||
#endif
|
||||
#include <llvm/ExecutionEngine/GenericValue.h>
|
||||
#include <llvm/Support/InstIterator.h>
|
||||
|
||||
|
||||
15
func.cpp
15
func.cpp
@@ -46,12 +46,21 @@
|
||||
#include "util.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Intrinsics.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#else
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/Intrinsics.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#endif
|
||||
#include <llvm/PassManager.h>
|
||||
#include <llvm/PassRegistry.h>
|
||||
#include <llvm/Transforms/IPO.h>
|
||||
@@ -303,8 +312,10 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
|
||||
(
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
(function->hasFnAttr(llvm::Attribute::AlwaysInline) == false)
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
(function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false)
|
||||
#else // LLVM 3.3+
|
||||
(function->getAttributes().getFnAttributes().hasAttribute(llvm::Attribute::AlwaysInline) == false)
|
||||
#endif
|
||||
&&
|
||||
costEstimate > CHECK_MASK_AT_FUNCTION_START_COST);
|
||||
|
||||
12
ispc.cpp
12
ispc.cpp
@@ -48,8 +48,15 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#else
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#endif
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include <llvm/Analysis/DebugInfo.h>
|
||||
#include <llvm/Analysis/DIBuilder.h>
|
||||
@@ -58,13 +65,14 @@
|
||||
#include <llvm/DIBuilder.h>
|
||||
#endif
|
||||
#include <llvm/Support/Dwarf.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/Target/TargetOptions.h>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include <llvm/Target/TargetData.h>
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
#include <llvm/DataLayout.h>
|
||||
#else // LLVM 3.3+
|
||||
#include <llvm/IR/DataLayout.h>
|
||||
#endif
|
||||
#include <llvm/Support/TargetRegistry.h>
|
||||
#include <llvm/Support/TargetSelect.h>
|
||||
|
||||
@@ -38,8 +38,13 @@
|
||||
#include "llvmutil.h"
|
||||
#include "ispc.h"
|
||||
#include "type.h"
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/BasicBlock.h>
|
||||
#else
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/BasicBlock.h>
|
||||
#endif
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
|
||||
@@ -38,10 +38,17 @@
|
||||
#ifndef ISPC_LLVMUTIL_H
|
||||
#define ISPC_LLVMUTIL_H 1
|
||||
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/Constants.h>
|
||||
#else
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#include <llvm/IR/Constants.h>
|
||||
#endif
|
||||
|
||||
namespace llvm {
|
||||
class PHINode;
|
||||
|
||||
26
module.cpp
26
module.cpp
@@ -64,12 +64,21 @@
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Intrinsics.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#else
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/Intrinsics.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#endif
|
||||
#include <llvm/PassManager.h>
|
||||
#include <llvm/PassRegistry.h>
|
||||
#include <llvm/Transforms/IPO.h>
|
||||
@@ -80,7 +89,11 @@
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include <llvm/Target/TargetData.h>
|
||||
#else
|
||||
#if defined(LLVM_3_2)
|
||||
#include <llvm/DataLayout.h>
|
||||
#else // LLVM 3.3+
|
||||
#include <llvm/IR/DataLayout.h>
|
||||
#endif
|
||||
#include <llvm/TargetTransformInfo.h>
|
||||
#endif
|
||||
#include <llvm/Analysis/Verifier.h>
|
||||
@@ -760,10 +773,10 @@ Module::AddFunctionDeclaration(const std::string &name,
|
||||
if (storageClass != SC_EXTERN_C &&
|
||||
!g->generateDebuggingSymbols &&
|
||||
isInline)
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
function->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
#else
|
||||
#ifdef LLVM_3_2
|
||||
function->addFnAttr(llvm::Attributes::AlwaysInline);
|
||||
#else
|
||||
function->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||
#endif
|
||||
if (functionType->isTask)
|
||||
// This also applies transitively to members I think?
|
||||
@@ -1799,8 +1812,13 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre
|
||||
}
|
||||
options.Triple = triple.getTriple();
|
||||
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
clang::TargetInfo *target =
|
||||
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options);
|
||||
#else // LLVM 3.3+
|
||||
clang::TargetInfo *target =
|
||||
clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options);
|
||||
#endif
|
||||
|
||||
inst.setTarget(target);
|
||||
inst.createSourceManager(inst.getFileManager());
|
||||
|
||||
29
opt.cpp
29
opt.cpp
@@ -48,15 +48,24 @@
|
||||
#include <set>
|
||||
|
||||
#include <llvm/Pass.h>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Intrinsics.h>
|
||||
#include <llvm/Function.h>
|
||||
#include <llvm/BasicBlock.h>
|
||||
#include <llvm/Constants.h>
|
||||
#else
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/Intrinsics.h>
|
||||
#include <llvm/IR/Function.h>
|
||||
#include <llvm/IR/BasicBlock.h>
|
||||
#include <llvm/IR/Constants.h>
|
||||
#endif
|
||||
#include <llvm/PassManager.h>
|
||||
#include <llvm/PassRegistry.h>
|
||||
#include <llvm/Assembly/PrintModulePass.h>
|
||||
#include <llvm/Function.h>
|
||||
#include <llvm/BasicBlock.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Intrinsics.h>
|
||||
#include <llvm/Constants.h>
|
||||
#include <llvm/Analysis/ConstantFolding.h>
|
||||
#include <llvm/Target/TargetLibraryInfo.h>
|
||||
#include <llvm/ADT/Triple.h>
|
||||
@@ -66,8 +75,11 @@
|
||||
#include <llvm/Target/TargetOptions.h>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include <llvm/Target/TargetData.h>
|
||||
#else
|
||||
#elif defined(LLVM_3_2)
|
||||
#include <llvm/DataLayout.h>
|
||||
#else // LLVM 3.3+
|
||||
#include <llvm/IR/DataLayout.h>
|
||||
#include <llvm/TargetTransformInfo.h>
|
||||
#endif
|
||||
#include <llvm/Target/TargetMachine.h>
|
||||
#include <llvm/Analysis/Verifier.h>
|
||||
@@ -416,8 +428,13 @@ Optimize(llvm::Module *module, int optLevel) {
|
||||
optPM.add(new llvm::DataLayout(*dl));
|
||||
else
|
||||
optPM.add(new llvm::DataLayout(module));
|
||||
#ifdef LLVM_3_2
|
||||
optPM.add(new llvm::TargetTransformInfo(targetMachine->getScalarTargetTransformInfo(),
|
||||
targetMachine->getVectorTargetTransformInfo()));
|
||||
#else // LLVM 3.3+
|
||||
optPM.add(llvm::createNoTTIPass(targetMachine->getScalarTargetTransformInfo(),
|
||||
targetMachine->getVectorTargetTransformInfo()));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
optPM.add(llvm::createIndVarSimplifyPass());
|
||||
|
||||
4
parse.yy
4
parse.yy
@@ -83,7 +83,11 @@ struct ForeachDimension;
|
||||
#include "util.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#if !defined(LLVM_3_0) && !defined(LLVM_3_1) && !defined(LLVM_3_2)
|
||||
#include <llvm/IR/Constants.h>
|
||||
#else
|
||||
#include <llvm/Constants.h>
|
||||
#endif
|
||||
|
||||
#define UNIMPLEMENTED \
|
||||
Error(yylloc, "Unimplemented parser functionality %s:%d", \
|
||||
|
||||
15
stmt.cpp
15
stmt.cpp
@@ -48,14 +48,25 @@
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Module.h>
|
||||
#include <llvm/Function.h>
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/Function.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#include <llvm/LLVMContext.h>
|
||||
#include <llvm/Metadata.h>
|
||||
#include <llvm/Instructions.h>
|
||||
#include <llvm/CallingConv.h>
|
||||
#else
|
||||
#include <llvm/IR/Module.h>
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/Function.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
#include <llvm/IR/Metadata.h>
|
||||
#include <llvm/IR/CallingConv.h>
|
||||
#endif
|
||||
#include <llvm/Support/raw_ostream.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
5
type.cpp
5
type.cpp
@@ -43,8 +43,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Value.h>
|
||||
#include <llvm/Module.h>
|
||||
#else
|
||||
#include <llvm/IR/Value.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
#endif
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1)
|
||||
#include <llvm/Analysis/DebugInfo.h>
|
||||
#include <llvm/Analysis/DIBuilder.h>
|
||||
|
||||
5
type.h
5
type.h
@@ -40,8 +40,13 @@
|
||||
|
||||
#include "ispc.h"
|
||||
#include "util.h"
|
||||
#if defined(LLVM_3_0) || defined(LLVM_3_1) || defined(LLVM_3_2)
|
||||
#include <llvm/Type.h>
|
||||
#include <llvm/DerivedTypes.h>
|
||||
#else
|
||||
#include <llvm/IR/Type.h>
|
||||
#include <llvm/IR/DerivedTypes.h>
|
||||
#endif
|
||||
#include <llvm/ADT/SmallVector.h>
|
||||
|
||||
class ConstExpr;
|
||||
|
||||
Reference in New Issue
Block a user