TargetData assumes (and some regression tests depend on it) that the size of

an unspecified datatype in the datalayout is capped by the size of a pointer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33411 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2007-01-20 23:07:13 +00:00
parent 4a8c32debf
commit 1027a533d4
2 changed files with 13 additions and 5 deletions

View File

@ -70,7 +70,8 @@ public:
/// Constructs a TargetData from a string of the following format: /// Constructs a TargetData from a string of the following format:
/// "E-p:64:64-d:64-f:32-l:64-i:32-s:16-b:8-B:8" /// "E-p:64:64-d:64-f:32-l:64-i:32-s:16-b:8-B:8"
/// The above string is considered the default, and any values not specified /// The above string is considered the default, and any values not specified
/// in the string will be assumed to be as above. /// in the string will be assumed to be as above, with the caveat that unspecified
/// values are always assumed to be smaller than the size of a pointer.
TargetData(const std::string &TargetDescription) { TargetData(const std::string &TargetDescription) {
init(TargetDescription); init(TargetDescription);
} }

View File

@ -103,9 +103,9 @@ void TargetData::init(const std::string &TargetDescription) {
LittleEndian = false; LittleEndian = false;
PointerMemSize = 8; PointerMemSize = 8;
PointerABIAlignment = 8; PointerABIAlignment = 8;
DoubleABIAlignment = 8; DoubleABIAlignment = 0;
FloatABIAlignment = 4; FloatABIAlignment = 4;
LongABIAlignment = 8; LongABIAlignment = 0;
IntABIAlignment = 4; IntABIAlignment = 4;
ShortABIAlignment = 2; ShortABIAlignment = 2;
ByteABIAlignment = 1; ByteABIAlignment = 1;
@ -114,9 +114,9 @@ void TargetData::init(const std::string &TargetDescription) {
BytePrefAlignment = ByteABIAlignment; BytePrefAlignment = ByteABIAlignment;
ShortPrefAlignment = ShortABIAlignment; ShortPrefAlignment = ShortABIAlignment;
IntPrefAlignment = IntABIAlignment; IntPrefAlignment = IntABIAlignment;
LongPrefAlignment = LongABIAlignment; LongPrefAlignment = 8;
FloatPrefAlignment = FloatABIAlignment; FloatPrefAlignment = FloatABIAlignment;
DoublePrefAlignment = DoubleABIAlignment; DoublePrefAlignment = 8;
PointerPrefAlignment = PointerABIAlignment; PointerPrefAlignment = PointerABIAlignment;
AggMinPrefAlignment = 0; AggMinPrefAlignment = 0;
@ -188,6 +188,13 @@ void TargetData::init(const std::string &TargetDescription) {
break; break;
} }
} }
// Unless explicitly specified, the alignments for longs and doubles is capped by
// pointer size.
if (LongABIAlignment == 0)
LongABIAlignment = LongPrefAlignment = PointerMemSize;
if (DoubleABIAlignment == 0)
DoubleABIAlignment = DoublePrefAlignment = PointerMemSize;
} }
TargetData::TargetData(const Module *M) { TargetData::TargetData(const Module *M) {