Mercurial > projects > ddmd
comparison dmd/backend/Config.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | 2cc604139636 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:10317f0c89a5 |
---|---|
1 module dmd.backend.Config; | |
2 | |
3 import dmd.backend.LINKAGE; | |
4 import dmd.EnumUtils; | |
5 | |
6 extern (C) { | |
7 void cod3_set64(); | |
8 void cod3_set386(); | |
9 } | |
10 | |
11 extern (C++) extern | |
12 { | |
13 __gshared char debuga; /* cg - watch assignaddr() */ | |
14 __gshared char debugb; /* watch block optimization */ | |
15 __gshared char debugc; /* watch code generated */ | |
16 __gshared char debugd; /* watch debug information generated */ | |
17 __gshared char debuge; // dump eh info | |
18 __gshared char debugf; /* trees after dooptim */ | |
19 __gshared char debugg; /* trees for code generator */ | |
20 __gshared char debugo; // watch optimizer | |
21 __gshared char debugr; // watch register allocation | |
22 __gshared char debugs; /* watch common subexp eliminator */ | |
23 __gshared char debugt; /* do test points */ | |
24 __gshared char debugu; | |
25 __gshared char debugw; /* watch progress */ | |
26 __gshared char debugx; /* suppress predefined CPP stuff */ | |
27 __gshared char debugy; /* watch output to il buffer */ | |
28 } | |
29 | |
30 // This part of the configuration is saved in the precompiled header for use | |
31 // in comparing to make sure it hasn't changed. | |
32 | |
33 enum CFG2 | |
34 { | |
35 CFG2comdat = 1, // use initialized common blocks | |
36 CFG2nodeflib = 2, // no default library imbedded in OBJ file | |
37 CFG2browse = 4, // generate browse records | |
38 CFG2dyntyping = 8, // generate dynamic typing information | |
39 CFG2fulltypes = 0x10, // don't optimize CV4 class info | |
40 CFG2warniserr = 0x20, // treat warnings as errors | |
41 CFG2phauto = 0x40, // automatic precompiled headers | |
42 CFG2phuse = 0x80, // use precompiled headers | |
43 CFG2phgen = 0x100, // generate precompiled header | |
44 CFG2once = 0x200, // only include header files once | |
45 CFG2hdrdebug = 0x400, // generate debug info for header | |
46 CFG2phautoy = 0x800, // fast build precompiled headers | |
47 CFG2noobj = 0x1000, // we are not generating a .OBJ file | |
48 CFG2noerrmax = 0x4000, // no error count maximum | |
49 CFG2expand = 0x8000, // expanded output to list file | |
50 CFG2seh = 0x10000, // use Win32 SEH to support any exception handling | |
51 CFGX2 = (CFG2warniserr | CFG2phuse | CFG2phgen | CFG2phauto | CFG2once | CFG2hdrdebug | CFG2noobj | CFG2noerrmax | CFG2expand | CFG2nodeflib), | |
52 } | |
53 | |
54 enum CFG3ju = 1; // char == unsigned char | |
55 enum CFG3eh = 4; // generate exception handling stuff | |
56 enum CFG3strcod = 8; // strings are placed in code segment | |
57 enum CFG3eseqds = 0x10; // ES == DS at all times | |
58 enum CFG3ptrchk = 0x20; // generate pointer validation code | |
59 enum CFG3strictproto = 0x40; // strict prototyping | |
60 enum CFG3autoproto = 0x80; // auto prototyping | |
61 enum CFG3rtti = 0x100; // add RTTI support | |
62 enum CFG3relax = 0x200; // relaxed type checking (C only) | |
63 enum CFG3cpp = 0x400; // C++ compile | |
64 enum CFG3igninc = 0x800; // ignore standard include directory | |
65 version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS) { | |
66 enum CFG3mars = 0x1000; // use mars libs and headers | |
67 enum NO_FAR = true; // always ignore __far and __huge keywords | |
68 } else { | |
69 enum CFG3nofar = 0x1000; // ignore __far and __huge keywords | |
70 ///enum NO_FAR = (config.flags3 & CFG3nofar); | |
71 } | |
72 enum CFG3noline = 0x2000; // do not output #line directives | |
73 enum CFG3comment = 0x4000; // leave comments in preprocessed output | |
74 enum CFG3cppcomment = 0x8000; // allow C++ style comments | |
75 enum CFG3wkfloat = 0x10000; // make floating point references weak externs | |
76 enum CFG3digraphs = 0x20000; // support ANSI C++ digraphs | |
77 ///#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS | |
78 enum CFG3semirelax = 0x40000; // moderate relaxed type checking | |
79 ///#endif | |
80 enum CFG3pic = 0x80000; // position independent code | |
81 enum CFGX3 = (CFG3strcod | CFG3ptrchk); | |
82 | |
83 enum CFG4speed = 1; // optimized for speed | |
84 enum CFG4space = 2; // optimized for space | |
85 enum CFG4optimized = (CFG4speed | CFG4space); | |
86 enum CFG4allcomdat = 4; // place all functions in COMDATs | |
87 enum CFG4fastfloat = 8; // fast floating point (-ff) | |
88 enum CFG4fdivcall = 0x10; // make function call for FDIV opcodes | |
89 enum CFG4tempinst = 0x20; // instantiate templates for undefined functions | |
90 enum CFG4oldstdmangle = 0x40; // do stdcall mangling without @ | |
91 enum CFG4pascal = 0x80; // default to pascal linkage | |
92 enum CFG4stdcall = 0x100; // default to std calling convention | |
93 enum CFG4cacheph = 0x200; // cache precompiled headers in memory | |
94 enum CFG4alternate = 0x400; // if alternate digraph tokens | |
95 enum CFG4bool = 0x800; // support 'bool' as basic type | |
96 enum CFG4wchar_t = 0x1000; // support 'wchar_t' as basic type | |
97 enum CFG4notempexp = 0x2000; // no instantiation of template functions | |
98 enum CFG4anew = 0x4000; // allow operator new[] and delete[] overloading | |
99 enum CFG4oldtmangle = 0x8000; // use old template name mangling | |
100 enum CFG4dllrtl = 0x10000; // link with DLL RTL | |
101 enum CFG4noemptybaseopt = 0x40000; // turn off empty base class optimization | |
102 enum CFG4stackalign = CFG4speed; // align stack to 8 bytes | |
103 enum CFG4nowchar_t = 0x80000; // use unsigned short name mangling for wchar_t | |
104 enum CFG4forscope = 0x100000; // new C++ for scoping rules | |
105 enum CFG4warnccast = 0x200000; // warn about C style casts | |
106 enum CFG4adl = 0x400000; // argument dependent lookup | |
107 enum CFG4enumoverload = 0x800000; // enum overloading | |
108 enum CFG4implicitfromvoid = 0x1000000; // allow implicit cast from void* to T* | |
109 enum CFG4dependent = 0x2000000; // dependent / non-dependent lookup | |
110 enum CFG4wchar_is_long = 0x4000000; // wchar_t is 4 bytes | |
111 enum CFG4underscore = 0x8000000; // prepend _ for C mangling | |
112 enum CFGX4 = (CFG4optimized | CFG4fastfloat | CFG4fdivcall | CFG4tempinst | CFG4cacheph | CFG4notempexp | CFG4stackalign | CFG4dependent); | |
113 enum CFGY4 = (CFG4nowchar_t | CFG4noemptybaseopt | CFG4adl | CFG4enumoverload | CFG4implicitfromvoid | CFG4wchar_is_long | CFG4underscore); | |
114 | |
115 mixin(BringToCurrentScope!(CFG2)); | |
116 | |
117 enum TARGET | |
118 { | |
119 TARGET_8086= 0, | |
120 TARGET_80286= 2, | |
121 TARGET_80386= 3, | |
122 TARGET_80486= 4, | |
123 TARGET_Pentium= 5, | |
124 TARGET_PentiumMMX= 6, | |
125 TARGET_PentiumPro= 7, | |
126 TARGET_PentiumII= 8, | |
127 TARGET_AMD64= 9, //(32 or 64 bit mode) | |
128 } | |
129 | |
130 mixin(BringToCurrentScope!(TARGET)); | |
131 | |
132 enum CV4 = 2; // Codeview 4 symbolic info | |
133 | |
134 struct Config | |
135 { | |
136 char language; // 'C' = C, 'D' = C++ | |
137 //#define CPP (config.language == 'D') | |
138 char version_[8]; // = VERSION | |
139 char exetype[3]; // distinguish exe types so PH | |
140 // files are distinct (= SUFFIX) | |
141 | |
142 char target_cpu; // instruction selection | |
143 char target_scheduler; // instruction scheduling (normally same as selection) | |
144 | |
145 short versionint; // intermediate file version (= VERSIONINT) | |
146 int defstructalign; // struct alignment specified by command line | |
147 short hxversion; // HX version number | |
148 char fulltypes; | |
149 uint wflags; // flags for Windows code generation | |
150 | |
151 char inline8087; /* 0: emulator | |
152 1: IEEE 754 inline 8087 code | |
153 2: fast inline 8087 code | |
154 */ | |
155 short memmodel; // 0:S,X,N,F, 1:M, 2:C, 3:L, 4:V | |
156 uint exe; // target operating system | |
157 | |
158 ///#define EX_flat (EX_OS2 | EX_NT | EX_LINUX | EX_WIN64 | EX_LINUX64 | \ | |
159 /// EX_OSX | EX_OSX64 | EX_FREEBSD | EX_FREEBSD64 | \ | |
160 /// EX_SOLARIS | EX_SOLARIS64) | |
161 ///#define EX_dos (EX_DOSX | EX_ZPM | EX_RATIONAL | EX_PHARLAP | \ | |
162 /// EX_COM | EX_MZ /*| EX_WIN16*/) | |
163 | |
164 /* CFGX: flags ignored in precompiled headers | |
165 * CFGY: flags copied from precompiled headers into current config | |
166 */ | |
167 uint flags; | |
168 uint flags2; | |
169 uint flags3; | |
170 uint flags4; | |
171 uint flags5; | |
172 ///#define CFG5debug 1 // compile in __debug code | |
173 ///#define CFG5in 2 // compile in __in code | |
174 ///#define CFG5out 4 // compile in __out code | |
175 ///#define CFG5invariant 8 // compile in __invariant code | |
176 | |
177 ///#if HTOD | |
178 /// unsigned htodFlags; // configuration for htod | |
179 ///#define HTODFinclude 1 // -hi drill down into #include files | |
180 ///#define HTODFsysinclude 2 // -hs drill down into system #include files | |
181 ///#define HTODFtypedef 4 // -ht drill down into typedefs | |
182 ///#define HTODFcdecl 8 // -hc skip C declarations as comments | |
183 ///#endif | |
184 char ansi_c; // strict ANSI C | |
185 // 89 for ANSI C89, 99 for ANSI C99 | |
186 char asian_char; /* 0: normal, 1: Japanese, 2: Chinese */ | |
187 /* and Taiwanese, 3: Korean */ | |
188 uint threshold; // data larger than threshold is assumed to | |
189 // be far (16 bit models only) | |
190 ///#define THRESHMAX 0xFFFF // if threshold == THRESHMAX, all data defaults | |
191 // to near | |
192 LINKAGE linkage; // default function call linkage | |
193 } | |
194 | |
195 extern (C++) extern __gshared Config config; | |
196 | |
197 enum CVNONE = 0; // No symbolic info | |
198 ///enum CVOLD = 1; // Codeview 1 symbolic info | |
199 ///enum CV4 = 2; // Codeview 4 symbolic info | |
200 ///enum CVSYM = 3; // Symantec format | |
201 ///enum CVTDB = 4; // Symantec format written to file | |
202 ///enum CVDWARF_C = 5; // Dwarf in C format | |
203 ///enum CVDWARF_D = 6; // Dwarf in D format | |
204 ///enum CVSTABS = 7; // Elf Stabs in C format | |
205 | |
206 enum CFGuchar = 1; // chars are unsigned | |
207 enum CFGsegs = 2; // new code seg for each far func | |
208 enum CFGtrace = 4; // output trace functions | |
209 enum CFGglobal = 8; // make all static functions global | |
210 enum CFGstack = 0x20; // add stack overflow checking | |
211 enum CFGalwaysframe = 0x40; // always generate stack frame | |
212 enum CFGnoebp = 0x80; // do not use EBP as general purpose register | |
213 enum CFGromable = 0x100; // put switch tables in code segment | |
214 enum CFGeasyomf = 0x200; // generate Pharlap Easy-OMF format | |
215 enum CFGfarvtbls = 0x800; // store vtables in far segments | |
216 enum CFGnoinlines = 0x1000; // do not inline functions | |
217 enum CFGnowarning = 0x8000; // disable warnings | |
218 enum CFGX = (CFGnowarning); | |
219 | |
220 enum EX_DOSX = 1; // DOSX 386 program | |
221 enum EX_ZPM = 2; // ZPM 286 program | |
222 enum EX_RATIONAL = 4; // RATIONAL 286 program | |
223 enum EX_PHARLAP = 8; // PHARLAP 386 program | |
224 enum EX_COM = 0x10; // MSDOS .COM program | |
225 //#define EX_WIN16 0x20 // Windows 3.x 16 bit program | |
226 enum EX_OS2 = 0x40; // OS/2 2.0 32 bit program | |
227 enum EX_OS1 = 0x80; // OS/2 1.x 16 bit program | |
228 enum EX_NT = 0x100; // NT | |
229 enum EX_MZ = 0x200; // MSDOS real mode program | |
230 enum EX_XENIX = 0x400; | |
231 enum EX_SCOUNIX = 0x800; | |
232 enum EX_UNIXSVR4 = 0x1000; | |
233 enum EX_LINUX = 0x2000; | |
234 enum EX_WIN64 = 0x4000; // AMD64 and Windows (64 bit mode) | |
235 enum EX_LINUX64 = 0x8000; // AMD64 and Linux (64 bit mode) | |
236 enum EX_OSX = 0x10000; | |
237 enum EX_OSX64 = 0x20000; | |
238 enum EX_FREEBSD = 0x40000; | |
239 enum EX_FREEBSD64 = 0x80000; | |
240 enum EX_SOLARIS = 0x100000; | |
241 enum EX_SOLARIS64 = 0x200000; | |
242 | |
243 enum WFwindows = 1; // generating code for Windows app or DLL | |
244 enum WFdll = 2; // generating code for Windows DLL | |
245 enum WFincbp = 4; // mark far stack frame with inc BP / dec BP | |
246 enum WFloadds = 8; // assume __loadds for all functions | |
247 enum WFexpdef = 0x10; // generate export definition records for | |
248 // exported functions | |
249 enum WFss = 0x20; // load DS from SS | |
250 enum WFreduced = 0x40; // skip DS load for non-exported functions | |
251 enum WFdgroup = 0x80; // load DS from DGROUP | |
252 enum WFexport = 0x100; // assume __export for all far functions | |
253 enum WFds = 0x200; // load DS from DS | |
254 enum WFmacros = 0x400; // define predefined windows macros | |
255 enum WFssneds = 0x800; // SS != DS | |
256 enum WFthunk = 0x1000; // use fixups instead of direct ref to CS | |
257 enum WFsaveds = 0x2000; // use push/pop DS for far functions | |
258 enum WFdsnedgroup = 0x4000; // DS != DGROUP | |
259 enum WFexe = 0x8000; // generating code for Windows EXE |