Mercurial > projects > ldc
comparison gen/asmstmt.cpp @ 304:3ebc136702dd trunk
[svn r325] Removed dead code.
Added license info to code from GDC (David Friedman permitted us to use the files under the Artistic License).
Added asmLabel check to DtoGoto to avoid jumping into inline asm. Doesn't work currently as LabelDsymbol::asmLabel is never set to true.
author | ChristianK |
---|---|
date | Wed, 25 Jun 2008 23:42:38 +0200 |
parents | 4aa2b6753059 |
children | 2b72433d5c8c |
comparison
equal
deleted
inserted
replaced
303:4aa2b6753059 | 304:3ebc136702dd |
---|---|
1 // Taken from GDC source tree, licence unclear? | 1 // Taken from GDC source tree. Original by David Friedman. |
2 // | 2 // Released under the Artistic License found in dmd/artistic.txt |
3 // Taken from an earlier version of DMD -- why is it missing from 0.79? | |
4 | 3 |
5 #include "gen/llvm.h" | 4 #include "gen/llvm.h" |
6 #include "llvm/InlineAsm.h" | 5 #include "llvm/InlineAsm.h" |
7 | 6 |
8 //#include "d-gcc-includes.h" | 7 //#include "d-gcc-includes.h" |
128 | 127 |
129 int AsmStatement::comeFrom() | 128 int AsmStatement::comeFrom() |
130 { | 129 { |
131 return FALSE; | 130 return FALSE; |
132 } | 131 } |
133 | |
134 /* GCC does not support jumps from asm statements. When optimization | |
135 is turned on, labels referenced only from asm statements will not | |
136 be output at the correct location. There are ways around this: | |
137 | |
138 1) Reference the label with a reachable goto statement | |
139 2) Have reachable computed goto in the function | |
140 3) Hack cfgbuild.c to act as though there is a computed goto. | |
141 | |
142 These are all pretty bad, but if would be nice to be able to tell | |
143 GCC not to optimize in this case (even on per label/block basis). | |
144 | |
145 The current solution is output our own private labels (as asm | |
146 statements) along with the "real" label. If the label happens to | |
147 be referred to by a goto statement, the "real" label will also be | |
148 output in the correct location. | |
149 | |
150 Also had to add 'asmLabelNum' to LabelDsymbol to indicate it needs | |
151 special processing. | |
152 | |
153 (junk) d-lang.cc:916:case LABEL_DECL: // C doesn't do this. D needs this for referencing labels in inline assembler since there may be not goto referencing it. | |
154 | |
155 */ | |
156 | |
157 static unsigned d_priv_asm_label_serial = 0; | |
158 | |
159 // may need to make this target-specific | |
160 static void d_format_priv_asm_label(char * buf, unsigned n) | |
161 { | |
162 //ASM_GENERATE_INTERNAL_LABEL(buf, "LDASM", n);//inserts a '*' for use with assemble_name | |
163 assert(0); | |
164 sprintf(buf, ".LDASM%u", n); | |
165 } | |
166 | |
167 void | |
168 d_expand_priv_asm_label(IRState * irs, unsigned n) | |
169 { | |
170 /* char buf[64]; | |
171 d_format_priv_asm_label(buf, n); | |
172 strcat(buf, ":"); | |
173 tree insnt = build_string(strlen(buf), buf); | |
174 #if D_GCC_VER < 40 | |
175 expand_asm(insnt, 1); | |
176 #else | |
177 tree t = d_build_asm_stmt(insnt, NULL_TREE, NULL_TREE, NULL_TREE); | |
178 ASM_VOLATILE_P( t ) = 1; | |
179 ASM_INPUT_P( t) = 1; // what is this doing? | |
180 irs->addExp(t); | |
181 #endif*/ | |
182 } | |
183 | |
184 | |
185 // StringExp::toIR usually adds a NULL. We don't want that... | |
186 | |
187 /*static tree | |
188 naturalString(Expression * e) | |
189 { | |
190 // don't fail, just an error? | |
191 assert(e->op == TOKstring); | |
192 StringExp * s = (StringExp *) e; | |
193 assert(s->sz == 1); | |
194 return build_string(s->len, (char *) s->string); | |
195 }*/ | |
196 | 132 |
197 | 133 |
198 #include "d-asm-i386.h" | 134 #include "d-asm-i386.h" |
199 | 135 |
200 bool d_have_inline_asm() { return true; } | 136 bool d_have_inline_asm() { return true; } |