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