29#define DEBUG_TYPE "postrapseudos"
63 if (!ExpandPostRA().
run(MF))
68 .preserve<MachineLoopAnalysis>()
72char ExpandPostRALegacy::ID = 0;
76 "Post-RA pseudo instruction expansion pass",
false,
false)
80 assert((
MI->getOperand(0).isReg() &&
MI->getOperand(0).isDef()) &&
81 MI->getOperand(1).isImm() &&
82 (
MI->getOperand(2).isReg() &&
MI->getOperand(2).isUse()) &&
83 MI->getOperand(3).isImm() &&
"Invalid subreg_to_reg");
87 assert(!
MI->getOperand(2).getSubReg() &&
"SubIdx on physreg?");
88 unsigned SubIdx =
MI->getOperand(3).getImm();
90 assert(SubIdx != 0 &&
"Invalid index for insert_subreg");
91 Register DstSubReg =
TRI->getSubReg(DstReg, SubIdx);
94 "Insert destination must be in a physical register");
96 "Inserted value must be in a physical register");
100 if (
MI->allDefsAreDead()) {
101 MI->setDesc(
TII->get(TargetOpcode::KILL));
102 MI->removeOperand(3);
103 MI->removeOperand(1);
108 if (DstSubReg == InsReg) {
113 if (DstReg != InsReg) {
114 MI->setDesc(
TII->get(TargetOpcode::KILL));
115 MI->removeOperand(3);
116 MI->removeOperand(1);
123 MI->getOperand(2).isKill());
128 CopyMI->addRegisterDefined(DstReg);
138 return ExpandPostRA().run(MF);
146 <<
"********** EXPANDING POST-RA PSEUDO INSTRS **********\n"
147 <<
"********** Function: " << MF.
getName() <<
'\n');
151 bool MadeChange =
false;
166 switch (
MI.getOpcode()) {
167 case TargetOpcode::SUBREG_TO_REG:
168 MadeChange |= LowerSubregToReg(&
MI);
170 case TargetOpcode::COPY:
174 case TargetOpcode::DBG_VALUE:
176 case TargetOpcode::INSERT_SUBREG:
177 case TargetOpcode::EXTRACT_SUBREG:
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreservedID(const void *ID)
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.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
Emit instructions to copy a pair of physical registers.
bool expandPostRAPseudo(MachineInstr &MI) const override
This function is called for all pseudo instructions that remain after register allocation.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Analysis pass which computes a MachineDominatorTree.
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
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.
Representation of each machine instruction.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Wrapper class representing virtual and physical registers.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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 char & MachineDominatorsID
MachineDominators - This pass is a machine dominators analysis pass.
LLVM_ABI char & ExpandPostRAPseudosID
ExpandPostRAPseudos - This pass expands pseudo instructions after register allocation.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void initializeExpandPostRALegacyPass(PassRegistry &)