Mercurial > projects > ldc
annotate gen/abi-generic.h @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | 34f2fd925de3 |
children |
rev | line source |
---|---|
1359
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
1 #ifndef LDC_GEN_ABI_GENERIC |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
2 #define LDC_GEN_ABI_GENERIC |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
3 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
4 #include "gen/llvmhelpers.h" |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
5 #include "gen/tollvm.h" |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
6 #include "gen/structs.h" |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
7 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
8 /// Removes padding fields for (non-union-containing!) structs |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
9 struct RemoveStructPadding : ABIRewrite { |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
10 /// get a rewritten value back to its original form |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
11 virtual LLValue* get(Type* dty, DValue* v) { |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
12 LLValue* lval = DtoAlloca(dty, ".rewritetmp"); |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
13 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
14 // Make sure the padding is zero, so struct comparisons work. |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
15 // TODO: Only do this if there's padding, and/or only initialize padding. |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
16 DtoMemSetZero(lval, DtoConstSize_t(getTypePaddedSize(DtoType(dty)))); |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
17 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
18 DtoPaddedStruct(dty, v->getRVal(), lval); |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
19 return lval; |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
20 } |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
21 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
22 /// get a rewritten value back to its original form and store result in provided lvalue |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
23 /// this one is optional and defaults to calling the one above |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
24 virtual void getL(Type* dty, DValue* v, llvm::Value* lval) { |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
25 DtoPaddedStruct(dty, v->getRVal(), lval); |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
26 } |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
27 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
28 /// put out rewritten value |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
29 virtual LLValue* put(Type* dty, DValue* v) { |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
30 return DtoUnpaddedStruct(dty, v->getRVal()); |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
31 } |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
32 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
33 /// return the transformed type for this rewrite |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
34 virtual const LLType* type(Type* dty, const LLType* t) { |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
35 return DtoUnpaddedStructType(dty); |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
36 } |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
37 }; |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
38 |
34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
Frits van Bommel <fvbommel wxs.nl>
parents:
diff
changeset
|
39 #endif |