63 #define FIXUPBW_DESC "X86 Byte/Word Instruction Fixup"
64 #define FIXUPBW_NAME "x86-fixup-bw-insts"
66 #define DEBUG_TYPE FIXUPBW_NAME
71 cl::desc(
"Change byte and word instructions to larger sizes"),
84 unsigned &SuperDestReg)
const;
155 MLI = &getAnalysis<MachineLoopInfo>();
158 DEBUG(
dbgs() <<
"Start X86FixupBWInsts\n";);
162 processBasicBlock(MF, MBB);
164 DEBUG(
dbgs() <<
"End X86FixupBWInsts\n";);
178 bool FixupBWInstPass::getSuperRegDestIfDead(
MachineInstr *OrigMI,
179 unsigned &SuperDestReg)
const {
185 const auto SubRegIdx = TRI->getSubRegIndex(SuperDestReg, OrigDestReg);
191 if (SubRegIdx == X86::sub_8bit_hi)
194 if (LiveRegs.contains(SuperDestReg))
197 if (SubRegIdx == X86::sub_8bit) {
201 unsigned UpperByteReg =
204 if (LiveRegs.contains(UpperByteReg))
211 MachineInstr *FixupBWInstPass::tryReplaceLoad(
unsigned New32BitOpcode,
219 if (!getSuperRegDestIfDead(MI, NewDestReg))
227 for (
unsigned i = 1; i < NumArgs; ++i)
241 if (!getSuperRegDestIfDead(MI, NewDestReg))
249 if (TRI->getSubRegIndex(NewSrcReg, OldSrc.getReg()) !=
250 TRI->getSubRegIndex(NewDestReg, OldDest.getReg()))
265 if (
Op.getReg() != (
Op.isDef() ? NewDestReg : NewSrcReg))
281 if (ML->begin() == ML->end() && !OptForSize)
282 return tryReplaceLoad(X86::MOVZX32rm8, MI);
290 return tryReplaceLoad(X86::MOVZX32rm16, MI);
298 return tryReplaceCopy(MI);
327 LiveRegs.addLiveOuts(MBB);
333 MIReplacements.
push_back(std::make_pair(MI, NewMI));
336 LiveRegs.stepBackward(*MI);
339 while (!MIReplacements.
empty()) {
void push_back(const T &Elt)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
FunctionPass * createX86FixupBWInsts()
Return a Machine IR pass that selectively replaces certain byte and word instructions by equivalent 3...
void initializeFixupBWInstPassPass(PassRegistry &)
const MachineInstrBuilder & add(const MachineOperand &MO) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
AnalysisUsage & addRequired()
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
const HexagonRegisterInfo & getRegisterInfo() const
HexagonInstrInfo specifics.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
reverse_iterator rbegin()
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
mmo_iterator memoperands_end() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
const MachineOperand & getOperand(unsigned i) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
Represent the analysis usage information of a pass.
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
FunctionPass class - This class is used to implement most global optimizations.
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static cl::opt< bool > FixupBWInsts("fixup-byte-word-insts", cl::desc("Change byte and word instructions to larger sizes"), cl::init(true), cl::Hidden)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned getX86SubSuperRegister(unsigned, unsigned, bool High=false)
Returns the sub or super register of a specific X86 register.
iterator_range< mop_iterator > implicit_operands()
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
MachineFunctionProperties & set(Property P)
Representation of each machine instruction.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr's memory reference descriptor list.
Properties which a MachineFunction may have at a given point in time.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.