[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.h SlotCalculator.cpp

Reid Spencer reid at x10sys.com
Thu Aug 26 15:32:10 PDT 2004



Changes in directory llvm/lib/Bytecode/Writer:

SlotCalculator.h updated: 1.20 -> 1.21
SlotCalculator.cpp updated: 1.61 -> 1.62
---
Log message:

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.


---
Diffs of the changes:  (+29 -0)

Index: llvm/lib/Bytecode/Writer/SlotCalculator.h
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.20 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.21
--- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.20	Sun Jul  4 06:42:49 2004
+++ llvm/lib/Bytecode/Writer/SlotCalculator.h	Thu Aug 26 17:32:00 2004
@@ -138,6 +138,9 @@
 
   const TypeList& getCompactionTypes() const { return CompactionTypes; }
 
+  /// @brief Determine if the compaction table (not types) is empty
+  bool CompactionTableIsEmpty() const;
+
 private:
   // getOrCreateSlot - Values can be crammed into here at will... if
   // they haven't been inserted already, they get inserted, otherwise


Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.61 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.62
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.61	Thu Jul 29 07:17:34 2004
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp	Thu Aug 26 17:32:00 2004
@@ -622,6 +622,32 @@
     }
 }
 
+/// 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()) {






More information about the llvm-commits mailing list