LLVM  13.0.0git
Public Types | Public Member Functions | List of all members
llvm::SlotTracker Class Reference

This class provides computation of slot numbers for LLVM Assembly writing. More...

Public Types

using ValueMap = DenseMap< const Value *, unsigned >
 ValueMap - A mapping of Values to slot numbers. More...
 
using mdn_iterator = DenseMap< const MDNode *, unsigned >::iterator
 MDNode map iterators. More...
 
using as_iterator = DenseMap< AttributeSet, unsigned >::iterator
 AttributeSet map iterators. More...
 
using guid_iterator = DenseMap< GlobalValue::GUID, unsigned >::iterator
 GUID map iterators. More...
 

Public Member Functions

 SlotTracker (const Module *M, bool ShouldInitializeAllMetadata=false)
 Construct from a module. More...
 
 SlotTracker (const Function *F, bool ShouldInitializeAllMetadata=false)
 Construct from a function, starting out in incorp state. More...
 
 SlotTracker (const ModuleSummaryIndex *Index)
 Construct from a module summary index. More...
 
 SlotTracker (const SlotTracker &)=delete
 
SlotTrackeroperator= (const SlotTracker &)=delete
 
int getLocalSlot (const Value *V)
 Return the slot number of the specified value in it's type plane. More...
 
int getGlobalSlot (const GlobalValue *V)
 getGlobalSlot - Get the slot number of a global value. More...
 
int getMetadataSlot (const MDNode *N)
 getMetadataSlot - Get the slot number of a MDNode. More...
 
int getAttributeGroupSlot (AttributeSet AS)
 
int getModulePathSlot (StringRef Path)
 
int getGUIDSlot (GlobalValue::GUID GUID)
 
int getTypeIdSlot (StringRef Id)
 
void incorporateFunction (const Function *F)
 If you'd like to deal with a function instead of just a module, use this method to get its data into the SlotTracker. More...
 
const FunctiongetFunction () const
 
void purgeFunction ()
 After calling incorporateFunction, use this method to remove the most recently incorporated function from the SlotTracker. More...
 
mdn_iterator mdn_begin ()
 
mdn_iterator mdn_end ()
 
unsigned mdn_size () const
 
bool mdn_empty () const
 
as_iterator as_begin ()
 
as_iterator as_end ()
 
unsigned as_size () const
 
bool as_empty () const
 
void initializeIfNeeded ()
 These functions do the actual initialization. More...
 
int initializeIndexIfNeeded ()
 

Detailed Description

This class provides computation of slot numbers for LLVM Assembly writing.

Definition at line 716 of file AsmWriter.cpp.

Member Typedef Documentation

◆ as_iterator

AttributeSet map iterators.

Definition at line 817 of file AsmWriter.cpp.

◆ guid_iterator

GUID map iterators.

Definition at line 825 of file AsmWriter.cpp.

◆ mdn_iterator

using llvm::SlotTracker::mdn_iterator = DenseMap<const MDNode*, unsigned>::iterator

MDNode map iterators.

Definition at line 809 of file AsmWriter.cpp.

◆ ValueMap

ValueMap - A mapping of Values to slot numbers.

Definition at line 719 of file AsmWriter.cpp.

Constructor & Destructor Documentation

◆ SlotTracker() [1/4]

SlotTracker::SlotTracker ( const Module M,
bool  ShouldInitializeAllMetadata = false 
)
explicit

Construct from a module.

If ShouldInitializeAllMetadata, initializes all metadata in all functions, giving correct numbering for metadata referenced only from within a function (even if no functions have been initialized).

Definition at line 945 of file AsmWriter.cpp.

◆ SlotTracker() [2/4]

SlotTracker::SlotTracker ( const Function F,
bool  ShouldInitializeAllMetadata = false 
)
explicit

Construct from a function, starting out in incorp state.

If ShouldInitializeAllMetadata, initializes all metadata in all functions, giving correct numbering for metadata referenced only from within a function (even if no functions have been initialized).

Definition at line 950 of file AsmWriter.cpp.

◆ SlotTracker() [3/4]

SlotTracker::SlotTracker ( const ModuleSummaryIndex Index)
explicit

Construct from a module summary index.

Definition at line 954 of file AsmWriter.cpp.

◆ SlotTracker() [4/4]

llvm::SlotTracker::SlotTracker ( const SlotTracker )
delete

Member Function Documentation

◆ as_begin()

as_iterator llvm::SlotTracker::as_begin ( )
inline

Definition at line 819 of file AsmWriter.cpp.

◆ as_empty()

bool llvm::SlotTracker::as_empty ( ) const
inline

Definition at line 822 of file AsmWriter.cpp.

◆ as_end()

as_iterator llvm::SlotTracker::as_end ( )
inline

Definition at line 820 of file AsmWriter.cpp.

◆ as_size()

unsigned llvm::SlotTracker::as_size ( ) const
inline

Definition at line 821 of file AsmWriter.cpp.

◆ getAttributeGroupSlot()

int SlotTracker::getAttributeGroupSlot ( AttributeSet  AS)

Definition at line 1173 of file AsmWriter.cpp.

References initializeIfNeeded(), and int.

◆ getFunction()

const Function* llvm::SlotTracker::getFunction ( ) const
inline

Definition at line 801 of file AsmWriter.cpp.

◆ getGlobalSlot()

int SlotTracker::getGlobalSlot ( const GlobalValue V)

◆ getGUIDSlot()

int SlotTracker::getGUIDSlot ( GlobalValue::GUID  GUID)

◆ getLocalSlot()

int SlotTracker::getLocalSlot ( const Value V)

Return the slot number of the specified value in it's type plane.

getLocalSlot - Get the slot number for a value that is local to a function.

If something is not in the SlotTracker, return -1.

Definition at line 1163 of file AsmWriter.cpp.

References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), initializeIfNeeded(), and int.

◆ getMetadataSlot()

int SlotTracker::getMetadataSlot ( const MDNode N)

getMetadataSlot - Get the slot number of a MDNode.

Definition at line 1153 of file AsmWriter.cpp.

References initializeIfNeeded(), int, MI, and N.

◆ getModulePathSlot()

int SlotTracker::getModulePathSlot ( StringRef  Path)

◆ getTypeIdSlot()

int SlotTracker::getTypeIdSlot ( StringRef  Id)

◆ incorporateFunction()

void llvm::SlotTracker::incorporateFunction ( const Function F)
inline

If you'd like to deal with a function instead of just a module, use this method to get its data into the SlotTracker.

Definition at line 796 of file AsmWriter.cpp.

◆ initializeIfNeeded()

void SlotTracker::initializeIfNeeded ( )
inline

These functions do the actual initialization.

< Prevent re-processing next time we're called.

Definition at line 957 of file AsmWriter.cpp.

Referenced by getAttributeGroupSlot(), getGlobalSlot(), getLocalSlot(), and getMetadataSlot().

◆ initializeIndexIfNeeded()

int SlotTracker::initializeIndexIfNeeded ( )

< Prevent re-processing next time we're called.

Definition at line 967 of file AsmWriter.cpp.

Referenced by getGUIDSlot(), getModulePathSlot(), and getTypeIdSlot().

◆ mdn_begin()

mdn_iterator llvm::SlotTracker::mdn_begin ( )
inline

Definition at line 811 of file AsmWriter.cpp.

◆ mdn_empty()

bool llvm::SlotTracker::mdn_empty ( ) const
inline

Definition at line 814 of file AsmWriter.cpp.

◆ mdn_end()

mdn_iterator llvm::SlotTracker::mdn_end ( )
inline

Definition at line 812 of file AsmWriter.cpp.

◆ mdn_size()

unsigned llvm::SlotTracker::mdn_size ( ) const
inline

Definition at line 813 of file AsmWriter.cpp.

◆ operator=()

SlotTracker& llvm::SlotTracker::operator= ( const SlotTracker )
delete

◆ purgeFunction()

void SlotTracker::purgeFunction ( )

After calling incorporateFunction, use this method to remove the most recently incorporated function from the SlotTracker.

Clean up after incorporating a function.

This will reset the state of the machine back to just the module contents.

This is the only way to get out of the function incorporation state that affects get*Slot/Create*Slot. Function incorporation state is indicated by TheFunction != 0.

Definition at line 1134 of file AsmWriter.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), and ST_DEBUG.


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