Make function documentation conform to llvm standards.

Expunge all remaining traces and use of live variable information.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180577 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Preston Gurd 2013-04-25 21:31:33 +00:00
parent 45c9e0b412
commit 7f8300b8f3

View File

@ -34,44 +34,66 @@ namespace {
class FixupLEAPass : public MachineFunctionPass { class FixupLEAPass : public MachineFunctionPass {
enum RegUsageState { RU_NotUsed, RU_Write, RU_Read }; enum RegUsageState { RU_NotUsed, RU_Write, RU_Read };
static char ID; static char ID;
/// \brief Loop over all of the instructions in the basic block
/// replacing applicable instructions with LEA instructions,
/// where appropriate.
bool processBasicBlock(MachineFunction &MF, MachineFunction::iterator MFI); bool processBasicBlock(MachineFunction &MF, MachineFunction::iterator MFI);
virtual const char *getPassName() const { return "X86 Atom LEA Fixup";} virtual const char *getPassName() const { return "X86 Atom LEA Fixup";}
/// \brief Given a machine register, look for the instruction
/// which writes it in the current basic block. If found,
/// try to replace it with an equivalent LEA instruction.
/// If replacement succeeds, then also process the the newly created
/// instruction.
void seekLEAFixup(MachineOperand& p, MachineBasicBlock::iterator& I, void seekLEAFixup(MachineOperand& p, MachineBasicBlock::iterator& I,
MachineFunction::iterator MFI); MachineFunction::iterator MFI);
/// \brief Given a memory access or LEA instruction
/// whose address mode uses a base and/or index register, look for
/// an opportunity to replace the instruction which sets the base or index
/// register with an equivalent LEA instruction.
void processInstruction(MachineBasicBlock::iterator& I, void processInstruction(MachineBasicBlock::iterator& I,
MachineFunction::iterator MFI); MachineFunction::iterator MFI);
/// \brief Determine if an instruction references a machine register
/// and, if so, whether it reads or writes the register.
RegUsageState usesRegister(MachineOperand& p, RegUsageState usesRegister(MachineOperand& p,
MachineBasicBlock::iterator I); MachineBasicBlock::iterator I);
/// \brief Step backwards through a basic block, looking
/// for an instruction which writes a register within
/// a maximum of INSTR_DISTANCE_THRESHOLD instruction latency cycles.
MachineBasicBlock::iterator searchBackwards(MachineOperand& p, MachineBasicBlock::iterator searchBackwards(MachineOperand& p,
MachineBasicBlock::iterator& I, MachineBasicBlock::iterator& I,
MachineFunction::iterator MFI); MachineFunction::iterator MFI);
/// \brief if an instruction can be converted to an
/// equivalent LEA, insert the new instruction into the basic block
/// and return a pointer to it. Otherwise, return zero.
MachineInstr* postRAConvertToLEA(MachineFunction::iterator &MFI, MachineInstr* postRAConvertToLEA(MachineFunction::iterator &MFI,
MachineBasicBlock::iterator &MBBI, MachineBasicBlock::iterator &MBBI) const;
LiveVariables *LV) const;
public: public:
FixupLEAPass() : MachineFunctionPass(ID) {} FixupLEAPass() : MachineFunctionPass(ID) {}
/// \brief Loop over all of the basic blocks,
/// replacing instructions by equivalent LEA instructions
/// if needed and when possible.
virtual bool runOnMachineFunction(MachineFunction &MF); virtual bool runOnMachineFunction(MachineFunction &MF);
private: private:
MachineFunction *MF; MachineFunction *MF;
const TargetMachine *TM; const TargetMachine *TM;
const TargetInstrInfo *TII; // Machine instruction info. const TargetInstrInfo *TII; // Machine instruction info.
LiveVariables *LV;
}; };
char FixupLEAPass::ID = 0; char FixupLEAPass::ID = 0;
} }
/// postRAConvertToLEA - if an instruction can be converted to an
/// equivalent LEA, insert the new instruction into the basic block
/// and return a pointer to it. Otherwise, return zero.
MachineInstr * MachineInstr *
FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI, FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI,
MachineBasicBlock::iterator &MBBI, MachineBasicBlock::iterator &MBBI) const {
LiveVariables *LV) const {
MachineInstr* MI = MBBI; MachineInstr* MI = MBBI;
MachineInstr* NewMI; MachineInstr* NewMI;
switch (MI->getOpcode()) { switch (MI->getOpcode()) {
@ -104,21 +126,17 @@ FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI,
return 0; return 0;
} }
} }
return TII->convertToThreeAddress(MFI, MBBI, LV); return TII->convertToThreeAddress(MFI, MBBI, 0);
} }
FunctionPass *llvm::createX86FixupLEAs() { FunctionPass *llvm::createX86FixupLEAs() {
return new FixupLEAPass(); return new FixupLEAPass();
} }
/// runOnMachineFunction - Loop over all of the basic blocks,
/// replacing instructions by equivalent LEA instructions
/// if needed and when possible.
bool FixupLEAPass::runOnMachineFunction(MachineFunction &Func) { bool FixupLEAPass::runOnMachineFunction(MachineFunction &Func) {
MF = &Func; MF = &Func;
TII = Func.getTarget().getInstrInfo(); TII = Func.getTarget().getInstrInfo();
TM = &MF->getTarget(); TM = &MF->getTarget();
LV = getAnalysisIfAvailable<LiveVariables>();
DEBUG(dbgs() << "Start X86FixupLEAs\n";); DEBUG(dbgs() << "Start X86FixupLEAs\n";);
// Process all basic blocks. // Process all basic blocks.
@ -129,8 +147,6 @@ bool FixupLEAPass::runOnMachineFunction(MachineFunction &Func) {
return true; return true;
} }
/// usesRegister - Determine if an instruction references a machine register
/// and, if so, whether it reads or writes the register.
FixupLEAPass::RegUsageState FixupLEAPass::usesRegister(MachineOperand& p, FixupLEAPass::RegUsageState FixupLEAPass::usesRegister(MachineOperand& p,
MachineBasicBlock::iterator I) { MachineBasicBlock::iterator I) {
RegUsageState RegUsage = RU_NotUsed; RegUsageState RegUsage = RU_NotUsed;
@ -165,9 +181,6 @@ static inline bool getPreviousInstr(MachineBasicBlock::iterator& I,
return true; return true;
} }
/// searchBackwards - Step backwards through a basic block, looking
/// for an instruction which writes a register within
/// a maximum of INSTR_DISTANCE_THRESHOLD instruction latency cycles.
MachineBasicBlock::iterator FixupLEAPass::searchBackwards(MachineOperand& p, MachineBasicBlock::iterator FixupLEAPass::searchBackwards(MachineOperand& p,
MachineBasicBlock::iterator& I, MachineBasicBlock::iterator& I,
MachineFunction::iterator MFI) { MachineFunction::iterator MFI) {
@ -192,10 +205,6 @@ MachineBasicBlock::iterator FixupLEAPass::searchBackwards(MachineOperand& p,
return 0; return 0;
} }
/// processInstruction - Given a memory access or LEA instruction
/// whose address mode uses a base and/or index register, look for
/// an opportunity to replace the instruction which sets the base or index
/// register with an equivalent LEA instruction.
void FixupLEAPass::processInstruction(MachineBasicBlock::iterator& I, void FixupLEAPass::processInstruction(MachineBasicBlock::iterator& I,
MachineFunction::iterator MFI) { MachineFunction::iterator MFI) {
// Process a load, store, or LEA instruction. // Process a load, store, or LEA instruction.
@ -216,17 +225,12 @@ void FixupLEAPass::processInstruction(MachineBasicBlock::iterator& I,
} }
} }
/// seekLEAFixup - Given a machine register, look for the instruction
/// which writes it in the current basic block. If found,
/// try to replace it with an equivalent LEA instruction.
/// If replacement succeeds, then also process the the newly created
/// instruction.
void FixupLEAPass::seekLEAFixup(MachineOperand& p, void FixupLEAPass::seekLEAFixup(MachineOperand& p,
MachineBasicBlock::iterator& I, MachineBasicBlock::iterator& I,
MachineFunction::iterator MFI) { MachineFunction::iterator MFI) {
MachineBasicBlock::iterator MBI = searchBackwards(p, I, MFI); MachineBasicBlock::iterator MBI = searchBackwards(p, I, MFI);
if (MBI) { if (MBI) {
MachineInstr* NewMI = postRAConvertToLEA(MFI, MBI, LV); MachineInstr* NewMI = postRAConvertToLEA(MFI, MBI);
if (NewMI) { if (NewMI) {
++NumLEAs; ++NumLEAs;
DEBUG(dbgs() << "Candidate to replace:"; MBI->dump();); DEBUG(dbgs() << "Candidate to replace:"; MBI->dump(););
@ -240,8 +244,6 @@ void FixupLEAPass::seekLEAFixup(MachineOperand& p,
} }
} }
/// processBasicBlock - Loop over all of the instructions in the basic block,
/// replacing adds and shifts with LEA instructions, where appropriate.
bool FixupLEAPass::processBasicBlock(MachineFunction &MF, bool FixupLEAPass::processBasicBlock(MachineFunction &MF,
MachineFunction::iterator MFI) { MachineFunction::iterator MFI) {