44#define DEBUG_TYPE "riscv-vmv0-elimination"
70char RISCVVMV0EliminationLegacy::ID = 0;
73 "RISC-V VMV0 Elimination",
false,
false)
76 return new RISCVVMV0EliminationLegacy();
80 return MCOI.RegClass == RISCV::VMV0RegClassID;
86 if (!ST->hasVInstructions())
98 bool V0Clobbered =
false;
100 assert(!(
MI.readsRegister(RISCV::V0,
TRI) && V0Clobbered) &&
101 "Inserting a copy to v0 would clobber a read");
102 if (
MI.modifiesRegister(RISCV::V0,
TRI))
111 [](
auto *Succ) { return Succ->isLiveIn(RISCV::V0); })) &&
112 "Clobbered a v0 used in a successor");
116 bool MadeChange =
false;
123 "Expected only one or zero vmv0 operands");
130 Src.isVirtual() &&
"vmv0 use in unexpected form");
134 SrcMI->isCopy() && SrcMI->getOperand(1).getReg().isVirtual() &&
135 SrcMI->getOperand(1).getSubReg() == RISCV::NoSubRegister) {
137 if (
MRI.hasOneNonDBGUse(Src))
139 Src = SrcMI->getOperand(1).getReg();
154 MI->eraseFromParent();
165 if (MO.isReg() && MO.getReg().isVirtual() &&
166 MRI.getRegClass(MO.getReg()) == &RISCV::VMV0RegClass) {
167 MRI.recomputeRegClass(MO.getReg());
168 assert((
MRI.getRegClass(MO.getReg()) != &RISCV::VMV0RegClass ||
170 MRI.getVRegDef(MO.getReg())->isInlineAsm()) &&
171 "Non-inline-asm use of vmv0 left behind");
180bool RISCVVMV0EliminationLegacy::runOnMachineFunction(
MachineFunction &MF) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
MachineRegisterInfo & MRI
static bool runVMV0Elimination(MachineFunction &MF)
static bool isVMV0(const MCOperandInfo &MCOI)
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
This holds information about one operand of a machine instruction, indicating the register class for ...
An RAII based helper class to modify MachineFunctionProperties when running pass.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Properties which a MachineFunction may have at a given point in time.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Wrapper class representing virtual and physical registers.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
FunctionPass * createRISCVVMV0EliminationLegacyPass()
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...