#include "X86.h"
#include "X86InstrInfo.h"
#include "X86Subtarget.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ProfileSummaryInfo.h"
#include "llvm/CodeGen/LazyMachineBlockFrequencyInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineSizeOpts.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetSchedule.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
usingnamespacellvm;
#define FIXUPLEA_DESC …
#define FIXUPLEA_NAME …
#define DEBUG_TYPE …
STATISTIC(NumLEAs, "Number of LEA instructions created");
namespace {
class FixupLEAPass : public MachineFunctionPass { … };
}
char FixupLEAPass::ID = …;
INITIALIZE_PASS(…)
MachineInstr *
FixupLEAPass::postRAConvertToLEA(MachineBasicBlock &MBB,
MachineBasicBlock::iterator &MBBI) const { … }
FunctionPass *llvm::createX86FixupLEAs() { … }
static bool isLEA(unsigned Opcode) { … }
bool FixupLEAPass::runOnMachineFunction(MachineFunction &MF) { … }
FixupLEAPass::RegUsageState
FixupLEAPass::usesRegister(MachineOperand &p, MachineBasicBlock::iterator I) { … }
static inline bool getPreviousInstr(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) { … }
MachineBasicBlock::iterator
FixupLEAPass::searchBackwards(MachineOperand &p, MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) { … }
static inline bool isInefficientLEAReg(unsigned Reg) { … }
static inline bool hasInefficientLEABaseReg(const MachineOperand &Base,
const MachineOperand &Index) { … }
static inline bool hasLEAOffset(const MachineOperand &Offset) { … }
static inline unsigned getADDrrFromLEA(unsigned LEAOpcode) { … }
static inline unsigned getSUBrrFromLEA(unsigned LEAOpcode) { … }
static inline unsigned getADDriFromLEA(unsigned LEAOpcode,
const MachineOperand &Offset) { … }
static inline unsigned getINCDECFromLEA(unsigned LEAOpcode, bool IsINC) { … }
MachineBasicBlock::iterator
FixupLEAPass::searchALUInst(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) const { … }
void FixupLEAPass::checkRegUsage(MachineBasicBlock::iterator &LeaI,
MachineBasicBlock::iterator &AluI,
bool &BaseIndexDef, bool &AluDestRef,
MachineOperand **KilledBase,
MachineOperand **KilledIndex) const { … }
bool FixupLEAPass::optLEAALU(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) const { … }
bool FixupLEAPass::optTwoAddrLEA(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB, bool OptIncDec,
bool UseLEAForSP) const { … }
void FixupLEAPass::processInstruction(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) { … }
void FixupLEAPass::seekLEAFixup(MachineOperand &p,
MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) { … }
void FixupLEAPass::processInstructionForSlowLEA(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB) { … }
void FixupLEAPass::processInstrForSlow3OpLEA(MachineBasicBlock::iterator &I,
MachineBasicBlock &MBB,
bool OptIncDec) { … }