/// Find the target operand flags that describe how a global value should be /// referenced for the current subtarget. unsigned char AArch64Subtarget::ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const { // MachO large model always goes via a GOT, simply to get a single 8-byte // absolute relocation on all global addresses. if (TM.getCodeModel() == CodeModel::Large && isTargetMachO()) return AArch64II::MO_GOT; if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) { if (GV->hasDLLImportStorageClass()) return AArch64II::MO_GOT | AArch64II::MO_DLLIMPORT; if (getTargetTriple().isOSWindows()) return AArch64II::MO_GOT | AArch64II::MO_COFFSTUB; return AArch64II::MO_GOT; } // The small code model's direct accesses use ADRP, which cannot // necessarily produce the value 0 (if the code is above 4GB). // Same for the tiny code model, where we have a pc relative LDR. if ((useSmallAddressing() || TM.getCodeModel() == CodeModel::Tiny) && GV->hasExternalWeakLinkage()) return AArch64II::MO_GOT; return AArch64II::MO_NO_FLAG; }
unsigned char AArch64Subtarget::classifyGlobalFunctionReference( const GlobalValue *GV, const TargetMachine &TM) const { // MachO large model always goes via a GOT, because we don't have the // relocations available to do anything else.. if (TM.getCodeModel() == CodeModel::Large && isTargetMachO() && !GV->hasInternalLinkage()) return AArch64II::MO_GOT; // NonLazyBind goes via GOT unless we know it's available locally. auto *F = dyn_cast<Function>(GV); if (UseNonLazyBind && F && F->hasFnAttribute(Attribute::NonLazyBind) && !TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) return AArch64II::MO_GOT; return AArch64II::MO_NO_FLAG; }
/// Find the target operand flags that describe how a global value should be /// referenced for the current subtarget. unsigned char AArch64Subtarget::ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const { // MachO large model always goes via a GOT, simply to get a single 8-byte // absolute relocation on all global addresses. if (TM.getCodeModel() == CodeModel::Large && isTargetMachO()) return AArch64II::MO_GOT; if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) return AArch64II::MO_GOT; // The small code mode's direct accesses use ADRP, which cannot necessarily // produce the value 0 (if the code is above 4GB). if (TM.getCodeModel() == CodeModel::Small && GV->hasExternalWeakLinkage()) return AArch64II::MO_GOT; return AArch64II::MO_NO_FLAG; }