Mercurial > projects > ldc
comparison gen/abi-x86-64.cpp @ 1359:34f2fd925de3
Intrinsics shouldn't see struct padding, so use a special TargetABI for them
that removes it.
This unbreaks the `llvm_*_with_overflow` intrinsics.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sat, 16 May 2009 13:06:49 +0200 |
parents | 701d11a1e7b1 |
children | d1fd46bbbff7 |
comparison
equal
deleted
inserted
replaced
1357:48747003a5de | 1359:34f2fd925de3 |
---|---|
41 #include "gen/logger.h" | 41 #include "gen/logger.h" |
42 #include "gen/dvalue.h" | 42 #include "gen/dvalue.h" |
43 #include "gen/llvmhelpers.h" | 43 #include "gen/llvmhelpers.h" |
44 #include "gen/abi.h" | 44 #include "gen/abi.h" |
45 #include "gen/abi-x86-64.h" | 45 #include "gen/abi-x86-64.h" |
46 #include "gen/structs.h" | 46 #include "gen/abi-generic.h" |
47 #include "ir/irfunction.h" | 47 #include "ir/irfunction.h" |
48 | 48 |
49 #include <cassert> | 49 #include <cassert> |
50 #include <map> | 50 #include <map> |
51 #include <string> | 51 #include <string> |
479 | 479 |
480 /// should return the transformed type for this rewrite | 480 /// should return the transformed type for this rewrite |
481 const LLType* type(Type* dty, const LLType* t) | 481 const LLType* type(Type* dty, const LLType* t) |
482 { | 482 { |
483 return getAbiType(dty); | 483 return getAbiType(dty); |
484 } | |
485 }; | |
486 | |
487 | |
488 /// Removes padding fields for (non-union-containing!) structs | |
489 struct RemoveStructPadding : ABIRewrite { | |
490 /// get a rewritten value back to its original form | |
491 virtual LLValue* get(Type* dty, DValue* v) { | |
492 LLValue* lval = DtoAlloca(dty, ".rewritetmp"); | |
493 | |
494 // Make sure the padding is zero, so struct comparisons work. | |
495 // TODO: Only do this if there's padding, and/or only initialize padding. | |
496 DtoMemSetZero(lval, DtoConstSize_t(getTypePaddedSize(DtoType(dty)))); | |
497 | |
498 DtoPaddedStruct(dty, v->getRVal(), lval); | |
499 return lval; | |
500 } | |
501 | |
502 /// get a rewritten value back to its original form and store result in provided lvalue | |
503 /// this one is optional and defaults to calling the one above | |
504 virtual void getL(Type* dty, DValue* v, llvm::Value* lval) { | |
505 DtoPaddedStruct(dty, v->getRVal(), lval); | |
506 } | |
507 | |
508 /// put out rewritten value | |
509 virtual LLValue* put(Type* dty, DValue* v) { | |
510 return DtoUnpaddedStruct(dty, v->getRVal()); | |
511 } | |
512 | |
513 /// return the transformed type for this rewrite | |
514 virtual const LLType* type(Type* dty, const LLType* t) { | |
515 return DtoUnpaddedStructType(dty); | |
516 } | 484 } |
517 }; | 485 }; |
518 | 486 |
519 | 487 |
520 struct RegCount { | 488 struct RegCount { |