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