diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2006-09-18 19:03:59 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2006-09-18 19:03:59 +0000 |
commit | 011f1846013e6c0c55e6e583a9ca1bc5e7e7fc1e (patch) | |
tree | 1e8d8f5db013b6b44f39904af4a29edcf3fc739e /include | |
parent | 6d7ca92bbf1d82905573ed04b015cfebc0f4c965 (diff) | |
download | external_llvm-011f1846013e6c0c55e6e583a9ca1bc5e7e7fc1e.zip external_llvm-011f1846013e6c0c55e6e583a9ca1bc5e7e7fc1e.tar.gz external_llvm-011f1846013e6c0c55e6e583a9ca1bc5e7e7fc1e.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30466 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Instructions.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 03ce246..5973add 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -1310,6 +1310,19 @@ public: 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); |