1 //===-- AlphaBranchSelector.cpp - Convert Pseudo branchs ----------*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Andrew Lenharth and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Replace Pseudo COND_BRANCH_* with their appropriate real branch
11 // Simplified version of the PPC Branch Selector
13 //===----------------------------------------------------------------------===//
16 #include "AlphaInstrInfo.h"
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18 #include "llvm/Support/Compiler.h"
19 #include "llvm/Target/TargetMachine.h"
20 #include "llvm/Target/TargetAsmInfo.h"
24 struct VISIBILITY_HIDDEN AlphaBSel : public MachineFunctionPass {
26 virtual bool runOnMachineFunction(MachineFunction &Fn);
28 virtual const char *getPassName() const {
29 return "Alpha Branch Selection";
34 /// createAlphaBranchSelectionPass - returns an instance of the Branch Selection
37 FunctionPass *llvm::createAlphaBranchSelectionPass() {
38 return new AlphaBSel();
41 bool AlphaBSel::runOnMachineFunction(MachineFunction &Fn) {
43 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E;
45 MachineBasicBlock *MBB = MFI;
47 for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end();
49 if (MBBI->getOpcode() == Alpha::COND_BRANCH_I ||
50 MBBI->getOpcode() == Alpha::COND_BRANCH_F) {
52 // condbranch operands:
56 const TargetInstrInfo *TII = Fn.getTarget().getInstrInfo();
57 MBBI->setInstrDescriptor(TII->get(MBBI->getOperand(0).getImm()));