[llvm-commits] CVS: llvm/include/llvm/SlotCalculator.h

Chris Lattner lattner at cs.uiuc.edu
Sun Jan 18 15:05:00 PST 2004


Changes in directory llvm/include/llvm:

SlotCalculator.h updated: 1.15 -> 1.16

---
Log message:

Add support for representing the "compaction table"
Change protected members to private.  Nothing should subclass SlotCalculator


---
Diffs of the changes:  (+40 -5)

Index: llvm/include/llvm/SlotCalculator.h
diff -u llvm/include/llvm/SlotCalculator.h:1.15 llvm/include/llvm/SlotCalculator.h:1.16
--- llvm/include/llvm/SlotCalculator.h:1.15	Wed Jan 14 17:37:43 2004
+++ llvm/include/llvm/SlotCalculator.h	Sun Jan 18 15:03:49 2004
@@ -22,6 +22,7 @@
 
 #include <vector>
 #include <map>
+#include <cassert>
 
 namespace llvm {
 
@@ -53,22 +54,50 @@
   ///
   std::vector<unsigned> ModuleLevel;
 
+  /// ModuleContainsAllFunctionConstants - This flag is set to true if all
+  /// function constants are incorporated into the module constant table.  This
+  /// is only possible if building information for a bytecode file.
+  bool ModuleContainsAllFunctionConstants;
+
+  /// CompactionTable/NodeMap - When function compaction has been performed,
+  /// these entries provide a compacted view of the namespace needed to emit
+  /// instructions in a function body.  The 'getSlot()' method automatically
+  /// returns these entries if applicable, or the global entries if not.
+  std::vector<TypePlane> CompactionTable;
+  std::map<const Value*, unsigned> CompactionNodeMap;
+
+  SlotCalculator(const SlotCalculator &);  // DO NOT IMPLEMENT
+  void operator=(const SlotCalculator &);  // DO NOT IMPLEMENT
 public:
   SlotCalculator(const Module *M, bool BuildBytecodeInfo);
   // Start out in incorp state
   SlotCalculator(const Function *F, bool BuildBytecodeInfo);
   
-  /// getSlot returns < 0 on error!
+  /// getSlot - Return the slot number of the specified value in it's type
+  /// plane.  This returns < 0 on error!
   ///
-  int getSlot(const Value *D) const;
+  int getSlot(const Value *V) const;
 
-  inline unsigned getNumPlanes() const { return Table.size(); }
+  /// getGlobalSlot - Return a slot number from the global table.  This can only
+  /// be used when a compaction table is active.
+  unsigned getGlobalSlot(const Value *V) const;
+
+  inline unsigned getNumPlanes() const {
+    if (CompactionTable.empty())
+      return Table.size();
+    else
+      return CompactionTable.size();
+  }
   inline unsigned getModuleLevel(unsigned Plane) const { 
     return Plane < ModuleLevel.size() ? ModuleLevel[Plane] : 0; 
   }
 
   inline const TypePlane &getPlane(unsigned Plane) const { 
-    return Table[Plane]; 
+    if (CompactionTable.empty() || CompactionTable.size() <= Plane ||
+        CompactionTable[Plane].empty())
+      return Table[Plane];
+    else
+      return CompactionTable[Plane];
   }
 
   /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
@@ -84,8 +113,11 @@
   string_iterator string_begin() const { return ConstantStrings.begin(); }
   string_iterator string_end() const   { return ConstantStrings.end(); }
 
+  const std::vector<TypePlane> &getCompactionTable() const {
+    return CompactionTable;
+  }
 
-protected:
+private:
   // getOrCreateSlot - Values can be crammed into here at will... if
   // they haven't been inserted already, they get inserted, otherwise
   // they are ignored.
@@ -111,6 +143,9 @@
   //
   void processSymbolTable(const SymbolTable *ST);
   void processSymbolTableConstants(const SymbolTable *ST);
+
+  void buildCompactionTable(const Function *F);
+  unsigned getOrCreateCompactionTableSlot(const Value *V);
 };
 
 } // End llvm namespace





More information about the llvm-commits mailing list