@@ -151,7 +151,8 @@ bool DataLayout::PrimitiveSpec::operator==(const PrimitiveSpec &Other) const {
151151bool DataLayout::PointerSpec::operator ==(const PointerSpec &Other) const {
152152 return AddrSpace == Other.AddrSpace && BitWidth == Other.BitWidth &&
153153 ABIAlign == Other.ABIAlign && PrefAlign == Other.PrefAlign &&
154- IndexBitWidth == Other.IndexBitWidth ;
154+ IndexBitWidth == Other.IndexBitWidth &&
155+ IsNonIntegral == Other.IsNonIntegral ;
155156}
156157
157158namespace {
@@ -206,7 +207,8 @@ constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[] = {
206207
207208// Default pointer type specifications.
208209constexpr DataLayout::PointerSpec DefaultPointerSpecs[] = {
209- {0 , 64 , Align::Constant<8 >(), Align::Constant<8 >(), 64 } // p0:64:64:64:64
210+ // p0:64:64:64:64
211+ {0 , 64 , Align::Constant<8 >(), Align::Constant<8 >(), 64 , false },
210212};
211213
212214DataLayout::DataLayout ()
@@ -239,13 +241,11 @@ DataLayout &DataLayout::operator=(const DataLayout &Other) {
239241 PointerSpecs = Other.PointerSpecs ;
240242 StructABIAlignment = Other.StructABIAlignment ;
241243 StructPrefAlignment = Other.StructPrefAlignment ;
242- NonIntegralAddressSpaces = Other.NonIntegralAddressSpaces ;
243244 return *this ;
244245}
245246
246247bool DataLayout::operator ==(const DataLayout &Other) const {
247248 // NOTE: StringRepresentation might differ, it is not canonicalized.
248- // FIXME: NonIntegralAddressSpaces isn't compared.
249249 return BigEndian == Other.BigEndian &&
250250 AllocaAddrSpace == Other.AllocaAddrSpace &&
251251 ProgramAddrSpace == Other.ProgramAddrSpace &&
@@ -454,11 +454,13 @@ Error DataLayout::parsePointerSpec(StringRef Spec) {
454454 return createStringError (
455455 " index size cannot be larger than the pointer size" );
456456
457- setPointerSpec (AddrSpace, BitWidth, ABIAlign, PrefAlign, IndexBitWidth);
457+ setPointerSpec (AddrSpace, BitWidth, ABIAlign, PrefAlign, IndexBitWidth,
458+ false );
458459 return Error::success ();
459460}
460461
461- Error DataLayout::parseSpecification (StringRef Spec) {
462+ Error DataLayout::parseSpecification (
463+ StringRef Spec, SmallVectorImpl<unsigned > &NonIntegralAddressSpaces) {
462464 // The "ni" specifier is the only two-character specifier. Handle it first.
463465 if (Spec.starts_with (" ni" )) {
464466 // ni:<address space>[:<address space>]...
@@ -614,12 +616,23 @@ Error DataLayout::parseLayoutString(StringRef LayoutString) {
614616
615617 // Split the data layout string into specifications separated by '-' and
616618 // parse each specification individually, updating internal data structures.
619+ SmallVector<unsigned , 8 > NonIntegralAddressSpaces;
617620 for (StringRef Spec : split (LayoutString, ' -' )) {
618621 if (Spec.empty ())
619622 return createStringError (" empty specification is not allowed" );
620- if (Error Err = parseSpecification (Spec))
623+ if (Error Err = parseSpecification (Spec, NonIntegralAddressSpaces ))
621624 return Err;
622625 }
626+ // Mark all address spaces that were qualified as non-integral now. This has
627+ // to be done later since the non-integral property is not part of the data
628+ // layout pointer specification.
629+ for (unsigned AS : NonIntegralAddressSpaces) {
630+ // If there is no special spec for a given AS, getPointerSpec(AS) returns
631+ // the spec for AS0, and we then update that to mark it non-integral.
632+ const PointerSpec &PS = getPointerSpec (AS);
633+ setPointerSpec (AS, PS.BitWidth , PS.ABIAlign , PS.PrefAlign , PS.IndexBitWidth ,
634+ true );
635+ }
623636
624637 return Error::success ();
625638}
@@ -666,16 +679,17 @@ DataLayout::getPointerSpec(uint32_t AddrSpace) const {
666679
667680void DataLayout::setPointerSpec (uint32_t AddrSpace, uint32_t BitWidth,
668681 Align ABIAlign, Align PrefAlign,
669- uint32_t IndexBitWidth) {
682+ uint32_t IndexBitWidth, bool IsNonIntegral ) {
670683 auto I = lower_bound (PointerSpecs, AddrSpace, LessPointerAddrSpace ());
671684 if (I == PointerSpecs.end () || I->AddrSpace != AddrSpace) {
672685 PointerSpecs.insert (I, PointerSpec{AddrSpace, BitWidth, ABIAlign, PrefAlign,
673- IndexBitWidth});
686+ IndexBitWidth, IsNonIntegral });
674687 } else {
675688 I->BitWidth = BitWidth;
676689 I->ABIAlign = ABIAlign;
677690 I->PrefAlign = PrefAlign;
678691 I->IndexBitWidth = IndexBitWidth;
692+ I->IsNonIntegral = IsNonIntegral;
679693 }
680694}
681695
0 commit comments