Mercurial > projects > ddmd
comparison dmd/backend/elem.d @ 0:10317f0c89a5
Initial commit
author | korDen |
---|---|
date | Sat, 24 Oct 2009 08:42:06 +0400 |
parents | |
children | e28b18c23469 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:10317f0c89a5 |
---|---|
1 module dmd.backend.elem; | |
2 | |
3 import dmd.Port; | |
4 import dmd.Complex; | |
5 | |
6 import dmd.backend.targ_types; | |
7 import dmd.backend.Symbol; | |
8 import dmd.backend.PARAM; | |
9 import dmd.backend.LIST; | |
10 import dmd.backend.Classsym; | |
11 import dmd.backend.TYPE; | |
12 import dmd.backend.Util; | |
13 import dmd.backend.Srcpos; | |
14 | |
15 /********************************* | |
16 * Union of all data types. Storage allocated must be the right | |
17 * size of the data on the TARGET, not the host. | |
18 */ | |
19 | |
20 union eve | |
21 { | |
22 targ_char Vchar; | |
23 targ_schar Vschar; | |
24 targ_uchar Vuchar; | |
25 targ_short Vshort; | |
26 targ_ushort Vushort; | |
27 targ_int Vint; // also used for tmp numbers (FLtmp) | |
28 targ_uns Vuns; | |
29 targ_long Vlong; | |
30 targ_ulong Vulong; | |
31 targ_llong Vllong; | |
32 targ_ullong Vullong; | |
33 targ_float Vfloat; | |
34 targ_double Vdouble; | |
35 targ_ldouble Vldouble; | |
36 Complex!(float) Vcfloat; | |
37 Complex!(double)Vcdouble; | |
38 Complex!(real) Vcldouble; | |
39 targ_size_t Vpointer; | |
40 targ_ptrdiff_t Vptrdiff; | |
41 targ_uchar Vreg; // register number for OPreg elems | |
42 | |
43 struct VFP // 48 bit 386 far pointer | |
44 { targ_long Voff; | |
45 targ_ushort Vseg; | |
46 } VFP Vfp; | |
47 | |
48 struct SP | |
49 { | |
50 targ_size_t Voffset;// offset from symbol | |
51 Symbol* Vsym; // pointer to symbol table | |
52 union SPU | |
53 { | |
54 PARAM* Vtal; // template-argument-list for SCfunctempl, | |
55 // used only to transmit it to cpp_overload() | |
56 LIST* Erd; // OPvar: reaching definitions | |
57 } SPU spu; | |
58 } SP sp; | |
59 | |
60 struct SM | |
61 { | |
62 targ_size_t Voffset;// member pointer offset | |
63 Classsym* Vsym; // struct tag | |
64 elem* ethis; // OPrelconst: 'this' for member pointer | |
65 } SM sm; | |
66 | |
67 struct SS | |
68 { | |
69 targ_size_t Voffset;// offset from string | |
70 char* Vstring; // pointer to string (OPstring or OPasm) | |
71 targ_size_t Vstrlen;// length of string | |
72 } SS ss; | |
73 | |
74 struct EOP | |
75 { | |
76 elem* Eleft; // left child for unary & binary nodes | |
77 elem* Eright; // right child for binary nodes | |
78 Symbol* Edtor; // OPctor: destructor | |
79 } EOP eop; | |
80 } // variants for each type of elem | |
81 | |
82 /****************************************** | |
83 * Elems: | |
84 * Elems are the basic tree element. They can be either | |
85 * terminal elems (leaves), unary elems (left subtree exists) | |
86 * or binary elems (left and right subtrees exist). | |
87 */ | |
88 struct elem | |
89 { | |
90 debug { | |
91 ushort id; | |
92 } | |
93 | |
94 ubyte Eoper; // operator (OPxxxx) | |
95 ubyte Ecount; // # of parents of this elem - 1, | |
96 // always 0 until CSE elimination is done | |
97 eve EV; // variants for each type of elem | |
98 | |
99 ref elem* E1() | |
100 { | |
101 return EV.eop.Eleft; /* left child */ | |
102 } | |
103 | |
104 ref elem* E2() | |
105 { | |
106 return EV.eop.Eright; /* right child */ | |
107 } | |
108 | |
109 ref LIST* Erd() | |
110 { | |
111 return EV.sp.spu.Erd; // reaching definition | |
112 } | |
113 | |
114 union | |
115 { | |
116 // PARSER | |
117 struct | |
118 { | |
119 TYPE* ET; // pointer to type of elem | |
120 ubyte PEFflags; | |
121 } | |
122 | |
123 // OPTIMIZER | |
124 struct | |
125 { | |
126 tym_t Ety; // data type (TYxxxx) | |
127 uint Eexp; // index into expnod[] | |
128 | |
129 // These flags are all temporary markers, used once and then | |
130 // thrown away. | |
131 ubyte Nflags; // NFLxxx | |
132 version (MARS) { | |
133 ubyte Ejty; // original Jupiter/Mars type | |
134 } | |
135 } | |
136 | |
137 // CODGEN | |
138 struct | |
139 { | |
140 // Ety2: Must be in same position as Ety! | |
141 tym_t Ety2; // data type (TYxxxx) | |
142 ubyte Ecomsub; // number of remaining references to | |
143 // this common subexp (used to determine | |
144 // first, intermediate, and last references | |
145 // to a CSE) | |
146 | |
147 version (TARGET_POWERPC) { | |
148 ubyte Gflags; | |
149 } | |
150 } | |
151 } | |
152 | |
153 targ_size_t Enumbytes; // number of bytes for type if TYstruct | TYarray | |
154 // TARGET_structELEM // target specific additions | |
155 Srcpos Esrcpos; // source file position | |
156 } |