/// IsGlobalInSmallSection - Return true if this global address should be /// placed into small data/bss section. bool MipsTargetObjectFile:: IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM, SectionKind Kind) const { const MipsSubtarget &Subtarget = TM.getSubtarget<MipsSubtarget>(); // Return if small section is not available. if (!Subtarget.useSmallSection()) return false; // Only global variables, not functions. const GlobalVariable *GVA = dyn_cast<GlobalVariable>(GV); if (!GVA) return false; // We can only do this for datarel or BSS objects for now. if (!Kind.isBSS() && !Kind.isDataRel()) return false; // If this is a internal constant string, there is a special // section for it, but not in small data/bss. if (Kind.isMergeable1ByteCString()) return false; Type *Ty = GV->getType()->getElementType(); return IsInSmallSection(TM.getDataLayout()->getTypeAllocSize(Ty)); }
/// getSectionPrefixForGlobal - Return the section prefix name used by options /// FunctionsSections and DataSections. static StringRef getSectionPrefixForGlobal(SectionKind Kind) { if (Kind.isText()) return ".text."; if (Kind.isReadOnly()) return ".rodata."; if (Kind.isBSS()) return ".bss."; if (Kind.isThreadData()) return ".tdata."; if (Kind.isThreadBSS()) return ".tbss."; if (Kind.isDataNoRel()) return ".data."; if (Kind.isDataRelLocal()) return ".data.rel.local."; if (Kind.isDataRel()) return ".data.rel."; if (Kind.isReadOnlyWithRelLocal()) return ".data.rel.ro.local."; assert(Kind.isReadOnlyWithRel() && "Unknown section kind"); return ".data.rel.ro."; }
/// Return true if this global address should be placed into small data/bss /// section. bool MipsTargetObjectFile:: IsGlobalInSmallSection(const GlobalValue *GV, const TargetMachine &TM, SectionKind Kind) const { return (IsGlobalInSmallSectionImpl(GV, TM) && (Kind.isDataRel() || Kind.isBSS() || Kind.isCommon())); }