Permalink
Browse files

WIP: port to llvm 3.0

  • Loading branch information...
1 parent 423076d commit 629f13929e1a236473c6adc6d874615eafbab122 @AlexeyProkhin AlexeyProkhin committed Oct 21, 2011
Showing with 934 additions and 897 deletions.
  1. +1 −1 dmd/module.c
  2. +2 −2 dmd/module.h
  3. +2 −18 dmd2/func.c
  4. +1 −1 dmd2/module.c
  5. +2 −2 dmd2/module.h
  6. +1 −0 dmd2/statement.h
  7. +10 −10 gen/aa.cpp
  8. +4 −4 gen/abi-generic.h
  9. +5 −5 gen/abi-x86-64.cpp
  10. +1 −1 gen/abi.cpp
  11. +1 −1 gen/abi.h
  12. +52 −41 gen/arrays.cpp
  13. +5 −5 gen/arrays.h
  14. +5 −5 gen/asmstmt.cpp
  15. +16 −15 gen/classes.cpp
  16. +9 −6 gen/complex.cpp
  17. +2 −2 gen/complex.h
  18. +1 −1 gen/configfile.cpp
  19. +34 −6 gen/declarations.cpp
  20. +1 −0 gen/dvalue.cpp
  21. +1 −1 gen/dvalue.h
  22. +14 −14 gen/functions.cpp
  23. +3 −3 gen/functions.h
  24. +5 −5 gen/irstate.cpp
  25. +11 −11 gen/irstate.h
  26. +0 −2 gen/llvm.h
  27. +114 −113 gen/llvmhelpers.cpp
  28. +3 −3 gen/llvmhelpers.h
  29. +1 −1 gen/logger.cpp
  30. +10 −10 gen/main.cpp
  31. +4 −4 gen/naked.cpp
  32. +7 −7 gen/nested.cpp
  33. +1 −2 gen/optimizer.cpp
  34. +4 −4 gen/passes/SimplifyDRuntimeCalls.cpp
  35. +20 −8 gen/rttibuilder.cpp
  36. +2 −1 gen/rttibuilder.h
  37. +188 −169 gen/runtime.cpp
  38. +10 −10 gen/statements.cpp
  39. +6 −7 gen/structs.cpp
  40. +19 −19 gen/tocall.cpp
  41. +8 −8 gen/todebug.cpp
  42. +30 −33 gen/toir.cpp
  43. +81 −86 gen/tollvm.cpp
  44. +30 −30 gen/tollvm.h
  45. +18 −20 gen/toobj.cpp
  46. +9 −8 gen/typinf.cpp
  47. +19 −24 ir/irclass.cpp
  48. +1 −1 ir/irfunction.h
  49. +1 −1 ir/irfuncty.h
  50. +2 −2 ir/irlandingpad.cpp
  51. +18 −21 ir/irstruct.cpp
  52. +7 −7 ir/irstruct.h
  53. +45 −40 ir/irtype.cpp
  54. +16 −14 ir/irtype.h
  55. +20 −35 ir/irtypeclass.cpp
  56. +8 −7 ir/irtypeclass.h
  57. +25 −19 ir/irtypefunction.cpp
  58. +5 −2 ir/irtypefunction.h
  59. +9 −15 ir/irtypestruct.cpp
  60. +1 −1 ir/irtypestruct.h
  61. +2 −2 ir/irvar.cpp
  62. +1 −1 ir/irvar.h
View
@@ -153,7 +153,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
// LDC
llvmForceLogging = false;
moduleInfoVar = NULL;
- moduleInfoType = new llvm::PATypeHolder(llvm::OpaqueType::get(llvm::getGlobalContext()));
+ moduleInfoType = llvm::StructType::create(llvm::getGlobalContext());
this->doDocComment = doDocComment;
this->doHdrGen = doHdrGen;
this->isRoot = false;
View
@@ -35,7 +35,7 @@ namespace llvm {
class LLVMContext;
class Module;
class GlobalVariable;
- class PATypeHolder;
+ class StructType;
}
#else
@@ -202,7 +202,7 @@ struct Module : Package
bool llvmForceLogging;
llvm::GlobalVariable* moduleInfoVar;
- llvm::PATypeHolder* moduleInfoType;
+ llvm::StructType* moduleInfoType;
// array ops emitted in this module already
StringTable arrayfuncs;
View
@@ -1640,29 +1640,13 @@ void FuncDeclaration::semantic3(Scope *sc)
#if STRUCTTHISREF
if (ad->isStructDeclaration())
v = v->addressOf(sc);
-#endif
-#if IN_LLVM
- //e = new AssertExp(loc, v, NULL);
-
- // LDC: check for null this
- //v = new ThisExp(0);
- //v->type = vthis->type;
- //v->var = vthis; // Error: Expression has no property var... in D1 typeof(v) == ThisExp
-
- //NullExp *nv = new NullExp(0);
- //nv->type = v->type;
-
- //IdentityExp *ie = new IdentityExp(TOKnotidentity, 0, v, nv);
- //ie->type = Type::tbool;
#endif
Expression *se = new StringExp(0, (char *)"null this");
se = se->semantic(sc);
+#if !IN_LLVM
se->type = Type::tchar->arrayOf();
-//#if IN_LLVM
-// ee = new AssertExp(loc, ie, se);
-//#else
+#endif
e = new AssertExp(loc, v, se);
-//#endif
}
if (ee)
{
View
@@ -213,7 +213,7 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen
// LDC
llvmForceLogging = false;
moduleInfoVar = NULL;
- moduleInfoType = new llvm::PATypeHolder(llvm::OpaqueType::get(llvm::getGlobalContext()));
+ moduleInfoType = llvm::StructType::create(llvm::getGlobalContext());
this->doDocComment = doDocComment;
this->doHdrGen = doHdrGen;
this->isRoot = false;
View
@@ -35,7 +35,7 @@ namespace llvm {
class LLVMContext;
class Module;
class GlobalVariable;
- class PATypeHolder;
+ class StructType;
}
#else
@@ -208,7 +208,7 @@ struct Module : Package
bool llvmForceLogging;
llvm::GlobalVariable* moduleInfoVar;
- llvm::PATypeHolder* moduleInfoType;
+ llvm::StructType* moduleInfoType;
// array ops emitted in this module already
StringTable arrayfuncs;
View
@@ -106,6 +106,7 @@ enum BE
struct Statement : Object
{
Loc loc;
+ virtual ~Statement() {}
Statement(Loc loc);
virtual Statement *syntaxCopy();
View
@@ -55,7 +55,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
#else
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, lvalue?"_aaGet":"_aaIn");
#endif
- const llvm::FunctionType* funcTy = func->getFunctionType();
+ LLFunctionType* funcTy = func->getFunctionType();
// aa param
LLValue* aaval = lvalue ? aa->getLVal() : aa->getRVal();
@@ -85,7 +85,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
}
// cast return value
- const LLType* targettype = getPtrToType(DtoType(type));
+ LLType* targettype = getPtrToType(DtoType(type));
if (ret->getType() != targettype)
ret = DtoBitCast(ret, targettype);
@@ -109,7 +109,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
#if DMDV2
// module param
LLValue *moduleInfoSymbol = gIR->func()->decl->getModule()->moduleInfoSymbol();
- const LLType *moduleInfoType = DtoType(Module::moduleinfo->type);
+ LLType *moduleInfoType = DtoType(Module::moduleinfo->type);
args.push_back(DtoBitCast(moduleInfoSymbol, getPtrToType(moduleInfoType)));
#else
// file param
@@ -123,7 +123,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
// call
llvm::Function* errorfn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_bounds");
- gIR->CreateCallOrInvoke(errorfn, args.begin(), args.end());
+ gIR->CreateCallOrInvoke(errorfn, args);
// the function does not return
gIR->ir->CreateUnreachable();
@@ -152,7 +152,7 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key)
#else
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaIn");
#endif
- const llvm::FunctionType* funcTy = func->getFunctionType();
+ LLFunctionType* funcTy = func->getFunctionType();
if (Logger::enabled())
Logger::cout() << "_aaIn = " << *func << '\n';
@@ -182,7 +182,7 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key)
LLValue* ret = gIR->CreateCallOrInvoke3(func, aaval, keyti, pkey, "aa.in").getInstruction();
// cast return value
- const LLType* targettype = DtoType(type);
+ LLType* targettype = DtoType(type);
if (ret->getType() != targettype)
ret = DtoBitCast(ret, targettype);
@@ -207,7 +207,7 @@ void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
#else
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaDel");
#endif
- const llvm::FunctionType* funcTy = func->getFunctionType();
+ LLFunctionType* funcTy = func->getFunctionType();
if (Logger::enabled())
Logger::cout() << "_aaDel = " << *func << '\n';
@@ -240,7 +240,7 @@ void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
args.push_back(pkey);
// call runtime
- gIR->CreateCallOrInvoke(func, args.begin(), args.end());
+ gIR->CreateCallOrInvoke(func, args);
}
/////////////////////////////////////////////////////////////////////////////////////
@@ -251,15 +251,15 @@ LLValue* DtoAAEquals(Loc& loc, TOK op, DValue* l, DValue* r)
assert(t == r->getType()->toBasetype() && "aa equality is only defined for aas of same type");
#if DMDV2
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEqual");
- const llvm::FunctionType* funcTy = func->getFunctionType();
+ LLFunctionType* funcTy = func->getFunctionType();
LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(1));
LLValue* abval = DtoBitCast(r->getRVal(), funcTy->getParamType(2));
LLValue* aaTypeInfo = DtoTypeInfoOf(t);
LLValue* res = gIR->CreateCallOrInvoke3(func, aaTypeInfo, aaval, abval, "aaEqRes").getInstruction();
#else
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaEq");
- const llvm::FunctionType* funcTy = func->getFunctionType();
+ LLFunctionType* funcTy = func->getFunctionType();
LLValue* aaval = DtoBitCast(l->getRVal(), funcTy->getParamType(0));
LLValue* abval = DtoBitCast(r->getRVal(), funcTy->getParamType(1));
View
@@ -29,7 +29,7 @@ struct RemoveStructPadding : ABIRewrite {
}
/// return the transformed type for this rewrite
- virtual const LLType* type(Type* dty, const LLType* t) {
+ virtual LLType* type(Type* dty, LLType* t) {
return DtoUnpaddedStructType(dty->toBasetype());
}
};
@@ -47,7 +47,7 @@ struct X87_complex_swap : ABIRewrite
{
return DtoAggrPairSwap(v->getRVal());
}
- const LLType* type(Type*, const LLType* t)
+ LLType* type(Type*, LLType* t)
{
return t;
}
@@ -84,10 +84,10 @@ struct X86_struct_to_register : ABIRewrite
Logger::println("rewriting struct -> int");
assert(dv->isLVal());
LLValue* mem = dv->getLVal();
- const LLType* t = LLIntegerType::get(gIR->context(), dty->size()*8);
+ LLType* t = LLIntegerType::get(gIR->context(), dty->size()*8);
return DtoLoad(DtoBitCast(mem, getPtrToType(t)));
}
- const LLType* type(Type* t, const LLType*)
+ LLType* type(Type* t, LLType*)
{
size_t sz = t->size()*8;
return LLIntegerType::get(gIR->context(), sz);
View
@@ -218,7 +218,7 @@ namespace {
// Okay, we may need to transform. Figure out a canonical type:
- std::vector<const LLType*> parts;
+ std::vector<LLType*> parts;
unsigned size = ty->size();
@@ -301,14 +301,14 @@ struct X86_64_C_struct_rewrite : ABIRewrite {
DtoStore(rval, lval);
}
- const LLType* pTy = getPtrToType(DtoType(dty));
+ LLType* pTy = getPtrToType(DtoType(dty));
return DtoLoad(DtoBitCast(lval, pTy), "get-result");
}
// Get struct from ABI-mangled representation, and store in the provided location.
void getL(Type* dty, DValue* v, llvm::Value* lval) {
LLValue* rval = v->getRVal();
- const LLType* pTy = getPtrToType(rval->getType());
+ LLType* pTy = getPtrToType(rval->getType());
DtoStore(rval, DtoBitCast(lval, pTy));
}
@@ -328,12 +328,12 @@ struct X86_64_C_struct_rewrite : ABIRewrite {
LLType* abiTy = getAbiType(dty);
assert(abiTy && "Why are we rewriting a non-rewritten type?");
- const LLType* pTy = getPtrToType(abiTy);
+ LLType* pTy = getPtrToType(abiTy);
return DtoLoad(DtoBitCast(lval, pTy), "put-result");
}
/// should return the transformed type for this rewrite
- const LLType* type(Type* dty, const LLType* t)
+ LLType* type(Type* dty, LLType* t)
{
return getAbiType(dty);
}
View
@@ -76,7 +76,7 @@ struct X86_cfloat_rewrite : ABIRewrite
}
// {float,float} -> i64
- const LLType* type(Type*, const LLType* t)
+ LLType* type(Type*, LLType* t)
{
return LLType::getInt64Ty(gIR->context());
}
View
@@ -27,7 +27,7 @@ struct ABIRewrite
virtual LLValue* put(Type* dty, DValue* v) = 0;
/// should return the transformed type for this rewrite
- virtual const LLType* type(Type* dty, const LLType* t) = 0;
+ virtual LLType* type(Type* dty, LLType* t) = 0;
};
// interface called by codegen
Oops, something went wrong.

0 comments on commit 629f139

Please sign in to comment.