2006-10-31 16:49:55 +00:00
|
|
|
//===-- AlphaBranchSelector.cpp - Convert Pseudo branchs ----------*- C++ -*-=//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-10-31 16:49:55 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Replace Pseudo COND_BRANCH_* with their appropriate real branch
|
|
|
|
// Simplified version of the PPC Branch Selector
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Alpha.h"
|
|
|
|
#include "AlphaInstrInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2009-08-22 20:48:53 +00:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2006-10-31 16:49:55 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
2009-10-25 06:33:48 +00:00
|
|
|
struct AlphaBSel : public MachineFunctionPass {
|
2007-05-03 01:11:54 +00:00
|
|
|
static char ID;
|
2010-08-06 18:33:48 +00:00
|
|
|
AlphaBSel() : MachineFunctionPass(ID) {}
|
2006-10-31 16:49:55 +00:00
|
|
|
|
|
|
|
virtual bool runOnMachineFunction(MachineFunction &Fn);
|
|
|
|
|
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "Alpha Branch Selection";
|
|
|
|
}
|
|
|
|
};
|
2007-05-03 01:11:54 +00:00
|
|
|
char AlphaBSel::ID = 0;
|
2006-10-31 16:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createAlphaBranchSelectionPass - returns an instance of the Branch Selection
|
|
|
|
/// Pass
|
|
|
|
///
|
|
|
|
FunctionPass *llvm::createAlphaBranchSelectionPass() {
|
|
|
|
return new AlphaBSel();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AlphaBSel::runOnMachineFunction(MachineFunction &Fn) {
|
|
|
|
|
|
|
|
for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E;
|
|
|
|
++MFI) {
|
|
|
|
MachineBasicBlock *MBB = MFI;
|
|
|
|
|
|
|
|
for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end();
|
|
|
|
MBBI != EE; ++MBBI) {
|
|
|
|
if (MBBI->getOpcode() == Alpha::COND_BRANCH_I ||
|
|
|
|
MBBI->getOpcode() == Alpha::COND_BRANCH_F) {
|
|
|
|
|
|
|
|
// condbranch operands:
|
|
|
|
// 0. bc opcode
|
|
|
|
// 1. reg
|
|
|
|
// 2. target MBB
|
2006-11-30 07:12:03 +00:00
|
|
|
const TargetInstrInfo *TII = Fn.getTarget().getInstrInfo();
|
2008-01-11 18:10:50 +00:00
|
|
|
MBBI->setDesc(TII->get(MBBI->getOperand(0).getImm()));
|
2006-10-31 16:49:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|