diff --git a/dmd/aggregate.d b/dmd/aggregate.d index 14ae0acf55..058b14bc80 100644 --- a/dmd/aggregate.d +++ b/dmd/aggregate.d @@ -829,9 +829,12 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol return type; } +version (IN_LLVM) {} else +{ // Back end Symbol* stag; // tag symbol for debug data Symbol* sinit; +} override final inout(AggregateDeclaration) isAggregateDeclaration() inout { diff --git a/dmd/aggregate.h b/dmd/aggregate.h index 8d129adbaf..739dac6473 100644 --- a/dmd/aggregate.h +++ b/dmd/aggregate.h @@ -138,9 +138,11 @@ public: // 'this' type Type *handleType() { return type; } +#if !IN_LLVM // Back end Symbol *stag; // tag symbol for debug data Symbol *sinit; +#endif AggregateDeclaration *isAggregateDeclaration() { return this; } void accept(Visitor *v) { v->visit(this); } @@ -279,7 +281,9 @@ public: Abstract isabstract; // 0: fwdref, 1: is abstract class, 2: not abstract Baseok baseok; // set the progress of base classes resolving ObjcClassDeclaration objc; // Data for a class declaration that is needed for the Objective-C integration +#if !IN_LLVM Symbol *cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr +#endif static ClassDeclaration *create(Loc loc, Identifier *id, BaseClasses *baseclasses, Dsymbols *members, bool inObject); Dsymbol *syntaxCopy(Dsymbol *s); diff --git a/dmd/dclass.d b/dmd/dclass.d index 2ff5800e70..280bcd52c4 100644 --- a/dmd/dclass.d +++ b/dmd/dclass.d @@ -223,7 +223,10 @@ extern (C++) class ClassDeclaration : AggregateDeclaration */ ObjcClassDeclaration objc; +version (IN_LLVM) {} else +{ Symbol* cpp_type_info_ptr_sym; // cached instance of class Id.cpp_type_info_ptr +} final extern (D) this(const ref Loc loc, Identifier id, BaseClasses* baseclasses, Dsymbols* members, bool inObject) { diff --git a/dmd/declaration.h b/dmd/declaration.h index ad09b9e30b..0791767008 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -543,7 +543,9 @@ public: // Support for NRVO (named return value optimization) bool nrvo_can; // true means we can do it VarDeclaration *nrvo_var; // variable to replace with shidden +#if !IN_LLVM Symbol *shidden; // hidden pointer passed to function +#endif ReturnStatements *returns; diff --git a/dmd/denum.d b/dmd/denum.d index 4122293e26..2542805c4f 100644 --- a/dmd/denum.d +++ b/dmd/denum.d @@ -360,7 +360,10 @@ extern (C++) final class EnumDeclaration : ScopeDsymbol return this; } +version (IN_LLVM) {} else +{ Symbol* sinit; +} override void accept(Visitor v) { diff --git a/dmd/dmodule.d b/dmd/dmodule.d index 5d0f313cd5..3a53aa7c31 100644 --- a/dmd/dmodule.d +++ b/dmd/dmodule.d @@ -1491,17 +1491,6 @@ else } // Back end - int doppelganger; // sub-module - Symbol* cov; // private uint[] __coverage; - uint* covb; // bit array of valid code line numbers - Symbol* sictor; // module order independent constructor - Symbol* sctor; // module constructor - Symbol* sdtor; // module destructor - Symbol* ssharedctor; // module shared constructor - Symbol* sshareddtor; // module shared destructor - Symbol* stest; // module unit test - Symbol* sfilename; // symbol for filename - version (IN_LLVM) { //llvm::Module* genLLVMModule(llvm::LLVMContext& context); @@ -1516,6 +1505,19 @@ version (IN_LLVM) void* d_cover_data; // llvm::GlobalVariable* --> private uint[] _d_cover_data; Array!size_t d_cover_valid_init; // initializer for _d_cover_valid } +else +{ + int doppelganger; // sub-module + Symbol* cov; // private uint[] __coverage; + uint* covb; // bit array of valid code line numbers + Symbol* sictor; // module order independent constructor + Symbol* sctor; // module constructor + Symbol* sdtor; // module destructor + Symbol* ssharedctor; // module shared constructor + Symbol* sshareddtor; // module shared destructor + Symbol* stest; // module unit test + Symbol* sfilename; // symbol for filename +} override inout(Module) isModule() inout { diff --git a/dmd/dsymbol.d b/dmd/dsymbol.d index f3133aaa88..3009410314 100644 --- a/dmd/dsymbol.d +++ b/dmd/dsymbol.d @@ -235,8 +235,16 @@ extern (C++) class Dsymbol : ASTNode Dsymbol parent; /// C++ namespace this symbol belongs to CPPNamespaceDeclaration cppnamespace; +version (IN_LLVM) +{ + void* ir; // IrDsymbol* + uint llvmInternal; +} +else +{ Symbol* csym; // symbol for code generator Symbol* isym; // import version of csym +} const(char)* comment; // documentation comment for this Dsymbol const Loc loc; // where defined Scope* _scope; // !=null means context to use for semantic() @@ -251,14 +259,6 @@ extern (C++) class Dsymbol : ASTNode // (only use this with ddoc) UnitTestDeclaration ddocUnittest; -version (IN_LLVM) -{ - // llvm stuff - uint llvmInternal; - - void* ir; // IrDsymbol* -} - final extern (D) this() { //printf("Dsymbol::Dsymbol(%p)\n", this); diff --git a/dmd/dsymbol.h b/dmd/dsymbol.h index 790b3597e4..3a24e00d18 100644 --- a/dmd/dsymbol.h +++ b/dmd/dsymbol.h @@ -82,7 +82,7 @@ class OverloadSet; struct AA; #ifdef IN_GCC typedef union tree_node Symbol; -#else +#elif !IN_LLVM struct Symbol; #endif @@ -157,9 +157,14 @@ public: Dsymbol *parent; /// C++ namespace this symbol belongs to CPPNamespaceDeclaration *namespace_; +#if IN_LLVM + IrDsymbol *ir; + uint32_t llvmInternal; +#else Symbol *csym; // symbol for code generator Symbol *isym; // import version of csym - const utf8_t *comment; // documentation comment for this Dsymbol +#endif + const utf8_t *comment; // documentation comment for this Dsymbol Loc loc; // where defined Scope *_scope; // !=NULL means context to use for semantic() const utf8_t *prettystring; @@ -169,13 +174,6 @@ public: UserAttributeDeclaration *userAttribDecl; // user defined attributes UnitTestDeclaration *ddocUnittest; // !=NULL means there's a ddoc unittest associated with this symbol (only use this with ddoc) -#if IN_LLVM - // llvm stuff - uint32_t llvmInternal; - - IrDsymbol *ir; -#endif - static Dsymbol *create(Identifier *); const char *toChars() const; virtual const char *toPrettyCharsHelper(); // helper to print fully qualified (template) arguments diff --git a/dmd/enum.h b/dmd/enum.h index 5d49a5e98f..b55ac17428 100644 --- a/dmd/enum.h +++ b/dmd/enum.h @@ -56,7 +56,9 @@ public: EnumDeclaration *isEnumDeclaration() { return this; } +#if !IN_LLVM Symbol *sinit; +#endif void accept(Visitor *v) { v->visit(this); } }; diff --git a/dmd/expression.d b/dmd/expression.d index 47b587d4fd..35000d1068 100644 --- a/dmd/expression.d +++ b/dmd/expression.d @@ -3056,8 +3056,10 @@ version (IN_LLVM) // to the memory used to build the literal for resolving such references. void* inProgressMemory; // llvm::Value* } - +else +{ Symbol* sym; /// back end symbol to initialize with literal +} /** pointer to the origin instance of the expression. * once a new expression is created, origin is set to 'this'. diff --git a/dmd/expression.h b/dmd/expression.h index 05a680175b..2dea779555 100644 --- a/dmd/expression.h +++ b/dmd/expression.h @@ -41,7 +41,7 @@ class StringExp; struct UnionExp; #ifdef IN_GCC typedef union tree_node Symbol; -#else +#elif !IN_LLVM struct Symbol; // back end symbol #endif @@ -463,10 +463,10 @@ public: // now contain pointers to themselves. While in toElem, contains a pointer // to the memory used to build the literal for resolving such references. llvm::Value *inProgressMemory; +#else + Symbol *sym; // back end symbol to initialize with literal #endif - Symbol *sym; // back end symbol to initialize with literal - /** pointer to the origin instance of the expression. * once a new expression is created, origin is set to 'this'. * anytime when an expression copy is created, 'origin' pointer is set to diff --git a/dmd/func.d b/dmd/func.d index a87c640f6b..87f2856bdb 100644 --- a/dmd/func.d +++ b/dmd/func.d @@ -296,7 +296,10 @@ version (IN_LLVM) // Support for NRVO (named return value optimization) bool nrvo_can = true; /// true means we can do NRVO VarDeclaration nrvo_var; /// variable to replace with shidden +version (IN_LLVM) {} else +{ Symbol* shidden; /// hidden pointer passed to function +} ReturnStatements* returns; diff --git a/dmd/gluelayer.d b/dmd/gluelayer.d index 65e197a48f..492c54eec8 100644 --- a/dmd/gluelayer.d +++ b/dmd/gluelayer.d @@ -22,7 +22,6 @@ import dmd.root.file; version (IN_LLVM) { - struct Symbol; struct code; struct block; struct Blockx; diff --git a/dmd/inline.d b/dmd/inline.d index 6f7ae2c94a..964a263821 100644 --- a/dmd/inline.d +++ b/dmd/inline.d @@ -663,8 +663,11 @@ public: auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init); memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration)); vto.parent = ids.parent; +version (IN_LLVM) {} else +{ vto.csym = null; vto.isym = null; +} ids.from.push(vd); ids.to.push(vto); @@ -817,8 +820,11 @@ public: auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init); memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration)); vto.parent = ids.parent; +version (IN_LLVM) {} else +{ vto.csym = null; vto.isym = null; +} ids.from.push(vd); ids.to.push(vto); @@ -846,8 +852,11 @@ public: auto vto = new VarDeclaration(vd.loc, vd.type, vd.ident, vd._init); memcpy(cast(void*)vto, cast(void*)vd, __traits(classInstanceSize, VarDeclaration)); vto.parent = ids.parent; +version (IN_LLVM) {} else +{ vto.csym = null; vto.isym = null; +} ids.from.push(vd); ids.to.push(vto); diff --git a/dmd/module.h b/dmd/module.h index b52a3e46cb..4a2b2ba14c 100644 --- a/dmd/module.h +++ b/dmd/module.h @@ -147,6 +147,20 @@ public: // Back end +#if IN_LLVM + llvm::Module *genLLVMModule(llvm::LLVMContext &context); + void checkAndAddOutputFile(const FileName &file); + void makeObjectFilenameUnique(); + + bool llvmForceLogging; + bool noModuleInfo; /// Do not emit any module metadata. + + // Coverage analysis + llvm::GlobalVariable + *d_cover_valid; // private immutable size_t[] _d_cover_valid; + llvm::GlobalVariable *d_cover_data; // private uint[] _d_cover_data; + Array d_cover_valid_init; // initializer for _d_cover_valid +#else int doppelganger; // sub-module Symbol *cov; // private uint[] __coverage; unsigned *covb; // bit array of valid code line numbers @@ -159,20 +173,6 @@ public: Symbol *stest; // module unit test Symbol *sfilename; // symbol for filename - -#if IN_LLVM - // LDC - llvm::Module* genLLVMModule(llvm::LLVMContext& context); - void checkAndAddOutputFile(const FileName &file); - void makeObjectFilenameUnique(); - - bool llvmForceLogging; - bool noModuleInfo; /// Do not emit any module metadata. - - // Coverage analysis - llvm::GlobalVariable* d_cover_valid; // private immutable size_t[] _d_cover_valid; - llvm::GlobalVariable* d_cover_data; // private uint[] _d_cover_data; - Array d_cover_valid_init; // initializer for _d_cover_valid #endif Module *isModule() { return this; } diff --git a/gen/toir.cpp b/gen/toir.cpp index a4c7d3b88f..f34ab1786c 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2924,14 +2924,3 @@ bool toInPlaceConstruction(DLValue *lhs, Expression *rhs) { return false; } - -//////////////////////////////////////////////////////////////////////////////// - -// FIXME: Implement & place in right module -Symbol *toModuleAssert(Module *m) { return nullptr; } - -// FIXME: Implement & place in right module -Symbol *toModuleUnittest(Module *m) { return nullptr; } - -// FIXME: Implement & place in right module -Symbol *toModuleArray(Module *m) { return nullptr; }