Mercurial > projects > ldc
annotate dmd/module.h @ 1052:12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
The switch allows the optimizer and inliner to run on all modules at once and opens the door for template instantiation improvements that should lower compile time and executable size.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sat, 07 Mar 2009 19:38:00 +0100 |
parents | 31bbc7f3b817 |
children | b30fe7e1dbb9 |
rev | line source |
---|---|
336 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2008 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_MODULE_H | |
12 #define DMD_MODULE_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 #include "dsymbol.h" | |
20 | |
21 struct ModuleInfoDeclaration; | |
22 struct ClassDeclaration; | |
23 struct ModuleDeclaration; | |
24 struct Macro; | |
25 struct Escape; | |
26 struct VarDeclaration; | |
27 struct Library; | |
28 | |
29 // Back end | |
30 #if IN_LLVM | |
31 struct DValue; | |
32 typedef DValue elem; | |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
957
diff
changeset
|
33 namespace llvm { class Module; } |
336 | 34 #else |
35 #ifdef IN_GCC | |
36 union tree_node; typedef union tree_node elem; | |
37 #else | |
38 struct elem; | |
39 #endif | |
40 #endif | |
41 | |
42 struct Package : ScopeDsymbol | |
43 { | |
44 Package(Identifier *ident); | |
45 const char *kind(); | |
46 | |
47 static DsymbolTable *resolve(Array *packages, Dsymbol **pparent, Package **ppkg); | |
48 | |
49 Package *isPackage() { return this; } | |
50 | |
51 virtual void semantic(Scope *sc) { } | |
52 }; | |
53 | |
54 struct Module : Package | |
55 { | |
56 static Module *rootModule; | |
57 static DsymbolTable *modules; // symbol table of all modules | |
58 static Array amodules; // array of all modules | |
59 static Array deferred; // deferred Dsymbol's needing semantic() run on them | |
60 static unsigned dprogress; // progress resolving the deferred list | |
61 static void init(); | |
62 | |
63 static ClassDeclaration *moduleinfo; | |
64 | |
65 | |
66 const char *arg; // original argument name | |
67 ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration | |
68 File *srcfile; // input source file | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
69 |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
70 File *objfile; // output object file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
71 File *docfile; // output doc file |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
72 File *hdrfile; // output hdr file |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
73 |
336 | 74 unsigned errors; // if any errors in file |
75 unsigned numlines; // number of lines in source file | |
76 int isHtml; // if it is an HTML file | |
77 int isDocFile; // if it is a documentation input file, not D source | |
78 int needmoduleinfo; | |
79 #ifdef IN_GCC | |
80 int strictlyneedmoduleinfo; | |
81 #endif | |
82 | |
83 int insearch; | |
84 Identifier *searchCacheIdent; | |
85 Dsymbol *searchCacheSymbol; // cached value of search | |
86 int searchCacheFlags; // cached flags | |
87 | |
88 int semanticstarted; // has semantic() been started? | |
89 int semanticdone; // has semantic() been done? | |
90 int root; // != 0 if this is a 'root' module, | |
91 // i.e. a module that will be taken all the | |
92 // way to an object file | |
93 Module *importedFrom; // module from command line we're imported from, | |
94 // i.e. a module that will be taken all the | |
95 // way to an object file | |
96 | |
97 Array *decldefs; // top level declarations for this Module | |
98 | |
99 Array aimports; // all imported modules | |
100 | |
101 ModuleInfoDeclaration *vmoduleinfo; | |
102 | |
103 unsigned debuglevel; // debug level | |
104 Array *debugids; // debug identifiers | |
105 Array *debugidsNot; // forward referenced debug identifiers | |
106 | |
107 unsigned versionlevel; // version level | |
108 Array *versionids; // version identifiers | |
109 Array *versionidsNot; // forward referenced version identifiers | |
110 | |
111 Macro *macrotable; // document comment macros | |
432 | 112 struct Escape *escapetable; // document comment escapes |
336 | 113 |
604
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
580
diff
changeset
|
114 int doDocComment; // enable generating doc comments for this module |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
580
diff
changeset
|
115 int doHdrGen; // enable generating header file for this module |
a30fc28e8f23
Make creating and deleting of doc and hdr files dependent on whether doc and
Christian Kamm <kamm incasoftware de>
parents:
580
diff
changeset
|
116 |
336 | 117 Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen); |
118 ~Module(); | |
119 | |
120 static Module *load(Loc loc, Array *packages, Identifier *ident); | |
121 | |
122 void toCBuffer(OutBuffer *buf, HdrGenState *hgs); | |
123 const char *kind(); | |
124 void read(Loc loc); // read file | |
125 #if IN_GCC | |
126 void parse(bool dump_source = false); // syntactic parse | |
127 #else | |
128 void parse(); // syntactic parse | |
129 #endif | |
751
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
130 void semantic(Scope* unused_sc = NULL); // semantic analysis |
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
131 void semantic2(Scope* unused_sc = NULL); // pass 2 semantic analysis |
dc8b8b7ea0c1
Fix compile-time warnings. Adjust include in d-asm-i386.
Christian Kamm <kamm incasoftware de>
parents:
703
diff
changeset
|
132 void semantic3(Scope* unused_sc = NULL); // pass 3 semantic analysis |
336 | 133 void inlineScan(); // scan for functions to inline |
134 #ifdef _DH | |
135 void genhdrfile(); // generate D import file | |
136 #endif | |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
137 // void gensymfile(); |
336 | 138 void gendocfile(); |
139 int needModuleInfo(); | |
140 Dsymbol *search(Loc loc, Identifier *ident, int flags); | |
141 void deleteObjFile(); | |
142 void addDeferredSemantic(Dsymbol *s); | |
143 void runDeferredSemantic(); | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
849
diff
changeset
|
144 int imports(Module *m); |
336 | 145 |
146 // Back end | |
147 | |
148 int doppelganger; // sub-module | |
149 Symbol *cov; // private uint[] __coverage; | |
150 unsigned *covb; // bit array of valid code line numbers | |
151 | |
152 Symbol *sictor; // module order independent constructor | |
153 Symbol *sctor; // module constructor | |
154 Symbol *sdtor; // module destructor | |
155 Symbol *stest; // module unit test | |
156 | |
157 Symbol *sfilename; // symbol for filename | |
158 | |
159 Symbol *massert; // module assert function | |
160 Symbol *toModuleAssert(); // get module assert function | |
161 | |
162 Symbol *marray; // module array bounds function | |
163 Symbol *toModuleArray(); // get module array bounds function | |
164 | |
165 | |
166 static Symbol *gencritsec(); | |
167 elem *toEfilename(); | |
168 elem *toEmodulename(); | |
169 | |
170 Symbol *toSymbol(); | |
171 void genmoduleinfo(); | |
172 | |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
604
diff
changeset
|
173 // LDC |
1052
12ea38902e83
Add '-singleobj' command line switch that will tell LDC to link LLVM modules internally and only emit a single object file.
Christian Kamm <kamm incasoftware de>
parents:
957
diff
changeset
|
174 llvm::Module* genLLVMModule(int multiobj); |
580
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
175 void buildTargetFiles(); |
7824c21a58e3
Restructure path handling a bit. Fixes #66.
Christian Kamm <kamm incasoftware de>
parents:
486
diff
changeset
|
176 File* buildFilePath(char* forcename, char* path, char* ext); |
336 | 177 Module *isModule() { return this; } |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
178 |
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
432
diff
changeset
|
179 bool llvmForceLogging; |
703
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
180 |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
181 // array ops emitted in this module already |
06576ece1a1b
Changed premake.lua to work with mingw.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
676
diff
changeset
|
182 StringTable arrayfuncs; |
336 | 183 }; |
184 | |
185 | |
186 struct ModuleDeclaration | |
187 { | |
188 Identifier *id; | |
189 Array *packages; // array of Identifier's representing packages | |
190 | |
191 ModuleDeclaration(Array *packages, Identifier *id); | |
192 | |
193 char *toChars(); | |
194 }; | |
195 | |
196 #endif /* DMD_MODULE_H */ |