| 1 |
#ifndef LDC_GEN_ABI_GENERIC |
|---|
| 2 |
#define LDC_GEN_ABI_GENERIC |
|---|
| 3 |
|
|---|
| 4 |
#include "gen/llvmhelpers.h" |
|---|
| 5 |
#include "gen/tollvm.h" |
|---|
| 6 |
#include "gen/structs.h" |
|---|
| 7 |
|
|---|
| 8 |
/// Removes padding fields for (non-union-containing!) structs |
|---|
| 9 |
struct RemoveStructPadding : ABIRewrite { |
|---|
| 10 |
/// get a rewritten value back to its original form |
|---|
| 11 |
virtual LLValue* get(Type* dty, DValue* v) { |
|---|
| 12 |
LLValue* lval = DtoAlloca(dty, ".rewritetmp"); |
|---|
| 13 |
|
|---|
| 14 |
// Make sure the padding is zero, so struct comparisons work. |
|---|
| 15 |
// TODO: Only do this if there's padding, and/or only initialize padding. |
|---|
| 16 |
DtoMemSetZero(lval, DtoConstSize_t(getTypePaddedSize(DtoType(dty)))); |
|---|
| 17 |
|
|---|
| 18 |
DtoPaddedStruct(dty, v->getRVal(), lval); |
|---|
| 19 |
return lval; |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
/// get a rewritten value back to its original form and store result in provided lvalue |
|---|
| 23 |
/// this one is optional and defaults to calling the one above |
|---|
| 24 |
virtual void getL(Type* dty, DValue* v, llvm::Value* lval) { |
|---|
| 25 |
DtoPaddedStruct(dty, v->getRVal(), lval); |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
/// put out rewritten value |
|---|
| 29 |
virtual LLValue* put(Type* dty, DValue* v) { |
|---|
| 30 |
return DtoUnpaddedStruct(dty, v->getRVal()); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
/// return the transformed type for this rewrite |
|---|
| 34 |
virtual const LLType* type(Type* dty, const LLType* t) { |
|---|
| 35 |
return DtoUnpaddedStructType(dty); |
|---|
| 36 |
} |
|---|
| 37 |
}; |
|---|
| 38 |
|
|---|
| 39 |
#endif |
|---|