MSP430BranchSelector.cpp (208954) | MSP430BranchSelector.cpp (212904) |
---|---|
1//===-- MSP430BranchSelector.cpp - Emit long conditional branches--*- C++ -*-=// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains a pass that scans a machine function to determine which 11// conditional branches need more than 10 bits of displacement to reach their 12// target basic block. It does this in two passes; a calculation of basic block | 1//===-- MSP430BranchSelector.cpp - Emit long conditional branches--*- C++ -*-=// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file contains a pass that scans a machine function to determine which 11// conditional branches need more than 10 bits of displacement to reach their 12// target basic block. It does this in two passes; a calculation of basic block |
13// positions pass, and a branch psuedo op to machine branch opcode pass. This | 13// positions pass, and a branch pseudo op to machine branch opcode pass. This |
14// pass should be run last, just before the assembly printer. 15// 16//===----------------------------------------------------------------------===// 17 18#define DEBUG_TYPE "msp430-branch-select" 19#include "MSP430.h" 20#include "MSP430InstrInfo.h" 21#include "llvm/CodeGen/MachineInstrBuilder.h" 22#include "llvm/CodeGen/MachineFunctionPass.h" 23#include "llvm/Target/TargetMachine.h" 24#include "llvm/ADT/Statistic.h" 25#include "llvm/Support/MathExtras.h" 26using namespace llvm; 27 28STATISTIC(NumExpanded, "Number of branches expanded to long format"); 29 30namespace { 31 struct MSP430BSel : public MachineFunctionPass { 32 static char ID; | 14// pass should be run last, just before the assembly printer. 15// 16//===----------------------------------------------------------------------===// 17 18#define DEBUG_TYPE "msp430-branch-select" 19#include "MSP430.h" 20#include "MSP430InstrInfo.h" 21#include "llvm/CodeGen/MachineInstrBuilder.h" 22#include "llvm/CodeGen/MachineFunctionPass.h" 23#include "llvm/Target/TargetMachine.h" 24#include "llvm/ADT/Statistic.h" 25#include "llvm/Support/MathExtras.h" 26using namespace llvm; 27 28STATISTIC(NumExpanded, "Number of branches expanded to long format"); 29 30namespace { 31 struct MSP430BSel : public MachineFunctionPass { 32 static char ID; |
33 MSP430BSel() : MachineFunctionPass(&ID) {} | 33 MSP430BSel() : MachineFunctionPass(ID) {} |
34 35 /// BlockSizes - The sizes of the basic blocks in the function. 36 std::vector<unsigned> BlockSizes; 37 38 virtual bool runOnMachineFunction(MachineFunction &Fn); 39 40 virtual const char *getPassName() const { 41 return "MSP430 Branch Selector"; --- 5 unchanged lines hidden (view full) --- 47/// createMSP430BranchSelectionPass - returns an instance of the Branch 48/// Selection Pass 49/// 50FunctionPass *llvm::createMSP430BranchSelectionPass() { 51 return new MSP430BSel(); 52} 53 54bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { | 34 35 /// BlockSizes - The sizes of the basic blocks in the function. 36 std::vector<unsigned> BlockSizes; 37 38 virtual bool runOnMachineFunction(MachineFunction &Fn); 39 40 virtual const char *getPassName() const { 41 return "MSP430 Branch Selector"; --- 5 unchanged lines hidden (view full) --- 47/// createMSP430BranchSelectionPass - returns an instance of the Branch 48/// Selection Pass 49/// 50FunctionPass *llvm::createMSP430BranchSelectionPass() { 51 return new MSP430BSel(); 52} 53 54bool MSP430BSel::runOnMachineFunction(MachineFunction &Fn) { |
55 const TargetInstrInfo *TII = Fn.getTarget().getInstrInfo(); | 55 const MSP430InstrInfo *TII = 56 static_cast<const MSP430InstrInfo*>(Fn.getTarget().getInstrInfo()); |
56 // Give the blocks of the function a dense, in-order, numbering. 57 Fn.RenumberBlocks(); 58 BlockSizes.resize(Fn.getNumBlockIDs()); 59 60 // Measure each MBB and compute a size for the entire function. 61 unsigned FuncSize = 0; 62 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; 63 ++MFI) { --- 116 unchanged lines hidden --- | 57 // Give the blocks of the function a dense, in-order, numbering. 58 Fn.RenumberBlocks(); 59 BlockSizes.resize(Fn.getNumBlockIDs()); 60 61 // Measure each MBB and compute a size for the entire function. 62 unsigned FuncSize = 0; 63 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; 64 ++MFI) { --- 116 unchanged lines hidden --- |