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