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