diff options
author | Andrew Lenharth <andrewl@lenharth.org> | 2006-10-31 16:49:55 +0000 |
---|---|---|
committer | Andrew Lenharth <andrewl@lenharth.org> | 2006-10-31 16:49:55 +0000 |
commit | f81173f70eb71def77a4f835e6fec616fe1101ce (patch) | |
tree | e3c660201f8f084f65d2ae80bee45579bbcfee1d /lib/Target/Alpha/AlphaBranchSelector.cpp | |
parent | b191e0ab51174cfb86502308f520f139daa9e4a0 (diff) |
Add all that branch mangling niftiness
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31313 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Alpha/AlphaBranchSelector.cpp')
-rw-r--r-- | lib/Target/Alpha/AlphaBranchSelector.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/Target/Alpha/AlphaBranchSelector.cpp b/lib/Target/Alpha/AlphaBranchSelector.cpp new file mode 100644 index 0000000000..55140e34e4 --- /dev/null +++ b/lib/Target/Alpha/AlphaBranchSelector.cpp @@ -0,0 +1,63 @@ +//===-- AlphaBranchSelector.cpp - Convert Pseudo branchs ----------*- C++ -*-=// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Andrew Lenharth and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// 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/Support/Compiler.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetAsmInfo.h" +using namespace llvm; + +namespace { + struct VISIBILITY_HIDDEN AlphaBSel : public MachineFunctionPass { + + virtual bool runOnMachineFunction(MachineFunction &Fn); + + virtual const char *getPassName() const { + return "Alpha Branch Selection"; + } + }; +} + +/// 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 + MBBI->setOpcode(MBBI->getOperand(0).getImm()); + } + } + } + + return true; +} + |