@@ -84,25 +84,17 @@ struct LLTypeMemoryLayout {
8484
8585// / Removes padding fields for (non-union-containing!) structs
8686struct RemoveStructPadding : ABIRewrite {
87- // / get a rewritten value back to its original form
88- LLValue *get (Type *dty, LLValue *v) override {
89- LLValue *lval = DtoAlloca (dty, " .rewritetmp" );
90- getL (dty, v, lval);
91- return lval;
87+ LLValue *put (DValue *v) override {
88+ return DtoUnpaddedStruct (v->getType ()->toBasetype (), v->getRVal ());
9289 }
9390
94- // / get a rewritten value back to its original form and store result in
95- // / provided lvalue
96- void getL (Type *dty, LLValue *v, LLValue *lval) override {
91+ LLValue *getLVal (Type *dty, LLValue *v) override {
92+ LLValue *lval = DtoAlloca (dty, " .RemoveStructPadding_dump" );
9793 // Make sure the padding is zero, so struct comparisons work.
9894 // TODO: Only do this if there's padding, and/or only initialize padding.
9995 DtoMemSetZero (lval, DtoConstSize_t (getTypeAllocSize (DtoType (dty))));
10096 DtoPaddedStruct (dty->toBasetype (), v, lval);
101- }
102-
103- // / put out rewritten value
104- LLValue *put (DValue *v) override {
105- return DtoUnpaddedStruct (v->getType ()->toBasetype (), v->getRVal ());
97+ return lval;
10698 }
10799
108100 // / return the transformed type for this rewrite
@@ -164,20 +156,14 @@ struct IntegerRewrite : ABIRewrite {
164156 return LLTypeMemoryLayout::typesAreEquivalent (llType, integerType);
165157 }
166158
167- LLValue *get (Type *dty, LLValue *v) override {
168- LLValue *integerDump = DtoAllocaDump (v, dty, " .IntegerRewrite_dump" );
169- LLType *type = DtoType (dty);
170- return loadFromMemory (integerDump, type, " .IntegerRewrite_getResult" );
171- }
172-
173- void getL (Type *dty, LLValue *v, LLValue *lval) override {
174- storeToMemory (v, lval);
175- }
176-
177159 LLValue *put (DValue *dv) override {
178160 LLValue *address = getAddressOf (dv);
179161 LLType *integerType = getIntegerType (dv->getType ()->size ());
180- return loadFromMemory (address, integerType, " .IntegerRewrite_putResult" );
162+ return loadFromMemory (address, integerType);
163+ }
164+
165+ LLValue *getLVal (Type *dty, LLValue *v) override {
166+ return DtoAllocaDump (v, dty, " .IntegerRewrite_dump" );
181167 }
182168
183169 LLType *type (Type *t, LLType *) override { return getIntegerType (t->size ()); }
@@ -204,29 +190,25 @@ struct ExplicitByvalRewrite : ABIRewrite {
204190 explicit ExplicitByvalRewrite (unsigned minAlignment = 16 )
205191 : minAlignment(minAlignment) {}
206192
207- LLValue *get (Type *dty, LLValue *v) override {
208- return DtoLoad (v, " .ExplicitByvalRewrite_getResult" );
209- }
210-
211- void getL (Type *dty, LLValue *v, LLValue *lval) override {
212- DtoMemCpy (lval, v);
213- }
214-
215193 LLValue *put (DValue *v) override {
216194 Type *dty = v->getType ();
217195 const unsigned align = alignment (dty);
218196
219- if (DtoIsInMemoryOnly (dty)) {
220- LLValue *originalPointer = v->getRVal ();
221- LLType *type = originalPointer->getType ()->getPointerElementType ();
222- LLValue *copyForCallee =
223- DtoRawAlloca (type, align, " .ExplicitByvalRewrite_putResult" );
224- DtoMemCpy (copyForCallee, originalPointer);
225- return copyForCallee;
197+ if (!DtoIsInMemoryOnly (dty)) {
198+ return DtoAllocaDump (v->getRVal (), align,
199+ " .ExplicitByvalRewrite_dump" );
226200 }
227201
228- return DtoAllocaDump (v->getRVal (), align,
229- " .ExplicitByvalRewrite_putResult" );
202+ LLValue *originalPointer = v->getRVal ();
203+ LLType *type = originalPointer->getType ()->getPointerElementType ();
204+ LLValue *copyForCallee =
205+ DtoRawAlloca (type, align, " .ExplicitByvalRewrite_dump" );
206+ DtoMemCpy (copyForCallee, originalPointer);
207+ return copyForCallee;
208+ }
209+
210+ LLValue *getLVal (Type *dty, LLValue *v) override {
211+ return DtoBitCast (v, DtoPtrToType (dty));
230212 }
231213
232214 LLType *type (Type *dty, LLType *t) override { return DtoPtrToType (dty); }
@@ -245,22 +227,18 @@ struct HFAToArray : ABIRewrite {
245227
246228 HFAToArray (const int max = 4 ) : maxFloats(max) {}
247229
248- LLValue *get (Type *dty, LLValue *v) override {
249- Logger::println (" rewriting array -> as HFA %s" , dty->toChars ());
250- LLValue *lval = DtoRawAlloca (v->getType (), 0 );
251- DtoStore (v, lval);
252-
253- LLType *pTy = getPtrToType (DtoType (dty));
254- return DtoLoad (DtoBitCast (lval, pTy), " get-result" );
255- }
256-
257230 LLValue *put (DValue *dv) override {
258231 Type *dty = dv->getType ();
259232 Logger::println (" rewriting HFA %s -> as array" , dty->toChars ());
260233 LLType *t = type (dty, nullptr );
261234 return DtoLoad (DtoBitCast (dv->getRVal (), getPtrToType (t)));
262235 }
263236
237+ LLValue *getLVal (Type *dty, LLValue *v) override {
238+ Logger::println (" rewriting array -> as HFA %s" , dty->toChars ());
239+ return DtoAllocaDump (v, dty, " .HFAToArray_dump" );
240+ }
241+
264242 LLType *type (Type *dty, LLType *) override {
265243 assert (dty->ty == Tstruct);
266244 LLType *floatArrayType = nullptr ;
@@ -274,22 +252,18 @@ struct HFAToArray : ABIRewrite {
274252 * Rewrite a composite as array of i64.
275253 */
276254struct CompositeToArray64 : ABIRewrite {
277- LLValue *get (Type *dty, LLValue *v) override {
278- Logger::println (" rewriting i64 array -> as %s" , dty->toChars ());
279- LLValue *lval = DtoRawAlloca (v->getType (), 0 );
280- DtoStore (v, lval);
281-
282- LLType *pTy = getPtrToType (DtoType (dty));
283- return DtoLoad (DtoBitCast (lval, pTy), " get-result" );
284- }
285-
286255 LLValue *put (DValue *dv) override {
287256 Type *dty = dv->getType ();
288257 Logger::println (" rewriting %s -> as i64 array" , dty->toChars ());
289258 LLType *t = type (dty, nullptr );
290259 return DtoLoad (DtoBitCast (dv->getRVal (), getPtrToType (t)));
291260 }
292261
262+ LLValue *getLVal (Type *dty, LLValue *v) override {
263+ Logger::println (" rewriting i64 array -> as %s" , dty->toChars ());
264+ return DtoAllocaDump (v, dty, " .CompositeToArray64_dump" );
265+ }
266+
293267 LLType *type (Type *t, LLType *) override {
294268 // An i64 array that will hold Type 't'
295269 size_t sz = (t->size () + 7 ) / 8 ;
@@ -301,22 +275,18 @@ struct CompositeToArray64 : ABIRewrite {
301275 * Rewrite a composite as array of i32.
302276 */
303277struct CompositeToArray32 : ABIRewrite {
304- LLValue *get (Type *dty, LLValue *v) override {
305- Logger::println (" rewriting i32 array -> as %s" , dty->toChars ());
306- LLValue *lval = DtoRawAlloca (v->getType (), 0 );
307- DtoStore (v, lval);
308-
309- LLType *pTy = getPtrToType (DtoType (dty));
310- return DtoLoad (DtoBitCast (lval, pTy), " get-result" );
311- }
312-
313278 LLValue *put (DValue *dv) override {
314279 Type *dty = dv->getType ();
315280 Logger::println (" rewriting %s -> as i32 array" , dty->toChars ());
316281 LLType *t = type (dty, nullptr );
317282 return DtoLoad (DtoBitCast (dv->getRVal (), getPtrToType (t)));
318283 }
319284
285+ LLValue *getLVal (Type *dty, LLValue *v) override {
286+ Logger::println (" rewriting i32 array -> as %s" , dty->toChars ());
287+ return DtoAllocaDump (v, dty, " .CompositeToArray32_dump" );
288+ }
289+
320290 LLType *type (Type *t, LLType *) override {
321291 // An i32 array that will hold Type 't'
322292 size_t sz = (t->size () + 3 ) / 4 ;
0 commit comments