Mercurial > projects > ldc
annotate dmd/mars.h @ 217:0806379a5eca trunk
[svn r233] Added: -oq command line option for writing fully qualified object names.
Added: started support for x86 80bit floating point.
Changed: aggregates passed by value now use the llvm 'byval' parameter attribute, also lays ground work for
using other attributes.
Changed: eliminated a lot more std::vectorS, these showed up pretty much at the top when profiling!
Changed: performed other misc. cleanups.
Changed: halt expression now call the new llvm trap intrinsic instead of an assert(0).
Changed: dstress suite now passes -O0 by default, this only eliminates unreferenced globals, which speeds up
linking quite a bit.
author | lindquist |
---|---|
date | Thu, 05 Jun 2008 06:38:36 +0200 |
parents | 5acec6b2eef8 |
children | ccc2e6898a78 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2007 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_MARS_H | |
12 #define DMD_MARS_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include <stdint.h> | |
19 #include <string> | |
20 #include <cstdarg> | |
21 | |
22 #ifdef __DMC__ | |
23 #ifdef DEBUG | |
24 #undef assert | |
25 #define assert(e) (static_cast<void>((e) || (printf("assert %s(%d) %s\n", __FILE__, __LINE__, #e), halt()))) | |
26 #endif | |
27 #endif | |
28 | |
29 #ifdef IN_GCC | |
30 /* Changes for the GDC compiler by David Friedman */ | |
31 #endif | |
32 | |
33 #define V2 0 // Version 2.0 features | |
34 #define BREAKABI 1 // 0 if not ready to break the ABI just yet | |
35 | |
36 struct Array; | |
37 | |
38 // Put command line switches in here | |
39 struct Param | |
40 { | |
41 char obj; // write object file | |
42 char link; // perform link | |
43 char trace; // insert profiling hooks | |
44 char quiet; // suppress non-error messages | |
45 char verbose; // verbose compile | |
46 char symdebug; // insert debug symbolic information | |
47 char optimize; // run optimizer | |
48 char optimizeLevel; // optimization level | |
49 char cpu; // target CPU | |
50 char is64bit; // generate 64 bit code | |
51 char isLE; // generate little endian code | |
52 char isLinux; // generate code for linux | |
53 char isWindows; // generate code for Windows | |
54 char scheduler; // which scheduler to use | |
55 char useDeprecated; // allow use of deprecated features | |
56 char useAssert; // generate runtime code for assert()'s | |
57 char useInvariants; // generate class invariant checks | |
58 char useIn; // generate precondition checks | |
59 char useOut; // generate postcondition checks | |
60 char useArrayBounds; // generate array bounds checks | |
61 char useSwitchError; // check for switches without a default | |
62 char useUnitTests; // generate unittest code | |
63 char useInline; // inline expand functions | |
64 char release; // build release version | |
65 char preservePaths; // !=0 means don't strip path from source file | |
66 char warnings; // enable warnings | |
67 char pic; // generate position-independent-code for shared libs | |
68 char cov; // generate code coverage data | |
69 char nofloat; // code should not pull in floating point support | |
70 char noruntime; // code is not allowed to make implicit calls to the runtime | |
71 char novalidate;// no bitcode validation | |
72 char Dversion; // D version number | |
73 char ignoreUnsupportedPragmas; // rather than error on them | |
74 | |
75 char *argv0; // program name | |
76 Array *imppath; // array of char*'s of where to look for import modules | |
77 Array *fileImppath; // array of char*'s of where to look for file import modules | |
78 char *runtimeImppath; // char* of where to look for the core runtime | |
79 char *objdir; // .obj file output directory | |
80 char *objname; // .obj file output name | |
81 | |
82 char doDocComments; // process embedded documentation comments | |
83 char *docdir; // write documentation file to docdir directory | |
84 char *docname; // write documentation file to docname | |
85 Array *ddocfiles; // macro include files for Ddoc | |
86 | |
87 char doHdrGeneration; // process embedded documentation comments | |
88 char *hdrdir; // write 'header' file to docdir directory | |
89 char *hdrname; // write 'header' file to docname | |
90 | |
91 unsigned debuglevel; // debug level | |
92 Array *debugids; // debug identifiers | |
93 | |
94 unsigned versionlevel; // version level | |
95 Array *versionids; // version identifiers | |
96 | |
97 bool dump_source; | |
98 | |
99 char *defaultlibname; // default library for non-debug builds | |
100 char *debuglibname; // default library for debug builds | |
101 | |
102 char *xmlname; // filename for XML output | |
103 | |
104 // Hidden debug switches | |
105 char debuga; | |
106 char debugb; | |
107 char debugc; | |
108 char debugf; | |
109 char debugr; | |
110 char debugw; | |
111 char debugx; | |
112 char debugy; | |
113 | |
114 char run; // run resulting executable | |
115 size_t runargs_length; | |
116 char** runargs; // arguments for executable | |
117 | |
118 // Linker stuff | |
119 Array *objfiles; | |
120 Array *linkswitches; | |
121 Array *libfiles; | |
122 char *deffile; | |
123 char *resfile; | |
124 char *exefile; | |
125 | |
126 // LLVM stuff | |
127 char *llvmArch; | |
128 char forceBE; | |
129 char *tt_arch; | |
130 char *tt_os; | |
131 char *data_layout; | |
132 char disassemble; | |
133 char llvmInline; | |
134 char llvmAnnotate; | |
135 char *runtimePath; | |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
159
diff
changeset
|
136 char useFP80; |
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
159
diff
changeset
|
137 char fqnPaths; // use fully qualified object names |
159 | 138 }; |
139 | |
140 struct Global | |
141 { | |
142 char *mars_ext; | |
143 char *sym_ext; | |
144 char *obj_ext; | |
145 char *ll_ext; | |
146 char *bc_ext; | |
147 char *nativeobj_ext; | |
148 char *doc_ext; // for Ddoc generated files | |
149 char *ddoc_ext; // for Ddoc macro include files | |
150 char *hdr_ext; // for D 'header' import files | |
151 char *copyright; | |
152 char *written; | |
153 Array *path; // Array of char*'s which form the import lookup path | |
154 Array *filePath; // Array of char*'s which form the file import lookup path | |
155 int structalign; | |
156 char *version; | |
157 char *llvmdc_version; | |
158 | |
159 Param params; | |
160 unsigned errors; // number of errors reported so far | |
161 unsigned gag; // !=0 means gag reporting of errors | |
162 | |
163 Global(); | |
164 }; | |
165 | |
166 extern Global global; | |
167 | |
168 #if __GNUC__ | |
169 //#define memicmp strncasecmp | |
170 //#define stricmp strcasecmp | |
171 #endif | |
172 | |
173 #ifdef __DMC__ | |
174 typedef _Complex long double complex_t; | |
175 #else | |
176 #ifndef IN_GCC | |
177 #include "complex_t.h" | |
178 #endif | |
179 #ifdef __APPLE__ | |
180 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
181 #define integer_t dmd_integer_t | |
182 #endif | |
183 #endif | |
184 | |
185 // Be careful not to care about sign when using integer_t | |
186 typedef uint64_t integer_t; | |
187 | |
188 // Signed and unsigned variants | |
189 typedef int64_t sinteger_t; | |
190 typedef uint64_t uinteger_t; | |
191 | |
192 typedef int8_t d_int8; | |
193 typedef uint8_t d_uns8; | |
194 typedef int16_t d_int16; | |
195 typedef uint16_t d_uns16; | |
196 typedef int32_t d_int32; | |
197 typedef uint32_t d_uns32; | |
198 typedef int64_t d_int64; | |
199 typedef uint64_t d_uns64; | |
200 | |
201 typedef float d_float32; | |
202 typedef double d_float64; | |
203 typedef long double d_float80; | |
204 | |
205 typedef d_uns8 d_char; | |
206 typedef d_uns16 d_wchar; | |
207 typedef d_uns32 d_dchar; | |
208 | |
209 #ifdef IN_GCC | |
210 #include "d-gcc-real.h" | |
211 #else | |
212 typedef long double real_t; | |
213 #endif | |
214 | |
215 // Modify OutBuffer::writewchar to write the correct size of wchar | |
216 #if _WIN32 | |
217 #define writewchar writeword | |
218 #else | |
219 // This needs a configuration test... | |
220 #define writewchar write4 | |
221 #endif | |
222 | |
223 #ifdef IN_GCC | |
224 #include "d-gcc-complex_t.h" | |
225 #endif | |
226 | |
227 struct Module; | |
228 | |
229 //typedef unsigned Loc; // file location | |
230 struct Loc | |
231 { | |
232 char *filename; | |
233 unsigned linnum; | |
234 | |
235 Loc() | |
236 { | |
237 linnum = 0; | |
238 filename = NULL; | |
239 } | |
240 | |
241 Loc(int x) | |
242 { | |
243 linnum = x; | |
244 filename = NULL; | |
245 } | |
246 | |
247 Loc(Module *mod, unsigned linnum); | |
248 | |
249 char *toChars() const; | |
250 }; | |
251 | |
252 #ifndef GCC_SAFE_DMD | |
253 #define TRUE 1 | |
254 #define FALSE 0 | |
255 #endif | |
256 | |
257 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
258 // in interface vtbl[]'s | |
259 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
260 // in the inheritance graph multiple | |
261 // times, only one is used | |
262 | |
263 enum LINK | |
264 { | |
265 LINKdefault, | |
266 LINKd, | |
267 LINKc, | |
268 LINKcpp, | |
269 LINKwindows, | |
270 LINKpascal, | |
271 }; | |
272 | |
273 enum DYNCAST | |
274 { | |
275 DYNCAST_OBJECT, | |
276 DYNCAST_EXPRESSION, | |
277 DYNCAST_DSYMBOL, | |
278 DYNCAST_TYPE, | |
279 DYNCAST_IDENTIFIER, | |
280 DYNCAST_TUPLE, | |
281 }; | |
282 | |
283 enum MATCH | |
284 { | |
285 MATCHnomatch, // no match | |
286 MATCHconvert, // match with conversions | |
287 #if V2 | |
288 MATCHconst, // match with conversion to const | |
289 #endif | |
290 MATCHexact // exact match | |
291 }; | |
292 | |
293 void error(Loc loc, const char *format, ...); | |
294 void verror(Loc loc, const char *format, va_list); | |
295 void fatal(); | |
296 void err_nomem(); | |
297 int runLINK(); | |
298 void deleteExeFile(); | |
299 int runProgram(); | |
300 void inifile(char *argv0, char *inifile); | |
301 void halt(); | |
302 | |
303 /*** Where to send error messages ***/ | |
304 #if IN_GCC | |
305 #define stdmsg stderr | |
306 #else | |
307 #define stdmsg stdout | |
308 #endif | |
309 | |
310 #endif /* DMD_MARS_H */ |