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