19#ifndef LLVM_IR_GLOBALVARIABLE_H
20#define LLVM_IR_GLOBALVARIABLE_H
49 bool isConstantGlobal : 1;
52 bool isExternallyInitializedConstant : 1;
56 static const unsigned CodeModelMask = (1 << CodeModelBits) - 1;
64 const Twine &Name =
"",
72 const Twine &Name =
"",
85 void setGlobalVariableNumOperands(
unsigned NumOps) {
86 assert(
NumOps <= 1 &&
"GlobalVariable can only have 0 or 1 operands");
97 setGlobalVariableNumOperands(1);
101 void *
operator new(
size_t s) {
return User::operator
new(s, AllocMarker); }
104 void operator delete(
void *ptr) { User::operator
delete(ptr, AllocMarker); }
187 return isExternallyInitializedConstant;
190 isExternallyInitializedConstant = Val;
220 Attrs = Attrs.addAttribute(
getContext(), Kind);
225 Attrs = Attrs.addAttribute(
getContext(), Kind, Val);
230 Attrs = Attrs.addAttributes(
getContext(), AttrBuilder);
235 return Attrs.hasAttribute(Kind);
240 return Attrs.hasAttribute(Kind);
245 return Attrs.hasAttributes();
250 return Attrs.getAttribute(Kind);
255 return Attrs.getAttribute(Kind);
268 return AttributeList();
269 std::pair<unsigned, AttributeSet> AS[1] = {{index, Attrs}};
290 return (
Data >> CodeModelShift) & CodeModelMask;
299 if (CodeModelData > 0)
331 return V->getValueID() == Value::GlobalVariableVal;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
This class holds the attributes for a particular argument, parameter, function, or return value.
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
This is an important base class in LLVM.
A pair of DIGlobalVariable and DIExpression.
A parsed version of the target data layout string in and methods for querying it.
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
LLVM_ABI void setAlignment(Align Align)
Sets the alignment attribute of the GlobalObject.
GlobalObject(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace=0)
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
LLVM_ABI bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
unsigned getGlobalValueSubClassData() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
unsigned getCodeModelRaw() const
Get the custom code model raw value of this global.
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists.
bool isExternallyInitialized() const
bool hasInitializer() const
Definitions have initializers, declarations don't.
Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
LLVM_ABI void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
bool hasAttributes() const
Return true if any attributes exist.
void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the GlobalVariable.
AttributeSet getAttributes() const
Return the attribute set for this global.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Provide fast operand accessors.
std::optional< CodeModel::Model > getCodeModel() const
Get the custom code model of this global if it has one.
void setAttributes(AttributeSet A)
Set attribute list for this global.
LLVM_ABI void replaceInitializer(Constant *InitVal)
replaceInitializer - Sets the initializer for this global variable, and sets the value type of the gl...
LLVM_ABI void clearCodeModel()
Remove the code model for this global.
MaybeAlign getAlign() const
Returns the alignment of the given variable.
void setConstant(bool Val)
GlobalVariable & operator=(const GlobalVariable &)=delete
LLVM_ABI void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
GlobalVariable(const GlobalVariable &)=delete
void addAttribute(StringRef Kind, StringRef Val=StringRef())
Add attribute to this global.
Constant * getInitializer()
bool hasImplicitSection() const
Check if section name is present.
uint64_t getAlignment() const
FIXME: Remove this function once transition to Align is over.
LLVM_ABI void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const
Fill the vector with all debug info attachements.
AttributeList getAttributesAsList(unsigned index) const
Return attribute set as list with index.
Attribute getAttribute(StringRef Kind) const
Return the attribute object.
LLVM_ABI uint64_t getGlobalSize(const DataLayout &DL) const
Get the size of this global variable in bytes.
static bool classof(const Value *V)
bool hasAttribute(StringRef Kind) const
Return true if the attribute exists.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
LLVM_ABI void setCodeModel(CodeModel::Model CM)
Change the code model for this global.
void addAttributes(const AttrBuilder &AttrBuilder)
Add attributes to this global.
bool hasUniqueInitializer() const
hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the in...
void setExternallyInitialized(bool Val)
LLVM_ABI void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
LLVM_ABI void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalVariable.
void addAttribute(Attribute::AttrKind Kind)
Add attribute to this global.
LLVM_ABI void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
LLVM_ABI GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=nullptr, const Twine &Name="", ThreadLocalMode=NotThreadLocal, unsigned AddressSpace=0, bool isExternallyInitialized=false)
GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the ...
A Module instance is used to store all the information related to an LLVM module.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
LLVMContext & getContext() const
All values hold a context through their type.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Compile-time customization of User operands.
OptionalOperandTraits - when the number of operands may change at runtime.
Indicates this User has operands co-allocated.