30#define DEBUG_TYPE "arm-mve-vpt"
48 return "MVE VPT block insertion pass";
55char MVEVPTBlock::ID = 0;
63 unsigned &NewOpcode) {
68 while (CmpMI !=
MI->getParent()->begin()) {
70 if (CmpMI->modifiesRegister(ARM::VPR,
TRI))
72 if (CmpMI->readsRegister(ARM::VPR,
TRI))
99 unsigned &NumInstrsSteppedOver) {
102 NumInstrsSteppedOver = 0;
104 while (Iter != EndIter) {
105 if (Iter->isDebugInstr()) {
113 "VPT block pass does not expect Else preds");
118 ++NumInstrsSteppedOver;
121 return NumInstrsSteppedOver != 0 &&
129 for (; Iter !=
End; ++Iter)
130 if (Iter->definesRegister(ARM::VPR,
nullptr) ||
131 Iter->killsRegister(ARM::VPR,
nullptr))
140 return ARM::PredBlockMask::T;
142 return ARM::PredBlockMask::TT;
144 return ARM::PredBlockMask::TTT;
146 return ARM::PredBlockMask::TTTT;
165 "Expected a Predicated Instruction");
174 AddedInstIter != Iter; ++AddedInstIter) {
175 if (AddedInstIter->isDebugInstr())
177 dbgs() <<
" adding: ";
178 AddedInstIter->dump();
187 while (
BlockSize < 4 && Iter != EndIter &&
188 Iter->getOpcode() == ARM::MVE_VPNOT) {
192 unsigned ElseInstCnt = 0;
217 for (; Iter != VPNOTBlockEndIter; ++Iter) {
218 if (Iter->isDebugInstr())
226 Iter->getOperand(
OpIdx).setImm(CurrentPredicate);
245 while (MBIter != EndIter) {
272 LLVM_DEBUG(
dbgs() <<
" final block mask: " << (
unsigned)BlockMask <<
"\n");
277 MIBuilder.
add(
VCMP->getOperand(1));
278 MIBuilder.
add(
VCMP->getOperand(2));
279 MIBuilder.
add(
VCMP->getOperand(3));
285 MII.clearRegisterKills(
VCMP->getOperand(1).getReg(),
TRI);
286 MII.clearRegisterKills(
VCMP->getOperand(2).getReg(),
TRI);
289 VCMP->eraseFromParent();
299 DeadInstructions.clear();
313 if (!STI.
isThumb2() || !STI.hasMVEIntegerOps())
320 <<
"********** Function: " << Fn.
getName() <<
'\n');
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
static ARM::PredBlockMask GetInitialBlockMask(unsigned BlockSize)
static ARM::PredBlockMask CreateVPTBlock(MachineBasicBlock::instr_iterator &Iter, MachineBasicBlock::instr_iterator EndIter, SmallVectorImpl< MachineInstr * > &DeadInstructions)
static bool StepOverPredicatedInstrs(MachineBasicBlock::instr_iterator &Iter, MachineBasicBlock::instr_iterator EndIter, unsigned MaxSteps, unsigned &NumInstrsSteppedOver)
static bool IsVPRDefinedOrKilledByBlock(MachineBasicBlock::iterator Iter, MachineBasicBlock::iterator End)
static MachineInstr * findVCMPToFoldIntoVPST(MachineBasicBlock::iterator MI, const TargetRegisterInfo *TRI, unsigned &NewOpcode)
Register const TargetRegisterInfo * TRI
MachineInstr unsigned OpIdx
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static cl::opt< unsigned > MaxSteps("has-predecessor-max-steps", cl::Hidden, cl::init(8192), cl::desc("DAG combiner limit number of steps when searching DAG " "for predecessor nodes"))
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
static const int BlockSize
const ARMBaseInstrInfo * getInstrInfo() const override
const ARMBaseRegisterInfo * getRegisterInfo() const override
FunctionPass class - This class is used to implement most global optimizations.
Instructions::iterator instr_iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual MachineFunctionProperties getRequiredProperties() const
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.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
Representation of each machine instruction.
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
PredBlockMask
Mask values for IT and VPT Blocks, to be used by MCOperands.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
int findFirstVPTPredOperandIdx(const MachineInstr &MI)
ARMVCC::VPTCodes getVPTInstrPredicate(const MachineInstr &MI, Register &PredReg)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool registerDefinedBetween(unsigned Reg, MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI)
Return true if Reg is defd between From and To.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
ARM::PredBlockMask expandPredBlockMask(ARM::PredBlockMask BlockMask, ARMVCC::VPTCodes Kind)
static unsigned VCMPOpcodeToVPT(unsigned Opcode)
FunctionPass * createMVEVPTBlockPass()
createMVEVPTBlock - Returns an instance of the MVE VPT block insertion pass.