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