Mercurial > projects > ldc
annotate dmd/mars.h @ 547:b0005772a88e
Add -enable/-disable for specific features.
Allow setting target os with -t.
Clean up the help message.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 26 Aug 2008 19:31:47 +0200 |
parents | 7e2867ed70d9 |
children | cbe08531430f |
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> | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
19 #include <stdarg.h> |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
20 #define __STDC_FORMAT_MACROS 1 |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
21 #include <inttypes.h> |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
22 #include <stdarg.h> |
159 | 23 |
24 #ifdef __DMC__ | |
25 #ifdef DEBUG | |
26 #undef assert | |
27 #define assert(e) (static_cast<void>((e) || (printf("assert %s(%d) %s\n", __FILE__, __LINE__, #e), halt()))) | |
28 #endif | |
29 #endif | |
30 | |
31 #ifdef IN_GCC | |
32 /* Changes for the GDC compiler by David Friedman */ | |
33 #endif | |
34 | |
336 | 35 #define DMDV2 0 // Version 2.0 features |
159 | 36 #define BREAKABI 1 // 0 if not ready to break the ABI just yet |
37 | |
38 struct Array; | |
39 | |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
40 // LLVMDC |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
41 enum ARCH |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
42 { |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
43 ARCHx86, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
44 ARCHx86_64, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
45 ARCHppc, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
46 ARCHppc_64 |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
47 }; |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
48 |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
49 enum OS |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
50 { |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
51 OSLinux, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
52 OSWindows, |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
53 OSMacOSX |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
54 }; |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
55 |
159 | 56 // Put command line switches in here |
57 struct Param | |
58 { | |
59 char obj; // write object file | |
60 char link; // perform link | |
61 char trace; // insert profiling hooks | |
62 char quiet; // suppress non-error messages | |
63 char verbose; // verbose compile | |
64 char symdebug; // insert debug symbolic information | |
65 char optimize; // run optimizer | |
66 char optimizeLevel; // optimization level | |
534
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
67 ARCH cpu; // target CPU |
7e2867ed70d9
Get rid of isLinux and isWindows in favor of global.params.os.
Christian Kamm <kamm incasoftware de>
parents:
445
diff
changeset
|
68 OS os; // target OS |
159 | 69 char is64bit; // generate 64 bit code |
70 char isLE; // generate little endian code | |
71 char scheduler; // which scheduler to use | |
72 char useDeprecated; // allow use of deprecated features | |
73 char useAssert; // generate runtime code for assert()'s | |
74 char useInvariants; // generate class invariant checks | |
75 char useIn; // generate precondition checks | |
76 char useOut; // generate postcondition checks | |
77 char useArrayBounds; // generate array bounds checks | |
78 char useSwitchError; // check for switches without a default | |
79 char useUnitTests; // generate unittest code | |
80 char useInline; // inline expand functions | |
81 char preservePaths; // !=0 means don't strip path from source file | |
82 char warnings; // enable warnings | |
83 char pic; // generate position-independent-code for shared libs | |
84 char cov; // generate code coverage data | |
85 char nofloat; // code should not pull in floating point support | |
86 char noruntime; // code is not allowed to make implicit calls to the runtime | |
87 char novalidate;// no bitcode validation | |
88 char Dversion; // D version number | |
89 char ignoreUnsupportedPragmas; // rather than error on them | |
90 | |
91 char *argv0; // program name | |
92 Array *imppath; // array of char*'s of where to look for import modules | |
93 Array *fileImppath; // array of char*'s of where to look for file import modules | |
94 char *runtimeImppath; // char* of where to look for the core runtime | |
95 char *objdir; // .obj file output directory | |
96 char *objname; // .obj file output name | |
97 | |
98 char doDocComments; // process embedded documentation comments | |
99 char *docdir; // write documentation file to docdir directory | |
100 char *docname; // write documentation file to docname | |
101 Array *ddocfiles; // macro include files for Ddoc | |
102 | |
103 char doHdrGeneration; // process embedded documentation comments | |
104 char *hdrdir; // write 'header' file to docdir directory | |
105 char *hdrname; // write 'header' file to docname | |
106 | |
107 unsigned debuglevel; // debug level | |
108 Array *debugids; // debug identifiers | |
109 | |
110 unsigned versionlevel; // version level | |
111 Array *versionids; // version identifiers | |
112 | |
113 bool dump_source; | |
114 | |
115 char *defaultlibname; // default library for non-debug builds | |
116 char *debuglibname; // default library for debug builds | |
117 | |
118 char *xmlname; // filename for XML output | |
119 | |
120 // Hidden debug switches | |
121 char debuga; | |
122 char debugb; | |
123 char debugc; | |
124 char debugf; | |
125 char debugr; | |
126 char debugw; | |
127 char debugx; | |
128 char debugy; | |
129 | |
130 char run; // run resulting executable | |
131 size_t runargs_length; | |
132 char** runargs; // arguments for executable | |
133 | |
134 // Linker stuff | |
135 Array *objfiles; | |
136 Array *linkswitches; | |
137 Array *libfiles; | |
138 char *deffile; | |
139 char *resfile; | |
140 char *exefile; | |
141 | |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
237
diff
changeset
|
142 // LLVMDC stuff |
159 | 143 char *llvmArch; |
144 char forceBE; | |
145 char *tt_arch; | |
146 char *tt_os; | |
147 char *data_layout; | |
148 char disassemble; | |
149 char llvmInline; | |
150 char llvmAnnotate; | |
151 char *runtimePath; | |
220
ccc2e6898a78
[svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
217
diff
changeset
|
152 char useInlineAsm; |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
159
diff
changeset
|
153 char fqnPaths; // use fully qualified object names |
159 | 154 }; |
155 | |
156 struct Global | |
157 { | |
158 char *mars_ext; | |
159 char *sym_ext; | |
160 char *obj_ext; | |
161 char *ll_ext; | |
162 char *bc_ext; | |
163 char *nativeobj_ext; | |
164 char *doc_ext; // for Ddoc generated files | |
165 char *ddoc_ext; // for Ddoc macro include files | |
166 char *hdr_ext; // for D 'header' import files | |
167 char *copyright; | |
168 char *written; | |
169 Array *path; // Array of char*'s which form the import lookup path | |
170 Array *filePath; // Array of char*'s which form the file import lookup path | |
171 int structalign; | |
172 char *version; | |
173 char *llvmdc_version; | |
174 | |
175 Param params; | |
176 unsigned errors; // number of errors reported so far | |
177 unsigned gag; // !=0 means gag reporting of errors | |
178 | |
179 Global(); | |
180 }; | |
181 | |
182 extern Global global; | |
183 | |
184 #if __GNUC__ | |
185 //#define memicmp strncasecmp | |
186 //#define stricmp strcasecmp | |
187 #endif | |
188 | |
189 #ifdef __DMC__ | |
190 typedef _Complex long double complex_t; | |
191 #else | |
192 #ifndef IN_GCC | |
193 #include "complex_t.h" | |
194 #endif | |
195 #ifdef __APPLE__ | |
196 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
197 #define integer_t dmd_integer_t | |
198 #endif | |
199 #endif | |
200 | |
201 // Be careful not to care about sign when using integer_t | |
202 typedef uint64_t integer_t; | |
203 | |
204 // Signed and unsigned variants | |
205 typedef int64_t sinteger_t; | |
206 typedef uint64_t uinteger_t; | |
207 | |
208 typedef int8_t d_int8; | |
209 typedef uint8_t d_uns8; | |
210 typedef int16_t d_int16; | |
211 typedef uint16_t d_uns16; | |
212 typedef int32_t d_int32; | |
213 typedef uint32_t d_uns32; | |
214 typedef int64_t d_int64; | |
215 typedef uint64_t d_uns64; | |
216 | |
217 typedef float d_float32; | |
218 typedef double d_float64; | |
219 typedef long double d_float80; | |
220 | |
221 typedef d_uns8 d_char; | |
222 typedef d_uns16 d_wchar; | |
223 typedef d_uns32 d_dchar; | |
224 | |
225 #ifdef IN_GCC | |
226 #include "d-gcc-real.h" | |
227 #else | |
228 typedef long double real_t; | |
229 #endif | |
230 | |
231 // Modify OutBuffer::writewchar to write the correct size of wchar | |
232 #if _WIN32 | |
233 #define writewchar writeword | |
234 #else | |
235 // This needs a configuration test... | |
236 #define writewchar write4 | |
237 #endif | |
238 | |
239 #ifdef IN_GCC | |
240 #include "d-gcc-complex_t.h" | |
241 #endif | |
242 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
243 // taken from GDC |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
244 // for handling printf incompatibilities |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
245 #if __MSVCRT__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
246 #define PRIuSIZE "Iu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
247 #define PRIxSIZE "Ix" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
248 #elif __MINGW32__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
249 #define PRIuSIZE "u" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
250 #define PRIxSIZE "x" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
251 #else |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
252 #define PRIuSIZE "zu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
253 #define PRIxSIZE "zx" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
254 #endif |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
255 |
159 | 256 struct Module; |
257 | |
258 //typedef unsigned Loc; // file location | |
259 struct Loc | |
260 { | |
261 char *filename; | |
262 unsigned linnum; | |
263 | |
264 Loc() | |
265 { | |
266 linnum = 0; | |
267 filename = NULL; | |
268 } | |
269 | |
270 Loc(int x) | |
271 { | |
272 linnum = x; | |
273 filename = NULL; | |
274 } | |
275 | |
276 Loc(Module *mod, unsigned linnum); | |
277 | |
278 char *toChars() const; | |
279 }; | |
280 | |
281 #ifndef GCC_SAFE_DMD | |
282 #define TRUE 1 | |
283 #define FALSE 0 | |
284 #endif | |
285 | |
286 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
287 // in interface vtbl[]'s | |
288 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
289 // in the inheritance graph multiple | |
290 // times, only one is used | |
291 | |
292 enum LINK | |
293 { | |
294 LINKdefault, | |
295 LINKd, | |
296 LINKc, | |
297 LINKcpp, | |
298 LINKwindows, | |
299 LINKpascal, | |
300 }; | |
301 | |
302 enum DYNCAST | |
303 { | |
304 DYNCAST_OBJECT, | |
305 DYNCAST_EXPRESSION, | |
306 DYNCAST_DSYMBOL, | |
307 DYNCAST_TYPE, | |
308 DYNCAST_IDENTIFIER, | |
309 DYNCAST_TUPLE, | |
310 }; | |
311 | |
312 enum MATCH | |
313 { | |
314 MATCHnomatch, // no match | |
315 MATCHconvert, // match with conversions | |
336 | 316 #if DMDV2 |
159 | 317 MATCHconst, // match with conversion to const |
318 #endif | |
319 MATCHexact // exact match | |
320 }; | |
321 | |
322 void error(Loc loc, const char *format, ...); | |
323 void verror(Loc loc, const char *format, va_list); | |
324 void fatal(); | |
325 void err_nomem(); | |
326 void inifile(char *argv0, char *inifile); | |
327 void halt(); | |
328 | |
329 /*** Where to send error messages ***/ | |
330 #if IN_GCC | |
331 #define stdmsg stderr | |
332 #else | |
333 #define stdmsg stdout | |
334 #endif | |
335 | |
336 #endif /* DMD_MARS_H */ |