LLVM: include/llvm/IR/GlobalVariable.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19#ifndef LLVM_IR_GLOBALVARIABLE_H

20#define LLVM_IR_GLOBALVARIABLE_H

21

29#include

30#include

31

32namespace llvm {

33

36

39

42

44

46

47

48 bool isConstantGlobal : 1;

49

50

51 bool isExternallyInitializedConstant : 1;

52

53private:

55 static const unsigned CodeModelMask = (1 << CodeModelBits) - 1;

57

58public:

59

60

62 Constant *Initializer = nullptr,

63 const Twine &Name = "",

67

68

71 const Twine &Name = "",

74 std::optional AddressSpace = std::nullopt,

78

79private:

80

81

82

83

84 void setGlobalVariableNumOperands(unsigned NumOps) {

85 assert(NumOps <= 1 && "GlobalVariable can only have 0 or 1 operands");

87 }

88

89public:

92

93

94

95

96 setGlobalVariableNumOperands(1);

97 }

98

99

100 void *operator new(size_t s) { return User::operator new(s, AllocMarker); }

101

102

103 void operator delete(void *ptr) { User::operator delete(ptr); }

104

105

107

108

109

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

137

138

139

141 return

142

144

145

146

148 }

149

150

151

152

153

162

163

164

166

167

168

169

170

172

173

174

175

176

177 bool isConstant() const { return isConstantGlobal; }

178 void setConstant(bool Val) { isConstantGlobal = Val; }

179

181 return isExternallyInitializedConstant;

182 }

184 isExternallyInitializedConstant = Val;

185 }

186

187

188

190

191

192

193

195

196

197

198

200

201

202

204

205

207

208

211

212

214 Attrs = Attrs.addAttribute(getContext(), Kind);

215 }

216

217

219 Attrs = Attrs.addAttribute(getContext(), Kind, Val);

220 }

221

222

224 Attrs = Attrs.addAttributes(getContext(), AttrBuilder);

225 }

226

227

229 return Attrs.hasAttribute(Kind);

230 }

231

232

234 return Attrs.hasAttribute(Kind);

235 }

236

237

239 return Attrs.hasAttributes();

240 }

241

242

244 return Attrs.getAttribute(Kind);

245 }

246

247

249 return Attrs.getAttribute(Kind);

250 }

251

252

256

257

258

259

262 return AttributeList();

263 std::pair<unsigned, AttributeSet> AS[1] = {{index, Attrs}};

264 return AttributeList::get(getContext(), AS);

265 }

266

267

271

272

279

280

281

284 return (Data >> CodeModelShift) & CodeModelMask;

285 }

286

287

288

289

290

293 if (CodeModelData > 0)

295 return {};

296 }

297

298

299

301

302

303

305

306

311

312

314

315

317

318

319

320

322

323

325 return V->getValueID() == Value::GlobalVariableVal;

326 }

327};

328

329template <>

333

335

336}

337

338#endif

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")

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.

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.

Definition GlobalVariable.h:40

const Constant * getInitializer() const

getInitializer - Return the initializer for this global variable.

Definition GlobalVariable.h:154

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.

Definition GlobalVariable.h:282

bool hasAttribute(Attribute::AttrKind Kind) const

Return true if the attribute exists.

Definition GlobalVariable.h:228

bool isExternallyInitialized() const

Definition GlobalVariable.h:180

bool hasInitializer() const

Definitions have initializers, declarations don't.

Definition GlobalVariable.h:110

Attribute getAttribute(Attribute::AttrKind Kind) const

Return the attribute object.

Definition GlobalVariable.h:243

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.

Definition GlobalVariable.h:238

void setAlignment(MaybeAlign Align)

Sets the alignment attribute of the GlobalVariable.

Definition GlobalVariable.h:321

AttributeSet getAttributes() const

Return the attribute set for this global.

Definition GlobalVariable.h:253

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.

Definition GlobalVariable.h:291

void setAttributes(AttributeSet A)

Set attribute list for this global.

Definition GlobalVariable.h:268

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.

Definition GlobalVariable.h:313

void setConstant(bool Val)

Definition GlobalVariable.h:178

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.

Definition GlobalVariable.h:218

Constant * getInitializer()

Definition GlobalVariable.h:158

bool hasImplicitSection() const

Check if section name is present.

Definition GlobalVariable.h:273

uint64_t getAlignment() const

FIXME: Remove this function once transition to Align is over.

Definition GlobalVariable.h:307

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.

Definition GlobalVariable.h:260

Attribute getAttribute(StringRef Kind) const

Return the attribute object.

Definition GlobalVariable.h:248

static bool classof(const Value *V)

Definition GlobalVariable.h:324

bool hasAttribute(StringRef Kind) const

Return true if the attribute exists.

Definition GlobalVariable.h:233

bool isConstant() const

If the value is a global constant, its value is immutable throughout the runtime execution of the pro...

Definition GlobalVariable.h:177

LLVM_ABI void setCodeModel(CodeModel::Model CM)

Change the code model for this global.

void addAttributes(const AttrBuilder &AttrBuilder)

Add attributes to this global.

Definition GlobalVariable.h:223

bool hasUniqueInitializer() const

hasUniqueInitializer - Whether the global variable has an initializer, and any changes made to the in...

Definition GlobalVariable.h:140

void setExternallyInitialized(bool Val)

Definition GlobalVariable.h:183

LLVM_ABI void eraseFromParent()

eraseFromParent - This method unlinks 'this' from the containing module and deletes it.

~GlobalVariable()

Definition GlobalVariable.h:90

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...

Definition GlobalVariable.h:128

void setAlignment(Align Align)

Sets the alignment attribute of the GlobalVariable.

Definition GlobalVariable.h:316

void addAttribute(Attribute::AttrKind Kind)

Add attribute to this global.

Definition GlobalVariable.h:213

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.

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.

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.