aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2010-03-23 17:11:51 +0000
committerTanya Lattner <tonic@nondot.org>2010-03-23 17:11:51 +0000
commit3e7b991362a600aed2ea0b24d6602bbbe797723c (patch)
tree69b4cd67c72958c1b51c827c4ec134a920f37d7e
parent95e705dba6e126959a3dfd38e052385e505f05a5 (diff)
downloadllvm-3e7b991362a600aed2ea0b24d6602bbbe797723c.zip
llvm-3e7b991362a600aed2ea0b24d6602bbbe797723c.tar.gz
llvm-3e7b991362a600aed2ea0b24d6602bbbe797723c.tar.bz2
Merge r98845 from mainline.
llvm-svn: 99291
-rw-r--r--llvm/include/llvm/CodeGen/MachineJumpTableInfo.h6
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp15
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp5
3 files changed, 19 insertions, 7 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h b/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h
index 5a4c9a9..c578d28 100644
--- a/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h
@@ -79,7 +79,11 @@ public:
/// getEntryAlignment - Return the alignment of each entry in the jump table.
unsigned getEntryAlignment(const TargetData &TD) const;
- /// getJumpTableIndex - Create a new jump table or return an existing one.
+ /// createJumpTableIndex - Create a new jump table.
+ ///
+ unsigned createJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs);
+
+ /// getJumpTableIndex - Return the index for an existing jump table.
///
unsigned getJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs);
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 4377d5b..ccbb2dd 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -594,16 +594,25 @@ unsigned MachineJumpTableInfo::getEntryAlignment(const TargetData &TD) const {
return ~0;
}
-/// getJumpTableIndex - Create a new jump table entry in the jump table info
-/// or return an existing one.
+/// createJumpTableIndex - Create a new jump table entry in the jump table info.
///
-unsigned MachineJumpTableInfo::getJumpTableIndex(
+unsigned MachineJumpTableInfo::createJumpTableIndex(
const std::vector<MachineBasicBlock*> &DestBBs) {
assert(!DestBBs.empty() && "Cannot create an empty jump table!");
JumpTables.push_back(MachineJumpTableEntry(DestBBs));
return JumpTables.size()-1;
}
+/// getJumpTableIndex - Return the index for an existing jump table entry in
+/// the jump table info.
+unsigned MachineJumpTableInfo::getJumpTableIndex(
+ const std::vector<MachineBasicBlock*> &DestBBs) {
+ for (unsigned i = 0, e = JumpTables.size(); i != e; ++i)
+ if (JumpTables[i].MBBs == DestBBs)
+ return i;
+ assert(false && "getJumpTableIndex failed to find matching table");
+ return ~0;
+}
/// ReplaceMBBInJumpTables - If Old is the target of any jump tables, update
/// the jump tables to branch to New instead.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 308742b..5ee2253 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1674,11 +1674,10 @@ bool SelectionDAGBuilder::handleJTSwitchCase(CaseRec& CR,
}
}
- // Create a jump table index for this jump table, or return an existing
- // one.
+ // Create a jump table index for this jump table.
unsigned JTEncoding = TLI.getJumpTableEncoding();
unsigned JTI = CurMF->getOrCreateJumpTableInfo(JTEncoding)
- ->getJumpTableIndex(DestBBs);
+ ->createJumpTableIndex(DestBBs);
// Set the jump table information so that we can codegen it as a second
// MachineBasicBlock