64#ifndef LLVM_CODEGEN_GLOBALISEL_REGBANKSELECT_H
65#define LLVM_CODEGEN_GLOBALISEL_REGBANKSELECT_H
80class MachineBlockFrequencyInfo;
81class MachineBranchProbabilityInfo;
83class MachineRegisterInfo;
86class TargetPassConfig;
87class TargetRegisterInfo;
188 virtual bool isSplit()
const {
return false; }
212 void materialize()
override;
217 return Instr.getNextNode() ? *Instr.getNextNode()
218 : Instr.getParent()->end();
222 return *Instr.getParent();
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;
295 return DstOrSplit->
begin();
302 : Src(Src), DstOrSplit(&Dst),
P(
P) {}
305 return Src.succ_size() > 1 && DstOrSplit->
pred_size() > 1;
343 bool HasSplit =
false;
400 assert(NewKind != Kind &&
"Already of the right Kind");
402 InsertPoints.
clear();
406 "We would need more MI to switch to Insert");
434 : LocalCost(LocalCost), NonLocalCost(NonLocalCost),
435 LocalFreq(LocalFreq) {}
438 bool isSaturated()
const;
469 return *
this !=
Cost &&
Cost < *
this;
505 std::unique_ptr<MachineOptimizationRemarkEmitter>
MORE;
529 bool &OnlyAssign)
const;
aarch64 AArch64 CCMP Pass
This file declares the MachineIRBuilder class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
void print(raw_ostream &OS) const
unsigned pred_size() const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned succ_size() const
bool isPredecessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a predecessor of this block.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
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'.
Insertion point on an edge.
uint64_t frequency(const Pass &P) const override
Frequency of the insertion point.
EdgeInsertPoint(MachineBasicBlock &Src, MachineBasicBlock &Dst, Pass &P)
bool isSplit() const override
Does this point involve splitting an edge or block? As soon as getPoint is called and thus,...
bool canMaterialize() const override
Check whether this insertion point can be materialized.
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? As soon as getPoint is called and thus,...
virtual MachineBasicBlock::iterator getPointImpl()=0
Return the materialized insertion point.
Insertion point before or after an instruction.
bool canMaterialize() const override
Check whether this insertion point can be materialized.
bool isSplit() const override
Does this point involve splitting an edge or block? As soon as getPoint is called and thus,...
uint64_t frequency(const Pass &P) const override
Frequency of the insertion point.
Insertion point at the beginning or end of a basic block.
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? As soon as getPoint is called and thus,...
uint64_t frequency(const Pass &P) const override
Frequency of the insertion point.
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.
void saturate()
Saturate the cost to the maximal representable value.
bool operator==(const MappingCost &Cost) const
Check if this is equal to Cost.
bool addLocalCost(uint64_t Cost)
Add Cost to the local cost.
void dump() const
Print this on dbgs() stream.
static MappingCost ImpossibleCost()
Return an instance of MappingCost that represents an impossible mapping.
bool addNonLocalCost(uint64_t Cost)
Add Cost to the non-local cost.
bool operator<(const MappingCost &Cost) const
Check if this is less than Cost.
friend raw_ostream & operator<<(raw_ostream &OS, const MappingCost &Cost)
Overload the stream operator for easy debug printing.
void print(raw_ostream &OS) const
Print this on OS;.
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
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
void switchTo(RepairingKind NewKind)
Change the type of this repairing placement to NewKind.
void addInsertPoint(MachineBasicBlock &MBB, bool Beginning)
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
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.
bool checkFunctionIsLegal(MachineFunction &MF) const
Check that our input is fully legal: we require the function to have the Legalized property,...
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.
bool assignRegisterBanks(MachineFunction &MF)
Walk through MF and assign a register bank to every virtual register that are still mapped to nothing...
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.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
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.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetPassConfig * TPC
Current target configuration. Controls how the pass handles errors.
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.
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
StringRef - 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.
Helper struct that represents how a value is mapped through different register banks.