37#define DEBUG_TYPE "x86-fixup-setcc"
39STATISTIC(NumSubstZexts,
"Number of setcc + zext pairs substituted");
48 StringRef getPassName()
const override {
return "X86 Fixup SetCC"; }
50 bool runOnMachineFunction(MachineFunction &MF)
override;
54char X86FixupSetCCLegacy::ID = 0;
59 return new X86FixupSetCCLegacy();
70 for (
auto &
MBB : MF) {
72 for (
auto &
MI :
MBB) {
74 if (
MI.definesRegister(X86::EFLAGS,
nullptr))
80 if (
MI.getOpcode() != X86::SETCCr &&
MI.getOpcode() != X86::SETZUCCr)
85 for (
auto &
Use :
MRI->use_instructions(Reg0))
86 if (
Use.getOpcode() == X86::MOVZX32rr8)
105 ST->is64Bit() ? &X86::GR32RegClass : &X86::GR32_ABCDRegClass;
120 if (!ST->preferLegacySetCC())
121 assert((
MI.getOpcode() == X86::SETZUCCr) &&
122 "Expect setzucc instruction!");
124 MI.setDesc(
TII->get(X86::SETZUCCr));
126 TII->get(TargetOpcode::IMPLICIT_DEF), ZeroReg);
142 {
MI.getDebugInstrNum(), 0});
148 for (
auto &
I : ToErase)
149 I->eraseFromParent();
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static bool fixupSetCC(MachineFunction &MF)
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair, unsigned SubReg=0)
Create a substitution between one <instr,operand> value to a different, new value.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr reads the specified register.
unsigned peekDebugInstrNum() const
Examine the instruction number of this MachineInstr.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
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.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
FunctionPass * createX86FixupSetCCLegacyPass()
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.