LLVM 23.0.0git
llvm::sandboxir::Region Class Reference

#include "llvm/SandboxIR/Region.h"

Inheritance diagram for llvm::sandboxir::Region:
[legend]

Public Types

using iterator = decltype(Insts.begin())

Public Member Functions

LLVM_ABI Region (Context &Ctx)
virtual LLVM_ABI ~Region ()
 Region (const Region &)=delete
 Region (Region &&)=default
ContextgetContext () const
bool contains (Instruction *I) const
 Returns true if I is in the Region.
bool empty () const
 Returns true if the Region has no instructions.
LLVM_ABI void setAux (ArrayRef< Instruction * > Aux)
 Set the auxiliary vector.
const SmallVector< Instruction * > & getAux () const
 \Returns the auxiliary vector.
LLVM_ABI void clearAux ()
 Clears all auxiliary data.
iterator begin ()
iterator end ()
iterator_range< iteratorinsts ()
RegionClassID getSubclassID () const
LLVM_ABI_FOR_TEST bool operator== (const Region &Other) const
 This is an expensive check, meant for testing.
bool operator!= (const Region &other) const
LLVM_ABI_FOR_TEST void dump (raw_ostream &OS) const
void dump () const

Static Public Member Functions

static LLVM_ABI SmallVector< std::unique_ptr< Region > > createRegionsFromMD (Function &F)

Protected Member Functions

void addRaw (Instruction *I)
 Adds I to the set.
virtual void add (Instruction *I)
 Adds I to the set.
virtual LLVM_ABI void remove (Instruction *I)
 Removes I from the set.
void setAux (unsigned Idx, Instruction *I)
 Set I as the Idx'th element in the auxiliary vector.
void dropAuxMetadata (Instruction *I)
 Helper for dropping Aux metadata for I.
void removeFromAux (Instruction *I)
 Remove instruction I from Aux and drop metadata.
LLVM_ABI Region (Context &Ctx, RegionClassID ID)

Static Protected Member Functions

template<typename RegionT, typename RegionFactoryT>
static SmallVector< std::unique_ptr< RegionT > > createRegionsFromMD (Function &F, RegionFactoryT Factory)

Protected Attributes

SetVector< Instruction * > Insts
 All the instructions in the Region.
SmallVector< Instruction * > Aux
 An auxiliary sequence of Instruction-Index pairs.
MDNodeRegionMDN
 MDNode that we'll use to mark instructions as being part of the region.
ContextCtx
RegionClassID ID
Context::CallbackID CreateInstCB
 ID (for later deregistration) of the "create instruction" callback.
Context::CallbackID EraseInstCB
 ID (for later deregistration) of the "erase instruction" callback.

Static Protected Attributes

static constexpr const charMDKind = "sandboxvec"
static constexpr const charRegionStr = "sandboxregion"
static constexpr const charAuxMDKind = "sandboxaux"

Friends

class Context
class RegionInternalsAttorney
raw_ostreamoperator<< (raw_ostream &OS, const Region &Rgn)

Detailed Description

Definition at line 66 of file Region.h.

Member Typedef Documentation

◆ iterator

using llvm::sandboxir::Region::iterator = decltype(Insts.begin())

Definition at line 181 of file Region.h.

Constructor & Destructor Documentation

◆ Region() [1/4]

◆ Region() [2/4]

LLVM_ABI llvm::sandboxir::Region::Region ( Context & Ctx)
inline

Definition at line 162 of file Region.h.

References Context, Ctx, LLVM_ABI, Region(), and llvm::sandboxir::RegionID.

◆ ~Region()

llvm::sandboxir::Region::~Region ( )
virtual

Definition at line 26 of file Region.cpp.

References CreateInstCB, Ctx, and EraseInstCB.

◆ Region() [3/4]

llvm::sandboxir::Region::Region ( const Region & )
delete

References Region().

◆ Region() [4/4]

llvm::sandboxir::Region::Region ( Region && )
default

References Region().

Member Function Documentation

◆ add()

virtual void llvm::sandboxir::Region::add ( Instruction * I)
inlineprotectedvirtual

Adds I to the set.

This is the main API for adding an instruction to the region.

Definition at line 104 of file Region.h.

References addRaw(), and I.

Referenced by llvm::sandboxir::RegionInternalsAttorney::add().

◆ addRaw()

void llvm::sandboxir::Region::addRaw ( Instruction * I)
inlineprotected

Adds I to the set.

Only to be used when we want to avoid the additional functionality provided by the subclass, e.g., to avoid score counting when adding instrs to the aux vector. NOTE: When an instruction is added to the region we track it cost in the scoreboard, which currently resides in the region class. However, when we add an instruction to the auxiliary vector it does get tagged as being a member of the region (for ownership reasons), but its cost does not get counted because the instruction hasn't been added in the "normal" way.

Definition at line 97 of file Region.h.

References llvm::cast(), I, Insts, MDKind, and RegionMDN.

Referenced by add(), Region(), setAux(), and setAux().

◆ begin()

iterator llvm::sandboxir::Region::begin ( )
inline

Definition at line 182 of file Region.h.

References Insts.

Referenced by insts().

◆ clearAux()

void llvm::sandboxir::Region::clearAux ( )

Clears all auxiliary data.

Definition at line 75 of file Region.cpp.

References Aux, dropAuxMetadata(), and llvm::seq().

Referenced by llvm::sandboxir::SeedCollection::runOnFunction().

◆ contains()

bool llvm::sandboxir::Region::contains ( Instruction * I) const
inline

Returns true if I is in the Region.

Definition at line 171 of file Region.h.

References I, and Insts.

◆ createRegionsFromMD() [1/2]

SmallVector< std::unique_ptr< Region > > llvm::sandboxir::Region::createRegionsFromMD ( Function & F)
static

Definition at line 115 of file Region.cpp.

References createRegionsFromMD(), and F.

◆ createRegionsFromMD() [2/2]

template<typename RegionT, typename RegionFactoryT>
SmallVector< std::unique_ptr< RegionT > > llvm::sandboxir::Region::createRegionsFromMD ( Function & F,
RegionFactoryT Factory )
inlinestaticprotected

◆ dropAuxMetadata()

void llvm::sandboxir::Region::dropAuxMetadata ( Instruction * I)
protected

Helper for dropping Aux metadata for I.

Definition at line 62 of file Region.cpp.

References AuxMDKind, llvm::cast(), and I.

Referenced by clearAux(), and removeFromAux().

◆ dump() [1/2]

void llvm::sandboxir::Region::dump ( ) const

Definition at line 109 of file Region.cpp.

References llvm::dbgs(), and dump().

Referenced by dump().

◆ dump() [2/2]

void llvm::sandboxir::Region::dump ( raw_ostream & OS) const

Definition at line 95 of file Region.cpp.

References Aux, I, and Insts.

Referenced by operator<<.

◆ empty()

bool llvm::sandboxir::Region::empty ( ) const
inline

Returns true if the Region has no instructions.

Definition at line 173 of file Region.h.

References Insts.

Referenced by llvm::sandboxir::PackReuse::runOnRegion().

◆ end()

iterator llvm::sandboxir::Region::end ( )
inline

Definition at line 183 of file Region.h.

References Insts.

Referenced by insts().

◆ getAux()

const SmallVector< Instruction * > & llvm::sandboxir::Region::getAux ( ) const
inline

\Returns the auxiliary vector.

Definition at line 177 of file Region.h.

References Aux.

Referenced by llvm::sandboxir::BottomUpVec::runOnRegion(), and llvm::sandboxir::LoadStoreVec::runOnRegion().

◆ getContext()

Context & llvm::sandboxir::Region::getContext ( ) const
inline

◆ getSubclassID()

RegionClassID llvm::sandboxir::Region::getSubclassID ( ) const
inline

Definition at line 189 of file Region.h.

References ID.

Referenced by llvm::sandboxir::RegionWithScore::classof().

◆ insts()

iterator_range< iterator > llvm::sandboxir::Region::insts ( )
inline

Definition at line 184 of file Region.h.

References begin(), end(), and llvm::make_range().

◆ operator!=()

bool llvm::sandboxir::Region::operator!= ( const Region & other) const
inline

Definition at line 194 of file Region.h.

References Region().

◆ operator==()

bool llvm::sandboxir::Region::operator== ( const Region & Other) const

This is an expensive check, meant for testing.

Definition at line 87 of file Region.cpp.

References Insts, llvm::Other, and Region().

◆ remove()

void llvm::sandboxir::Region::remove ( Instruction * I)
protectedvirtual

Removes I from the set.

Definition at line 81 of file Region.cpp.

References llvm::cast(), I, Insts, and MDKind.

Referenced by Region(), and llvm::sandboxir::RegionInternalsAttorney::remove().

◆ removeFromAux()

void llvm::sandboxir::Region::removeFromAux ( Instruction * I)
protected

Remove instruction I from Aux and drop metadata.

Definition at line 67 of file Region.cpp.

References Aux, dropAuxMetadata(), llvm::find(), and I.

Referenced by Region().

◆ setAux() [1/2]

void llvm::sandboxir::Region::setAux ( ArrayRef< Instruction * > Aux)

◆ setAux() [2/2]

void llvm::sandboxir::Region::setAux ( unsigned Idx,
Instruction * I )
protected

Set I as the Idx'th element in the auxiliary vector.

NOTE: This is for internal use, it does not set the metadata.

Definition at line 46 of file Region.cpp.

References addRaw(), assert(), Aux, and I.

Referenced by llvm::sandboxir::SeedCollection::runOnFunction().

◆ Context

friend class Context
friend

◆ operator<<

raw_ostream & operator<< ( raw_ostream & OS,
const Region & Rgn )
friend

Definition at line 198 of file Region.h.

References dump(), and Region().

◆ RegionInternalsAttorney

friend class RegionInternalsAttorney
friend

Definition at line 108 of file Region.h.

References Context, Ctx, I, ID, LLVM_ABI, and RegionInternalsAttorney.

Referenced by RegionInternalsAttorney.

Member Data Documentation

◆ Aux

SmallVector<Instruction *> llvm::sandboxir::Region::Aux
protected

An auxiliary sequence of Instruction-Index pairs.

Definition at line 72 of file Region.h.

Referenced by clearAux(), dump(), getAux(), removeFromAux(), setAux(), and setAux().

◆ AuxMDKind

const char* llvm::sandboxir::Region::AuxMDKind = "sandboxaux"
staticconstexprprotected

Definition at line 78 of file Region.h.

Referenced by createRegionsFromMD(), dropAuxMetadata(), and setAux().

◆ CreateInstCB

Context::CallbackID llvm::sandboxir::Region::CreateInstCB
protected

ID (for later deregistration) of the "create instruction" callback.

Definition at line 85 of file Region.h.

Referenced by Region(), and ~Region().

◆ Ctx

Context& llvm::sandboxir::Region::Ctx
protected

◆ EraseInstCB

Context::CallbackID llvm::sandboxir::Region::EraseInstCB
protected

ID (for later deregistration) of the "erase instruction" callback.

Definition at line 87 of file Region.h.

Referenced by Region(), and ~Region().

◆ ID

RegionClassID llvm::sandboxir::Region::ID
protected

Definition at line 82 of file Region.h.

Referenced by getSubclassID(), Region(), and RegionInternalsAttorney.

◆ Insts

SetVector<Instruction *> llvm::sandboxir::Region::Insts
protected

All the instructions in the Region.

Only new instructions generated during vectorization are part of the Region.

Definition at line 70 of file Region.h.

Referenced by addRaw(), begin(), contains(), dump(), empty(), end(), operator==(), and remove().

◆ MDKind

const char* llvm::sandboxir::Region::MDKind = "sandboxvec"
staticconstexprprotected

Definition at line 76 of file Region.h.

Referenced by addRaw(), createRegionsFromMD(), and remove().

◆ RegionMDN

MDNode* llvm::sandboxir::Region::RegionMDN
protected

MDNode that we'll use to mark instructions as being part of the region.

Definition at line 75 of file Region.h.

Referenced by addRaw(), and Region().

◆ RegionStr

const char* llvm::sandboxir::Region::RegionStr = "sandboxregion"
staticconstexprprotected

Definition at line 77 of file Region.h.

Referenced by Region().


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