This patch refactors GlobalVariable section classification on targets by adding the target-independent notion of small-data sections in SectionKind. This is done by logically extending those sections that may be small, with existing predicates masking the "small bit" out:
/// SmallDataSections - Data sections where individual entries are capped /// for size, typically for global-register-relative relocation. /// These test as logical equivalents with respect to their unspecified /// counterparts, but not vice-versa. /// SmallKindMask - Used to access the underlying Kind SmallKindMask = 0x7f, /// SmallData - This is writeable data that has a non-zero initializer. SmallData = (Data | 0x80), /// SmallReadOnly - This is non-writeable data that has a non-zero /// initializer. SmallReadOnly = (ReadOnly | 0x80), /// SmallBSS - This is writeable data that has a zero initializer. SmallBSS = (BSS | 0x80), /// SmallCommon - These represent tentative definitions, which always /// have a zero initializer and are never marked 'constant'. SmallCommon = (Common | 0x80)
Small data support calls were seemingly duplicated from the Mips TargetLoweringObjectFile into Hexagon and Lanai targets. This has been folded into a virtual TargetLoweringObjectFile::isGlobalInSmallSectionKind method; targets may implement this to share the core SectionKind classification mechanism invoked by TargetLoweringObjectFile::getKindForGlobal. TargetLoweringObjectFile::isGlobalInSmallSection is a new target-independent way to perform this test on any GlobalObject, definition or declaration. Additionally, this aids SelectionDAG implementations by having a consistent and clear predicate when producing small data access code.
Additionally, a new PPC-EABI Subtarget is defined with memri relocation triggering to take advantage of the R_PPC_EMB_SDA21 relocation type.
You should define SmallKind = 0x80, and use that throughout instead of the magic number 0x80.