64#ifndef LLVM_CODEGEN_GLOBALISEL_REGBANKSELECT_H
65#define LLVM_CODEGEN_GLOBALISEL_REGBANKSELECT_H
188 virtual bool isSplit()
const {
return false; }
212 void materialize()
override;
217 return Instr.getNextNode() ? *Instr.getNextNode()
218 : Instr.getParent()->end();
245 void materialize()
override {
249 return Beginning ? MBB.begin() : MBB.end();
256 : MBB(MBB), Beginning(Beginning) {
259 assert((!Beginning || MBB.getFirstNonPHI() == MBB.begin()) &&
260 "Invalid beginning point");
263 assert((Beginning || MBB.getFirstTerminator() == MBB.end()) &&
264 "Invalid end point");
267 bool isSplit()
const override {
return false; }
286 void materialize()
override;
292 assert(DstOrSplit && DstOrSplit->isPredecessor(&Src) &&
293 DstOrSplit->pred_size() == 1 && DstOrSplit->succ_size() == 1 &&
295 return DstOrSplit->begin();
302 : Src(Src), DstOrSplit(&Dst), P(P) {}
305 return Src.succ_size() > 1 && DstOrSplit->pred_size() > 1;
309 bool canMaterialize()
const override;
343 bool HasSplit =
false;
401 assert(NewKind != Kind &&
"Already of the right Kind");
403 InsertPoints.clear();
407 "We would need more MI to switch to Insert");
435 : LocalCost(LocalCost), NonLocalCost(NonLocalCost),
436 LocalFreq(LocalFreq) {}
439 bool isSaturated()
const;
470 return *
this !=
Cost &&
Cost < *
this;
506 std::unique_ptr<MachineOptimizationRemarkEmitter>
MORE;
527 bool &OnlyAssign)
const;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
bool operator<(const DeltaInfo &LHS, int64_t Delta)
This file declares the MachineIRBuilder class.
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineInstrBundleIterator< MachineInstr > iterator
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
MachineFunctionPass(char &ID)
Properties which a MachineFunction may have at a given point in time.
Helper class to build MachineInstr.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Pass interface - Implemented by all 'passes'.
EdgeInsertPoint(MachineBasicBlock &Src, MachineBasicBlock &Dst, Pass &P)
bool isSplit() const override
Does this point involve splitting an edge or block?
Abstract class used to represent an insertion point in a CFG.
virtual uint64_t frequency(const Pass &P) const
Frequency of the insertion point.
MachineBasicBlock & getInsertMBB()
The first call to this method will cause the splitting to happen if need be, then sub sequent calls j...
virtual MachineBasicBlock & getInsertMBBImpl()=0
Return the materialized insertion basic block.
MachineBasicBlock::iterator getPoint()
The first call to this method will cause the splitting to happen if need be, then sub sequent calls j...
bool WasMaterialized
Tell if the insert point has already been materialized.
virtual ~InsertPoint()=default
MachineBasicBlock::iterator insert(MachineInstr &MI)
Insert MI in the just before getPoint()
virtual void materialize()=0
Materialize the insertion point.
virtual bool canMaterialize() const
Check whether this insertion point can be materialized.
virtual bool isSplit() const
Does this point involve splitting an edge or block?
virtual MachineBasicBlock::iterator getPointImpl()=0
Return the materialized insertion point.
bool canMaterialize() const override
Check whether this insertion point can be materialized.
InstrInsertPoint(MachineInstr &Instr, bool Before=true)
Create an insertion point before (Before=true) or after Instr.
bool isSplit() const override
Does this point involve splitting an edge or block?
uint64_t frequency(const Pass &P) const override
Frequency of the insertion point.
bool canMaterialize() const override
Check whether this insertion point can be materialized.
MBBInsertPoint(MachineBasicBlock &MBB, bool Beginning=true)
bool isSplit() const override
Does this point involve splitting an edge or block?
Helper class used to represent the cost for mapping an instruction.
bool operator!=(const MappingCost &Cost) const
Check if this is not equal to Cost.
LLVM_ABI void saturate()
Saturate the cost to the maximal representable value.
LLVM_ABI bool addLocalCost(uint64_t Cost)
Add Cost to the local cost.
static LLVM_ABI MappingCost ImpossibleCost()
Return an instance of MappingCost that represents an impossible mapping.
LLVM_ABI bool addNonLocalCost(uint64_t Cost)
Add Cost to the non-local cost.
friend raw_ostream & operator<<(raw_ostream &OS, const MappingCost &Cost)
Overload the stream operator for easy debug printing.
bool operator>(const MappingCost &Cost) const
Check if this is greater than Cost.
Struct used to represent the placement of a repairing point for a given operand.
unsigned getNumInsertPoints() const
bool canMaterialize() const
InsertionPoints::const_iterator const_insertpt_iterator
LLVM_ABI RepairingPlacement(MachineInstr &MI, unsigned OpIdx, const TargetRegisterInfo &TRI, Pass &P, RepairingKind Kind=RepairingKind::Insert)
Create a repairing placement for the OpIdx-th operand of MI.
unsigned getOpIdx() const
RepairingKind
Define the kind of action this repairing needs.
@ Insert
Reparing code needs to happen before InsertPoints.
@ None
Nothing to repair, just drop this action.
@ Reassign
(Re)assign the register bank of the operand.
@ Impossible
Mark this repairing placement as impossible.
const_insertpt_iterator begin() const
insertpt_iterator begin()
const_insertpt_iterator end() const
RepairingKind getKind() const
SmallVector< std::unique_ptr< InsertPoint >, 2 > InsertionPoints
InsertionPoints::iterator insertpt_iterator
void switchTo(RepairingKind NewKind)
Change the type of this repairing placement to NewKind.
Mode
List of the modes supported by the RegBankSelect pass.
@ Fast
Assign the register banks as fast as possible (default).
@ Greedy
Greedily minimize the cost of assigning register banks.
MachineIRBuilder MIRBuilder
Helper class used for every code morphing.
MachineBlockFrequencyInfo * MBFI
Get the frequency of blocks.
MachineFunctionProperties getClearedProperties() const override
MachineFunctionProperties getSetProperties() const override
Mode OptMode
Optimization mode of the pass.
const RegisterBankInfo::InstructionMapping & findBestMapping(MachineInstr &MI, RegisterBankInfo::InstructionMappings &PossibleMappings, SmallVectorImpl< RepairingPlacement > &RepairPts)
Find the best mapping for MI from PossibleMappings.
MachineFunctionProperties getRequiredProperties() const override
RegBankSelect(Mode RunningMode=Fast)
Create a RegBankSelect pass with the specified RunningMode.
bool assignInstr(MachineInstr &MI)
Assign the register bank of each operand of MI.
void init(MachineFunction &MF)
Initialize the field members using MF.
void tryAvoidingSplit(RegBankSelect::RepairingPlacement &RepairPt, const MachineOperand &MO, const RegisterBankInfo::ValueMapping &ValMapping) const
When RepairPt involves splitting to repair MO for the given ValMapping, try to change the way we repa...
const TargetRegisterInfo * TRI
Information on the register classes for the current function.
MachineBranchProbabilityInfo * MBPI
Get the frequency of the edges.
bool assignmentMatch(Register Reg, const RegisterBankInfo::ValueMapping &ValMapping, bool &OnlyAssign) const
Check if Reg is already assigned what is described by ValMapping.
uint64_t getRepairCost(const MachineOperand &MO, const RegisterBankInfo::ValueMapping &ValMapping) const
Return the cost of the instruction needed to map MO to ValMapping.
MappingCost computeMapping(MachineInstr &MI, const RegisterBankInfo::InstructionMapping &InstrMapping, SmallVectorImpl< RepairingPlacement > &RepairPts, const MappingCost *BestCost=nullptr)
Compute the cost of mapping MI with InstrMapping and compute the repairing placement for such mapping...
bool repairReg(MachineOperand &MO, const RegisterBankInfo::ValueMapping &ValMapping, RegBankSelect::RepairingPlacement &RepairPt, const iterator_range< SmallVectorImpl< Register >::const_iterator > &NewVRegs)
Insert repairing code for Reg as specified by ValMapping.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
MachineRegisterInfo * MRI
MRI contains all the register class/bank information that this pass uses and updates.
const RegisterBankInfo * RBI
Interface to the target lowering info related to register banks.
std::unique_ptr< MachineOptimizationRemarkEmitter > MORE
Current optimization remark emitter. Used to report failures.
bool applyMapping(MachineInstr &MI, const RegisterBankInfo::InstructionMapping &InstrMapping, SmallVectorImpl< RepairingPlacement > &RepairPts)
Apply Mapping to MI.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
Holds all the information related to register banks.
SmallVector< const InstructionMapping *, 4 > InstructionMappings
Convenient type to represent the alternatives for mapping an instruction.
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::const_iterator const_iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Target-Independent Code Generator Pass Configuration Options.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
Helper struct that represents how a value is mapped through different register banks.