61 if (!isa<ConstantAggregate>(C))
96 unsigned NumElts = CDS->getNumElements();
97 assert(NumElts != 0 &&
"Can't have an empty CDS");
99 if (CDS->getElementAsInteger(NumElts-1) != 0)
103 for (
unsigned i = 0; i != NumElts-1; ++i)
104 if (CDS->getElementAsInteger(i) == 0)
110 if (isa<ConstantAggregateZero>(C))
111 return cast<ArrayType>(C->
getType())->getNumElements() == 1;
123 NameStr.append(Suffix.
begin(), Suffix.
end());
146 "Can only be used for global definitions");
149 if (isa<Function>(GO))
153 const auto *GVar = cast<GlobalVariable>(GO);
156 if (GVar->isThreadLocal()) {
163 if (GVar->hasCommonLinkage())
169 if (GVar->hasLocalLinkage())
171 else if (GVar->hasExternalLinkage())
178 if (GVar->isConstant()) {
182 const Constant *
C = GVar->getInitializer();
187 if (!GVar->hasGlobalUnnamedAddr())
194 dyn_cast<IntegerType>(ATy->getElementType())) {
195 if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
196 ITy->getBitWidth() == 32) &&
198 if (ITy->getBitWidth() == 8)
200 if (ITy->getBitWidth() == 16)
203 assert(ITy->getBitWidth() == 32 &&
"Unknown width");
213 GVar->getParent()->getDataLayout().getTypeAllocSize(C->
getType())) {
252 if (
auto *GVar = dyn_cast<GlobalVariable>(GO)) {
253 auto Attrs = GVar->getAttributes();
254 if ((
Attrs.hasAttribute(
"bss-section") && Kind.
isBSS()) ||
255 (
Attrs.hasAttribute(
"data-section") && Kind.
isData()) ||
261 if (
auto *
F = dyn_cast<Function>(GO)) {
262 if (
F->hasFnAttribute(
"implicit-section-name"))
279 bool UsesLabelDifference,
const Function &
F)
const {
283 if (UsesLabelDifference)
297 unsigned &
Align)
const {
319 switch (Encoding & 0x70) {
Instances of this class represent a uniqued identifier for a section in the current translation unit...
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static SectionKind getData()
static bool isNullOrUndef(const Constant *C)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
static SectionKind getMergeableConst32()
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym) const
MCSection * SectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const
This method computes the appropriate section to emit the specified global variable or function defini...
StringRef getPrivateGlobalPrefix() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
bool hasAvailableExternallyLinkage() const
static SectionKind getMergeableConst8()
static SectionKind getMergeableConst16()
static SectionKind getMergeable1ByteCString()
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
static SectionKind getCommon()
static SectionKind getMergeableConst4()
unsigned PersonalityEncoding
PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values for EH.
static SectionKind getBSS()
static SectionKind getMergeable4ByteCString()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
Base class for the full range of assembler expressions which are needed for parsing.
The access may reference the value stored in memory.
Represent a reference to a symbol from inside an expression.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
Context object for machine code objects.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Type * getType() const
All values are typed, get the type of this value.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
Class to represent array types.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
static SectionKind getThreadData()
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
MCSection * DataSection
Section directive for standard data.
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
static SectionKind getBSSLocal()
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
virtual MCSection * getSectionForConstant(const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const
Given a constant with the SectionKind, return a section that it should be placed in.
MCSymbol * getSymbol(const GlobalValue *GV) const
MCSymbol * getSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix, const TargetMachine &TM) const
Return the MCSymbol for a private symbol with global value name as its base, with the specified suffi...
SectionKind - This is a simple POD value that classifies the properties of a section.
MCContext & getContext() const
const Triple & getTargetTriple() const
virtual const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, MachineModuleInfo *MMI, MCStreamer &Streamer) const
Return an MCExpr to use for a reference to the specified global variable from exception handling info...
Class to represent integer types.
unsigned NoZerosInBSS
NoZerosInBSS - By default some codegens place zero-initialized data to .bss section.
static SectionKind getThreadBSS()
bool hasSection() const
Check if this global has a custom object file section.
static SectionKind getReadOnlyWithRel()
static bool isSuitableForBSS(const GlobalVariable *GV)
This file contains constants used for implementing Dwarf debug support.
CodeModel::Model getCodeModel() const
Returns the code model.
static bool IsNullTerminatedString(const Constant *C)
IsNullTerminatedString - Return true if the specified constant (which is known to have a type that is...
static SectionKind getMergeable2ByteCString()
void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx, bool LargeCodeModel=false)
virtual ~TargetLoweringObjectFile()
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool isPositionIndependent() const
iterator_range< value_op_iterator > operand_values()
static SectionKind getBSSExtern()
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
virtual MCSection * getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const =0
Targets should implement this method to assign a section to globals with an explicit section specfied...
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
virtual MCSection * SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const =0
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Primary interface to the complete machine description for the target machine.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
StringRef - Represent a constant reference to a string, i.e.
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) const
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info...
static SectionKind getReadOnly()
This class contains meta information specific to a module.
static SectionKind getText()