19#ifndef LLVM_IR_GLOBALVARIABLE_H
20#define LLVM_IR_GLOBALVARIABLE_H
48 bool isConstantGlobal : 1;
51 bool isExternallyInitializedConstant : 1;
55 static const unsigned CodeModelMask = (1 << CodeModelBits) - 1;
84 void setGlobalVariableNumOperands(
unsigned NumOps) {
85 assert(NumOps <= 1 &&
"GlobalVariable can only have 0 or 1 operands");
96 setGlobalVariableNumOperands(1);
100 void *
operator new(
size_t s) {
return User::operator
new(s, AllocMarker); }
103 void operator delete(
void *ptr) { User::operator
delete(ptr); }
181 return isExternallyInitializedConstant;
184 isExternallyInitializedConstant = Val;
214 Attrs = Attrs.addAttribute(
getContext(), Kind);
219 Attrs = Attrs.addAttribute(
getContext(), Kind, Val);
224 return Attrs.hasAttribute(Kind);
229 return Attrs.hasAttribute(Kind);
234 return Attrs.hasAttributes();
239 return Attrs.getAttribute(Kind);
244 return Attrs.getAttribute(Kind);
258 std::pair<unsigned, AttributeSet> AS[1] = {{index, Attrs}};
279 return (
Data >> CodeModelShift) & CodeModelMask;
288 if (CodeModelData > 0)
320 return V->getValueID() == Value::GlobalVariableVal;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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")
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
static LLVM_ABI AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)
Create an AttributeList with the specified parameters in it.
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
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.
This class represents an Operation in the Expression.
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.
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.
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.
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.
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.
LLVM_ABI 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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.