summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-08-26 22:32:00 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-08-26 22:32:00 +0000
commit3b789ad2b851e7a9076d23bc3f07efa92f6bdef4 (patch)
treefdceffeac76ff9f40c22502eeca0036a24863348 /llvm/lib/Bytecode/Writer/SlotCalculator.cpp
parent2c69803b616141f3d9b089d2133fdc0910ba55b0 (diff)
downloadbcm5719-llvm-3b789ad2b851e7a9076d23bc3f07efa92f6bdef4.tar.gz
bcm5719-llvm-3b789ad2b851e7a9076d23bc3f07efa92f6bdef4.zip
Add the CompactionTableIsEmpty function so that we can determine if a
CompactionTable really needs to be emitted. This is not a straight forward computation, hence the need for a member function here. llvm-svn: 16062
Diffstat (limited to 'llvm/lib/Bytecode/Writer/SlotCalculator.cpp')
-rw-r--r--llvm/lib/Bytecode/Writer/SlotCalculator.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Bytecode/Writer/SlotCalculator.cpp b/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
index 75fb4185f7f..2656edd8a54 100644
--- a/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -622,6 +622,32 @@ void SlotCalculator::pruneCompactionTable() {
}
}
+/// Determine if the compaction table is actually empty. Because the
+/// compaction table always includes the primitive type planes, we
+/// can't just check getCompactionTable().size() because it will never
+/// be zero. Furthermore, the ModuleLevel factors into whether a given
+/// plane is empty or not. This function does the necessary computation
+/// to determine if its actually empty.
+bool SlotCalculator::CompactionTableIsEmpty() const {
+ // Check a degenerate case, just in case.
+ if (CompactionTable.size() == 0) return true;
+
+ // Check each plane
+ for (unsigned i = 0, e = CompactionTable.size(); i < e; ++i) {
+ // If the plane is not empty
+ if (!CompactionTable[i].empty()) {
+ // If the module level is non-zero then at least the
+ // first element of the plane is valid and therefore not empty.
+ unsigned End = getModuleLevel(i);
+ if (End != 0)
+ return false;
+ }
+ }
+ // All the compaction table planes are empty so the table is
+ // considered empty too.
+ return true;
+}
+
int SlotCalculator::getSlot(const Value *V) const {
// If there is a CompactionTable active...
if (!CompactionNodeMap.empty()) {
OpenPOWER on IntegriCloud