Mercurial > projects > ldc
annotate dmd/mars.h @ 414:ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Cleaned up CallExp::toElem, moved implementation to tocall.cpp providing a single procedure to call arbitrary D functions fairly easily.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 28 Jul 2008 02:11:34 +0200 |
parents | 1a9bdbd4ac60 |
children | 491264b7cb93 |
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; | |
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; | |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
413
diff
changeset
|
216 // this should be enough |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
413
diff
changeset
|
217 #if defined(i386) || defined(__i386__) || defined(_WIN32) || defined(__MINGW32__) |
413
1a9bdbd4ac60
Make RealEquals only compare the data bytes.
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
218 #define REAL_T_SIZE 12 |
1a9bdbd4ac60
Make RealEquals only compare the data bytes.
Christian Kamm <kamm incasoftware de>
parents:
336
diff
changeset
|
219 #define REAL_T_PAD 2 |
414
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
413
diff
changeset
|
220 #else |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
413
diff
changeset
|
221 #define REAL_T_SIZE sizeof(real_t) |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
413
diff
changeset
|
222 #define REAL_T_PAD 0 |
ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
413
diff
changeset
|
223 #endif |
159 | 224 #endif |
225 | |
226 // Modify OutBuffer::writewchar to write the correct size of wchar | |
227 #if _WIN32 | |
228 #define writewchar writeword | |
229 #else | |
230 // This needs a configuration test... | |
231 #define writewchar write4 | |
232 #endif | |
233 | |
234 #ifdef IN_GCC | |
235 #include "d-gcc-complex_t.h" | |
236 #endif | |
237 | |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
238 // taken from GDC |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
239 // 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
|
240 #if __MSVCRT__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
241 #define PRIuSIZE "Iu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
242 #define PRIxSIZE "Ix" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
243 #elif __MINGW32__ |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
244 #define PRIuSIZE "u" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
245 #define PRIxSIZE "x" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
246 #else |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
247 #define PRIuSIZE "zu" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
248 #define PRIxSIZE "zx" |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
249 #endif |
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
277
diff
changeset
|
250 |
159 | 251 struct Module; |
252 | |
253 //typedef unsigned Loc; // file location | |
254 struct Loc | |
255 { | |
256 char *filename; | |
257 unsigned linnum; | |
258 | |
259 Loc() | |
260 { | |
261 linnum = 0; | |
262 filename = NULL; | |
263 } | |
264 | |
265 Loc(int x) | |
266 { | |
267 linnum = x; | |
268 filename = NULL; | |
269 } | |
270 | |
271 Loc(Module *mod, unsigned linnum); | |
272 | |
273 char *toChars() const; | |
274 }; | |
275 | |
276 #ifndef GCC_SAFE_DMD | |
277 #define TRUE 1 | |
278 #define FALSE 0 | |
279 #endif | |
280 | |
281 #define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry | |
282 // in interface vtbl[]'s | |
283 #define INTERFACE_VIRTUAL 0 // 1 means if an interface appears | |
284 // in the inheritance graph multiple | |
285 // times, only one is used | |
286 | |
287 enum LINK | |
288 { | |
289 LINKdefault, | |
290 LINKd, | |
291 LINKc, | |
292 LINKcpp, | |
293 LINKwindows, | |
294 LINKpascal, | |
295 }; | |
296 | |
297 enum DYNCAST | |
298 { | |
299 DYNCAST_OBJECT, | |
300 DYNCAST_EXPRESSION, | |
301 DYNCAST_DSYMBOL, | |
302 DYNCAST_TYPE, | |
303 DYNCAST_IDENTIFIER, | |
304 DYNCAST_TUPLE, | |
305 }; | |
306 | |
307 enum MATCH | |
308 { | |
309 MATCHnomatch, // no match | |
310 MATCHconvert, // match with conversions | |
336 | 311 #if DMDV2 |
159 | 312 MATCHconst, // match with conversion to const |
313 #endif | |
314 MATCHexact // exact match | |
315 }; | |
316 | |
275
665b81613475
[svn r296] Removed: the 'suite' dir, it never took off!
lindquist
parents:
237
diff
changeset
|
317 // 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
|
318 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
|
319 { |
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
|
320 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
|
321 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
|
322 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
|
323 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
|
324 }; |
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
|
325 |
159 | 326 void error(Loc loc, const char *format, ...); |
327 void verror(Loc loc, const char *format, va_list); | |
328 void fatal(); | |
329 void err_nomem(); | |
330 void inifile(char *argv0, char *inifile); | |
331 void halt(); | |
332 | |
333 /*** Where to send error messages ***/ | |
334 #if IN_GCC | |
335 #define stdmsg stderr | |
336 #else | |
337 #define stdmsg stdout | |
338 #endif | |
339 | |
340 #endif /* DMD_MARS_H */ |