Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/IR/DataLayout.cpp
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | static const LayoutAlignElem DefaultAlignments[] = { | ||||
{AGGREGATE_ALIGN, 0, Align(1), Align(8)} // struct | {AGGREGATE_ALIGN, 0, Align(1), Align(8)} // struct | ||||
}; | }; | ||||
void DataLayout::reset(StringRef Desc) { | void DataLayout::reset(StringRef Desc) { | ||||
clear(); | clear(); | ||||
LayoutMap = nullptr; | LayoutMap = nullptr; | ||||
BigEndian = false; | BigEndian = false; | ||||
ConsidersElementAlignment = false; | |||||
AllocaAddrSpace = 0; | AllocaAddrSpace = 0; | ||||
StackNaturalAlign.reset(); | StackNaturalAlign.reset(); | ||||
ProgramAddrSpace = 0; | ProgramAddrSpace = 0; | ||||
DefaultGlobalsAddrSpace = 0; | DefaultGlobalsAddrSpace = 0; | ||||
FunctionPtrAlign.reset(); | FunctionPtrAlign.reset(); | ||||
TheFunctionPtrAlignType = FunctionPtrAlignType::Independent; | TheFunctionPtrAlignType = FunctionPtrAlignType::Independent; | ||||
ManglingMode = MM_None; | ManglingMode = MM_None; | ||||
NonIntegralAddressSpaces.clear(); | NonIntegralAddressSpaces.clear(); | ||||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | case 'm': | ||||
case 'x': | case 'x': | ||||
ManglingMode = MM_WinCOFFX86; | ManglingMode = MM_WinCOFFX86; | ||||
break; | break; | ||||
case 'a': | case 'a': | ||||
ManglingMode = MM_XCOFF; | ManglingMode = MM_XCOFF; | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
case 'V': | |||||
ConsidersElementAlignment = true; | |||||
break; | |||||
default: | default: | ||||
return reportError("Unknown specifier in datalayout string"); | return reportError("Unknown specifier in datalayout string"); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return Error::success(); | return Error::success(); | ||||
} | } | ||||
DataLayout::DataLayout(const Module *M) { | DataLayout::DataLayout(const Module *M) { | ||||
init(M); | init(M); | ||||
} | } | ||||
void DataLayout::init(const Module *M) { *this = M->getDataLayout(); } | void DataLayout::init(const Module *M) { *this = M->getDataLayout(); } | ||||
bool DataLayout::operator==(const DataLayout &Other) const { | bool DataLayout::operator==(const DataLayout &Other) const { | ||||
bool Ret = BigEndian == Other.BigEndian && | bool Ret = BigEndian == Other.BigEndian && | ||||
ConsidersElementAlignment == Other.ConsidersElementAlignment && | |||||
AllocaAddrSpace == Other.AllocaAddrSpace && | AllocaAddrSpace == Other.AllocaAddrSpace && | ||||
StackNaturalAlign == Other.StackNaturalAlign && | StackNaturalAlign == Other.StackNaturalAlign && | ||||
ProgramAddrSpace == Other.ProgramAddrSpace && | ProgramAddrSpace == Other.ProgramAddrSpace && | ||||
DefaultGlobalsAddrSpace == Other.DefaultGlobalsAddrSpace && | DefaultGlobalsAddrSpace == Other.DefaultGlobalsAddrSpace && | ||||
FunctionPtrAlign == Other.FunctionPtrAlign && | FunctionPtrAlign == Other.FunctionPtrAlign && | ||||
TheFunctionPtrAlignType == Other.TheFunctionPtrAlignType && | TheFunctionPtrAlignType == Other.TheFunctionPtrAlignType && | ||||
ManglingMode == Other.ManglingMode && | ManglingMode == Other.ManglingMode && | ||||
LegalIntWidths == Other.LegalIntWidths && | LegalIntWidths == Other.LegalIntWidths && | ||||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | case Type::X86_FP80TyID: { | ||||
return Align(PowerOf2Ceil(BitWidth / 8)); | return Align(PowerOf2Ceil(BitWidth / 8)); | ||||
} | } | ||||
case Type::X86_MMXTyID: | case Type::X86_MMXTyID: | ||||
case Type::FixedVectorTyID: | case Type::FixedVectorTyID: | ||||
case Type::ScalableVectorTyID: { | case Type::ScalableVectorTyID: { | ||||
unsigned BitWidth = getTypeSizeInBits(Ty).getKnownMinSize(); | unsigned BitWidth = getTypeSizeInBits(Ty).getKnownMinSize(); | ||||
auto I = findAlignmentLowerBound(VECTOR_ALIGN, BitWidth); | auto I = findAlignmentLowerBound(VECTOR_ALIGN, BitWidth); | ||||
if (I != Alignments.end() && I->AlignType == VECTOR_ALIGN && | if (I != Alignments.end() && I->AlignType == VECTOR_ALIGN && | ||||
I->TypeBitWidth == BitWidth) | I->TypeBitWidth == BitWidth) { | ||||
return abi_or_pref ? I->ABIAlign : I->PrefAlign; | Align VectorAlign = abi_or_pref ? I->ABIAlign : I->PrefAlign; | ||||
tex3d: Shouldn't this capture the preferred alignment value for use in the maxAlignment, or return if… | |||||
// If we have a specified vector alignment the vector ABI should be the | |||||
// larger of the vector alignment and the element type's alignment. | |||||
if (considersElementAlignment()) | |||||
if (auto VTy = dyn_cast<VectorType>(Ty)) | |||||
return std::max(VectorAlign, | |||||
getAlignment(VTy->getElementType(), abi_or_pref)); | |||||
return VectorAlign; | |||||
} | |||||
// By default, use natural alignment for vector types. This is consistent | // By default, use natural alignment for vector types. This is consistent | ||||
// with what clang and llvm-gcc do. | // with what clang and llvm-gcc do. | ||||
// | // | ||||
// We're only calculating a natural alignment, so it doesn't have to be | // We're only calculating a natural alignment, so it doesn't have to be | ||||
// based on the full size for scalable vectors. Using the minimum element | // based on the full size for scalable vectors. Using the minimum element | ||||
// count should be enough here. | // count should be enough here. | ||||
return Align(PowerOf2Ceil(getTypeStoreSize(Ty).getKnownMinSize())); | return Align(PowerOf2Ceil(getTypeStoreSize(Ty).getKnownMinSize())); | ||||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |
Shouldn't this capture the preferred alignment value for use in the maxAlignment, or return if not vector? Or is this mechanism intended to only apply to ABI alignment and not preferred alignment?