mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
Remove unused, empty Ir type.
The codegen parameter was changed to IRState instead of removing it to set the stage for an eventual eradication of the gIR global.
This commit is contained in:
parent
c6cf35a012
commit
1242be25d0
27 changed files with 64 additions and 182 deletions
|
@ -209,7 +209,7 @@ struct StructDeclaration : AggregateDeclaration
|
||||||
StructDeclaration *isStructDeclaration() { return this; }
|
StructDeclaration *isStructDeclaration() { return this; }
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ struct ClassDeclaration : AggregateDeclaration
|
||||||
ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; }
|
ClassDeclaration *isClassDeclaration() { return (ClassDeclaration *)this; }
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
virtual void codegen(Ir*);
|
virtual void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ struct InterfaceDeclaration : ClassDeclaration
|
||||||
InterfaceDeclaration *isInterfaceDeclaration() { return this; }
|
InterfaceDeclaration *isInterfaceDeclaration() { return this; }
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct AttribDeclaration : Dsymbol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
virtual void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ struct PragmaDeclaration : AttribDeclaration
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ struct TupleDeclaration : Declaration
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void semantic3(Scope *sc);
|
void semantic3(Scope *sc);
|
||||||
/// Codegen traversal
|
/// Codegen traversal
|
||||||
void codegen(Ir* ir);
|
void codegen(IRState* ir);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ struct TypedefDeclaration : Declaration
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
/// Codegen traversal
|
/// Codegen traversal
|
||||||
void codegen(Ir* ir);
|
void codegen(IRState* ir);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ struct VarDeclaration : Declaration
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
/// Codegen traversal
|
/// Codegen traversal
|
||||||
virtual void codegen(Ir* ir);
|
void codegen(IRState* ir);
|
||||||
|
|
||||||
/// Index into parent aggregate.
|
/// Index into parent aggregate.
|
||||||
/// Set during type generation.
|
/// Set during type generation.
|
||||||
|
@ -450,7 +450,7 @@ struct TypeInfoDeclaration : VarDeclaration
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
/// Codegen traversal
|
/// Codegen traversal
|
||||||
void codegen(Ir* ir);
|
void codegen(IRState* ir);
|
||||||
virtual void llvmDefine();
|
virtual void llvmDefine();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -482,7 +482,7 @@ struct TypeInfoClassDeclaration : TypeInfoDeclaration
|
||||||
// __ClassZ/__InterfaceZ symbols instead of a TypeInfo_….init one. DMD also
|
// __ClassZ/__InterfaceZ symbols instead of a TypeInfo_….init one. DMD also
|
||||||
// generates them for SomeInterface.classinfo access, so we can't just
|
// generates them for SomeInterface.classinfo access, so we can't just
|
||||||
// distinguish between them using tinfo and thus need to override codegen().
|
// distinguish between them using tinfo and thus need to override codegen().
|
||||||
void codegen(Ir* p);
|
void codegen(IRState* ir);
|
||||||
void llvmDefine();
|
void llvmDefine();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -919,7 +919,7 @@ struct FuncDeclaration : Declaration
|
||||||
IrFuncTy irFty;
|
IrFuncTy irFty;
|
||||||
|
|
||||||
/// Codegen traversal
|
/// Codegen traversal
|
||||||
void codegen(Ir* ir);
|
void codegen(IRState* ir);
|
||||||
|
|
||||||
// vars declared in this function that nested funcs reference
|
// vars declared in this function that nested funcs reference
|
||||||
// is this is not empty, nestedFrameRef is set and these VarDecls
|
// is this is not empty, nestedFrameRef is set and these VarDecls
|
||||||
|
|
|
@ -95,7 +95,7 @@ struct TYPE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
class Ir;
|
class IRState;
|
||||||
namespace llvm
|
namespace llvm
|
||||||
{
|
{
|
||||||
class Value;
|
class Value;
|
||||||
|
@ -287,7 +287,7 @@ struct Dsymbol : Object
|
||||||
virtual ClassInfoDeclaration* isClassInfoDeclaration() { return NULL; }
|
virtual ClassInfoDeclaration* isClassInfoDeclaration() { return NULL; }
|
||||||
|
|
||||||
/// Codegen traversal
|
/// Codegen traversal
|
||||||
virtual void codegen(Ir* ir);
|
virtual void codegen(IRState* p);
|
||||||
|
|
||||||
// llvm stuff
|
// llvm stuff
|
||||||
int llvmInternal;
|
int llvmInternal;
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct EnumDeclaration : ScopeDsymbol
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ class Library;
|
||||||
|
|
||||||
// Back end
|
// Back end
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
class Ir;
|
|
||||||
class DValue;
|
class DValue;
|
||||||
typedef DValue elem;
|
typedef DValue elem;
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
@ -196,7 +195,7 @@ struct Module : Package
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
// LDC
|
// LDC
|
||||||
llvm::Module* genLLVMModule(llvm::LLVMContext& context, Ir* sir);
|
llvm::Module* genLLVMModule(llvm::LLVMContext& context);
|
||||||
void buildTargetFiles(bool singleObj);
|
void buildTargetFiles(bool singleObj);
|
||||||
File* buildFilePath(const char* forcename, const char* path, const char* ext);
|
File* buildFilePath(const char* forcename, const char* path, const char* ext);
|
||||||
Module *isModule() { return this; }
|
Module *isModule() { return this; }
|
||||||
|
|
11
dmd2/mtype.c
11
dmd2/mtype.c
|
@ -50,9 +50,6 @@
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
#include "hdrgen.h"
|
#include "hdrgen.h"
|
||||||
|
|
||||||
#if IN_LLVM
|
|
||||||
Ir* Type::sir = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FuncDeclaration *hasThis(Scope *sc);
|
FuncDeclaration *hasThis(Scope *sc);
|
||||||
|
|
||||||
|
@ -197,11 +194,7 @@ char Type::needThisPrefix()
|
||||||
return 'M'; // name mangling prefix for functions needing 'this'
|
return 'M'; // name mangling prefix for functions needing 'this'
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IN_LLVM
|
|
||||||
void Type::init(Ir* _sir)
|
|
||||||
#else
|
|
||||||
void Type::init()
|
void Type::init()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
stringtable._init(1543);
|
stringtable._init(1543);
|
||||||
Lexer::initKeywords();
|
Lexer::initKeywords();
|
||||||
|
@ -353,10 +346,6 @@ void Type::init()
|
||||||
Tptrdiff_t = Tint32;
|
Tptrdiff_t = Tint32;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IN_LLVM
|
|
||||||
sir = _sir;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tsize_t = basic[Tsize_t];
|
tsize_t = basic[Tsize_t];
|
||||||
tptrdiff_t = basic[Tptrdiff_t];
|
tptrdiff_t = basic[Tptrdiff_t];
|
||||||
thash_t = tsize_t;
|
thash_t = tsize_t;
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
#include "../ir/irfuncty.h"
|
#include "../ir/irfuncty.h"
|
||||||
namespace llvm { class Type; }
|
namespace llvm { class Type; }
|
||||||
class Ir;
|
|
||||||
class IrType;
|
class IrType;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -247,11 +246,7 @@ struct Type : Object
|
||||||
int covariant(Type *t, StorageClass *pstc = NULL);
|
int covariant(Type *t, StorageClass *pstc = NULL);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
static char needThisPrefix();
|
static char needThisPrefix();
|
||||||
#if IN_LLVM
|
|
||||||
static void init(Ir*);
|
|
||||||
#else
|
|
||||||
static void init();
|
static void init();
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SIZE_INVALID (~(d_uns64)0)
|
#define SIZE_INVALID (~(d_uns64)0)
|
||||||
d_uns64 size();
|
d_uns64 size();
|
||||||
|
@ -371,7 +366,6 @@ struct Type : Object
|
||||||
virtual TypeBasic *isTypeBasic();
|
virtual TypeBasic *isTypeBasic();
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
static Ir* sir;
|
|
||||||
IrType* irtype;
|
IrType* irtype;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -356,7 +356,7 @@ struct TemplateInstance : ScopeDsymbol
|
||||||
bool ignore; // true if the instance must be ignored when codegen'ing
|
bool ignore; // true if the instance must be ignored when codegen'ing
|
||||||
Module* emittedInModule; // which module this template instance has been emitted in
|
Module* emittedInModule; // which module this template instance has been emitted in
|
||||||
|
|
||||||
void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ struct TemplateMixin : TemplateInstance
|
||||||
TemplateMixin *isTemplateMixin() { return this; }
|
TemplateMixin *isTemplateMixin() { return this; }
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void codegen(Ir*);
|
void codegen(IRState*);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -614,9 +614,6 @@ int main(int argc, char **argv)
|
||||||
if (global.errors)
|
if (global.errors)
|
||||||
fatal();
|
fatal();
|
||||||
|
|
||||||
// create a proper target
|
|
||||||
Ir ir;
|
|
||||||
|
|
||||||
// Set up the TargetMachine.
|
// Set up the TargetMachine.
|
||||||
ExplicitBitness::Type bitness = ExplicitBitness::None;
|
ExplicitBitness::Type bitness = ExplicitBitness::None;
|
||||||
if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty()))
|
if ((m32bits || m64bits) && (!mArch.empty() || !mTargetTriple.empty()))
|
||||||
|
@ -669,7 +666,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
Type::init(&ir);
|
Type::init();
|
||||||
Id::initialize();
|
Id::initialize();
|
||||||
Module::init();
|
Module::init();
|
||||||
Target::init();
|
Target::init();
|
||||||
|
@ -987,7 +984,7 @@ int main(int argc, char **argv)
|
||||||
printf("code %s\n", m->toChars());
|
printf("code %s\n", m->toChars());
|
||||||
if (global.params.obj)
|
if (global.params.obj)
|
||||||
{
|
{
|
||||||
llvm::Module* lm = m->genLLVMModule(context, &ir);
|
llvm::Module* lm = m->genLLVMModule(context);
|
||||||
if (!singleObj)
|
if (!singleObj)
|
||||||
{
|
{
|
||||||
m->deleteObjFile();
|
m->deleteObjFile();
|
||||||
|
|
|
@ -22,20 +22,19 @@
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
#include "gen/tollvm.h"
|
#include "gen/tollvm.h"
|
||||||
#include "gen/utils.h"
|
#include "gen/utils.h"
|
||||||
#include "ir/ir.h"
|
|
||||||
#include "ir/irtype.h"
|
#include "ir/irtype.h"
|
||||||
#include "ir/irvar.h"
|
#include "ir/irvar.h"
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void Dsymbol::codegen(Ir*)
|
void Dsymbol::codegen(IRState *)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("Ignoring Dsymbol::codegen for %s", toPrettyChars());
|
IF_LOG Logger::println("Ignoring Dsymbol::codegen for %s", toPrettyChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void InterfaceDeclaration::codegen(Ir* p)
|
void InterfaceDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("InterfaceDeclaration::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("InterfaceDeclaration::codegen: '%s'", toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
@ -70,7 +69,7 @@ void InterfaceDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void StructDeclaration::codegen(Ir* p)
|
void StructDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("StructDeclaration::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("StructDeclaration::codegen: '%s'", toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
@ -104,7 +103,7 @@ void StructDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void ClassDeclaration::codegen(Ir* p)
|
void ClassDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("ClassDeclaration::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("ClassDeclaration::codegen: '%s'", toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
@ -146,7 +145,7 @@ void ClassDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void TupleDeclaration::codegen(Ir* p)
|
void TupleDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("TupleDeclaration::codegen(): '%s'", toPrettyChars());
|
IF_LOG Logger::println("TupleDeclaration::codegen(): '%s'", toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
@ -169,7 +168,7 @@ void TupleDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void VarDeclaration::codegen(Ir* p)
|
void VarDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("VarDeclaration::codegen(): '%s'", toPrettyChars());
|
IF_LOG Logger::println("VarDeclaration::codegen(): '%s'", toPrettyChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -258,7 +257,7 @@ void VarDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void TypedefDeclaration::codegen(Ir*)
|
void TypedefDeclaration::codegen(IRState *)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("TypedefDeclaration::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("TypedefDeclaration::codegen: '%s'", toPrettyChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -277,7 +276,7 @@ void TypedefDeclaration::codegen(Ir*)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void EnumDeclaration::codegen(Ir*)
|
void EnumDeclaration::codegen(IRState *)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("Ignoring EnumDeclaration::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("Ignoring EnumDeclaration::codegen: '%s'", toPrettyChars());
|
||||||
|
|
||||||
|
@ -289,7 +288,7 @@ void EnumDeclaration::codegen(Ir*)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void FuncDeclaration::codegen(Ir* p)
|
void FuncDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
// don't touch function aliases, they don't contribute any new symbols
|
// don't touch function aliases, they don't contribute any new symbols
|
||||||
if (!isFuncAliasDeclaration())
|
if (!isFuncAliasDeclaration())
|
||||||
|
@ -300,7 +299,7 @@ void FuncDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void TemplateInstance::codegen(Ir* p)
|
void TemplateInstance::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("TemplateInstance::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("TemplateInstance::codegen: '%s'", toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
@ -319,7 +318,7 @@ void TemplateInstance::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void TemplateMixin::codegen(Ir* p)
|
void TemplateMixin::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
IF_LOG Logger::println("TemplateInstance::codegen: '%s'", toPrettyChars());
|
IF_LOG Logger::println("TemplateInstance::codegen: '%s'", toPrettyChars());
|
||||||
LOG_SCOPE
|
LOG_SCOPE
|
||||||
|
@ -338,7 +337,7 @@ void TemplateMixin::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void AttribDeclaration::codegen(Ir* p)
|
void AttribDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
Array *d = include(NULL, NULL);
|
Array *d = include(NULL, NULL);
|
||||||
|
|
||||||
|
@ -353,7 +352,7 @@ void AttribDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
/* ================================================================== */
|
/* ================================================================== */
|
||||||
|
|
||||||
void PragmaDeclaration::codegen(Ir* p)
|
void PragmaDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
if (ident == Id::lib)
|
if (ident == Id::lib)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1210,7 +1210,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
// static
|
// static
|
||||||
if (vd->isDataseg())
|
if (vd->isDataseg())
|
||||||
{
|
{
|
||||||
vd->codegen(Type::sir);
|
vd->codegen(gIR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1222,19 +1222,19 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
||||||
else if (StructDeclaration* s = declaration->isStructDeclaration())
|
else if (StructDeclaration* s = declaration->isStructDeclaration())
|
||||||
{
|
{
|
||||||
Logger::println("StructDeclaration");
|
Logger::println("StructDeclaration");
|
||||||
s->codegen(Type::sir);
|
s->codegen(gIR);
|
||||||
}
|
}
|
||||||
// function declaration
|
// function declaration
|
||||||
else if (FuncDeclaration* f = declaration->isFuncDeclaration())
|
else if (FuncDeclaration* f = declaration->isFuncDeclaration())
|
||||||
{
|
{
|
||||||
Logger::println("FuncDeclaration");
|
Logger::println("FuncDeclaration");
|
||||||
f->codegen(Type::sir);
|
f->codegen(gIR);
|
||||||
}
|
}
|
||||||
// class
|
// class
|
||||||
else if (ClassDeclaration* e = declaration->isClassDeclaration())
|
else if (ClassDeclaration* e = declaration->isClassDeclaration())
|
||||||
{
|
{
|
||||||
Logger::println("ClassDeclaration");
|
Logger::println("ClassDeclaration");
|
||||||
e->codegen(Type::sir);
|
e->codegen(gIR);
|
||||||
}
|
}
|
||||||
// typedef
|
// typedef
|
||||||
else if (TypedefDeclaration* tdef = declaration->isTypedefDeclaration())
|
else if (TypedefDeclaration* tdef = declaration->isTypedefDeclaration())
|
||||||
|
@ -1482,7 +1482,7 @@ LLConstant* DtoTypeInfoOf(Type* type, bool base)
|
||||||
type->getTypeInfo(NULL);
|
type->getTypeInfo(NULL);
|
||||||
TypeInfoDeclaration* tidecl = type->vtinfo;
|
TypeInfoDeclaration* tidecl = type->vtinfo;
|
||||||
assert(tidecl);
|
assert(tidecl);
|
||||||
tidecl->codegen(Type::sir);
|
tidecl->codegen(gIR);
|
||||||
assert(tidecl->ir.irGlobal != NULL);
|
assert(tidecl->ir.irGlobal != NULL);
|
||||||
assert(tidecl->ir.irGlobal->value != NULL);
|
assert(tidecl->ir.irGlobal->value != NULL);
|
||||||
LLConstant* c = isaConstant(tidecl->ir.irGlobal->value);
|
LLConstant* c = isaConstant(tidecl->ir.irGlobal->value);
|
||||||
|
|
|
@ -326,7 +326,7 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
|
||||||
return ctor;
|
return ctor;
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context)
|
||||||
{
|
{
|
||||||
bool logenabled = Logger::enabled();
|
bool logenabled = Logger::enabled();
|
||||||
if (llvmForceLogging && !logenabled)
|
if (llvmForceLogging && !logenabled)
|
||||||
|
@ -363,8 +363,6 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
// reset all IR data stored in Dsymbols
|
// reset all IR data stored in Dsymbols
|
||||||
IrDsymbol::resetAll();
|
IrDsymbol::resetAll();
|
||||||
|
|
||||||
sir->setState(&ir);
|
|
||||||
|
|
||||||
// set target triple
|
// set target triple
|
||||||
ir.module->setTargetTriple(global.params.targetTriple.str());
|
ir.module->setTargetTriple(global.params.targetTriple.str());
|
||||||
|
|
||||||
|
@ -395,7 +393,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
for (unsigned k=0; k < members->dim; k++) {
|
for (unsigned k=0; k < members->dim; k++) {
|
||||||
Dsymbol* dsym = static_cast<Dsymbol*>(members->data[k]);
|
Dsymbol* dsym = static_cast<Dsymbol*>(members->data[k]);
|
||||||
assert(dsym);
|
assert(dsym);
|
||||||
dsym->codegen(sir);
|
dsym->codegen(&ir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for singleobj-compilation, fully emit all seen template instances
|
// for singleobj-compilation, fully emit all seen template instances
|
||||||
|
@ -405,7 +403,7 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
{
|
{
|
||||||
IRState::TemplateInstanceSet::iterator it, end = ir.seenTemplateInstances.end();
|
IRState::TemplateInstanceSet::iterator it, end = ir.seenTemplateInstances.end();
|
||||||
for (it = ir.seenTemplateInstances.begin(); it != end; ++it)
|
for (it = ir.seenTemplateInstances.begin(); it != end; ++it)
|
||||||
(*it)->codegen(sir);
|
(*it)->codegen(&ir);
|
||||||
ir.seenTemplateInstances.clear();
|
ir.seenTemplateInstances.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,8 +424,6 @@ llvm::Module* Module::genLLVMModule(llvm::LLVMContext& context, Ir* sir)
|
||||||
Logger::disable();
|
Logger::disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
sir->setState(NULL);
|
|
||||||
|
|
||||||
return ir.module;
|
return ir.module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ void ExpStatement::toNakedIR(IRState *p)
|
||||||
|
|
||||||
// make sure the symbols gets processed
|
// make sure the symbols gets processed
|
||||||
// TODO: codegen() here is likely incorrect
|
// TODO: codegen() here is likely incorrect
|
||||||
d->declaration->codegen(Type::sir);
|
d->declaration->codegen(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -10,14 +10,10 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
#include "gen/irstate.h"
|
||||||
#include "mars.h"
|
#include "mars.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
|
|
||||||
unsigned GetTypeAlignment(Type* t);
|
|
||||||
unsigned GetPointerSize();
|
|
||||||
unsigned GetTypeStoreSize(Type* t);
|
|
||||||
unsigned GetTypeAllocSize(Type* t);
|
|
||||||
|
|
||||||
int Target::ptrsize;
|
int Target::ptrsize;
|
||||||
int Target::realsize;
|
int Target::realsize;
|
||||||
int Target::realpad;
|
int Target::realpad;
|
||||||
|
@ -25,10 +21,12 @@ int Target::realalignsize;
|
||||||
|
|
||||||
void Target::init()
|
void Target::init()
|
||||||
{
|
{
|
||||||
ptrsize = GetPointerSize();
|
ptrsize = gDataLayout->getPointerSize(ADDRESS_SPACE);
|
||||||
realsize = GetTypeAllocSize(Type::basic[Tfloat80]);
|
|
||||||
realpad = realsize - GetTypeStoreSize(Type::basic[Tfloat80]);
|
llvm::Type* real = DtoType(Type::basic[Tfloat80]);
|
||||||
realalignsize = GetTypeAlignment(Type::basic[Tfloat80]);
|
realsize = gDataLayout->getTypeAllocSize(real);
|
||||||
|
realpad = realsize - gDataLayout->getTypeStoreSize(real);
|
||||||
|
realalignsize = gDataLayout->getABITypeAlignment(real);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
@ -39,7 +37,7 @@ unsigned Target::alignsize (Type* type)
|
||||||
{
|
{
|
||||||
assert (type->isTypeBasic());
|
assert (type->isTypeBasic());
|
||||||
if (type->ty == Tvoid) return 1;
|
if (type->ty == Tvoid) return 1;
|
||||||
return GetTypeAlignment(type);
|
return gDataLayout->getABITypeAlignment(DtoType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************
|
/******************************
|
||||||
|
|
|
@ -2551,7 +2551,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||||
owner = owner->toParent();
|
owner = owner->toParent();
|
||||||
if (owner->isTemplateInstance() || owner == p->dmodule)
|
if (owner->isTemplateInstance() || owner == p->dmodule)
|
||||||
{
|
{
|
||||||
func->codegen(Type::sir);
|
func->codegen(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2800,7 +2800,7 @@ DValue* FuncExp::toElem(IRState* p)
|
||||||
|
|
||||||
// We need to actually codegen the function here, as literals are not added
|
// We need to actually codegen the function here, as literals are not added
|
||||||
// to the module member list.
|
// to the module member list.
|
||||||
fd->codegen(Type::sir);
|
fd->codegen(p);
|
||||||
assert(fd->ir.irFunc->func);
|
assert(fd->ir.irFunc->func);
|
||||||
|
|
||||||
if (fd->isNested()) {
|
if (fd->isNested()) {
|
||||||
|
@ -2869,7 +2869,7 @@ LLConstant* FuncExp::toConstElem(IRState* p)
|
||||||
|
|
||||||
// We need to actually codegen the function here, as literals are not added
|
// We need to actually codegen the function here, as literals are not added
|
||||||
// to the module member list.
|
// to the module member list.
|
||||||
fd->codegen(Type::sir);
|
fd->codegen(p);
|
||||||
assert(fd->ir.irFunc->func);
|
assert(fd->ir.irFunc->func);
|
||||||
|
|
||||||
return fd->ir.irFunc->func;
|
return fd->ir.irFunc->func;
|
||||||
|
|
|
@ -152,7 +152,7 @@ Expression *Type::getTypeInfo(Scope *sc)
|
||||||
}
|
}
|
||||||
else // if in obj generation pass
|
else // if in obj generation pass
|
||||||
{
|
{
|
||||||
t->vtinfo->codegen(sir);
|
t->vtinfo->codegen(gIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,10 +317,10 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
|
||||||
|
|
||||||
// TypeInfo instances (except ClassInfo ones) are always emitted as weak
|
// TypeInfo instances (except ClassInfo ones) are always emitted as weak
|
||||||
// symbols when they are used.
|
// symbols when they are used.
|
||||||
tid->codegen(Type::sir);
|
tid->codegen(gIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeInfoDeclaration::codegen(Ir*)
|
void TypeInfoDeclaration::codegen(IRState* p)
|
||||||
{
|
{
|
||||||
Logger::println("TypeInfoDeclaration::codegen(%s)", toPrettyChars());
|
Logger::println("TypeInfoDeclaration::codegen(%s)", toPrettyChars());
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
@ -728,7 +728,7 @@ void TypeInfoStructDeclaration::llvmDefine()
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
|
||||||
void TypeInfoClassDeclaration::codegen(Ir* p)
|
void TypeInfoClassDeclaration::codegen(IRState *p)
|
||||||
{
|
{
|
||||||
// For classes, the TypeInfo is in fact a ClassInfo instance and emitted
|
// For classes, the TypeInfo is in fact a ClassInfo instance and emitted
|
||||||
// as a __ClassZ symbol. For interfaces, the __InterfaceZ symbol is
|
// as a __ClassZ symbol. For interfaces, the __InterfaceZ symbol is
|
||||||
|
|
49
ir/ir.cpp
49
ir/ir.cpp
|
@ -1,49 +0,0 @@
|
||||||
//===-- ir.cpp ------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// LDC – the LLVM D compiler
|
|
||||||
//
|
|
||||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
|
||||||
// file for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
#if LDC_LLVM_VER >= 303
|
|
||||||
#include "llvm/IR/DataLayout.h"
|
|
||||||
#elif LDC_LLVM_VER == 302
|
|
||||||
#include "llvm/DataLayout.h"
|
|
||||||
#else
|
|
||||||
#include "llvm/Target/TargetData.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gen/irstate.h"
|
|
||||||
#include "gen/tollvm.h"
|
|
||||||
#include "gen/functions.h"
|
|
||||||
|
|
||||||
#include "ir/ir.h"
|
|
||||||
#include "ir/irfunction.h"
|
|
||||||
|
|
||||||
|
|
||||||
unsigned GetTypeAlignment(Type* t)
|
|
||||||
{
|
|
||||||
return gDataLayout->getABITypeAlignment(DtoType(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetPointerSize()
|
|
||||||
{
|
|
||||||
return gDataLayout->getPointerSize(ADDRESS_SPACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetTypeStoreSize(Type* t)
|
|
||||||
{
|
|
||||||
return gDataLayout->getTypeStoreSize(DtoType(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned GetTypeAllocSize(Type* t)
|
|
||||||
{
|
|
||||||
return gDataLayout->getTypeAllocSize(DtoType(t));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ir::Ir()
|
|
||||||
: irs(NULL)
|
|
||||||
{
|
|
||||||
}
|
|
40
ir/ir.h
40
ir/ir.h
|
@ -1,40 +0,0 @@
|
||||||
//===-- ir/ir.h - Base definitions for codegen metadata ---------*- C++ -*-===//
|
|
||||||
//
|
|
||||||
// LDC – the LLVM D compiler
|
|
||||||
//
|
|
||||||
// This file is distributed under the BSD-style LDC license. See the LICENSE
|
|
||||||
// file for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Declares the base class for all codegen info classes and the top-level Ir
|
|
||||||
// class.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef LDC_IR_IR_H
|
|
||||||
#define LDC_IR_IR_H
|
|
||||||
|
|
||||||
#include "root.h"
|
|
||||||
#include "ir/irforw.h"
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
struct IRState;
|
|
||||||
struct IrFunction;
|
|
||||||
|
|
||||||
class Ir
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Ir();
|
|
||||||
|
|
||||||
void setState(IRState* p) { irs = p; }
|
|
||||||
IRState* getState() { return irs; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
IRState* irs;
|
|
||||||
|
|
||||||
std::deque<IrFunction*> functionbodies;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -15,7 +15,6 @@
|
||||||
#ifndef LDC_IR_IRAGGR_H
|
#ifndef LDC_IR_IRAGGR_H
|
||||||
#define LDC_IR_IRAGGR_H
|
#define LDC_IR_IRAGGR_H
|
||||||
|
|
||||||
#include "ir/ir.h"
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
|
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
#include "gen/logger.h"
|
#include "gen/logger.h"
|
||||||
#include "ir/ir.h"
|
|
||||||
#include "ir/irdsymbol.h"
|
#include "ir/irdsymbol.h"
|
||||||
#include "ir/irvar.h"
|
#include "ir/irvar.h"
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ struct IrParameter;
|
||||||
struct IrField;
|
struct IrField;
|
||||||
struct IrVar;
|
struct IrVar;
|
||||||
struct Dsymbol;
|
struct Dsymbol;
|
||||||
|
struct Module;
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Value;
|
class Value;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#define LDC_IR_IRFUNCTION_H
|
#define LDC_IR_IRFUNCTION_H
|
||||||
|
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
#include "ir/ir.h"
|
|
||||||
#include "ir/irlandingpad.h"
|
#include "ir/irlandingpad.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#ifndef LDC_IR_IRFUNCTY_H
|
#ifndef LDC_IR_IRFUNCTY_H
|
||||||
#define LDC_IR_IRFUNCTY_H
|
#define LDC_IR_IRFUNCTY_H
|
||||||
|
|
||||||
#include "ir/ir.h"
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
#include "llvm/IR/Attributes.h"
|
#include "llvm/IR/Attributes.h"
|
||||||
|
@ -27,6 +26,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class DValue;
|
class DValue;
|
||||||
|
struct Type;
|
||||||
struct ABIRewrite;
|
struct ABIRewrite;
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class Type;
|
class Type;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#define LDC_IR_IRLANDINGPADINFO_H
|
#define LDC_IR_IRLANDINGPADINFO_H
|
||||||
|
|
||||||
#include "statement.h"
|
#include "statement.h"
|
||||||
#include "ir/ir.h"
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
#ifndef LDC_IR_IRMODULE_H
|
#ifndef LDC_IR_IRMODULE_H
|
||||||
#define LDC_IR_IRMODULE_H
|
#define LDC_IR_IRMODULE_H
|
||||||
|
|
||||||
#include "ir/ir.h"
|
|
||||||
|
|
||||||
struct Module;
|
struct Module;
|
||||||
|
namespace llvm
|
||||||
|
{
|
||||||
|
class GlobalVariable;
|
||||||
|
}
|
||||||
|
|
||||||
struct IrModule
|
struct IrModule
|
||||||
{
|
{
|
||||||
|
@ -26,7 +28,7 @@ struct IrModule
|
||||||
|
|
||||||
Module* M;
|
Module* M;
|
||||||
|
|
||||||
LLGlobalVariable* fileName;
|
llvm::GlobalVariable* fileName;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#ifndef LDC_IR_IRVAR_H
|
#ifndef LDC_IR_IRVAR_H
|
||||||
#define LDC_IR_IRVAR_H
|
#define LDC_IR_IRVAR_H
|
||||||
|
|
||||||
#include "ir/ir.h"
|
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
#include "llvm/IR/Type.h"
|
#include "llvm/IR/Type.h"
|
||||||
#else
|
#else
|
||||||
|
@ -23,6 +22,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct IrFuncTyArg;
|
struct IrFuncTyArg;
|
||||||
|
struct VarDeclaration;
|
||||||
|
|
||||||
struct IrVar
|
struct IrVar
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue