1 //===-- AlphaBranchSelector.cpp - Convert Pseudo branchs ----------*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // 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/MC/MCAsmInfo.h"
24 struct VISIBILITY_HIDDEN AlphaBSel
: public MachineFunctionPass
{
26 AlphaBSel() : MachineFunctionPass(&ID
) {}
28 virtual bool runOnMachineFunction(MachineFunction
&Fn
);
30 virtual const char *getPassName() const {
31 return "Alpha Branch Selection";
34 char AlphaBSel::ID
= 0;
37 /// createAlphaBranchSelectionPass - returns an instance of the Branch Selection
40 FunctionPass
*llvm::createAlphaBranchSelectionPass() {
41 return new AlphaBSel();
44 bool AlphaBSel::runOnMachineFunction(MachineFunction
&Fn
) {
46 for (MachineFunction::iterator MFI
= Fn
.begin(), E
= Fn
.end(); MFI
!= E
;
48 MachineBasicBlock
*MBB
= MFI
;
50 for (MachineBasicBlock::iterator MBBI
= MBB
->begin(), EE
= MBB
->end();
52 if (MBBI
->getOpcode() == Alpha::COND_BRANCH_I
||
53 MBBI
->getOpcode() == Alpha::COND_BRANCH_F
) {
55 // condbranch operands:
59 const TargetInstrInfo
*TII
= Fn
.getTarget().getInstrInfo();
60 MBBI
->setDesc(TII
->get(MBBI
->getOperand(0).getImm()));