Mercurial > projects > ldc
annotate dmd/mars.h @ 566:68d7df3f9b05
Added some sanity checks for target detection.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sun, 31 Aug 2008 18:51:14 +0200 |
parents | cbe08531430f |
children | f75b16f1e405 |
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 | |
114 char *defaultlibname; // default library for non-debug builds | |
115 char *debuglibname; // default library for debug builds | |
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; | |
150 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
|
151 char useInlineAsm; |
217
0806379a5eca
[svn r233] Added: -oq command line option for writing fully qualified object names.
lindquist
parents:
159
diff
changeset
|
152 char fqnPaths; // use fully qualified object names |
159 | 153 }; |
154 | |
155 struct Global | |
156 { | |
157 char *mars_ext; | |
158 char *sym_ext; | |
159 char *obj_ext; | |
160 char *ll_ext; | |
161 char *bc_ext; | |
162 char *nativeobj_ext; | |
163 char *doc_ext; // for Ddoc generated files | |
164 char *ddoc_ext; // for Ddoc macro include files | |
165 char *hdr_ext; // for D 'header' import files | |
166 char *copyright; | |
167 char *written; | |
168 Array *path; // Array of char*'s which form the import lookup path | |
169 Array *filePath; // Array of char*'s which form the file import lookup path | |
170 int structalign; | |
171 char *version; | |
172 char *llvmdc_version; | |
173 | |
174 Param params; | |
175 unsigned errors; // number of errors reported so far | |
176 unsigned gag; // !=0 means gag reporting of errors | |
177 | |
178 Global(); | |
179 }; | |
180 | |
181 extern Global global; | |
182 | |
183 #if __GNUC__ | |
184 //#define memicmp strncasecmp | |
185 //#define stricmp strcasecmp | |
186 #endif | |
187 | |
188 #ifdef __DMC__ | |
189 typedef _Complex long double complex_t; | |
190 #else | |
191 #ifndef IN_GCC | |
192 #include "complex_t.h" | |
193 #endif | |
194 #ifdef __APPLE__ | |
195 //#include "complex.h"//This causes problems with include the c++ <complex> and not the C "complex.h" | |
196 #define integer_t dmd_integer_t | |
197 #endif | |
198 #endif | |
199 | |
200 // Be careful not to care about sign when using integer_t | |
201 typedef uint64_t integer_t; | |
202 | |
203 // Signed and unsigned variants | |
204 typedef int64_t sinteger_t; | |
205 typedef uint64_t uinteger_t; | |
206 | |
207 typedef int8_t d_int8; | |
208 typedef uint8_t d_uns8; | |
209 typedef int16_t d_int16; | |
210 typedef uint16_t d_uns16; | |
211 typedef int32_t d_int32; | |
212 typedef uint32_t d_uns32; | |
213 typedef int64_t d_int64; | |
214 typedef uint64_t d_uns64; | |
215 | |
216 typedef float d_float32; | |
217 typedef double d_float64; | |
218 typedef long double d_float80; | |
219 | |
220 typedef d_uns8 d_char; | |
221 typedef d_uns16 d_wchar; | |
222 typedef d_uns32 d_dchar; | |
223 | |
224 #ifdef IN_GCC | |
225 #include "d-gcc-real.h" | |
226 #else | |
227 typedef long double real_t; | |
228 #endif | |
229 | |
230 // Modify OutBuffer::writewchar to write the correct size of wchar | |
231 #if _WIN32 | |
232 #define writewchar writeword | |
233 #else | |
234 // This needs a configuration test... | |
235 #define writewchar write4 | |
236 #endif | |
237 | |
238 #ifdef IN_GCC | |
239 #include "d-gcc-complex_t.h" | |
240 #endif | |
241 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
242 // taken from GDC |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
243 // 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
|
244 #if __MSVCRT__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
245 #define PRIuSIZE "Iu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
246 #define PRIxSIZE "Ix" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
247 #elif __MINGW32__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
248 #define PRIuSIZE "u" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
249 #define PRIxSIZE "x" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
250 #else |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
251 #define PRIuSIZE "zu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
252 #define PRIxSIZE "zx" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
253 #endif |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
254 |
159 | 255 struct Module; |
256 | |
257 //typedef unsigned Loc; // file location | |
258 struct Loc | |
259 { | |
260 char *filename; | |
261 unsigned linnum; | |
262 | |
263 Loc() | |
264 { | |
265 linnum = 0; | |
266 filename = NULL; | |
267 } | |
268 | |
269 Loc(int x) | |
270 { | |
271 linnum = x; | |
272 filename = NULL; | |
273 } | |
274 | |
275 Loc(Module *mod, unsigned linnum); | |
276 | |
277 char *toChars() const; | |
278 }; | |
279 | |
280 #ifndef GCC_SAFE_DMD | |
281 #define TRUE 1 | |
282 #define FALSE 0 | |
283 #endif | |
284 | |
285 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
286 // in interface vtbl[]'s | |
287 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
288 // in the inheritance graph multiple | |
289 // times, only one is used | |
290 | |
291 enum LINK | |
292 { | |
293 LINKdefault, | |
294 LINKd, | |
295 LINKc, | |
296 LINKcpp, | |
297 LINKwindows, | |
298 LINKpascal, | |
299 }; | |
300 | |
301 enum DYNCAST | |
302 { | |
303 DYNCAST_OBJECT, | |
304 DYNCAST_EXPRESSION, | |
305 DYNCAST_DSYMBOL, | |
306 DYNCAST_TYPE, | |
307 DYNCAST_IDENTIFIER, | |
308 DYNCAST_TUPLE, | |
309 }; | |
310 | |
311 enum MATCH | |
312 { | |
313 MATCHnomatch, // no match | |
314 MATCHconvert, // match with conversions | |
336 | 315 #if DMDV2 |
159 | 316 MATCHconst, // match with conversion to const |
317 #endif | |
318 MATCHexact // exact match | |
319 }; | |
320 | |
321 void error(Loc loc, const char *format, ...); | |
322 void verror(Loc loc, const char *format, va_list); | |
323 void fatal(); | |
324 void err_nomem(); | |
325 void inifile(char *argv0, char *inifile); | |
326 void halt(); | |
327 | |
328 /*** Where to send error messages ***/ | |
329 #if IN_GCC | |
330 #define stdmsg stderr | |
331 #else | |
332 #define stdmsg stdout | |
333 #endif | |
334 | |
335 #endif /* DMD_MARS_H */ |