summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2016-10-12 22:49:01 +0000
committerTim Northover <tnorthover@apple.com>2016-10-12 22:49:01 +0000
commit5e3dbf326c9c28180d66334a1ee6d3e98e14c9a2 (patch)
treeeb44ca7f3b2275c06e547c68ca376ba0e5283c85 /llvm/lib/Target
parent6aacd27cd7c5c118b297987a56a8b5f1c6ec1138 (diff)
downloadbcm5719-llvm-5e3dbf326c9c28180d66334a1ee6d3e98e14c9a2.tar.gz
bcm5719-llvm-5e3dbf326c9c28180d66334a1ee6d3e98e14c9a2.zip
GlobalISel: select G_BRCOND instructions on AArch64.
llvm-svn: 284071
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
index d9d24779a18..5be437d610b 100644
--- a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
@@ -299,6 +299,28 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const {
return true;
}
+ case TargetOpcode::G_BRCOND: {
+ if (Ty.getSizeInBits() > 32) {
+ // We shouldn't need this on AArch64, but it would be implemented as an
+ // EXTRACT_SUBREG followed by a TBNZW because TBNZX has no encoding if the
+ // bit being tested is < 32.
+ DEBUG(dbgs() << "G_BRCOND has type: " << Ty
+ << ", expected at most 32-bits");
+ return false;
+ }
+
+ const unsigned CondReg = I.getOperand(0).getReg();
+ MachineBasicBlock *DestMBB = I.getOperand(1).getMBB();
+
+ auto MIB = BuildMI(MBB, I, I.getDebugLoc(), TII.get(AArch64::TBNZW))
+ .addUse(CondReg)
+ .addImm(/*bit offset=*/0)
+ .addMBB(DestMBB);
+
+ I.eraseFromParent();
+ return constrainSelectedInstRegOperands(*MIB.getInstr(), TII, TRI, RBI);
+ }
+
case TargetOpcode::G_CONSTANT: {
if (Ty.getSizeInBits() <= 32)
I.setDesc(TII.get(AArch64::MOVi32imm));
OpenPOWER on IntegriCloud