[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
Chris Lattner
sabre at nondot.org
Thu Nov 16 17:52:38 PST 2006
Changes in directory llvm/lib/Target/PowerPC:
PPCBranchSelector.cpp updated: 1.32 -> 1.33
---
Log message:
implement a todo: change a map into a vector
---
Diffs of the changes: (+6 -6)
PPCBranchSelector.cpp | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
Index: llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
diff -u llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.32 llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.33
--- llvm/lib/Target/PowerPC/PPCBranchSelector.cpp:1.32 Thu Nov 16 18:49:36 2006
+++ llvm/lib/Target/PowerPC/PPCBranchSelector.cpp Thu Nov 16 19:52:23 2006
@@ -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 @@
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 @@
// 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 @@
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;
More information about the llvm-commits
mailing list