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