@@ -151,7 +151,8 @@ bool DataLayout::PrimitiveSpec::operator==(const PrimitiveSpec &Other) const {
151
151
bool DataLayout::PointerSpec::operator ==(const PointerSpec &Other) const {
152
152
return AddrSpace == Other.AddrSpace && BitWidth == Other.BitWidth &&
153
153
ABIAlign == Other.ABIAlign && PrefAlign == Other.PrefAlign &&
154
- IndexBitWidth == Other.IndexBitWidth ;
154
+ IndexBitWidth == Other.IndexBitWidth &&
155
+ IsNonIntegral == Other.IsNonIntegral ;
155
156
}
156
157
157
158
namespace {
@@ -206,7 +207,8 @@ constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[] = {
206
207
207
208
// Default pointer type specifications.
208
209
constexpr 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 },
210
212
};
211
213
212
214
DataLayout::DataLayout ()
@@ -239,13 +241,11 @@ DataLayout &DataLayout::operator=(const DataLayout &Other) {
239
241
PointerSpecs = Other.PointerSpecs ;
240
242
StructABIAlignment = Other.StructABIAlignment ;
241
243
StructPrefAlignment = Other.StructPrefAlignment ;
242
- NonIntegralAddressSpaces = Other.NonIntegralAddressSpaces ;
243
244
return *this ;
244
245
}
245
246
246
247
bool DataLayout::operator ==(const DataLayout &Other) const {
247
248
// NOTE: StringRepresentation might differ, it is not canonicalized.
248
- // FIXME: NonIntegralAddressSpaces isn't compared.
249
249
return BigEndian == Other.BigEndian &&
250
250
AllocaAddrSpace == Other.AllocaAddrSpace &&
251
251
ProgramAddrSpace == Other.ProgramAddrSpace &&
@@ -454,11 +454,13 @@ Error DataLayout::parsePointerSpec(StringRef Spec) {
454
454
return createStringError (
455
455
" index size cannot be larger than the pointer size" );
456
456
457
- setPointerSpec (AddrSpace, BitWidth, ABIAlign, PrefAlign, IndexBitWidth);
457
+ setPointerSpec (AddrSpace, BitWidth, ABIAlign, PrefAlign, IndexBitWidth,
458
+ false );
458
459
return Error::success ();
459
460
}
460
461
461
- Error DataLayout::parseSpecification (StringRef Spec) {
462
+ Error DataLayout::parseSpecification (
463
+ StringRef Spec, SmallVectorImpl<unsigned > &NonIntegralAddressSpaces) {
462
464
// The "ni" specifier is the only two-character specifier. Handle it first.
463
465
if (Spec.starts_with (" ni" )) {
464
466
// ni:<address space>[:<address space>]...
@@ -614,12 +616,23 @@ Error DataLayout::parseLayoutString(StringRef LayoutString) {
614
616
615
617
// Split the data layout string into specifications separated by '-' and
616
618
// parse each specification individually, updating internal data structures.
619
+ SmallVector<unsigned , 8 > NonIntegralAddressSpaces;
617
620
for (StringRef Spec : split (LayoutString, ' -' )) {
618
621
if (Spec.empty ())
619
622
return createStringError (" empty specification is not allowed" );
620
- if (Error Err = parseSpecification (Spec))
623
+ if (Error Err = parseSpecification (Spec, NonIntegralAddressSpaces ))
621
624
return Err;
622
625
}
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
+ }
623
636
624
637
return Error::success ();
625
638
}
@@ -666,16 +679,17 @@ DataLayout::getPointerSpec(uint32_t AddrSpace) const {
666
679
667
680
void DataLayout::setPointerSpec (uint32_t AddrSpace, uint32_t BitWidth,
668
681
Align ABIAlign, Align PrefAlign,
669
- uint32_t IndexBitWidth) {
682
+ uint32_t IndexBitWidth, bool IsNonIntegral ) {
670
683
auto I = lower_bound (PointerSpecs, AddrSpace, LessPointerAddrSpace ());
671
684
if (I == PointerSpecs.end () || I->AddrSpace != AddrSpace) {
672
685
PointerSpecs.insert (I, PointerSpec{AddrSpace, BitWidth, ABIAlign, PrefAlign,
673
- IndexBitWidth});
686
+ IndexBitWidth, IsNonIntegral });
674
687
} else {
675
688
I->BitWidth = BitWidth;
676
689
I->ABIAlign = ABIAlign;
677
690
I->PrefAlign = PrefAlign;
678
691
I->IndexBitWidth = IndexBitWidth;
692
+ I->IsNonIntegral = IsNonIntegral;
679
693
}
680
694
}
681
695
0 commit comments