summaryrefslogtreecommitdiff
path: root/lib/Target/ARM/Thumb2ITBlockPass.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2009-07-11 07:26:20 +0000
committerEvan Cheng <evan.cheng@apple.com>2009-07-11 07:26:20 +0000
commited338e80f92d6efa961d9f8c29239dde1507e683 (patch)
tree976bc905e2343db2d88d405da341c48b995977a0 /lib/Target/ARM/Thumb2ITBlockPass.cpp
parent2f297df02eac140de4e2f85e56bd79abf883360c (diff)
downloadllvm-ed338e80f92d6efa961d9f8c29239dde1507e683.tar.gz
llvm-ed338e80f92d6efa961d9f8c29239dde1507e683.tar.bz2
llvm-ed338e80f92d6efa961d9f8c29239dde1507e683.tar.xz
Don't put IT instruction before conditional branches.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75361 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/Thumb2ITBlockPass.cpp')
-rw-r--r--lib/Target/ARM/Thumb2ITBlockPass.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Target/ARM/Thumb2ITBlockPass.cpp b/lib/Target/ARM/Thumb2ITBlockPass.cpp
index f6f75a1a4b..3ff31aa28b 100644
--- a/lib/Target/ARM/Thumb2ITBlockPass.cpp
+++ b/lib/Target/ARM/Thumb2ITBlockPass.cpp
@@ -9,8 +9,8 @@
#define DEBUG_TYPE "thumb2-it"
#include "ARM.h"
-#include "ARMInstrInfo.h"
#include "ARMMachineFunctionInfo.h"
+#include "Thumb2InstrInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
@@ -25,7 +25,7 @@ namespace {
static char ID;
Thumb2ITBlockPass() : MachineFunctionPass(&ID) {}
- const ARMBaseInstrInfo *TII;
+ const Thumb2InstrInfo *TII;
ARMFunctionInfo *AFI;
virtual bool runOnMachineFunction(MachineFunction &Fn);
@@ -40,13 +40,21 @@ namespace {
char Thumb2ITBlockPass::ID = 0;
}
+ARMCC::CondCodes getPredicate(const MachineInstr *MI,
+ const Thumb2InstrInfo *TII) {
+ unsigned Opc = MI->getOpcode();
+ if (Opc == ARM::tBcc || Opc == ARM::t2Bcc)
+ return ARMCC::AL;
+ return TII->getPredicate(MI);
+}
+
bool Thumb2ITBlockPass::InsertITBlocks(MachineBasicBlock &MBB) {
bool Modified = false;
MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end();
while (MBBI != E) {
MachineInstr *MI = &*MBBI;
- ARMCC::CondCodes CC = TII->getPredicate(MI);
+ ARMCC::CondCodes CC = getPredicate(MI, TII);
if (CC == ARMCC::AL) {
++MBBI;
continue;
@@ -64,7 +72,7 @@ bool Thumb2ITBlockPass::InsertITBlocks(MachineBasicBlock &MBB) {
ARMCC::CondCodes OCC = ARMCC::getOppositeCondition(CC);
unsigned Mask = 0x8;
while (MBBI != E || (Mask & 1)) {
- ARMCC::CondCodes NCC = TII->getPredicate(&*MBBI);
+ ARMCC::CondCodes NCC = getPredicate(&*MBBI, TII);
if (NCC == CC) {
Mask >>= 1;
Mask |= 0x8;
@@ -86,7 +94,7 @@ bool Thumb2ITBlockPass::InsertITBlocks(MachineBasicBlock &MBB) {
bool Thumb2ITBlockPass::runOnMachineFunction(MachineFunction &Fn) {
const TargetMachine &TM = Fn.getTarget();
AFI = Fn.getInfo<ARMFunctionInfo>();
- TII = static_cast<const ARMBaseInstrInfo*>(TM.getInstrInfo());
+ TII = static_cast<const Thumb2InstrInfo*>(TM.getInstrInfo());
if (!AFI->isThumbFunction())
return false;