aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-18 21:03:49 +0000
committerChris Lattner <sabre@nondot.org>2004-01-18 21:03:49 +0000
commitaf894e963bb3b98605e161b662c66b2286eef140 (patch)
tree4df3026c300965f9e939049077e1aa929398957f
parent2ff95b6b4e9bcc0167a32f0ed09120298b5a3713 (diff)
Add support for representing the "compaction table"
Change protected members to private. Nothing should subclass SlotCalculator git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10912 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/SlotCalculator.h45
-rw-r--r--include/llvm/SlotCalculator.h45
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h45
3 files changed, 120 insertions, 15 deletions
diff --git a/include/llvm/Analysis/SlotCalculator.h b/include/llvm/Analysis/SlotCalculator.h
index fbd0976c8c..105e585d85 100644
--- a/include/llvm/Analysis/SlotCalculator.h
+++ b/include/llvm/Analysis/SlotCalculator.h
@@ -22,6 +22,7 @@
#include <vector>
#include <map>
+#include <cassert>
namespace llvm {
@@ -53,22 +54,50 @@ class SlotCalculator {
///
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;
+
+ /// 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 { return Table.size(); }
+ 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 @@ public:
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 @@ protected:
//
void processSymbolTable(const SymbolTable *ST);
void processSymbolTableConstants(const SymbolTable *ST);
+
+ void buildCompactionTable(const Function *F);
+ unsigned getOrCreateCompactionTableSlot(const Value *V);
};
} // End llvm namespace
diff --git a/include/llvm/SlotCalculator.h b/include/llvm/SlotCalculator.h
index fbd0976c8c..105e585d85 100644
--- a/include/llvm/SlotCalculator.h
+++ b/include/llvm/SlotCalculator.h
@@ -22,6 +22,7 @@
#include <vector>
#include <map>
+#include <cassert>
namespace llvm {
@@ -53,22 +54,50 @@ class SlotCalculator {
///
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;
+
+ /// 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 { return Table.size(); }
+ 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 @@ public:
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 @@ protected:
//
void processSymbolTable(const SymbolTable *ST);
void processSymbolTableConstants(const SymbolTable *ST);
+
+ void buildCompactionTable(const Function *F);
+ unsigned getOrCreateCompactionTableSlot(const Value *V);
};
} // End llvm namespace
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index fbd0976c8c..105e585d85 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/lib/Bytecode/Writer/SlotCalculator.h
@@ -22,6 +22,7 @@
#include <vector>
#include <map>
+#include <cassert>
namespace llvm {
@@ -53,22 +54,50 @@ class SlotCalculator {
///
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;
+
+ /// 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 { return Table.size(); }
+ 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 @@ public:
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 @@ protected:
//
void processSymbolTable(const SymbolTable *ST);
void processSymbolTableConstants(const SymbolTable *ST);
+
+ void buildCompactionTable(const Function *F);
+ unsigned getOrCreateCompactionTableSlot(const Value *V);
};
} // End llvm namespace