LLVM 20.0.0git
|
The CSE Analysis object. More...
#include "llvm/CodeGen/GlobalISel/CSEInfo.h"
Public Member Functions | |
GISelCSEInfo ()=default | |
virtual | ~GISelCSEInfo () |
void | setMF (MachineFunction &MF) |
-----— GISelCSEInfo ----------—// | |
Error | verify () |
void | recordNewInstruction (MachineInstr *MI) |
Records a newly created inst in a list and lazily insert it to the CSEMap. | |
void | handleRecordedInst (MachineInstr *MI) |
Use this callback to inform CSE about a newly fully created instruction. | |
void | handleRecordedInsts () |
Use this callback to insert all the recorded instructions. | |
void | handleRemoveInst (MachineInstr *MI) |
Remove this inst from the CSE map. | |
void | releaseMemory () |
void | setCSEConfig (std::unique_ptr< CSEConfigBase > Opt) |
bool | shouldCSE (unsigned Opc) const |
void | analyze (MachineFunction &MF) |
void | countOpcodeHit (unsigned Opc) |
void | print () |
void | erasingInstr (MachineInstr &MI) override |
An instruction is about to be erased. | |
void | createdInstr (MachineInstr &MI) override |
An instruction has been created and inserted into the function. | |
void | changingInstr (MachineInstr &MI) override |
This instruction is about to be mutated in some way. | |
void | changedInstr (MachineInstr &MI) override |
This instruction was mutated in some way. | |
Public Member Functions inherited from llvm::GISelChangeObserver | |
virtual | ~GISelChangeObserver ()=default |
virtual void | erasingInstr (MachineInstr &MI)=0 |
An instruction is about to be erased. | |
virtual void | createdInstr (MachineInstr &MI)=0 |
An instruction has been created and inserted into the function. | |
virtual void | changingInstr (MachineInstr &MI)=0 |
This instruction is about to be mutated in some way. | |
virtual void | changedInstr (MachineInstr &MI)=0 |
This instruction was mutated in some way. | |
void | changingAllUsesOfReg (const MachineRegisterInfo &MRI, Register Reg) |
All the instructions using the given register are being changed. | |
void | finishedChangingAllUsesOfReg () |
All instructions reported as changing by changingAllUsesOfReg() have finished being changed. | |
Friends | |
class | CSEMIRBuilder |
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.
|
default |
|
virtualdefault |
void GISelCSEInfo::analyze | ( | MachineFunction & | MF | ) |
Definition at line 244 of file CSEInfo.cpp.
References llvm::dbgs(), LLVM_DEBUG, MBB, MI, setMF(), and shouldCSE().
Referenced by llvm::GISelCSEAnalysisWrapper::get().
|
overridevirtual |
This instruction was mutated in some way.
Implements llvm::GISelChangeObserver.
Definition at line 242 of file CSEInfo.cpp.
References changingInstr(), and MI.
|
overridevirtual |
This instruction is about to be mutated in some way.
Implements llvm::GISelChangeObserver.
Definition at line 237 of file CSEInfo.cpp.
References createdInstr(), erasingInstr(), and MI.
Referenced by changedInstr().
void GISelCSEInfo::countOpcodeHit | ( | unsigned | Opc | ) |
Definition at line 172 of file CSEInfo.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::count().
|
overridevirtual |
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.
Implements llvm::GISelChangeObserver.
Definition at line 236 of file CSEInfo.cpp.
References MI, and recordNewInstruction().
Referenced by changingInstr().
|
overridevirtual |
An instruction is about to be erased.
Implements llvm::GISelChangeObserver.
Definition at line 235 of file CSEInfo.cpp.
References handleRemoveInst(), and MI.
Referenced by changingInstr().
void GISelCSEInfo::handleRecordedInst | ( | MachineInstr * | MI | ) |
Use this callback to inform CSE about a newly fully created instruction.
Now insert the new instruction.
We'll reuse the same UniqueMachineInstr to avoid the new allocation.
This is a new instruction. Allocate a new UniqueMachineInstr and Insert.
Definition at line 189 of file CSEInfo.cpp.
References assert(), llvm::dbgs(), LLVM_DEBUG, MI, and shouldCSE().
Referenced by handleRecordedInsts().
void GISelCSEInfo::handleRecordedInsts | ( | ) |
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.
Definition at line 219 of file CSEInfo.cpp.
References llvm::GISelWorkList< N >::empty(), handleRecordedInst(), MI, and llvm::GISelWorkList< N >::pop_back_val().
Referenced by verify().
void GISelCSEInfo::handleRemoveInst | ( | MachineInstr * | MI | ) |
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.
Definition at line 211 of file CSEInfo.cpp.
References MI, and llvm::GISelWorkList< N >::remove().
Referenced by llvm::CSEMIRBuilder::buildInstr(), and erasingInstr().
void GISelCSEInfo::print | ( | ) |
Definition at line 315 of file CSEInfo.cpp.
References llvm::dbgs(), and LLVM_DEBUG.
Referenced by releaseMemory().
void GISelCSEInfo::recordNewInstruction | ( | MachineInstr * | MI | ) |
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,
Definition at line 182 of file CSEInfo.cpp.
References llvm::dbgs(), llvm::GISelWorkList< N >::insert(), LLVM_DEBUG, MI, and shouldCSE().
Referenced by createdInstr().
void GISelCSEInfo::releaseMemory | ( | ) |
Definition at line 256 of file CSEInfo.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::GISelWorkList< N >::clear(), print(), and llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Reset().
Referenced by llvm::GISelCSEAnalysisWrapper::get().
|
inline |
Definition at line 147 of file CSEInfo.h.
Referenced by llvm::GISelCSEAnalysisWrapper::get().
void GISelCSEInfo::setMF | ( | MachineFunction & | MF | ) |
-----— GISelCSEInfo ----------—//
Definition at line 91 of file CSEInfo.cpp.
References llvm::MachineFunction::getRegInfo().
Referenced by analyze().
Definition at line 230 of file CSEInfo.cpp.
References assert().
Referenced by analyze(), handleRecordedInst(), and recordNewInstruction().
Error GISelCSEInfo::verify | ( | ) |
Definition at line 278 of file CSEInfo.cpp.
References llvm::GISelInstProfileBuilder::addNodeID(), llvm::createStringError(), handleRecordedInsts(), S1, stringify(), and llvm::Error::success().
Referenced by llvm::Combiner::combineMachineInstrs(), and llvm::Legalizer::runOnMachineFunction().
|
friend |