Mercurial > projects > ldc
annotate gen/tocsym.cpp @ 1117:4c20fcc4252b
Fun with parameter attributes: For several of the "synthetic" parameters added
to D functions, we can apply noalias and nocapture. They are sret parameters,
'nest' pointers passed to nested functions, and _argptr:
Nocapture:
- Sret and nest are nocapture because they don't represent D-level variables,
and thus the callee can't (validly) obtain a pointer to them, let alone keep
it around after it returns.
- _argptr is nocapture because although the callee has access to it as a
pointer, that pointer is invalidated when it returns.
All three are noalias because they're function-local variables
- Sret and _argptr are noalias because they're freshly alloca'd memory only
used for a single function call that's not allowed to keep an aliasing
pointer to it around (since the parameter is nocapture).
- 'Nest' is noalias because the callee only ever has access to one such pointer
per parent function, and every parent function has a different one.
This commit also ensures attributes set on sret, _arguments and _argptr are
propagated to calls to such functions.
It also adds one exception to the general rule that attributes on function types
should propagate to calls: the type of a delegate's function pointer has a
'nest' parameter, but this can either be a true 'nest' (for delegates to nested
functions) or a 'this' (for delegates to member functions). Since 'this' is
neither noalias nor nocapture, and there's generally no way to tell which one it
is, we remove these attributes at the call site if the callee is a delegate.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 14 Mar 2009 22:15:31 +0100 |
parents | 29c0d1194033 |
children |
rev | line source |
---|---|
1 | 1 |
2 // Copyright (c) 1999-2005 by Digital Mars | |
3 // All Rights Reserved | |
4 // written by Walter Bright | |
5 // www.digitalmars.com | |
6 // License for redistribution is by either the Artistic License | |
7 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
8 // See the included readme.txt for details. | |
9 | |
10 // stubbed out for dmdfe. Original is in dmd/tocsym.c | |
11 | |
12 #include <stddef.h> | |
13 | |
14 #include "mars.h" | |
15 #include "module.h" | |
16 #include "mtype.h" | |
17 #include "declaration.h" | |
18 #include "statement.h" | |
19 #include "enum.h" | |
20 #include "aggregate.h" | |
21 #include "init.h" | |
22 #include "attrib.h" | |
23 #include "lexer.h" | |
24 | |
25 | |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
758
diff
changeset
|
26 Symbol *StaticStructInitDeclaration::toSymbol() |
1 | 27 { |
913
29c0d1194033
Fix #198 and #199 by making CTFE on static struct initializers work.
Christian Kamm <kamm incasoftware de>
parents:
758
diff
changeset
|
28 return 0; |
1 | 29 } |
30 | |
31 /************************************* | |
32 * Helper | |
33 */ | |
34 | |
35 Symbol *Dsymbol::toSymbolX(const char *prefix, int sclass, TYPE *t, const char *suffix) | |
36 { | |
37 return 0; | |
38 } | |
39 | |
40 /************************************* | |
41 */ | |
42 | |
43 Symbol *Dsymbol::toSymbol() | |
44 { | |
45 return 0; | |
46 } | |
47 | |
48 /********************************* | |
49 * Generate import symbol from symbol. | |
50 */ | |
51 | |
52 Symbol *Dsymbol::toImport() | |
53 { | |
54 return 0; | |
55 } | |
56 | |
57 /************************************* | |
58 */ | |
59 | |
60 Symbol *Dsymbol::toImport(Symbol *sym) | |
61 { | |
62 return 0; | |
63 } | |
64 | |
65 /************************************* | |
66 */ | |
67 | |
68 Symbol *VarDeclaration::toSymbol() | |
69 { | |
70 return 0; | |
71 } | |
72 | |
73 /************************************* | |
74 */ | |
75 | |
76 Symbol *ClassInfoDeclaration::toSymbol() | |
77 { | |
78 return 0; | |
79 } | |
80 | |
81 /************************************* | |
82 */ | |
83 | |
84 Symbol *ModuleInfoDeclaration::toSymbol() | |
85 { | |
86 return 0; | |
87 } | |
88 | |
89 /************************************* | |
90 */ | |
91 | |
92 Symbol *TypeInfoDeclaration::toSymbol() | |
93 { | |
94 return 0; | |
95 } | |
96 | |
97 /************************************* | |
98 */ | |
99 | |
100 Symbol *FuncDeclaration::toSymbol() | |
101 { | |
102 | |
103 return 0; | |
104 } | |
105 | |
106 /************************************* | |
107 */ | |
108 | |
109 Symbol *FuncDeclaration::toThunkSymbol(int offset) | |
110 { | |
111 return 0; | |
112 } | |
113 | |
114 /************************************* | |
115 */ | |
116 | |
117 Symbol *FuncAliasDeclaration::toSymbol() | |
118 { | |
119 | |
120 return 0; | |
121 } | |
122 | |
123 | |
124 /**************************************** | |
125 * Create a static symbol we can hang DT initializers onto. | |
126 */ | |
127 | |
128 Symbol *static_sym() | |
129 { | |
130 return 0; | |
131 } | |
132 | |
133 /************************************* | |
134 * Create the "ClassInfo" symbol | |
135 */ | |
136 | |
137 Symbol *ClassDeclaration::toSymbol() | |
138 { | |
139 return 0; | |
140 } | |
141 | |
142 /************************************* | |
143 * Create the "InterfaceInfo" symbol | |
144 */ | |
145 | |
146 Symbol *InterfaceDeclaration::toSymbol() | |
147 { | |
148 return 0; | |
149 } | |
150 | |
151 /************************************* | |
152 * Create the "ModuleInfo" symbol | |
153 */ | |
154 | |
155 Symbol *Module::toSymbol() | |
156 { | |
157 return 0; | |
158 } | |
159 | |
160 /************************************* | |
161 * This is accessible via the ClassData, but since it is frequently | |
162 * needed directly (like for rtti comparisons), make it directly accessible. | |
163 */ | |
164 | |
165 Symbol *ClassDeclaration::toVtblSymbol() | |
166 { | |
167 return 0; | |
168 } | |
169 | |
170 /********************************** | |
171 * Create the static initializer for the struct/class. | |
172 */ | |
173 | |
174 Symbol *AggregateDeclaration::toInitializer() | |
175 { | |
176 return 0; | |
177 } | |
178 | |
179 | |
180 /****************************************** | |
181 */ | |
182 | |
183 Symbol *Module::toModuleAssert() | |
184 { | |
185 return 0; | |
186 } | |
187 | |
188 /****************************************** | |
189 */ | |
190 | |
191 Symbol *Module::toModuleArray() | |
192 { | |
193 return 0; | |
194 } | |
195 | |
196 /******************************************** | |
197 * Determine the right symbol to look up | |
198 * an associative array element. | |
199 * Input: | |
200 * flags 0 don't add value signature | |
201 * 1 add value signature | |
202 */ | |
203 | |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
96
diff
changeset
|
204 Symbol *TypeAArray::aaGetSymbol(const char *func, int flags) |
1 | 205 { |
206 return 0; | |
207 } | |
208 |