mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
Split interfaces to the glue layer and backend into different files
This commit is contained in:
parent
d2c607f210
commit
be9c324e28
21 changed files with 166 additions and 127 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
|||
src/cdxxx.c
|
||||
src/debtab.c
|
||||
src/dmd
|
||||
src/dmd_frontend
|
||||
src/ddmd
|
||||
src/dmd.conf
|
||||
src/elxxx.c
|
||||
|
@ -18,6 +19,7 @@ test/test_results
|
|||
*.obj
|
||||
src/idgen.exe
|
||||
src/dmd.exe
|
||||
src/dmd_frontend.exe
|
||||
src/optabgen.exe
|
||||
src/verstr.h
|
||||
*.map
|
||||
|
|
|
@ -11,7 +11,7 @@ module ddmd.aggregate;
|
|||
import core.stdc.stdio;
|
||||
import ddmd.access;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.clone;
|
||||
import ddmd.dclass;
|
||||
import ddmd.declaration;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
module ddmd.arraytypes;
|
||||
|
||||
import ddmd.aggregate;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.dclass;
|
||||
import ddmd.declaration;
|
||||
import ddmd.dmodule;
|
||||
|
|
|
@ -8,33 +8,14 @@
|
|||
|
||||
module ddmd.backend;
|
||||
|
||||
import ddmd.aggregate;
|
||||
import ddmd.dmodule;
|
||||
import ddmd.dscope;
|
||||
import ddmd.expression;
|
||||
import ddmd.lib;
|
||||
import ddmd.mtype;
|
||||
import ddmd.root.file;
|
||||
|
||||
struct Symbol;
|
||||
struct code;
|
||||
struct block;
|
||||
struct Blockx;
|
||||
struct elem;
|
||||
|
||||
extern extern (C++) void backend_init();
|
||||
extern extern (C++) void backend_term();
|
||||
extern extern (C++) void obj_start(char* srcfile);
|
||||
extern extern (C++) void obj_end(Library library, File* objfile);
|
||||
extern extern (C++) void obj_write_deferred(Library library);
|
||||
|
||||
extern extern (C++) void genObjFile(Module m, bool multiobj);
|
||||
|
||||
extern extern (C++) Symbol* toInitializer(AggregateDeclaration sd);
|
||||
|
||||
// type.h
|
||||
|
||||
|
||||
alias tym_t = uint;
|
||||
alias mangle_t = ubyte;
|
||||
alias targ_size_t = ulong;
|
||||
|
|
|
@ -11,7 +11,7 @@ module ddmd.dclass;
|
|||
import core.stdc.string;
|
||||
import ddmd.aggregate;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.clone;
|
||||
import ddmd.declaration;
|
||||
import ddmd.dmodule;
|
||||
|
|
|
@ -10,7 +10,7 @@ module ddmd.denum;
|
|||
|
||||
import core.stdc.stdio;
|
||||
import ddmd.access;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.declaration;
|
||||
import ddmd.dmodule;
|
||||
import ddmd.doc;
|
||||
|
|
|
@ -13,7 +13,7 @@ import core.stdc.stdlib;
|
|||
import core.stdc.string;
|
||||
import ddmd.aggregate;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.dimport;
|
||||
import ddmd.dmacro;
|
||||
import ddmd.doc;
|
||||
|
|
|
@ -11,7 +11,7 @@ module ddmd.dstruct;
|
|||
import ddmd.aggregate;
|
||||
import ddmd.argtypes;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.clone;
|
||||
import ddmd.declaration;
|
||||
import ddmd.dmodule;
|
||||
|
|
|
@ -15,7 +15,7 @@ import ddmd.aggregate;
|
|||
import ddmd.aliasthis;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.attrib;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.dclass;
|
||||
import ddmd.declaration;
|
||||
import ddmd.denum;
|
||||
|
|
|
@ -15,7 +15,7 @@ import ddmd.aggregate;
|
|||
import ddmd.aliasthis;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.attrib;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.dcast;
|
||||
import ddmd.dclass;
|
||||
import ddmd.declaration;
|
||||
|
|
|
@ -19,7 +19,7 @@ import ddmd.argtypes;
|
|||
import ddmd.arrayop;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.attrib;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.canthrow;
|
||||
import ddmd.clone;
|
||||
import ddmd.complex;
|
||||
|
|
|
@ -13,7 +13,7 @@ import core.stdc.string;
|
|||
import ddmd.aggregate;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.attrib;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.builtin;
|
||||
import ddmd.ctfeexpr;
|
||||
import ddmd.dclass;
|
||||
|
@ -48,8 +48,6 @@ import ddmd.target;
|
|||
import ddmd.tokens;
|
||||
import ddmd.visitor;
|
||||
|
||||
extern extern (C++) RET retStyle(TypeFunction tf);
|
||||
|
||||
enum ILS : int
|
||||
{
|
||||
ILSuninitialized, // not computed yet
|
||||
|
|
121
src/gluelayer.d
Normal file
121
src/gluelayer.d
Normal file
|
@ -0,0 +1,121 @@
|
|||
// Compiler implementation of the D programming language
|
||||
// Copyright (c) 1999-2015 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
module ddmd.gluelayer;
|
||||
|
||||
import ddmd.aggregate;
|
||||
import ddmd.dmodule;
|
||||
import ddmd.dscope;
|
||||
import ddmd.dsymbol;
|
||||
import ddmd.expression;
|
||||
import ddmd.lib;
|
||||
import ddmd.mtype;
|
||||
import ddmd.statement;
|
||||
import ddmd.root.file;
|
||||
|
||||
version (NoBackend)
|
||||
{
|
||||
struct Symbol;
|
||||
struct code;
|
||||
struct block;
|
||||
struct Blockx;
|
||||
struct elem;
|
||||
struct TYPE;
|
||||
alias type = TYPE;
|
||||
|
||||
// tocsym
|
||||
|
||||
extern (C++) Symbol* toInitializer(AggregateDeclaration ad)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// glue
|
||||
|
||||
extern (C++) void obj_write_deferred(Library library)
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void obj_start(char* srcfile)
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void obj_end(Library library, File* objfile)
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void genObjFile(Module m, bool multiobj)
|
||||
{
|
||||
}
|
||||
|
||||
// msc
|
||||
|
||||
extern (C++) void backend_init()
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void backend_term()
|
||||
{
|
||||
}
|
||||
|
||||
// iasm
|
||||
|
||||
extern (C++) Statement asmSemantic(AsmStatement s, Scope* sc)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// toir
|
||||
|
||||
extern (C++) RET retStyle(TypeFunction tf)
|
||||
{
|
||||
return RETregs;
|
||||
}
|
||||
|
||||
extern (C++) void toObjFile(Dsymbol ds, bool multiobj)
|
||||
{
|
||||
}
|
||||
|
||||
version (OSX)
|
||||
{
|
||||
extern(C++) void objc_initSymbols()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
import ddmd.backend;
|
||||
|
||||
alias Symbol = ddmd.backend.Symbol;
|
||||
alias code = ddmd.backend.code;
|
||||
alias block = ddmd.backend.block;
|
||||
alias Blockx = ddmd.backend.Blockx;
|
||||
alias elem = ddmd.backend.elem;
|
||||
alias type = ddmd.backend.type;
|
||||
|
||||
extern extern (C++) Symbol* toInitializer(AggregateDeclaration sd);
|
||||
|
||||
extern extern (C++) void obj_write_deferred(Library library);
|
||||
extern extern (C++) void obj_start(char* srcfile);
|
||||
extern extern (C++) void obj_end(Library library, File* objfile);
|
||||
extern extern (C++) void genObjFile(Module m, bool multiobj);
|
||||
|
||||
extern extern (C++) void backend_init();
|
||||
extern extern (C++) void backend_term();
|
||||
|
||||
extern extern (C++) Statement asmSemantic(AsmStatement s, Scope* sc);
|
||||
|
||||
extern extern (C++) RET retStyle(TypeFunction tf);
|
||||
extern extern (C++) void toObjFile(Dsymbol ds, bool multiobj);
|
||||
|
||||
version (OSX)
|
||||
{
|
||||
extern(C++) void objc_initSymbols();
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/* Compiler implementation of the D programming language
|
||||
* Copyright (c) 1999-2014 by Digital Mars
|
||||
* All Rights Reserved
|
||||
* http://www.digitalmars.com
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* http://www.boost.org/LICENSE_1_0.txt
|
||||
* https://github.com/D-Programming-Language/dmd/blob/master/src/gluestub.c
|
||||
*/
|
||||
|
||||
module ddmd.gluestub;
|
||||
|
||||
import ddmd.backend;
|
||||
import ddmd.aggregate;
|
||||
import ddmd.dmodule;
|
||||
import ddmd.dscope;
|
||||
import ddmd.dsymbol;
|
||||
import ddmd.lib;
|
||||
import ddmd.mtype;
|
||||
import ddmd.root.file;
|
||||
import ddmd.statement;
|
||||
|
||||
// tocsym
|
||||
|
||||
extern (C++) Symbol* toInitializer(AggregateDeclaration ad)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// glue
|
||||
|
||||
extern (C++) void obj_write_deferred(Library library)
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void obj_start(char* srcfile)
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void obj_end(Library library, File* objfile)
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void genObjFile(Module m, bool multiobj)
|
||||
{
|
||||
}
|
||||
|
||||
// msc
|
||||
|
||||
extern (C++) void backend_init()
|
||||
{
|
||||
}
|
||||
|
||||
extern (C++) void backend_term()
|
||||
{
|
||||
}
|
||||
|
||||
// iasm
|
||||
|
||||
extern (C++) Statement asmSemantic(AsmStatement s, Scope* sc)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// toir
|
||||
|
||||
extern (C++) RET retStyle(TypeFunction tf)
|
||||
{
|
||||
return RETregs;
|
||||
}
|
||||
|
||||
extern (C++) void toObjFile(Dsymbol ds, bool multiobj)
|
||||
{
|
||||
}
|
|
@ -16,7 +16,7 @@ import core.stdc.stdio;
|
|||
import core.stdc.stdlib;
|
||||
import core.stdc.string;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.builtin;
|
||||
import ddmd.cond;
|
||||
import ddmd.dinifile;
|
||||
|
|
|
@ -22,7 +22,7 @@ import ddmd.aliasthis;
|
|||
import ddmd.argtypes;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.attrib;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.complex;
|
||||
import ddmd.ctfeexpr;
|
||||
import ddmd.dcast;
|
||||
|
|
|
@ -18,14 +18,13 @@ import ddmd.dstruct;
|
|||
import ddmd.expression;
|
||||
import ddmd.func;
|
||||
import ddmd.globals;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.id;
|
||||
import ddmd.identifier;
|
||||
import ddmd.mtype;
|
||||
import ddmd.root.outbuffer;
|
||||
import ddmd.root.stringtable;
|
||||
|
||||
extern(C++) void objc_initSymbols();
|
||||
|
||||
struct ObjcSelector
|
||||
{
|
||||
// MARK: Selector
|
||||
|
|
|
@ -179,20 +179,20 @@ endif
|
|||
endif
|
||||
|
||||
|
||||
DMD_SRCS=$(addsuffix .d,access aggregate aliasthis apply argtypes arrayop \
|
||||
arraytypes attrib backend builtin canthrow clone complex cond constfold \
|
||||
FRONT_SRCS=$(addsuffix .d,access aggregate aliasthis apply argtypes arrayop \
|
||||
arraytypes attrib builtin canthrow clone complex cond constfold \
|
||||
cppmangle ctfeexpr dcast dclass declaration delegatize denum dimport \
|
||||
dinifile dinterpret dmacro dmangle dmodule doc dscope dstruct dsymbol \
|
||||
dtemplate dunittest dversion entity errors escape expression func \
|
||||
globals hdrgen id identifier impcnvtab imphint init inline intrange \
|
||||
json lexer lib link mars mtype nogc nspace opover optimize parse sapply \
|
||||
sideeffect statement staticassert target tokens traits utf visitor \
|
||||
typinf irstate toelfdebug toctype)
|
||||
typinf)
|
||||
|
||||
ifeq ($(D_OBJC),1)
|
||||
DMD_SRCS += objc.d
|
||||
FRONT_SRCS += objc.d
|
||||
else
|
||||
DMD_SRCS += objc_stubs.d
|
||||
FRONT_SRCS += objc_stubs.d
|
||||
endif
|
||||
|
||||
ROOT_SRCS = $(addsuffix .d,$(addprefix $(ROOT)/,aav array file filename \
|
||||
|
@ -210,11 +210,15 @@ else
|
|||
endif
|
||||
|
||||
ifeq (osx,$(OS))
|
||||
DMD_SRCS += libmach.d scanmach.d
|
||||
FRONT_SRCS += libmach.d scanmach.d
|
||||
else
|
||||
DMD_SRCS += libelf.d scanelf.d
|
||||
FRONT_SRCS += libelf.d scanelf.d
|
||||
endif
|
||||
|
||||
GLUE_SRCS=$(addsuffix .d,backend irstate toelfdebug toctype gluelayer)
|
||||
|
||||
DMD_SRCS=$(FRONT_SRCS) $(GLUE_SRCS)
|
||||
|
||||
BACK_OBJS = go.o gdag.o gother.o gflow.o gloop.o var.o el.o \
|
||||
glocal.o os.o nteh.o evalu8.o cgcs.o \
|
||||
rtlsym.o cgelem.o cgen.o cgreg.o out.o \
|
||||
|
@ -285,7 +289,7 @@ DEPS = $(patsubst %.o,%.deps,$(DMD_OBJS) $(GLUE_OBJS) $(BACK_OBJS))
|
|||
|
||||
all: dmd
|
||||
|
||||
auto-tester-build: dmd checkwhitespace
|
||||
auto-tester-build: dmd checkwhitespace dmd_frontend
|
||||
.PHONY: auto-tester-build
|
||||
|
||||
glue.a: $(GLUE_OBJS)
|
||||
|
@ -294,6 +298,9 @@ glue.a: $(GLUE_OBJS)
|
|||
backend.a: $(BACK_OBJS)
|
||||
$(AR) rcs backend.a $(BACK_OBJS)
|
||||
|
||||
dmd_frontend: $(FRONT_SRCS) gluelayer.d $(ROOT_SRCS) newdelete.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
|
||||
CC=$(HOST_CC) $(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J. -L-lstdc++ $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^) -version=NoBackend
|
||||
|
||||
ifdef ENABLE_LTO
|
||||
dmd: $(DMD_SRCS) $(ROOT_SRCS) newdelete.o $(GLUE_OBJS) $(BACK_OBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
|
||||
CC=$(HOST_CC) $(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J. -L-lstdc++ $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)
|
||||
|
|
|
@ -15,7 +15,7 @@ import ddmd.aliasthis;
|
|||
import ddmd.arrayop;
|
||||
import ddmd.arraytypes;
|
||||
import ddmd.attrib;
|
||||
import ddmd.backend;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.canthrow;
|
||||
import ddmd.clone;
|
||||
import ddmd.cond;
|
||||
|
@ -54,8 +54,6 @@ import ddmd.target;
|
|||
import ddmd.tokens;
|
||||
import ddmd.visitor;
|
||||
|
||||
extern extern (C++) Statement asmSemantic(AsmStatement s, Scope* sc);
|
||||
|
||||
extern (C++) Identifier fixupLabelName(Scope* sc, Identifier ident)
|
||||
{
|
||||
uint flags = (sc.flags & SCOPEcontract);
|
||||
|
|
|
@ -15,11 +15,10 @@ import ddmd.dstruct;
|
|||
import ddmd.dsymbol;
|
||||
import ddmd.errors;
|
||||
import ddmd.globals;
|
||||
import ddmd.gluelayer;
|
||||
import ddmd.mtype;
|
||||
import ddmd.visitor;
|
||||
|
||||
extern (C++) void toObjFile(Dsymbol ds, bool multiobj);
|
||||
|
||||
/****************************************************
|
||||
* Get the exact TypeInfo.
|
||||
*/
|
||||
|
|
|
@ -136,9 +136,8 @@ DMDMAKE=$(MAKE) -fwin32.mak C=$C TK=$(TK) ROOT=$(ROOT) HOST_DC="$(HOST_DC)"
|
|||
############################### Rule Variables ###############################
|
||||
|
||||
# D front end
|
||||
# mars.obj
|
||||
DMD_SRCS=access.d aggregate.d aliasthis.d apply.d argtypes.d arrayop.d \
|
||||
arraytypes.d attrib.d backend.d builtin.d canthrow.d clone.d complex.d \
|
||||
FRONT_SRCS=access.d aggregate.d aliasthis.d apply.d argtypes.d arrayop.d \
|
||||
arraytypes.d attrib.d builtin.d canthrow.d clone.d complex.d \
|
||||
cond.d constfold.d cppmangle.d ctfeexpr.d dcast.d dclass.d \
|
||||
declaration.d delegatize.d denum.d dimport.d dinifile.d dinterpret.d \
|
||||
dmacro.d dmangle.d dmodule.d doc.d dscope.d dstruct.d dsymbol.d \
|
||||
|
@ -148,7 +147,11 @@ DMD_SRCS=access.d aggregate.d aliasthis.d apply.d argtypes.d arrayop.d \
|
|||
mars.d mtype.d nogc.d nspace.d objc_stubs.d opover.d optimize.d parse.d \
|
||||
sapply.d sideeffect.d statement.d staticassert.d target.d tokens.d \
|
||||
traits.d utf.d visitor.d libomf.d scanomf.d typinf.d \
|
||||
libmscoff.d scanmscoff.d irstate.d toctype.d
|
||||
libmscoff.d scanmscoff.d
|
||||
|
||||
GLUE_SRCS=irstate.d toctype.d backend.d gluelayer.d
|
||||
|
||||
DMD_SRCS=$(FRONT_SRCS) $(GLUE_SRCS)
|
||||
|
||||
# Glue layer
|
||||
GLUEOBJ=glue.obj msc.obj s2ir.obj todt.obj e2ir.obj tocsym.obj \
|
||||
|
@ -188,7 +191,8 @@ GLUESRC= glue.c msc.c s2ir.c todt.c e2ir.c tocsym.c \
|
|||
toobj.c tocvdebug.c toir.h toir.c \
|
||||
irstate.h iasm.c \
|
||||
toelfdebug.d libelf.d scanelf.d libmach.d scanmach.d \
|
||||
tk.c eh.c objc_glue_stubs.c objc_glue.c gluestub.d
|
||||
tk.c eh.c objc_glue_stubs.c objc_glue.c \
|
||||
$(GLUE_SRCS)
|
||||
|
||||
# D back end
|
||||
BACKSRC= $C\cdef.h $C\cc.h $C\oper.h $C\ty.h $C\optabgen.c \
|
||||
|
@ -244,7 +248,7 @@ MAKEFILES=win32.mak posix.mak osmodel.mak
|
|||
|
||||
defaulttarget: debdmd
|
||||
|
||||
auto-tester-build: dmd checkwhitespace
|
||||
auto-tester-build: dmd checkwhitespace dmd_frontend.exe
|
||||
|
||||
dmd: reldmd
|
||||
|
||||
|
@ -272,6 +276,9 @@ backend.lib : $(BACKOBJ)
|
|||
|
||||
LIBS= glue.lib backend.lib
|
||||
|
||||
dmd_frontend.exe: $(FRONT_SRCS) gluelayer.d $(ROOT_SRCS) newdelete.obj verstr.h
|
||||
$(HOST_DC) $(DSRC) -of$@ -vtls -J. -L/STACK:8388608 $(DFLAGS) $(FRONT_SRCS) gluelayer.d $(ROOT_SRCS) newdelete.obj -version=NoBackend
|
||||
|
||||
$(TARGETEXE): $(DMD_SRCS) $(ROOT_SRCS) newdelete.obj $(LIBS) verstr.h
|
||||
$(HOST_DC) $(DSRC) -of$@ -vtls -J. -L/STACK:8388608 $(DFLAGS) $(DMD_SRCS) $(ROOT_SRCS) newdelete.obj $(LIBS)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue