47 if (Mang !=
nullptr)
delete Mang;
87 unsigned NumElts = CDS->getNumElements();
88 assert(NumElts != 0 &&
"Can't have an empty CDS");
90 if (CDS->getElementAsInteger(NumElts-1) != 0)
94 for (
unsigned i = 0;
i != NumElts-1; ++
i)
95 if (CDS->getElementAsInteger(
i) == 0)
101 if (isa<ConstantAggregateZero>(C))
102 return cast<ArrayType>(C->
getType())->getNumElements() == 1;
114 NameStr.append(Suffix.
begin(), Suffix.
end());
138 "Can only be used for global definitions");
148 if (GVar->isThreadLocal()) {
155 if (GVar->hasCommonLinkage())
160 if (GVar->hasLocalLinkage())
162 else if (GVar->hasExternalLinkage())
167 const Constant *
C = GVar->getInitializer();
171 if (GVar->isConstant()) {
179 if (!GVar->hasGlobalUnnamedAddr())
186 dyn_cast<IntegerType>(ATy->getElementType())) {
187 if ((ITy->getBitWidth() == 8 || ITy->getBitWidth() == 16 ||
188 ITy->getBitWidth() == 32) &&
190 if (ITy->getBitWidth() == 8)
192 if (ITy->getBitWidth() == 16)
195 assert(ITy->getBitWidth() == 32 &&
"Unknown width");
205 GVar->getParent()->getDataLayout().getTypeAllocSize(C->
getType())) {
256 bool UsesLabelDifference,
const Function &
F)
const {
260 if (UsesLabelDifference)
277 unsigned &Align)
const {
299 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. ...
static SectionKind getData()
StringRef getPrivateGlobalPrefix() const
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
static SectionKind getMergeableConst32()
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCSymbol * getSymbol(const GlobalValue *GV) const
static SectionKind getMergeableConst8()
bool hasAvailableExternallyLinkage() const
static SectionKind getMergeableConst16()
static SectionKind getMergeable1ByteCString()
virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM, const MCSymbol *Sym) const
static SectionKind getCommon()
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
static SectionKind getMergeableConst4()
void InitMCObjectFileInfo(const Triple &TT, bool PIC, CodeModel::Model CM, MCContext &ctx)
const Triple & getTargetTriple() const
static SectionKind getBSS()
static SectionKind getMergeable4ByteCString()
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...
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
This method must be called before any actual lowering is done.
Base class for the full range of assembler expressions which are needed for parsing.
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
Represent a reference to a symbol from inside an expression.
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
Context object for machine code objects.
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.
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...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
static SectionKind getThreadData()
MCContext & getContext() const
MCSection * DataSection
Section directive for standard data.
virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference, const Function &F) const
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
bool hasSection() const
Check if this global has a custom object file section.
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.
CodeModel::Model getCodeModel() const
Returns the code model.
This is an important base class in LLVM.
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.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS)
bool isPositionIndependent() const
SectionKind - This is a simple POD value that classifies the properties of a section.
Class to represent integer types.
bool needsRelocation() const
This method classifies the entry according to whether or not it may generate a relocation entry...
unsigned NoZerosInBSS
NoZerosInBSS - By default some codegens place zero-initialized data to .bss section.
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...
static SectionKind getThreadBSS()
virtual MCSection * getSectionForJumpTable(const Function &F, const TargetMachine &TM) const
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
Type * getType() const
All values are typed, get the type of this value.
static SectionKind getReadOnlyWithRel()
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
virtual ~TargetLoweringObjectFile()
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static SectionKind getBSSExtern()
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...
virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, const TargetMachine &TM, MachineModuleInfo *MMI) 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...
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
Primary interface to the complete machine description for the target machine.
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...
static SectionKind getReadOnly()
This class contains meta information specific to a module.
This file describes how to lower LLVM code to machine code.
static SectionKind getText()