@@ -193,9 +193,11 @@ constexpr DataLayout::PrimitiveSpec DefaultVectorSpecs[] = {
193193};
194194
195195// Default pointer type specifications.
196- constexpr DataLayout::PointerSpec DefaultPointerSpecs[] = {
196+ const DataLayout::PointerSpec DefaultPointerSpecs[] = {
197197 // p0:64:64:64:64
198- {0 , 64 , Align::Constant<8 >(), Align::Constant<8 >(), 64 , false , false },
198+ {0 , 64 , Align::Constant<8 >(), Align::Constant<8 >(), /* IndexBitWidth=*/ 64 ,
199+ /* NullPtrValue=*/ APInt (64 , 0 ), /* HasUnstableRepr=*/ false ,
200+ /* HasExternalState=*/ false },
199201};
200202
201203DataLayout::DataLayout ()
@@ -461,8 +463,9 @@ Error DataLayout::parsePointerSpec(StringRef Spec) {
461463 return createStringError (
462464 " index size cannot be larger than the pointer size" );
463465
466+ // TODO: update the spec string parser to get the correct nullptr value.
464467 setPointerSpec (AddrSpace, BitWidth, ABIAlign, PrefAlign, IndexBitWidth,
465- UnstableRepr, ExternalState);
468+ APInt (BitWidth, 0 ), UnstableRepr, ExternalState);
466469 return Error::success ();
467470}
468471
@@ -638,6 +641,7 @@ Error DataLayout::parseLayoutString(StringRef LayoutString) {
638641 // the spec for AS0, and we then update that to mark it non-integral.
639642 const PointerSpec &PS = getPointerSpec (AS);
640643 setPointerSpec (AS, PS.BitWidth , PS.ABIAlign , PS.PrefAlign , PS.IndexBitWidth ,
644+ PS.NullPtrValue ,
641645 /* HasUnstableRepr=*/ true , /* HasExternalState=*/ false );
642646 }
643647
@@ -686,18 +690,20 @@ DataLayout::getPointerSpec(uint32_t AddrSpace) const {
686690
687691void DataLayout::setPointerSpec (uint32_t AddrSpace, uint32_t BitWidth,
688692 Align ABIAlign, Align PrefAlign,
689- uint32_t IndexBitWidth, bool HasUnstableRepr,
690- bool HasExternalState) {
693+ uint32_t IndexBitWidth,
694+ std::optional<APInt> NullPtrValue,
695+ bool HasUnstableRepr, bool HasExternalState) {
691696 auto I = lower_bound (PointerSpecs, AddrSpace, LessPointerAddrSpace ());
692697 if (I == PointerSpecs.end () || I->AddrSpace != AddrSpace) {
693698 PointerSpecs.insert (I, PointerSpec{AddrSpace, BitWidth, ABIAlign, PrefAlign,
694- IndexBitWidth, HasUnstableRepr ,
695- HasExternalState});
699+ IndexBitWidth, NullPtrValue ,
700+ HasUnstableRepr, HasExternalState});
696701 } else {
697702 I->BitWidth = BitWidth;
698703 I->ABIAlign = ABIAlign;
699704 I->PrefAlign = PrefAlign;
700705 I->IndexBitWidth = IndexBitWidth;
706+ I->NullPtrValue = NullPtrValue;
701707 I->HasUnstableRepresentation = HasUnstableRepr;
702708 I->HasExternalState = HasExternalState;
703709 }
0 commit comments