Skip to content

Commit

Permalink
[llvm-exegesis][NFC] Rename ExegesisTarget::decrementLoopCounterAndLo…
Browse files Browse the repository at this point in the history
…op()

Summary: To decrementLoopCounterAndJump, and explicitely take the jump target.

Reviewers: gchatelet

Subscribers: tschuett, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68375

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373571 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
legrosbuffle committed Oct 3, 2019
1 parent d698e44 commit fa63bf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion tools/llvm-exegesis/lib/SnippetRepetitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class LoopSnippetRepetitor : public SnippetRepetitor {
for (const auto &LiveIn : Entry.MBB->liveins())
Loop.MBB->addLiveIn(LiveIn);
Loop.addInstructions(Instructions);
ET.decrementLoopCounterAndLoop(*Loop.MBB, State.getInstrInfo());
ET.decrementLoopCounterAndJump(*Loop.MBB, *Loop.MBB,
State.getInstrInfo());

// Set up the exit basic block.
Loop.MBB->addSuccessor(Exit.MBB, llvm::BranchProbability::getZero());
Expand Down
3 changes: 2 additions & 1 deletion tools/llvm-exegesis/lib/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class ExegesisTarget {
}

// Adds the code to decrement the loop counter and
virtual void decrementLoopCounterAndLoop(MachineBasicBlock &MBB,
virtual void decrementLoopCounterAndJump(MachineBasicBlock &MBB,
MachineBasicBlock &TargetMBB,
const llvm::MCInstrInfo &MII) const {
llvm_unreachable("decrementLoopCounterAndBranch() requires "
"getLoopCounterRegister() > 0");
Expand Down
10 changes: 6 additions & 4 deletions tools/llvm-exegesis/lib/X86/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ class ExegesisX86Target : public ExegesisTarget {
void fillMemoryOperands(InstructionTemplate &IT, unsigned Reg,
unsigned Offset) const override;

void decrementLoopCounterAndLoop(MachineBasicBlock &MBB,
void decrementLoopCounterAndJump(MachineBasicBlock &MBB,
MachineBasicBlock &TargetMBB,
const llvm::MCInstrInfo &MII) const override;

std::vector<llvm::MCInst> setRegTo(const llvm::MCSubtargetInfo &STI,
Expand Down Expand Up @@ -558,14 +559,15 @@ void ExegesisX86Target::fillMemoryOperands(InstructionTemplate &IT,
SetOp(MemOpIdx + 4, MCOperand::createReg(0)); // Segment
}

void ExegesisX86Target::decrementLoopCounterAndLoop(
MachineBasicBlock &MBB, const llvm::MCInstrInfo &MII) const {
void ExegesisX86Target::decrementLoopCounterAndJump(
MachineBasicBlock &MBB, MachineBasicBlock &TargetMBB,
const llvm::MCInstrInfo &MII) const {
BuildMI(&MBB, DebugLoc(), MII.get(X86::ADD64ri8))
.addDef(kLoopCounterReg)
.addUse(kLoopCounterReg)
.addImm(-1);
BuildMI(&MBB, DebugLoc(), MII.get(X86::JCC_1))
.addMBB(&MBB)
.addMBB(&TargetMBB)
.addImm(X86::COND_NE);
}

Expand Down

0 comments on commit fa63bf3

Please sign in to comment.