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

redundant extern(C)
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Tue, 14 Sep 2010 23:34:50 +0100
parents e28b18c23469
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.TYFL;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 14
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 extern(C++) ubyte* get_tytab();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 ubyte* tytab() { return get_tytab(); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 extern(C++) ubyte* get_tytab2();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 ubyte* tytab2() { return get_tytab2(); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 /* Array to give the size in bytes of a type, -1 means error */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 extern(C++) byte* get_tysize();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 byte* tysize() { return get_tysize(); }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 enum TYFL
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 /* Flags in tytab[] array */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 TYFLptr = 1,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 TYFLreal = 2,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 TYFLintegral = 4,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 TYFLcomplex = 8,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 TYFLimaginary = 0x10,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 TYFLuns = 0x20,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 TYFLmptr = 0x40,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 TYFLfv = 0x80, /* TYfptr || TYvptr */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 /* Flags in tytab2[] array */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 ///version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 TYFLfarfunc = 1,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 TYFLpascal = 2, /* callee cleans up stack */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 TYFLrevparam = 4, /* function parameters are reversed */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 ///} else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 /// TYFLcallstkc = 1, /* callee cleans up stack */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 /// TYFLrevparam = 2, /* function parameters are reversed */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 ///}
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 TYFLshort = 0x10,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 TYFLaggregate = 0x20,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 TYFLfunc = 0x40,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 TYFLref = 0x80,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 /* Groupings of types */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 ubyte tyintegral(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 return (tytab[(ty) & 0xFF] & TYFL.TYFLintegral);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 ubyte tyarithmetic(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 return (tytab[(ty) & 0xFF] & (TYFL.TYFLintegral | TYFL.TYFLreal | TYFL.TYFLimaginary | TYFL.TYFLcomplex));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 ubyte tyaggregate(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 return (tytab2[(ty) & 0xFF] & TYFL.TYFLaggregate);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 ubyte tyscalar(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 return (tytab[(ty) & 0xFF] & (TYFL.TYFLintegral | TYFL.TYFLreal | TYFL.TYFLimaginary | TYFL.TYFLcomplex | TYFL.TYFLptr | TYFL.TYFLmptr));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 ubyte tyfloating(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 return (tytab[(ty) & 0xFF] & (TYFL.TYFLreal | TYFL.TYFLimaginary | TYFL.TYFLcomplex));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 ubyte tyimaginary(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 return (tytab[(ty) & 0xFF] & TYFL.TYFLimaginary);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 ubyte tycomplex(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 return (tytab[(ty) & 0xFF] & TYFL.TYFLcomplex);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 ubyte tyreal(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 return (tytab[(ty) & 0xFF] & TYFL.TYFLreal);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 /* Types that are chars or shorts */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 ubyte tyshort(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 return (tytab2[(ty) & 0xFF] & TYFL.TYFLshort);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 /* Detect TYlong or TYulong */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 #define tylong(ty) (tybasic(ty) == TYlong || tybasic(ty) == TYulong)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 /* Use to detect a pointer type */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 ubyte typtr(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 return (tytab[(ty) & 0xFF] & TYFL.TYFLptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 /* Use to detect a reference type */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 ubyte tyref(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 return (tytab2[(ty) & 0xFF] & TYFL.TYFLref);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 /* Use to detect a pointer type or a member pointer */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 ubyte tymptr(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 return (tytab[(ty) & 0xFF] & (TYFL.TYFLptr | TYFL.TYFLmptr));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 /* Detect TYfptr or TYvptr */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 ubyte tyfv(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 return (tytab[(ty) & 0xFF] & TYFL.TYFLfv);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 // Give size of type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 char tysize(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 return tysize[(ty) & 0xFF];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 /* All data types that fit in exactly 8 bits */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 bool tybyte(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 return (tysize(ty) == 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 /* Types that fit into a single machine register */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 bool tyreg(TY ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 return (tysize(ty) <= REGSIZE);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 /* Detect function type */
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
125 ubyte tyfunc(ulong ty) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 return (tytab2[(ty) & 0xFF] & TYFL.TYFLfunc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 /* Detect function type where parameters are pushed in reverse order */
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
130 ubyte tyrevfunc(ulong ty) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 return (tytab2[(ty) & 0xFF] & TYFL.TYFLrevparam);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 /* Detect unsigned types */
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
135 ubyte tyuns(ulong ty) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 return (tytab[(ty) & 0xFF] & (TYFL.TYFLuns | TYFL.TYFLptr));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 /* Target dependent info */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 version (TX86) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 /// #define TYoffset TYuint /* offset to an address */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 /* Detect cpp function type (callee cleans up stack) */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 ubyte typfunc(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 return (tytab2[(ty) & 0xFF] & TYFL.TYFLpascal);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 /* Detect cpp function type (callee cleans up stack) */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 ubyte typfunc(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 return (tytab2[(ty) & 0xFF] & TYFL.TYFLcallstkc);
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 /* Array to convert a type to its unsigned equivalent */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 extern(C++) extern tym_t* get_tytouns();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156
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
157 tym_t touns(ulong ty) {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 return get_tytouns[ty & 0xFF];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 /* Determine if TYffunc or TYfpfunc (a far function) */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 ubyte tyfarfunc(uint ty) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 return (tytab2[(ty) & 0xFF] & TYFL.TYFLfarfunc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 // Determine if parameter can go in register for TYjfunc
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 #ifndef tyjparam
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 #define tyjparam(ty) (tysize(ty) <= intsize && !tyfloating(ty) && tybasic(ty) != TYstruct)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 #endif
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 /* Determine relaxed type */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 #ifndef tyrelax
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 #define tyrelax(ty) (_tyrelax[tybasic(ty)])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 #endif
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
176 +/