class GISelCSEInfo
Declaration
class GISelCSEInfo : public GISelChangeObserver { /* full declaration omitted */ };
Description
The CSE Analysis object. This installs itself as a delegate to the MachineFunction to track new instructions as well as deletions. It however will not be able to track instruction mutations. In such cases, recordNewInstruction should be called (for eg inside MachineIRBuilder::recordInsertion). Also because of how just the instruction can be inserted without adding any operands to the instruction, instructions are uniqued and inserted lazily. CSEInfo should assert when trying to enter an incomplete instruction into the CSEMap. There is Opcode level granularity on which instructions can be CSE'd and for now, only Generic instructions are CSEable.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:69
Inherits from: GISelChangeObserver
Member Variables
- private llvm::BumpPtrAllocator UniqueInstrAllocator
- private FoldingSet<llvm::UniqueMachineInstr> CSEMap
- private llvm::MachineRegisterInfo* MRI = nullptr
- private llvm::MachineFunction* MF = nullptr
- private std::unique_ptr<CSEConfigBase> CSEOpt
- private DenseMap<const llvm::MachineInstr*, llvm::UniqueMachineInstr*> InstrMapping
- Keep a cache of UniqueInstrs for each MachineInstr. In GISel, often instructions are mutated (while their ID has completely changed). Whenever mutation happens, invalidate the UniqueMachineInstr for the MachineInstr
- private GISelWorkList<8> TemporaryInsts
- Store instructions that are not fully formed in TemporaryInsts. Also because CSE insertion happens lazily, we can remove insts from this list and avoid inserting and then removing from the CSEMap.
- private DenseMap<unsigned int, unsigned int> OpcodeHitTable
Method Overview
- public GISelCSEInfo()
- public void analyze(llvm::MachineFunction & MF)
- public void changedInstr(llvm::MachineInstr & MI)
- public void changingInstr(llvm::MachineInstr & MI)
- public void countOpcodeHit(unsigned int Opc)
- public void createdInstr(llvm::MachineInstr & MI)
- public void erasingInstr(llvm::MachineInstr & MI)
- private llvm::MachineInstr * getMachineInstrIfExists(llvm::FoldingSetNodeID & ID, llvm::MachineBasicBlock * MBB, void *& InsertPos)
- private llvm::UniqueMachineInstr * getNodeIfExists(llvm::FoldingSetNodeID & ID, llvm::MachineBasicBlock * MBB, void *& InsertPos)
- private llvm::UniqueMachineInstr * getUniqueInstrForMI(const llvm::MachineInstr * MI)
- public void handleRecordedInst(llvm::MachineInstr * MI)
- public void handleRecordedInsts()
- public void handleRemoveInst(llvm::MachineInstr * MI)
- private void insertInstr(llvm::MachineInstr * MI, void * InsertPos = nullptr)
- private void insertNode(llvm::UniqueMachineInstr * UMI, void * InsertPos = nullptr)
- private void invalidateUniqueMachineInstr(llvm::UniqueMachineInstr * UMI)
- private bool isUniqueMachineInstValid(const llvm::UniqueMachineInstr & UMI) const
- public void print()
- public void recordNewInstruction(llvm::MachineInstr * MI)
- public void releaseMemory()
- public void setCSEConfig(std::unique_ptr<CSEConfigBase> Opt)
- public void setMF(llvm::MachineFunction & MF)
- public bool shouldCSE(unsigned int Opc) const
- public llvm::Error verify()
- public virtual ~GISelCSEInfo()
Inherited from GISelChangeObserver:
- public changedInstr
- public changingAllUsesOfReg
- public changingInstr
- public createdInstr
- public erasingInstr
- public finishedChangingAllUsesOfReg
Methods
¶GISelCSEInfo()
GISelCSEInfo()
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:115
¶void analyze(llvm::MachineFunction& MF)
void analyze(llvm::MachineFunction& MF)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:150
Parameters
¶void changedInstr(llvm::MachineInstr& MI)
void changedInstr(llvm::MachineInstr& MI)
Description
This instruction was mutated in some way.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:160
Parameters
¶void changingInstr(llvm::MachineInstr& MI)
void changingInstr(llvm::MachineInstr& MI)
Description
This instruction is about to be mutated in some way.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:159
Parameters
¶void countOpcodeHit(unsigned int Opc)
void countOpcodeHit(unsigned int Opc)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:152
Parameters
- unsigned int Opc
¶void createdInstr(llvm::MachineInstr& MI)
void createdInstr(llvm::MachineInstr& MI)
Description
An instruction has been created and inserted into the function. Note that the instruction might not be a fully fledged instruction at this point and won't be if the MachineFunction::Delegate is calling it. This is because the delegate only sees the construction of the MachineInstr before operands have been added.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:158
Parameters
¶void erasingInstr(llvm::MachineInstr& MI)
void erasingInstr(llvm::MachineInstr& MI)
Description
An instruction is about to be erased.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:157
Parameters
¶llvm::MachineInstr* getMachineInstrIfExists(
llvm::FoldingSetNodeID& ID,
llvm::MachineBasicBlock* MBB,
void*& InsertPos)
llvm::MachineInstr* getMachineInstrIfExists(
llvm::FoldingSetNodeID& ID,
llvm::MachineBasicBlock* MBB,
void*& InsertPos)
Description
Get the MachineInstr(Unique) if it exists already in the CSEMap and the same MachineBasicBlock.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:106
Parameters
- llvm::FoldingSetNodeID& ID
- llvm::MachineBasicBlock* MBB
- void*& InsertPos
¶llvm::UniqueMachineInstr* getNodeIfExists(
llvm::FoldingSetNodeID& ID,
llvm::MachineBasicBlock* MBB,
void*& InsertPos)
llvm::UniqueMachineInstr* getNodeIfExists(
llvm::FoldingSetNodeID& ID,
llvm::MachineBasicBlock* MBB,
void*& InsertPos)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:96
Parameters
- llvm::FoldingSetNodeID& ID
- llvm::MachineBasicBlock* MBB
- void*& InsertPos
¶llvm::UniqueMachineInstr* getUniqueInstrForMI(
const llvm::MachineInstr* MI)
llvm::UniqueMachineInstr* getUniqueInstrForMI(
const llvm::MachineInstr* MI)
Description
Allocate and construct a new UniqueMachineInstr for MI and return.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:100
Parameters
- const llvm::MachineInstr* MI
¶void handleRecordedInst(llvm::MachineInstr* MI)
void handleRecordedInst(llvm::MachineInstr* MI)
Description
Use this callback to inform CSE about a newly fully created instruction.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:131
Parameters
¶void handleRecordedInsts()
void handleRecordedInsts()
Description
Use this callback to insert all the recorded instructions. At this point, all of these insts need to be fully constructed and should not be missing any operands.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:136
¶void handleRemoveInst(llvm::MachineInstr* MI)
void handleRemoveInst(llvm::MachineInstr* MI)
Description
Remove this inst from the CSE map. If this inst has not been inserted yet, it will be removed from the Tempinsts list if it exists.
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:140
Parameters
¶void insertInstr(llvm::MachineInstr* MI,
void* InsertPos = nullptr)
void insertInstr(llvm::MachineInstr* MI,
void* InsertPos = nullptr)
Description
Use this method to allocate a new UniqueMachineInstr for MI and insert it into the CSEMap. MI should return true for shouldCSE(MI->getOpcode())
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:112
Parameters
- llvm::MachineInstr* MI
- void* InsertPos = nullptr
¶void insertNode(llvm::UniqueMachineInstr* UMI,
void* InsertPos = nullptr)
void insertNode(llvm::UniqueMachineInstr* UMI,
void* InsertPos = nullptr)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:102
Parameters
- llvm::UniqueMachineInstr* UMI
- void* InsertPos = nullptr
¶void invalidateUniqueMachineInstr(
llvm::UniqueMachineInstr* UMI)
void invalidateUniqueMachineInstr(
llvm::UniqueMachineInstr* UMI)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:94
Parameters
¶bool isUniqueMachineInstValid(
const llvm::UniqueMachineInstr& UMI) const
bool isUniqueMachineInstValid(
const llvm::UniqueMachineInstr& UMI) const
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:92
Parameters
- const llvm::UniqueMachineInstr& UMI
¶void print()
void print()
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:154
¶void recordNewInstruction(llvm::MachineInstr* MI)
void recordNewInstruction(llvm::MachineInstr* MI)
Description
Records a newly created inst in a list and lazily insert it to the CSEMap. Sometimes, this method might be called with a partially constructed MachineInstr,
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:128
Parameters
¶void releaseMemory()
void releaseMemory()
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:142
¶void setCSEConfig(
std::unique_ptr<CSEConfigBase> Opt)
void setCSEConfig(
std::unique_ptr<CSEConfigBase> Opt)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:144
Parameters
- std::unique_ptr<CSEConfigBase> Opt
¶void setMF(llvm::MachineFunction& MF)
void setMF(llvm::MachineFunction& MF)
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:119
Parameters
¶bool shouldCSE(unsigned int Opc) const
bool shouldCSE(unsigned int Opc) const
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:148
Parameters
- unsigned int Opc
¶llvm::Error verify()
llvm::Error verify()
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:121
¶virtual ~GISelCSEInfo()
virtual ~GISelCSEInfo()
Declared at: llvm/include/llvm/CodeGen/GlobalISel/CSEInfo.h:117