LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

llvm::GlobalVariable Class Reference

#include <GlobalVariable.h>

Inheritance diagram for llvm::GlobalVariable:

Inheritance graph
[legend]
Collaboration diagram for llvm::GlobalVariable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GlobalVariable (const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=0, const std::string &Name="", Module *Parent=0)
virtual void setName (const std::string &name, SymbolTable *ST=0)
virtual bool isExternal () const
bool hasInitializer () const
ConstantgetInitializer () const
ConstantgetInitializer ()
void setInitializer (Constant *CPV)
GlobalVariablegetNext ()
const GlobalVariablegetNext () const
GlobalVariablegetPrev ()
const GlobalVariablegetPrev () const
bool isConstant () const
void setConstant (bool Value)
void removeFromParent ()
void eraseFromParent ()
virtual void replaceUsesOfWithOnConstant (Value *From, Value *To, bool DisableChecking=false)
virtual void print (std::ostream &OS) const

Static Public Member Functions

static bool classof (const GlobalVariable *)
static bool classof (const Value *V)

Friends

class SymbolTableListTraits< GlobalVariable, Module, Module,ilist_traits< GlobalVariable > >

Detailed Description

Definition at line 34 of file GlobalVariable.h.


Constructor & Destructor Documentation

GlobalVariable::GlobalVariable const Type Ty,
bool  isConstant,
LinkageTypes  Linkage,
Constant Initializer = 0,
const std::string &  Name = "",
Module Parent = 0
 

GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the end of the specified modules global list.

Definition at line 74 of file Globals.cpp.

References llvm::LeakDetector::addGarbageObject(), llvm::Module::getGlobalList(), llvm::Value::getType(), and llvm::User::Operands.


Member Function Documentation

static bool llvm::GlobalVariable::classof const Value V  )  [inline, static]
 

Reimplemented from llvm::GlobalValue.

Definition at line 120 of file GlobalVariable.h.

References llvm::Value::getValueType(), and llvm::Value::GlobalVariableVal.

static bool llvm::GlobalVariable::classof const GlobalVariable  )  [inline, static]
 

Definition at line 119 of file GlobalVariable.h.

void GlobalVariable::eraseFromParent  ) 
 

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

Definition at line 113 of file Globals.cpp.

References llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().

Referenced by LinkGlobals(), OptimizeAwayTrappingUsesOfLoads(), and OptimizeGlobalAddressOfMalloc().

Constant* llvm::GlobalVariable::getInitializer  )  [inline]
 

Definition at line 75 of file GlobalVariable.h.

References hasInitializer(), and llvm::User::Operands.

Constant* llvm::GlobalVariable::getInitializer  )  const [inline]
 

getInitializer - Return the initializer for this global variable. It is illegal to call this method if the global is external, because we cannot tell what the value is initialized to!

Definition at line 71 of file GlobalVariable.h.

References hasInitializer(), and llvm::User::Operands.

Referenced by llvm::ExecutionEngine::EmitGlobalVariable(), GetAddressedElementFromGlobal(), llvm::ProgramInfo::getFunction(), llvm::ProgramInfo::getSourceFile(), LinkAppendingVars(), LinkGlobalInits(), OptimizeOnceStoredGlobal(), llvm::SourceFileInfo::SourceFileInfo(), llvm::SourceFunctionInfo::SourceFunctionInfo(), and SRAGlobal().

const GlobalVariable* llvm::GlobalVariable::getNext  )  const [inline]
 

Definition at line 90 of file GlobalVariable.h.

References Next().

GlobalVariable* llvm::GlobalVariable::getNext  )  [inline]
 

Definition at line 89 of file GlobalVariable.h.

References Next().

const GlobalVariable* llvm::GlobalVariable::getPrev  )  const [inline]
 

Definition at line 92 of file GlobalVariable.h.

GlobalVariable* llvm::GlobalVariable::getPrev  )  [inline]
 

Definition at line 91 of file GlobalVariable.h.

bool llvm::GlobalVariable::hasInitializer  )  const [inline]
 

hasInitializer - Unless a global variable isExternal(), it has an initializer. The initializer for the global variable/constant is held by Operands[0] if an initializer is specified.

Definition at line 65 of file GlobalVariable.h.

References isExternal().

Referenced by llvm::ProgramInfo::getFunction(), getInitializer(), llvm::ProgramInfo::getSourceFile(), LinkGlobalInits(), LinkGlobals(), llvm::BytecodeReader::ParseModule(), setInitializer(), llvm::SourceFileInfo::SourceFileInfo(), and llvm::SourceFunctionInfo::SourceFunctionInfo().

bool llvm::GlobalVariable::isConstant  )  const [inline]
 

If the value is a global constant, its value is immutable throughout the runtime execution of the program. Assigning a value into the constant leads to undefined behavior.

Definition at line 98 of file GlobalVariable.h.

Referenced by LinkAppendingVars(), LinkGlobals(), and SRAGlobal().

virtual bool llvm::GlobalVariable::isExternal  )  const [inline, virtual]
 

isExternal - Is this global variable lacking an initializer? If so, the global variable is defined in some other translation unit, and is thus externally defined here.

Implements llvm::GlobalValue.

Definition at line 59 of file GlobalVariable.h.

References llvm::User::Operands.

Referenced by llvm::JIT::getOrEmitGlobalVariable(), hasInitializer(), LinkGlobals(), and ProcessGlobalsWithSameName().

void GlobalVariable::print std::ostream &  OS  )  const [virtual]
 

print - Implement operator<< on Value...

Reimplemented from llvm::Constant.

Definition at line 1194 of file AsmWriter.cpp.

References llvm::GlobalValue::getParent(), and llvm::AssemblyWriter::write().

void GlobalVariable::removeFromParent  ) 
 

removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.

Definition at line 109 of file Globals.cpp.

References llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().

void GlobalVariable::replaceUsesOfWithOnConstant Value From,
Value To,
bool  DisableChecking = false
[virtual]
 

Override Constant's implementation of this method so we can replace constant initializers.

Reimplemented from llvm::Constant.

Definition at line 117 of file Globals.cpp.

References llvm::User::getNumOperands(), llvm::Constant::getOperand(), and llvm::Constant::setOperand().

void llvm::GlobalVariable::setConstant bool  Value  )  [inline]
 

Definition at line 99 of file GlobalVariable.h.

Referenced by LinkGlobals(), and ParseGlobalVariable().

void llvm::GlobalVariable::setInitializer Constant CPV  )  [inline]
 

Definition at line 79 of file GlobalVariable.h.

References hasInitializer(), and llvm::User::Operands.

Referenced by llvm::CloneModule(), LinkAppendingVars(), LinkGlobalInits(), LinkGlobals(), ParseGlobalVariable(), and ProcessGlobalsWithSameName().

void GlobalVariable::setName const std::string &  name,
SymbolTable ST = 0
[virtual]
 

Reimplemented from llvm::Constant.

Definition at line 100 of file Globals.cpp.

References llvm::GlobalValue::getParent(), llvm::Module::getSymbolTable(), llvm::Value::hasName(), llvm::SymbolTable::insert(), llvm::SymbolTable::remove(), and llvm::Value::setName().


Friends And Related Function Documentation

friend class SymbolTableListTraits< GlobalVariable, Module, Module,ilist_traits< GlobalVariable > > [friend]
 

Definition at line 36 of file GlobalVariable.h.


The documentation for this class was generated from the following files: