diff options
author | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-05-28 10:41:11 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2013-05-28 10:41:11 +0000 |
commit | d50bcb2162a529534da42748ab4a418bfc9aaf06 (patch) | |
tree | fc9a388bd749853d9a65985890f9a81f37391a8b /lib/Target/SystemZ/SystemZInstrInfo.cpp | |
parent | fe4716f7cf0bbabb5694fa452f435cec59bbd0e3 (diff) | |
download | llvm-d50bcb2162a529534da42748ab4a418bfc9aaf06.tar.gz llvm-d50bcb2162a529534da42748ab4a418bfc9aaf06.tar.bz2 llvm-d50bcb2162a529534da42748ab4a418bfc9aaf06.tar.xz |
[SystemZ] Register compare-and-branch support
This patch adds support for the CRJ and CGRJ instructions. Support for
the immediate forms will be a separate patch.
The architecture has a large number of comparison instructions. I think
it's generally better to concentrate on using the "best" comparison
instruction first and foremost, then only use something like CRJ if
CR really was the natual choice of comparison instruction. The patch
therefore opportunistically converts separate CR and BRC instructions
into a single CRJ while emitting instructions in ISelLowering.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182764 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SystemZ/SystemZInstrInfo.cpp')
-rw-r--r-- | lib/Target/SystemZ/SystemZInstrInfo.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/Target/SystemZ/SystemZInstrInfo.cpp b/lib/Target/SystemZ/SystemZInstrInfo.cpp index 6296e4a480..dcce5a7b7f 100644 --- a/lib/Target/SystemZ/SystemZInstrInfo.cpp +++ b/lib/Target/SystemZ/SystemZInstrInfo.cpp @@ -132,6 +132,10 @@ bool SystemZInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, if (!Branch.Target->isMBB()) return true; + // Punt on compound branches. + if (Branch.Type != SystemZII::BranchNormal) + return true; + if (Branch.CCMask == SystemZ::CCMASK_ANY) { // Handle unconditional branches. if (!AllowModify) { @@ -361,11 +365,21 @@ SystemZInstrInfo::getBranchInfo(const MachineInstr *MI) const { case SystemZ::BR: case SystemZ::J: case SystemZ::JG: - return SystemZII::Branch(SystemZ::CCMASK_ANY, &MI->getOperand(0)); + return SystemZII::Branch(SystemZII::BranchNormal, SystemZ::CCMASK_ANY, + &MI->getOperand(0)); case SystemZ::BRC: case SystemZ::BRCL: - return SystemZII::Branch(MI->getOperand(0).getImm(), &MI->getOperand(1)); + return SystemZII::Branch(SystemZII::BranchNormal, + MI->getOperand(0).getImm(), &MI->getOperand(1)); + + case SystemZ::CRJ: + return SystemZII::Branch(SystemZII::BranchC, MI->getOperand(2).getImm(), + &MI->getOperand(3)); + + case SystemZ::CGRJ: + return SystemZII::Branch(SystemZII::BranchCG, MI->getOperand(2).getImm(), + &MI->getOperand(3)); default: llvm_unreachable("Unrecognized branch opcode"); @@ -426,6 +440,17 @@ unsigned SystemZInstrInfo::getOpcodeForOffset(unsigned Opcode, return 0; } +unsigned SystemZInstrInfo::getCompareAndBranch(unsigned Opcode) const { + switch (Opcode) { + case SystemZ::CR: + return SystemZ::CRJ; + case SystemZ::CGR: + return SystemZ::CGRJ; + default: + return 0; + } +} + void SystemZInstrInfo::loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned Reg, uint64_t Value) const { |