annotate dmd/backend/elem.d @ 146:af7e5ebef6ad

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