Go to the documentation of this file.
33 #define DEBUG_TYPE "hexagon-sdata"
39 cl::desc(
"The maximum size of an object in the sdata section"));
46 cl::desc(
"Allow static variables in .sdata"));
50 cl::desc(
"Trace global value placement"));
54 cl::desc(
"Emit hexagon jump tables in function section"));
58 cl::desc(
"Emit hexagon lookup tables in function section"));
63 #define TRACE_TO(s, X) s << X
67 if (TraceGVPlacement) { \
68 TRACE_TO(errs(), X); \
74 if (TraceGVPlacement) { \
75 TRACE_TO(errs(), X); \
77 LLVM_DEBUG(TRACE_TO(dbgs(), X)); \
128 TRACE(
"[SelectSectionForGlobal] GO(" << GO->
getName() <<
") ");
137 << (
Kind.isCommon() ?
"kind_common " :
"" )
138 << (
Kind.isBSS() ?
"kind_bss " :
"" )
139 << (
Kind.isBSSLocal() ?
"kind_bss_local " :
"" ));
145 return selectSectionForLookupTable(GO,
TM, Fn);
149 return selectSmallSectionForGlobal(GO,
Kind,
TM);
151 if (
Kind.isCommon()) {
159 TRACE(
"default_ELF_section\n");
166 TRACE(
"[getExplicitSectionGlobal] GO(" << GO->
getName() <<
") from("
174 << (
Kind.isCommon() ?
"kind_common " :
"" )
175 << (
Kind.isBSS() ?
"kind_bss " :
"" )
176 << (
Kind.isBSSLocal() ?
"kind_bss_local " :
"" ));
180 if (Section.contains(
".access.text.group"))
183 if (Section.contains(
".access.data.group"))
189 return selectSmallSectionForGlobal(GO,
Kind,
TM);
192 TRACE(
"default_ELF_section\n");
202 LLVM_DEBUG(
dbgs() <<
"Small-data allocation is disabled, but symbols "
203 "may have explicit section assignments...\n");
219 <<
", has section: " << GVar->
getSection() <<
'\n');
241 if (isa<ArrayType>(GType)) {
251 if (
ST->isOpaque()) {
263 LLVM_DEBUG(
dbgs() <<
"no, size exceeds sdata threshold: " << Size <<
'\n');
281 bool UsesLabelDifference,
const Function &
F)
const {
288 unsigned HexagonTargetObjectFile::getSmallestAddressableSize(
const Type *Ty,
292 unsigned SmallestElement = 8;
298 const StructType *STy = cast<const StructType>(Ty);
300 unsigned AtomicSize = getSmallestAddressableSize(
E, GV,
TM);
301 if (AtomicSize < SmallestElement)
302 SmallestElement = AtomicSize;
307 const ArrayType *ATy = cast<const ArrayType>(Ty);
312 const VectorType *PTy = cast<const VectorType>(Ty);
322 return DL.getTypeAllocSize(
const_cast<Type*
>(Ty));
342 MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
345 unsigned Size = getSmallestAddressableSize(GTy, GO,
TM);
351 TRACE(
"Small data. Size(" << Size <<
")");
353 if (
Kind.isBSS() ||
Kind.isBSSLocal()) {
361 TRACE(
" default sbss\n");
362 return SmallBSSSection;
369 if (EmitUniquedSection) {
378 if (
Kind.isCommon()) {
387 TRACE(
" small COMMON (" <<
Name <<
")\n");
396 if (
Kind.isMergeableConst()) {
397 TRACE(
" const_object_as_data ");
405 TRACE(
" default sdata\n");
406 return SmallDataSection;
413 if (EmitUniquedSection) {
417 TRACE(
" unique sdata(" <<
Name <<
")\n");
422 TRACE(
"default ELF section\n");
433 for (
auto U : GO->
users()) {
435 auto *
I = dyn_cast<Instruction>(U);
438 auto *Bb =
I->getParent();
441 auto *UserFn = Bb->getParent();
444 else if (ReturnFn != UserFn)
450 MCSection *HexagonTargetObjectFile::selectSectionForLookupTable(
459 const auto *FuncObj = dyn_cast<GlobalObject>(Fn);
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
@ FloatTyID
32-bit floating point type
@ DoubleTyID
64-bit floating point type
This is an optimization pass for GlobalISel generic memory operations.
bool hasCommonLinkage() const
A parsed version of the target data layout string in and methods for querying it.
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
bool hasExternalLinkage() const
static const char * getSectionSuffixForSize(unsigned Size)
Context object for machine code objects.
@ VoidTyID
type with no size
StringRef getSection() const
Get the custom section of this global if it has one.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
TypeID getTypeID() const
Return the type id for the type.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM) const
Return true if this global value should be placed into small data/bss section.
static cl::opt< bool > EmitJtInText("hexagon-emit-jt-text", cl::Hidden, cl::init(false), cl::desc("Emit hexagon jump tables in function section"))
Type * getElementType() const
Class to represent array types.
MCContext & getContext() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static cl::opt< bool > NoSmallDataSorting("mno-sort-sda", cl::init(false), cl::Hidden, cl::desc("Disable small data sections sorting"))
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool hasPrivateLinkage() const
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
unsigned getSmallDataSize() const
bool hasInternalLinkage() const
static SectionKind getText()
@ BFloatTyID
16-bit floating point type (7-bit significand)
static bool isSmallDataSection(StringRef Sec)
static cl::opt< bool > StaticsInSData("hexagon-statics-in-small-data", cl::Hidden, cl::desc("Allow static variables in .sdata"))
LLVM_NODISCARD bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
bool isPositionIndependent() const
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const override
@ DXILPointerTyID
DXIL typed pointer used by DirectX target.
Base class of all SIMD vector types.
bool hasSection() const
Check if this global has a custom object file section.
Module * getParent()
Get the module that this global value is contained inside of...
@ X86_MMXTyID
MMX vectors (64 bits, X86 specific)
initializer< Ty > init(const Ty &Val)
Primary interface to the complete machine description for the target machine.
bool hasLocalLinkage() const
@ FP128TyID
128-bit floating point type (112-bit significand)
static cl::opt< bool > TraceGVPlacement("trace-gv-placement", cl::Hidden, cl::init(false), cl::desc("Trace global value placement"))
Class to represent struct types.
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
StringRef - Represent a constant reference to a string, i.e.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static cl::opt< bool > EmitLutInText("hexagon-emit-lut-text", cl::Hidden, cl::init(false), cl::desc("Emit hexagon lookup tables in function section"))
Instances of this class represent a uniqued identifier for a section in the current translation unit.
StringRef getName() const
Return a constant reference to the value's name.
static cl::opt< unsigned > SmallDataThreshold("hexagon-small-data-threshold", cl::init(8), cl::Hidden, cl::desc("The maximum size of an object in the sdata section"))
unsigned getNumElements() const
Random access to the elements.
MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
Targets should implement this method to assign a section to globals with an explicit section specfied...
@ IntegerTyID
Arbitrary bit width integers.
static SectionKind getData()
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isSmallDataEnabled(const TargetMachine &TM) const
SectionKind - This is a simple POD value that classifies the properties of a section.
ArrayRef< Type * > elements() const
@ FixedVectorTyID
Fixed width SIMD vector type.
void Initialize(MCContext &Ctx, const TargetMachine &TM) override
This method must be called before any actual lowering is done.
const Function * getLutUsedFunction(const GlobalObject *GO) const
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
MCSection * BSSSection
Section that is default initialized to zero.
@ ScalableVectorTyID
Scalable SIMD vector type.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Type * getValueType() const
const char LLVMTargetMachineRef TM
MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const override
@ HalfTyID
16-bit floating point type
iterator_range< user_iterator > users()
@ X86_FP80TyID
80-bit floating point type (X87)
Type * getElementType() const
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...