[llvm-commits] CVS: llvm/include/llvm/Instructions.h
Nick Lewycky
nicholas at mxc.ca
Mon Sep 18 12:04:14 PDT 2006
Changes in directory llvm/include/llvm:
Instructions.h updated: 1.40 -> 1.41
---
Log message:
Add a new helper method to SwitchInst. Useful when you've got a BB from
somewhere (like the dominator graph) and would like to know which case it
came from.
---
Diffs of the changes: (+13 -0)
Instructions.h | 13 +++++++++++++
1 files changed, 13 insertions(+)
Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.40 llvm/include/llvm/Instructions.h:1.41
--- llvm/include/llvm/Instructions.h:1.40 Sun Sep 17 23:54:57 2006
+++ llvm/include/llvm/Instructions.h Mon Sep 18 14:03:59 2006
@@ -1310,6 +1310,19 @@
return 0;
}
+ /// findCaseDest - Finds the unique case value for a given successor. Returns
+ /// null if the successor is not found, not unique, or is the default case.
+ ConstantInt *findCaseDest(BasicBlock *BB) {
+ ConstantInt *CI = NULL;
+ for (unsigned i = 1, e = getNumCases(); i != e; ++i) {
+ if (getSuccessor(i) == BB) {
+ if (CI) return NULL; // Multiple cases lead to BB.
+ else CI = getCaseValue(i);
+ }
+ }
+ return CI;
+ }
+
/// addCase - Add an entry to the switch instruction...
///
void addCase(ConstantInt *OnVal, BasicBlock *Dest);
More information about the llvm-commits
mailing list