Mercurial > projects > ddmd
annotate dmd/backend/OPER.d @ 140:31c086f76669
dmd.lib now only contains the backend
backward references from the backend to the frontend are implemented in ddmd
win32_lib.mak is replaced by a patch
also fixed VisualD project file predefined versions
author | Trass3r |
---|---|
date | Tue, 14 Sep 2010 01:54:48 +0200 |
parents | 5c9b78899f5d |
children |
rev | line source |
---|---|
0 | 1 module dmd.backend.OPER; |
2 | |
3 enum OPER : ubyte /// | |
4 { | |
5 OPunde, /* place holder for undefined operator */ | |
6 | |
7 OPadd, | |
8 OPmin, | |
9 OPmul, | |
10 OPdiv, | |
11 OPmod, | |
12 OPshr, // unsigned right shift | |
13 OPshl, | |
14 OPand, | |
15 OPxor, | |
16 OPor, | |
17 OPashr, // signed right shift | |
18 OPnot, | |
19 OPbool, /* "booleanize" */ | |
20 OPcom, | |
21 OPcond, | |
22 OPcomma, | |
23 OPoror, | |
24 OPandand, | |
25 OPbit, /* ref to bit field */ | |
26 OPind, /* *E */ | |
27 OPaddr, /* &E */ | |
28 OPneg, /* unary - */ | |
29 OPuadd, /* unary + */ | |
30 ///#if TX86 | |
31 OPvoid, // where casting to void is not a no-op | |
32 OPabs, /* absolute value */ | |
33 OPsqrt, /* square root */ | |
34 OPrndtol, // round to short, long, long long (inline 8087 only) | |
35 OPsin, // sine | |
36 OPcos, // cosine | |
37 OPrint, // round to int | |
38 OPscale, // ldexp | |
39 OPyl2x, // y * log2(x) | |
40 OPyl2xp1, // y * log2(x + 1) | |
41 OPstrlen, /* strlen() */ | |
42 OPstrcpy, /* strcpy() */ | |
43 OPstrcat, /* strcat() */ | |
44 OPstrcmp, /* strcmp() */ | |
45 OPmemcpy, | |
46 OPmemcmp, | |
47 OPmemset, | |
48 OPsetjmp, // setjmp() | |
49 OPremquo, // / and % in one operation | |
50 | |
51 OPbsf, // bit scan forward | |
52 OPbsr, // bit scan reverse | |
53 OPbt, // bit test | |
54 OPbtc, // bit test and complement | |
55 OPbtr, // bit test and reset | |
56 OPbts, // bit test and set | |
57 OPbswap, // swap bytes | |
58 ///#endif | |
59 | |
60 OPstreq, /* structure assignment */ | |
61 | |
62 OPnegass, // x = -x | |
63 OPpostinc, /* x++ */ | |
64 OPpostdec, /* x-- */ | |
65 | |
66 OPeq, | |
67 OPaddass, | |
68 OPminass, | |
69 OPmulass, | |
70 OPdivass, | |
71 OPmodass, | |
72 OPshrass, | |
73 OPshlass, | |
74 OPandass, | |
75 OPxorass, | |
76 OPorass, | |
77 | |
78 /* Convert from token to assignment operator */ | |
79 ///#define asgtoktoop(tok) ((int) (tok) + ((int)OPeq - (int) TKeq)) | |
80 | |
81 OPashrass, | |
82 | |
83 /* relational operators (in same order as corresponding tokens) */ | |
84 ///#define RELOPMIN ((int)OPle) | |
85 OPle, | |
86 OPgt, | |
87 OPlt, | |
88 OPge, | |
89 OPeqeq, | |
90 OPne, | |
91 | |
92 OPunord, /* !<>= */ | |
93 OPlg, /* <> */ | |
94 OPleg, /* <>= */ | |
95 OPule, /* !> */ | |
96 OPul, /* !>= */ | |
97 OPuge, /* !< */ | |
98 OPug, /* !<= */ | |
99 OPue, /* !<> */ | |
100 OPngt, | |
101 OPnge, | |
102 OPnlt, | |
103 OPnle, | |
104 OPord, | |
105 OPnlg, | |
106 OPnleg, | |
107 OPnule, | |
108 OPnul, | |
109 OPnuge, | |
110 OPnug, | |
111 OPnue, | |
112 | |
113 ///#define rel_toktoop(tk) ((enum OPER)((int)tk - (int)TKle + (int)OPle)) | |
114 | |
115 /***************** End of relational operators ******************/ | |
116 ///#define CNVOPMIN (OPnue+1) | |
117 | |
118 // parallel array inconvtab[] in cgelem.c) | |
119 | |
120 ///#if TX86 | |
121 | |
122 /* Convert from conversion operator to conversion index */ | |
123 ///#define convidx(op) ((int)(op) - CNVOPMIN) | |
124 | |
125 /* 8,16,32,64 integral type of unspecified sign | |
126 s,u signed/unsigned | |
127 f,d,ld float/double/long double | |
128 np,fp,vp,f16p near pointer/far pointer/handle pointer/far16 pointer | |
129 cvp const handle pointer | |
130 */ | |
131 | |
132 OPb_8, // convert bit to byte | |
133 OPd_s32, | |
134 OPs32_d, | |
135 OPd_s16, | |
136 OPs16_d, | |
137 OPd_u16, | |
138 OPu16_d, | |
139 OPd_u32, | |
140 OPu32_d, | |
141 OPd_s64, | |
142 OPs64_d, | |
143 OPd_u64, | |
144 OPu64_d, | |
145 OPd_f, | |
146 OPf_d, | |
147 OPvp_fp, | |
148 OPcvp_fp, // const handle * => far * | |
149 OPs16_32, // short to long | |
150 OPu16_32, // unsigned short to long | |
151 OP32_16, // long to short | |
152 OPu8_16, // unsigned char to short | |
153 OPs8_16, // signed char to short | |
154 OP16_8, // short to 8 bits | |
155 OPu32_64, // unsigned long to long long | |
156 OPs32_64, // long to long long | |
157 OP64_32, // long long to long | |
158 ///#define OPsfltdbl OPunde | |
159 ///#define OPdblsflt OPunde | |
160 OPoffset, // get offset of far pointer | |
161 OPnp_fp, // convert near pointer to far | |
162 OPnp_f16p, // from 0:32 to 16:16 | |
163 OPf16p_np, // from 16:16 to 0:32 | |
164 OPld_d, | |
165 OPd_ld, | |
166 OPld_u64, | |
167 ///#else | |
168 ///TARGET_CONVERSION_OPS | |
169 ///#endif | |
170 | |
171 ///#define CNVOPMAX (OPc_r-1) | |
172 ///#define convidx(op) ((int)(op) - CNVOPMIN) | |
173 /* Convert from conversion operator to conversion index */ | |
174 | |
175 ///#if 1 | |
176 // The old conversion operators - retain until we get the code fixed | |
177 ///#define OPlngdbl OPs32_d | |
178 ///#define OPdblint OPd_s16 | |
179 ///#define OPintdbl OPs16_d | |
180 ///#define OPdbluns OPd_u16 | |
181 ///#define OPunsdbl OPu16_d | |
182 ///#define OPdblulng OPd_u32 | |
183 ///#define OPulngdbl OPu32_d | |
184 ///#define OPdblllng OPd_s64 | |
185 ///#define OPllngdbl OPs64_d | |
186 ///#define OPdblullng OPd_u64 | |
187 ///#define OPdblflt OPd_f | |
188 ///#define OPvptrfptr OPvp_fp | |
189 ///#define OPcvptrfptr OPcvp_fp // const handle * => far * | |
190 ///#define OPshtlng OPs16_32 // short to long | |
191 ///#define OPushtlng OPu16_32 // unsigned short to long | |
192 ///#define OPlngsht OP32_16 // long to short | |
193 ///#define OPu8int OPu8_16 // unsigned char to short | |
194 ///#define OPs8int OPs8_16 // signed char to short | |
195 ///#define OPint8 OP16_8 // short to 8 bits | |
196 ///#define OPulngllng OPu32_64 // unsigned long to long long | |
197 ///#define OPlngllng OPs32_64 // long to long long | |
198 ///#define OPllnglng OP64_32 // long long to long | |
199 ///#define OPsfltdbl OPunde | |
200 ///#define OPdblsflt OPunde | |
201 ///#define OPoffset OPoffset // get offset of far pointer | |
202 ///#define OPptrlptr OPnp_fp // convert near pointer to far | |
203 ///#define OPtofar16 OPnp_f16p // from 0:32 to 16:16 | |
204 ///#define OPfromfar16 OPf16p_np // from 16:16 to 0:32 | |
205 | |
206 ///#endif | |
207 | |
208 /***************** End of conversion operators ******************/ | |
209 | |
210 OPc_r, // complex to real | |
211 OPc_i, // complex to imaginary | |
212 OPmsw, // top 32 bits of 64 bit word (32 bit code gen) | |
213 // top 16 bits of 32 bit word (16 bit code gen) | |
214 | |
215 OPparam, /* function parameter separator */ | |
216 OPcall, /* binary function call */ | |
217 OPucall, /* unary function call */ | |
218 OPcallns, // binary function call, no side effects | |
219 OPucallns, // unary function call, no side effects | |
220 | |
221 OPsizeof, /* for forward-ref'd structs */ | |
222 OPstrctor, /* call ctor on struct param */ | |
223 OPstrthis, // 'this' pointer for OPstrctor | |
224 OPstrpar, /* structure func param */ | |
225 OPconst, /* constant */ | |
226 OPrelconst, /* constant that contains an address */ | |
227 OPvar, /* variable */ | |
228 OPreg, // register (used in inline asm operand expressions) | |
229 OPcolon, /* : as in ?: */ | |
230 OPcolon2, // alternate version with different EH semantics | |
231 OPstring, /* address of string */ | |
232 OPasm, /* in-line assembly code */ | |
233 OPinfo, // attach info (used to attach ctor/dtor | |
234 OPhalt, // insert HLT instruction | |
235 // info for exception handling) | |
236 OPctor, | |
237 OPdtor, | |
238 OPmark, | |
239 OPpair, // build register pair, E1 is lsb, E2 = msb | |
240 OPrpair, // build reversed register pair, E1 is msb, E2 = lsb | |
241 OPframeptr, // load pointer to base of frame | |
242 OPgot, // load pointer to global offset table | |
243 | |
244 // Jupiter operators | |
245 OParray, // access Jupiter array, left is handle, right is index | |
246 OParraylength, // evaluates array handle into array length | |
247 OPfield, // access Jupiter object field, left is handle, right is offset | |
248 OPnewarray, // allocate Jupiter array, left is dimension, right is type | |
249 OPmultinewarray, // allocate multidimensional Jupiter array | |
250 // left is dimensions, right is (numdims,type signature) | |
251 OPinstanceof, // left is class id, right is handle | |
252 OPfinalinstanceof, // left is class id, right is handle | |
253 OPcheckcast, // left is class id, right is handle | |
254 OPhstring, // handle to static string | |
255 OPnullcheck, // check if pointer is null | |
256 | |
257 ///#if TX86 | |
258 OPinp, /* input from I/O port */ | |
259 OPoutp, /* output to I/O port */ | |
260 ///#endif | |
261 /* C++ operators */ | |
262 OPnew, // operator new | |
263 OPanew, // operator new[] | |
264 OPdelete, // operator delete | |
265 OPadelete, // operator delete[] | |
266 OPbrack, /* [] subscript */ | |
267 OParrow, /* for -> overloading */ | |
268 OParrowstar, /* for ->* overloading */ | |
269 OPpreinc, /* ++x overloading */ | |
270 OPpredec, /* --x overloading */ | |
271 | |
272 ///#ifdef TARGET_INLINEFUNC_OPS | |
273 /// TARGET_INLINEFUNC_OPS | |
274 ///#endif | |
275 | |
276 ///#if (TARGET_POWERPC) | |
277 OPeieio, | |
278 ///#endif | |
279 | |
280 OPMAX /* 1 past last operator */ | |
281 } | |
282 | |
283 enum RELOPMIN = cast(int)OPER.OPle; | |
284 | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
285 version (Windows) |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
286 { |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
287 extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab1; |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
288 extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab2; |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
289 extern(C++) extern __gshared const ubyte[OPER.OPMAX] optab3; |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
290 extern(C++) extern __gshared const ubyte[OPER.OPMAX] opcost; |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
291 } |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
292 else |
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
293 { |
16
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
294 extern(C) extern __gshared const ubyte[OPER.OPMAX] optab1; |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
295 extern(C) extern __gshared const ubyte[OPER.OPMAX] optab2; |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
296 extern(C) extern __gshared const ubyte[OPER.OPMAX] optab3; |
5c9b78899f5d
Implemented methods for Tuples, fixed some linking issues.
Robert Clipsham <robert@octarineparrot.com>
parents:
14
diff
changeset
|
297 extern(C) extern __gshared const ubyte[OPER.OPMAX] opcost; |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
298 } |
0 | 299 |
300 enum _OT | |
301 { | |
302 _OTbinary = 1, | |
303 _OTunary = 2, | |
304 _OTcommut = 4, | |
305 _OTassoc = 8, | |
306 _OTsideff = 0x10, | |
307 _OTeop0e = 0x20, | |
308 _OTeop00 = 0x40, | |
309 _OTeop1e = 0x80, | |
310 | |
311 /* optab2[] */ | |
312 _OTlogical = 1, | |
313 _OTwid = 2, | |
314 _OTcall = 4, | |
315 _OTrtol = 8, | |
316 _OTassign = 0x10, | |
317 _OTdef = 0x20, | |
318 _OTae = 0x40, | |
319 _OTexp = 0x80, | |
320 } | |
321 | |
322 /+ | |
323 // optab3[] | |
324 #define _OTboolnop 1 | |
325 +/ | |
326 | |
140 | 327 ubyte OTbinary(OPER op) |
328 { | |
0 | 329 return (optab1[op] & _OT._OTbinary); |
330 } | |
331 | |
140 | 332 ubyte OTunary(OPER op) |
333 { | |
334 return (optab1[op] & _OT._OTunary); | |
335 } | |
336 | |
0 | 337 /+ |
338 #define OTleaf(op) (!(optab1[op]&(_OTunary|_OTbinary))) | |
339 #define OTcommut(op) (optab1[op]&_OTcommut) | |
340 #define OTassoc(op) (optab1[op]&_OTassoc) | |
341 #define OTassign(op) (optab2[op]&_OTassign) | |
342 #define OTpost(op) ((op) == OPpostinc || (op) == OPpostdec) | |
343 #define OTeop0e(op) (optab1[op]&_OTeop0e) | |
344 #define OTeop00(op) (optab1[op]&_OTeop00) | |
345 #define OTeop1e(op) (optab1[op]&_OTeop1e) | |
346 #define OTsideff(op) (optab1[op]&_OTsideff) | |
347 #define OTconv(op) ((op) >= CNVOPMIN && (op) <= CNVOPMAX) | |
348 #define OTlogical(op) (optab2[op]&_OTlogical) | |
349 #define OTwid(op) (optab2[op]&_OTwid) | |
350 #define OTopeq(op) ((op) >= OPaddass && (op) <= OPashrass) | |
351 #define OTop(op) ((op) >= OPadd && (op) <= OPor) | |
352 #define OTcall(op) (optab2[op]&_OTcall) | |
353 #define OTrtol(op) (optab2[op]&_OTrtol) | |
354 #define OTrel(op) ((op) >= OPle && (op) <= OPnue) | |
355 #define OTrel2(op) ((op) >= OPle && (op) <= OPge) | |
356 #define OTdef(op) (optab2[op]&_OTdef) | |
357 #define OTae(op) (optab2[op]&_OTae) | |
358 #define OTexp(op) (optab2[op]&_OTexp) | |
359 #if 1 | |
360 #define OTboolnop(op) (optab3[op]&_OTboolnop) | |
361 #define OTcalldef(op) (OTcall(op) || (op) == OPstrcpy || (op) == OPstrcat || (op) == OPmemcpy) | |
362 #else | |
363 #endif | |
364 | |
365 /* Convert op= to op */ | |
366 #define opeqtoop(opx) ((opx) - OPaddass + OPadd) | |
367 | |
368 /* Convert op to op= */ | |
369 #define optoopeq(opx) ((opx) - OPadd + OPaddass) | |
370 +/ | |
371 | |
372 import dmd.EnumUtils; | |
14
2cc604139636
Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents:
0
diff
changeset
|
373 mixin(BringToCurrentScope!(OPER)); |