mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-05 06:54:10 +02:00
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles without exceptions and rtti by default. We do need exceptions for the libconfig stuff, but rtti isn't necessary (anymore). Debug info needs to be rewritten, as in LLVM 2.7 the format has completely changed. To have something to look at while rewriting, the old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means that you have to define this to compile at the moment. Updated tango 0.99.9 patch to include updated EH runtime code, which is needed for LLVM 2.7 as well.
This commit is contained in:
@@ -121,7 +121,7 @@ LLGlobalVariable * IrStruct::getInterfaceArraySymbol()
|
||||
name.append("16__interfaceInfosZ");
|
||||
|
||||
llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(aggrdecl);
|
||||
classInterfacesArray = new llvm::GlobalVariable(*gIR->module,
|
||||
classInterfacesArray = new llvm::GlobalVariable(*gIR->module,
|
||||
array_type, true, _linkage, NULL, name);
|
||||
|
||||
return classInterfacesArray;
|
||||
@@ -396,7 +396,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan
|
||||
mangle.append("6__vtblZ");
|
||||
|
||||
llvm::GlobalVariable* GV = new llvm::GlobalVariable(
|
||||
*gIR->module,
|
||||
*gIR->module,
|
||||
vtbl_constant->getType(),
|
||||
true,
|
||||
_linkage,
|
||||
@@ -483,7 +483,7 @@ LLConstant * IrStruct::getClassInfoInterfaces()
|
||||
|
||||
// create Interface struct
|
||||
LLConstant* inits[3] = { ci, vtb, off };
|
||||
LLConstant* entry = LLConstantStruct::get(gIR->context(), inits, 3);
|
||||
LLConstant* entry = LLConstantStruct::get(gIR->context(), inits, 3, false);
|
||||
constants.push_back(entry);
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
}
|
||||
// if there's a finally, the eh table has to have a 0 action
|
||||
if(hasFinally)
|
||||
selectorargs.push_back(DtoConstSize_t(0));//LLConstantInt::get(LLType::getInt32Ty(gIR->context()), 0));
|
||||
selectorargs.push_back(DtoConstUint(0));
|
||||
|
||||
// personality fn
|
||||
llvm::Function* personality_fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_eh_personality");
|
||||
@@ -144,18 +144,14 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
selectorargs.insert(selectorargs.begin(), eh_ptr);
|
||||
|
||||
// if there is a catch and some catch allocated storage, store exception object
|
||||
if(catchToInt.size() && catch_var)
|
||||
if(catchToInt.size() && catch_var)
|
||||
{
|
||||
const LLType* objectTy = DtoType(ClassDeclaration::object->type);
|
||||
gIR->ir->CreateStore(gIR->ir->CreateBitCast(eh_ptr, objectTy), catch_var);
|
||||
}
|
||||
|
||||
// eh_sel = llvm.eh.selector(eh_ptr, cast(byte*)&_d_eh_personality, <selectorargs>);
|
||||
llvm::Function* eh_selector_fn;
|
||||
if (global.params.is64bit)
|
||||
eh_selector_fn = GET_INTRINSIC_DECL(eh_selector_i64);
|
||||
else
|
||||
eh_selector_fn = GET_INTRINSIC_DECL(eh_selector_i32);
|
||||
llvm::Function* eh_selector_fn = GET_INTRINSIC_DECL(eh_selector);
|
||||
LLValue* eh_sel = gIR->ir->CreateCall(eh_selector_fn, selectorargs.begin(), selectorargs.end());
|
||||
|
||||
// emit finallys and switches that branch to catches until there are no more catches
|
||||
@@ -186,7 +182,7 @@ void IRLandingPad::constructLandingPad(llvm::BasicBlock* inBB)
|
||||
}
|
||||
// dubious comment
|
||||
// catches matched first get the largest switchval, so do size - unique int
|
||||
llvm::ConstantInt* switchval = LLConstantInt::get(DtoSize_t(), catchToInt[rit->catchType]);
|
||||
llvm::ConstantInt* switchval = DtoConstUint(catchToInt[rit->catchType]);
|
||||
// and make sure we don't add the same switchval twice, may happen with nested trys
|
||||
if(!switchinst->findCaseValue(switchval))
|
||||
switchinst->addCase(switchval, rit->target);
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "mars.h"
|
||||
#include "mtype.h"
|
||||
#include "gen/irstate.h"
|
||||
#include "gen/logger.h"
|
||||
#include "ir/irtype.h"
|
||||
|
||||
// This code uses llvm::getGlobalContext() as these functions are invoked before gIR is set.
|
||||
// ... thus it segfaults on gIR==NULL
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern const llvm::Type* DtoType(Type* dt);
|
||||
@@ -43,30 +47,31 @@ const llvm::Type * IrTypeBasic::basic2llvm(Type* t)
|
||||
{
|
||||
const llvm::Type* t2;
|
||||
|
||||
// FIXME: don't use getGlobalContext
|
||||
llvm::LLVMContext& ctx = llvm::getGlobalContext();
|
||||
|
||||
switch(t->ty)
|
||||
{
|
||||
case Tvoid:
|
||||
return llvm::Type::getVoidTy(llvm::getGlobalContext());
|
||||
return llvm::Type::getVoidTy(ctx);
|
||||
|
||||
case Tint8:
|
||||
case Tuns8:
|
||||
case Tchar:
|
||||
return llvm::Type::getInt8Ty(llvm::getGlobalContext());
|
||||
return llvm::Type::getInt8Ty(ctx);
|
||||
|
||||
case Tint16:
|
||||
case Tuns16:
|
||||
case Twchar:
|
||||
return llvm::Type::getInt16Ty(llvm::getGlobalContext());
|
||||
return llvm::Type::getInt16Ty(ctx);
|
||||
|
||||
case Tint32:
|
||||
case Tuns32:
|
||||
case Tdchar:
|
||||
return llvm::Type::getInt32Ty(llvm::getGlobalContext());
|
||||
return llvm::Type::getInt32Ty(ctx);
|
||||
|
||||
case Tint64:
|
||||
case Tuns64:
|
||||
return llvm::Type::getInt64Ty(llvm::getGlobalContext());
|
||||
return llvm::Type::getInt64Ty(ctx);
|
||||
|
||||
/*
|
||||
case Tint128:
|
||||
@@ -76,37 +81,37 @@ const llvm::Type * IrTypeBasic::basic2llvm(Type* t)
|
||||
|
||||
case Tfloat32:
|
||||
case Timaginary32:
|
||||
return llvm::Type::getFloatTy(llvm::getGlobalContext());
|
||||
return llvm::Type::getFloatTy(ctx);
|
||||
|
||||
case Tfloat64:
|
||||
case Timaginary64:
|
||||
return llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
return llvm::Type::getDoubleTy(ctx);
|
||||
|
||||
case Tfloat80:
|
||||
case Timaginary80:
|
||||
// only x86 has 80bit float
|
||||
if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
|
||||
return llvm::Type::getX86_FP80Ty(llvm::getGlobalContext());
|
||||
return llvm::Type::getX86_FP80Ty(ctx);
|
||||
// other platforms use 64bit reals
|
||||
else
|
||||
return llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
return llvm::Type::getDoubleTy(ctx);
|
||||
|
||||
case Tcomplex32:
|
||||
t2 = llvm::Type::getFloatTy(llvm::getGlobalContext());
|
||||
return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL);
|
||||
t2 = llvm::Type::getFloatTy(ctx);
|
||||
return llvm::StructType::get(ctx, t2, t2, NULL);
|
||||
|
||||
case Tcomplex64:
|
||||
t2 = llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL);
|
||||
t2 = llvm::Type::getDoubleTy(ctx);
|
||||
return llvm::StructType::get(ctx, t2, t2, NULL);
|
||||
|
||||
case Tcomplex80:
|
||||
t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
|
||||
? llvm::Type::getX86_FP80Ty(llvm::getGlobalContext())
|
||||
: llvm::Type::getDoubleTy(llvm::getGlobalContext());
|
||||
return llvm::StructType::get(llvm::getGlobalContext(), t2, t2, NULL);
|
||||
? llvm::Type::getX86_FP80Ty(ctx)
|
||||
: llvm::Type::getDoubleTy(ctx);
|
||||
return llvm::StructType::get(ctx, t2, t2, NULL);
|
||||
|
||||
case Tbool:
|
||||
return llvm::Type::getInt1Ty(llvm::getGlobalContext());
|
||||
return llvm::Type::getInt1Ty(ctx);
|
||||
}
|
||||
|
||||
assert(0 && "not basic type");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "gen/llvm.h"
|
||||
#include "declaration.h"
|
||||
#include "gen/irstate.h"
|
||||
#include "ir/irvar.h"
|
||||
|
||||
|
||||
@@ -18,7 +19,7 @@ IrVar::IrVar(VarDeclaration* var)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrGlobal::IrGlobal(VarDeclaration* v): IrVar(v),
|
||||
type(llvm::OpaqueType::get(llvm::getGlobalContext()))
|
||||
type(llvm::OpaqueType::get(gIR->context()))
|
||||
{
|
||||
constInit = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user