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

28#include

29#include

30

31namespace llvm {

32

35

38

41

43

45

46

47 bool isConstantGlobal : 1;

48

49

50 bool isExternallyInitializedConstant : 1;

51

52private:

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

56

57public:

58

59

64

65

70 std::optional AddressSpace = std::nullopt,

74

75private:

76

77

78

79

80 void setGlobalVariableNumOperands(unsigned NumOps) {

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

83 }

84

85public:

88

89

90

91

92 setGlobalVariableNumOperands(1);

93 }

94

95

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

97

98

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

100

101

103

104

105

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

126

127

129

130

132 }

133

134

135

137 return

138

140

141

142

144 }

145

146

147

148

149

153 }

157 }

158

159

160

162

163

164

165

166

168

169

170

171

172

173 bool isConstant() const { return isConstantGlobal; }

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

175

177 return isExternallyInitializedConstant;

178 }

180 isExternallyInitializedConstant = Val;

181 }

182

183

184

186

187

188

189

191

192

193

194

196

197

198

200

201

203

204

206

207

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

210 }

211

212

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

215 }

216

217

219 return Attrs.hasAttribute(Kind);

220 }

221

222

224 return Attrs.hasAttribute(Kind);

225 }

226

227

229 return Attrs.hasAttributes();

230 }

231

232

234 return Attrs.getAttribute(Kind);

235 }

236

237

239 return Attrs.getAttribute(Kind);

240 }

241

242

244 return Attrs;

245 }

246

247

248

249

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

255 }

256

257

259 Attrs = A;

260 }

261

262

268 }

269

270

271

274 return (Data >> CodeModelShift) & CodeModelMask;

275 }

276

277

278

279

280

283 if (CodeModelData > 0)

285 return {};

286 }

287

288

289

291

292

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

295 }

296};

297

298template <>

301};

302

304

305}

306

307#endif

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.

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute > > Attrs)

Create an AttributeList with the specified parameters in it.

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.

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.

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.

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.

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.

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.

void replaceInitializer(Constant *InitVal)

replaceInitializer - Sets the initializer for this global variable, and sets the value type of the gl...

void setConstant(bool Val)

GlobalVariable & operator=(const GlobalVariable &)=delete

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.

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

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)

void eraseFromParent()

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

void addDebugInfo(DIGlobalVariableExpression *GV)

Attach a DIGlobalVariableExpression.

bool hasDefinitiveInitializer() const

hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...

void addAttribute(Attribute::AttrKind Kind)

Add attribute to this global.

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.

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.

Compile-time customization of User operands.

OptionalOperandTraits - when the number of operands may change at runtime.

Indicates this User has operands co-allocated.