33 #define DEBUG_TYPE "thumb2-it" 34 #define PASS_NAME "Thumb IT blocks insertion pass" 36 STATISTIC(NumITs,
"Number of IT blocks inserted");
37 STATISTIC(NumMovedInsts,
"Number of predicated instructions moved");
87 for (
auto &MO :
MI->operands()) {
91 if (!Reg || Reg == ARM::ITSTATE || Reg == ARM::SP)
94 LocalUses.push_back(Reg);
96 LocalDefs.push_back(Reg);
99 auto InsertUsesDefs = [&](RegList &Regs,
RegisterSet &UsesDefs) {
100 for (
unsigned Reg : Regs)
103 UsesDefs.insert(*Subreg);
106 InsertUsesDefs(LocalDefs, Defs);
107 InsertUsesDefs(LocalUses, Uses);
115 if (!MO.isReg() || MO.isDef() || !MO.isKill())
117 if (!Uses.count(MO.getReg()))
146 "Sub-register indices still around?");
152 if (Uses.count(DstReg) || Defs.count(SrcReg))
182 while (I != E && I->isDebugInstr())
186 unsigned NPredReg = 0;
188 if (NCC == CC || NCC == OCC)
202 unsigned PredReg = 0;
227 unsigned Mask = 0, Pos = 3;
234 for (; MBBI !=
E && Pos &&
236 if (MBBI->isDebugInstr())
242 unsigned NPredReg = 0;
244 if (NCC == CC || NCC == OCC) {
245 Mask |= ((NCC ^ CC) & 1) << Pos;
252 MoveCopyOutOfITBlock(NMI, CC, OCC, Defs, Uses)) {
255 MBB.
insert(InsertPos, NMI);
295 if (!AFI->isThumbFunction())
299 for (
auto &MBB : Fn )
300 Modified |= InsertITInstructions(MBB);
303 AFI->setHasITBlocks(
true);
MachineOperand * findRegisterUseOperand(Register Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr)
Wrapper for findRegisterUseOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
static bool isCopy(MachineInstr *MI)
This class represents lattice values for constants.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Describe properties that are true of each instruction in the target description file.
unsigned getSubReg() const
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
iterator_range< mop_iterator > operands()
const ARMBaseInstrInfo * getInstrInfo() const override
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
const HexagonInstrInfo * TII
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
instr_iterator getInstrIterator() const
SmallSet< unsigned, 4 > RegisterSet
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
bool isReturn(QueryType Type=AnyInBundle) const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static void ClearKillFlags(MachineInstr *MI, RegisterSet &Uses)
Clear kill flags for any uses in the given set.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
static void TrackDefUses(MachineInstr *MI, RegisterSet &Defs, RegisterSet &Uses, const TargetRegisterInfo *TRI)
TrackDefUses - Tracking what registers are being defined and used by instructions in the IT block...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
void setIsKill(bool Val=true)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
ARMCC::CondCodes getITInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getITInstrPredicate - Valid only in Thumb2 mode.
MachineOperand class - Representation of each machine instruction operand.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
const MachineBasicBlock * getParent() const
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
static CondCodes getOppositeCondition(CondCodes CC)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
const ARMBaseRegisterInfo * getRegisterInfo() const override
bool hasOptionalDef(QueryType Type=IgnoreBundle) const
Set if this instruction has an optional definition, e.g.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
StringRef - Represent a constant reference to a string, i.e.
FunctionPass * createThumb2ITBlockPass()
createThumb2ITBlockPass - Returns an instance of the Thumb2 IT blocks insertion pass.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
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...
Properties which a MachineFunction may have at a given point in time.
Wrapper class representing virtual and physical registers.