diff options
author | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-05-28 10:13:54 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-05-28 10:13:54 +0000 |
commit | 06c3c9a9e1cc313d911e939e3e994feaf43cc3a7 (patch) | |
tree | f3b05ff8e8f185af8d40ec50aab831eeef11ff41 /lib/Target/SystemZ/SystemZInstrInfo.cpp | |
parent | c1a0806ff53bef0abc805a4062cd42b05ef8088b (diff) | |
download | external_llvm-06c3c9a9e1cc313d911e939e3e994feaf43cc3a7.zip external_llvm-06c3c9a9e1cc313d911e939e3e994feaf43cc3a7.tar.gz external_llvm-06c3c9a9e1cc313d911e939e3e994feaf43cc3a7.tar.bz2 |
[SystemZ] Tweak SystemZInstrInfo::isBranch() interface
This is needed for the upcoming compare-and-branch patch. No functional
change intended.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182762 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SystemZ/SystemZInstrInfo.cpp')
-rw-r--r-- | lib/Target/SystemZ/SystemZInstrInfo.cpp | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/lib/Target/SystemZ/SystemZInstrInfo.cpp b/lib/Target/SystemZ/SystemZInstrInfo.cpp index e13a3d9..6296e4a 100644 --- a/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -124,19 +124,18 @@ bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, // A terminator that isn't a branch can't easily be handled by this // analysis. - unsigned ThisCond; - const MachineOperand *ThisTarget; - if (!isBranch(I, ThisCond, ThisTarget)) + if (!I->isBranch()) return true; // Can't handle indirect branches. - if (!ThisTarget->isMBB()) + SystemZII::Branch Branch(getBranchInfo(I)); + if (!Branch.Target->isMBB()) return true; - if (ThisCond == SystemZ::CCMASK_ANY) { + if (Branch.CCMask == SystemZ::CCMASK_ANY) { // Handle unconditional branches. if (!AllowModify) { - TBB = ThisTarget->getMBB(); + TBB = Branch.Target->getMBB(); continue; } @@ -148,7 +147,7 @@ bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, FBB = 0; // Delete the JMP if it's equivalent to a fall-through. - if (MBB.isLayoutSuccessor(ThisTarget->getMBB())) { + if (MBB.isLayoutSuccessor(Branch.Target->getMBB())) { TBB = 0; I->eraseFromParent(); I = MBB.end(); @@ -156,7 +155,7 @@ bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, } // TBB is used to indicate the unconditinal destination. - TBB = ThisTarget->getMBB(); + TBB = Branch.Target->getMBB(); continue; } @@ -164,8 +163,8 @@ bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, if (Cond.empty()) { // FIXME: add X86-style branch swap FBB = TBB; - TBB = ThisTarget->getMBB(); - Cond.push_back(MachineOperand::CreateImm(ThisCond)); + TBB = Branch.Target->getMBB(); + Cond.push_back(MachineOperand::CreateImm(Branch.CCMask)); continue; } @@ -175,12 +174,12 @@ bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, // Only handle the case where all conditional branches branch to the same // destination. - if (TBB != ThisTarget->getMBB()) + if (TBB != Branch.Target->getMBB()) return true; // If the conditions are the same, we can leave them alone. unsigned OldCond = Cond[0].getImm(); - if (OldCond == ThisCond) + if (OldCond == Branch.CCMask) continue; // FIXME: Try combining conditions like X86 does. Should be easy on Z! @@ -198,11 +197,9 @@ unsigned SystemZInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { --I; if (I->isDebugValue()) continue; - unsigned Cond; - const MachineOperand *Target; - if (!isBranch(I, Cond, Target)) + if (!I->isBranch()) break; - if (!Target->isMBB()) + if (!getBranchInfo(I).Target->isMBB()) break; // Remove the branch. I->eraseFromParent(); @@ -358,25 +355,20 @@ uint64_t SystemZInstrInfo::getInstSizeInBytes(const MachineInstr *MI) const { return MI->getDesc().getSize(); } -bool SystemZInstrInfo::isBranch(const MachineInstr *MI, unsigned &Cond, - const MachineOperand *&Target) const { +SystemZII::Branch +SystemZInstrInfo::getBranchInfo(const MachineInstr *MI) const { switch (MI->getOpcode()) { case SystemZ::BR: case SystemZ::J: case SystemZ::JG: - Cond = SystemZ::CCMASK_ANY; - Target = &MI->getOperand(0); - return true; + return SystemZII::Branch(SystemZ::CCMASK_ANY, &MI->getOperand(0)); case SystemZ::BRC: case SystemZ::BRCL: - Cond = MI->getOperand(0).getImm(); - Target = &MI->getOperand(1); - return true; + return SystemZII::Branch(MI->getOperand(0).getImm(), &MI->getOperand(1)); default: - assert(!MI->getDesc().isBranch() && "Unknown branch opcode"); - return false; + llvm_unreachable("Unrecognized branch opcode"); } } |