@@ -542,31 +542,31 @@ void DataLayout::setPointerAlignment(uint32_t AddrSpace, llvm::Align ABIAlign,
542
542
543
543
// / getAlignmentInfo - Return the alignment (either ABI if ABIInfo = true or
544
544
// / preferred if ABIInfo = false) the layout wants for the specified datatype.
545
- unsigned DataLayout::getAlignmentInfo (AlignTypeEnum AlignType,
546
- uint32_t BitWidth, bool ABIInfo,
547
- Type *Ty) const {
545
+ llvm::Align DataLayout::getAlignmentInfo (AlignTypeEnum AlignType,
546
+ uint32_t BitWidth, bool ABIInfo,
547
+ Type *Ty) const {
548
548
AlignmentsTy::const_iterator I = findAlignmentLowerBound (AlignType, BitWidth);
549
549
// See if we found an exact match. Of if we are looking for an integer type,
550
550
// but don't have an exact match take the next largest integer. This is where
551
551
// the lower_bound will point to when it fails an exact match.
552
552
if (I != Alignments.end () && I->AlignType == (unsigned )AlignType &&
553
553
(I->TypeBitWidth == BitWidth || AlignType == INTEGER_ALIGN))
554
- return ( ABIInfo ? I->ABIAlign : I->PrefAlign ). value () ;
554
+ return ABIInfo ? I->ABIAlign : I->PrefAlign ;
555
555
556
556
if (AlignType == INTEGER_ALIGN) {
557
557
// If we didn't have a larger value try the largest value we have.
558
558
if (I != Alignments.begin ()) {
559
559
--I; // Go to the previous entry and see if its an integer.
560
560
if (I->AlignType == INTEGER_ALIGN)
561
- return ( ABIInfo ? I->ABIAlign : I->PrefAlign ). value () ;
561
+ return ABIInfo ? I->ABIAlign : I->PrefAlign ;
562
562
}
563
563
} else if (AlignType == VECTOR_ALIGN) {
564
564
// By default, use natural alignment for vector types. This is consistent
565
565
// with what clang and llvm-gcc do.
566
566
unsigned Align = getTypeAllocSize (cast<VectorType>(Ty)->getElementType ());
567
567
Align *= cast<VectorType>(Ty)->getNumElements ();
568
568
Align = PowerOf2Ceil (Align);
569
- return Align;
569
+ return llvm:: Align(Align) ;
570
570
}
571
571
572
572
// If we still couldn't find a reasonable default alignment, fall back
@@ -577,7 +577,7 @@ unsigned DataLayout::getAlignmentInfo(AlignTypeEnum AlignType,
577
577
// layout.
578
578
unsigned Align = getTypeStoreSize (Ty);
579
579
Align = PowerOf2Ceil (Align);
580
- return Align;
580
+ return llvm:: Align(Align) ;
581
581
}
582
582
583
583
namespace {
@@ -704,33 +704,32 @@ unsigned DataLayout::getIndexTypeSizeInBits(Type *Ty) const {
704
704
Get the ABI (\a abi_or_pref == true) or preferred alignment (\a abi_or_pref
705
705
== false) for the requested type \a Ty.
706
706
*/
707
- unsigned DataLayout::getAlignment (Type *Ty, bool abi_or_pref) const {
707
+ llvm::Align DataLayout::getAlignment (Type *Ty, bool abi_or_pref) const {
708
708
AlignTypeEnum AlignType;
709
709
710
710
assert (Ty->isSized () && " Cannot getTypeInfo() on a type that is unsized!" );
711
711
switch (Ty->getTypeID ()) {
712
712
// Early escape for the non-numeric types.
713
713
case Type::LabelTyID:
714
- return (abi_or_pref
715
- ? getPointerABIAlignment (0 )
716
- : getPointerPrefAlignment (0 ));
714
+ return llvm::Align (abi_or_pref ? getPointerABIAlignment (0 )
715
+ : getPointerPrefAlignment (0 ));
717
716
case Type::PointerTyID: {
718
717
unsigned AS = cast<PointerType>(Ty)->getAddressSpace ();
719
- return (abi_or_pref
720
- ? getPointerABIAlignment (AS)
721
- : getPointerPrefAlignment (AS));
718
+ return llvm::Align (abi_or_pref ? getPointerABIAlignment (AS)
719
+ : getPointerPrefAlignment (AS));
722
720
}
723
721
case Type::ArrayTyID:
724
722
return getAlignment (cast<ArrayType>(Ty)->getElementType (), abi_or_pref);
725
723
726
724
case Type::StructTyID: {
727
725
// Packed structure types always have an ABI alignment of one.
728
726
if (cast<StructType>(Ty)->isPacked () && abi_or_pref)
729
- return 1 ;
727
+ return llvm::Align::None () ;
730
728
731
729
// Get the layout annotation... which is lazily created on demand.
732
730
const StructLayout *Layout = getStructLayout (cast<StructType>(Ty));
733
- unsigned Align = getAlignmentInfo (AGGREGATE_ALIGN, 0 , abi_or_pref, Ty);
731
+ const llvm::Align Align =
732
+ getAlignmentInfo (AGGREGATE_ALIGN, 0 , abi_or_pref, Ty);
734
733
return std::max (Align, Layout->getAlignment ());
735
734
}
736
735
case Type::IntegerTyID:
@@ -758,17 +757,17 @@ unsigned DataLayout::getAlignment(Type *Ty, bool abi_or_pref) const {
758
757
}
759
758
760
759
unsigned DataLayout::getABITypeAlignment (Type *Ty) const {
761
- return getAlignment (Ty, true );
760
+ return getAlignment (Ty, true ). value () ;
762
761
}
763
762
764
763
// / getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for
765
764
// / an integer type of the specified bitwidth.
766
765
unsigned DataLayout::getABIIntegerTypeAlignment (unsigned BitWidth) const {
767
- return getAlignmentInfo (INTEGER_ALIGN, BitWidth, true , nullptr );
766
+ return getAlignmentInfo (INTEGER_ALIGN, BitWidth, true , nullptr ). value () ;
768
767
}
769
768
770
769
unsigned DataLayout::getPrefTypeAlignment (Type *Ty) const {
771
- return getAlignment (Ty, false );
770
+ return getAlignment (Ty, false ). value () ;
772
771
}
773
772
774
773
IntegerType *DataLayout::getIntPtrType (LLVMContext &C,
0 commit comments