21 #define DEBUG_TYPE "thumb2-it"
23 STATISTIC(NumITs,
"Number of IT blocks inserted");
24 STATISTIC(NumMovedInsts,
"Number of predicated instructions moved");
45 return "Thumb IT blocks insertion pass";
73 if (!Reg || Reg == ARM::ITSTATE || Reg == ARM::SP)
81 for (
unsigned i = 0, e = LocalUses.
size();
i != e; ++
i) {
82 unsigned Reg = LocalUses[
i];
88 for (
unsigned i = 0, e = LocalDefs.
size();
i != e; ++
i) {
89 unsigned Reg = LocalDefs[
i];
103 if (!MO.isReg() || MO.isDef() || !MO.isKill())
105 if (!Uses.
count(MO.getReg()))
135 "Sub-register indices still around?");
169 while (I != E && I->isDebugValue())
172 unsigned NPredReg = 0;
174 if (NCC == CC || NCC == OCC)
181 bool Modified =
false;
189 unsigned PredReg = 0;
214 unsigned Mask = 0, Pos = 3;
221 for (; MBBI != E && Pos &&
223 if (MBBI->isDebugValue())
229 unsigned NPredReg = 0;
231 if (NCC == CC || NCC == OCC) {
232 Mask |= (NCC & 1) << Pos;
239 MoveCopyOutOfITBlock(NMI, CC, OCC, Defs, Uses)) {
242 MBB.
insert(InsertPos, NMI);
257 Mask |= (CC & 1) << 4;
284 if (!AFI->isThumbFunction())
287 bool Modified =
false;
291 Modified |= InsertITInstructions(MBB);
295 AFI->setHasITBlocks(
true);
303 return new Thumb2ITBlockPass();
void push_back(const T &Elt)
static bool isCopy(MachineInstr *MI)
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
STATISTIC(NumFunctions,"Total number of functions")
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
Describe properties that are true of each instruction in the target description file.
MachineOperand * findRegisterUseOperand(unsigned Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr)
Wrapper for findRegisterUseOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static void ClearKillFlags(MachineInstr *MI, SmallSet< unsigned, 4 > &Uses)
Clear kill flags for any uses in the given set.
iterator_range< mop_iterator > operands()
const ARMBaseInstrInfo * getInstrInfo() const override
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
static MachineOperand CreateReg(unsigned 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 isReg() const
isReg - Tests if this is a MO_Register operand.
Reg
All possible values of the reg field in the ModR/M byte.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
const MachineBasicBlock * getParent() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool isReturn(QueryType Type=AnyInBundle) const
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
const MachineOperand & getOperand(unsigned i) const
static void TrackDefUses(MachineInstr *MI, SmallSet< unsigned, 4 > &Defs, SmallSet< unsigned, 4 > &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()
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
unsigned getSubReg() const
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)
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
Iterator for intrusive lists based on ilist_node.
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.
instr_iterator getInstrIterator() const
MachineInstr * remove(MachineInstr *I)
Remove the unbundled instruction from the instruction list without deleting it.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
static CondCodes getOppositeCondition(CondCodes CC)
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
const ARMBaseRegisterInfo * getRegisterInfo() const override
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
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.
bool hasOptionalDef(QueryType Type=IgnoreBundle) const
Set if this instruction has an optional definition, e.g.
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.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...