summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-11-17 01:52:23 +0000
committerChris Lattner <sabre@nondot.org>2006-11-17 01:52:23 +0000
commit280b714cd064224c6cfe1724f22cca4d6b8eed37 (patch)
tree214423f01c71e7fa64e1e4cdc9776692cbab93a5 /lib
parentfb1aab0673a699c39281e3bdc1091c0ed8fd1d1c (diff)
downloadllvm-280b714cd064224c6cfe1724f22cca4d6b8eed37.tar.gz
llvm-280b714cd064224c6cfe1724f22cca4d6b8eed37.tar.bz2
llvm-280b714cd064224c6cfe1724f22cca4d6b8eed37.tar.xz
implement a todo: change a map into a vector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31805 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/PowerPC/PPCBranchSelector.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Target/PowerPC/PPCBranchSelector.cpp b/lib/Target/PowerPC/PPCBranchSelector.cpp
index dcbcfbd297..7efa2ef78a 100644
--- a/lib/Target/PowerPC/PPCBranchSelector.cpp
+++ b/lib/Target/PowerPC/PPCBranchSelector.cpp
@@ -23,7 +23,6 @@
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
-#include <map>
using namespace llvm;
static Statistic<> NumExpanded("ppc-branch-select",
@@ -31,9 +30,8 @@ static Statistic<> NumExpanded("ppc-branch-select",
namespace {
struct VISIBILITY_HIDDEN PPCBSel : public MachineFunctionPass {
- /// OffsetMap - Mapping between BB and byte offset from start of function.
- /// TODO: replace this with a vector, using the MBB idx as the key.
- std::map<MachineBasicBlock*, unsigned> OffsetMap;
+ /// OffsetMap - Mapping between BB # and byte offset from start of function.
+ std::vector<unsigned> OffsetMap;
virtual bool runOnMachineFunction(MachineFunction &Fn);
@@ -81,12 +79,14 @@ bool PPCBSel::runOnMachineFunction(MachineFunction &Fn) {
// Running total of instructions encountered since beginning of function
unsigned ByteCount = 0;
+ OffsetMap.resize(Fn.getNumBlockIDs());
+
// For each MBB, add its offset to the offset map, and count up its
// instructions
for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E;
++MFI) {
MachineBasicBlock *MBB = MFI;
- OffsetMap[MBB] = ByteCount;
+ OffsetMap[MBB->getNumber()] = ByteCount;
for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end();
MBBI != EE; ++MBBI)
@@ -128,7 +128,7 @@ bool PPCBSel::runOnMachineFunction(MachineFunction &Fn) {
unsigned Opcode = MBBI->getOperand(1).getImmedValue();
unsigned CRReg = MBBI->getOperand(0).getReg();
- int Displacement = OffsetMap[DestMBB] - ByteCount;
+ int Displacement = OffsetMap[DestMBB->getNumber()] - ByteCount;
unsigned Inverted = PPCInstrInfo::invertPPCBranchOpcode(Opcode);
MachineBasicBlock::iterator MBBJ;