summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-14 23:37:43 +0000
committerChris Lattner <sabre@nondot.org>2004-01-14 23:37:43 +0000
commit7851e1b32803a9b0d373e74bb85145368779b177 (patch)
tree9dd6c05d2ef7d982a54407e20a51cb6b98c14f68
parentd924edb845101f89744344aee66bbf9f2e89c3c6 (diff)
downloadllvm-7851e1b32803a9b0d373e74bb85145368779b177.tar.gz
llvm-7851e1b32803a9b0d373e74bb85145368779b177.tar.bz2
llvm-7851e1b32803a9b0d373e74bb85145368779b177.tar.xz
Improve comments, add support for remembering the constants strings that
are to be emitted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10866 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/SlotCalculator.h41
-rw-r--r--include/llvm/SlotCalculator.h41
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.h41
3 files changed, 81 insertions, 42 deletions
diff --git a/include/llvm/Analysis/SlotCalculator.h b/include/llvm/Analysis/SlotCalculator.h
index 60cf516a10..fbd0976c8c 100644
--- a/include/llvm/Analysis/SlotCalculator.h
+++ b/include/llvm/Analysis/SlotCalculator.h
@@ -29,32 +29,37 @@ class Value;
class Module;
class Function;
class SymbolTable;
+class ConstantArray;
class SlotCalculator {
const Module *TheModule;
- // BuildBytecodeInfo - If true, this is the creating information for the
- // bytecode writer, if false, we are building information for the assembly
- // emitter. The assembly emitter doesn't need named objects numbered, among
- // other differences.
+ /// BuildBytecodeInfo - If true, this is the creating information for the
+ /// bytecode writer, if false, we are building information for the assembly
+ /// emitter. The assembly emitter doesn't need named objects numbered, among
+ /// other differences.
bool BuildBytecodeInfo;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
- std::map<const Value *, unsigned> NodeMap;
+ std::map<const Value*, unsigned> NodeMap;
- // ModuleLevel - Used to keep track of which values belong to the module,
- // and which values belong to the currently incorporated function.
- //
+ /// ConstantStrings - If we are indexing for a bytecode file, this keeps track
+ /// of all of the constants strings that need to be emitted.
+ std::vector<const ConstantArray*> ConstantStrings;
+
+ /// ModuleLevel - Used to keep track of which values belong to the module,
+ /// and which values belong to the currently incorporated function.
+ ///
std::vector<unsigned> ModuleLevel;
public:
SlotCalculator(const Module *M, bool BuildBytecodeInfo);
// Start out in incorp state
- SlotCalculator(const Function *M, bool BuildBytecodeInfo);
- inline ~SlotCalculator() {}
+ SlotCalculator(const Function *F, bool BuildBytecodeInfo);
- // getSlot returns < 0 on error!
+ /// getSlot returns < 0 on error!
+ ///
int getSlot(const Value *D) const;
inline unsigned getNumPlanes() const { return Table.size(); }
@@ -66,12 +71,20 @@ public:
return Table[Plane];
}
- // If you'd like to deal with a function, use these two methods to get its
- // data into the SlotCalculator!
- //
+ /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
+ /// use these two methods to get its data into the SlotCalculator!
+ ///
void incorporateFunction(const Function *F);
void purgeFunction();
+ /// string_iterator/string_begin/end - Access the list of module-level
+ /// constant strings that have been incorporated. This is only applicable to
+ /// bytecode files.
+ typedef std::vector<const ConstantArray*>::const_iterator string_iterator;
+ string_iterator string_begin() const { return ConstantStrings.begin(); }
+ string_iterator string_end() const { return ConstantStrings.end(); }
+
+
protected:
// getOrCreateSlot - Values can be crammed into here at will... if
// they haven't been inserted already, they get inserted, otherwise
diff --git a/include/llvm/SlotCalculator.h b/include/llvm/SlotCalculator.h
index 60cf516a10..fbd0976c8c 100644
--- a/include/llvm/SlotCalculator.h
+++ b/include/llvm/SlotCalculator.h
@@ -29,32 +29,37 @@ class Value;
class Module;
class Function;
class SymbolTable;
+class ConstantArray;
class SlotCalculator {
const Module *TheModule;
- // BuildBytecodeInfo - If true, this is the creating information for the
- // bytecode writer, if false, we are building information for the assembly
- // emitter. The assembly emitter doesn't need named objects numbered, among
- // other differences.
+ /// BuildBytecodeInfo - If true, this is the creating information for the
+ /// bytecode writer, if false, we are building information for the assembly
+ /// emitter. The assembly emitter doesn't need named objects numbered, among
+ /// other differences.
bool BuildBytecodeInfo;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
- std::map<const Value *, unsigned> NodeMap;
+ std::map<const Value*, unsigned> NodeMap;
- // ModuleLevel - Used to keep track of which values belong to the module,
- // and which values belong to the currently incorporated function.
- //
+ /// ConstantStrings - If we are indexing for a bytecode file, this keeps track
+ /// of all of the constants strings that need to be emitted.
+ std::vector<const ConstantArray*> ConstantStrings;
+
+ /// ModuleLevel - Used to keep track of which values belong to the module,
+ /// and which values belong to the currently incorporated function.
+ ///
std::vector<unsigned> ModuleLevel;
public:
SlotCalculator(const Module *M, bool BuildBytecodeInfo);
// Start out in incorp state
- SlotCalculator(const Function *M, bool BuildBytecodeInfo);
- inline ~SlotCalculator() {}
+ SlotCalculator(const Function *F, bool BuildBytecodeInfo);
- // getSlot returns < 0 on error!
+ /// getSlot returns < 0 on error!
+ ///
int getSlot(const Value *D) const;
inline unsigned getNumPlanes() const { return Table.size(); }
@@ -66,12 +71,20 @@ public:
return Table[Plane];
}
- // If you'd like to deal with a function, use these two methods to get its
- // data into the SlotCalculator!
- //
+ /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
+ /// use these two methods to get its data into the SlotCalculator!
+ ///
void incorporateFunction(const Function *F);
void purgeFunction();
+ /// string_iterator/string_begin/end - Access the list of module-level
+ /// constant strings that have been incorporated. This is only applicable to
+ /// bytecode files.
+ typedef std::vector<const ConstantArray*>::const_iterator string_iterator;
+ string_iterator string_begin() const { return ConstantStrings.begin(); }
+ string_iterator string_end() const { return ConstantStrings.end(); }
+
+
protected:
// getOrCreateSlot - Values can be crammed into here at will... if
// they haven't been inserted already, they get inserted, otherwise
diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h
index 60cf516a10..fbd0976c8c 100644
--- a/lib/Bytecode/Writer/SlotCalculator.h
+++ b/lib/Bytecode/Writer/SlotCalculator.h
@@ -29,32 +29,37 @@ class Value;
class Module;
class Function;
class SymbolTable;
+class ConstantArray;
class SlotCalculator {
const Module *TheModule;
- // BuildBytecodeInfo - If true, this is the creating information for the
- // bytecode writer, if false, we are building information for the assembly
- // emitter. The assembly emitter doesn't need named objects numbered, among
- // other differences.
+ /// BuildBytecodeInfo - If true, this is the creating information for the
+ /// bytecode writer, if false, we are building information for the assembly
+ /// emitter. The assembly emitter doesn't need named objects numbered, among
+ /// other differences.
bool BuildBytecodeInfo;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
- std::map<const Value *, unsigned> NodeMap;
+ std::map<const Value*, unsigned> NodeMap;
- // ModuleLevel - Used to keep track of which values belong to the module,
- // and which values belong to the currently incorporated function.
- //
+ /// ConstantStrings - If we are indexing for a bytecode file, this keeps track
+ /// of all of the constants strings that need to be emitted.
+ std::vector<const ConstantArray*> ConstantStrings;
+
+ /// ModuleLevel - Used to keep track of which values belong to the module,
+ /// and which values belong to the currently incorporated function.
+ ///
std::vector<unsigned> ModuleLevel;
public:
SlotCalculator(const Module *M, bool BuildBytecodeInfo);
// Start out in incorp state
- SlotCalculator(const Function *M, bool BuildBytecodeInfo);
- inline ~SlotCalculator() {}
+ SlotCalculator(const Function *F, bool BuildBytecodeInfo);
- // getSlot returns < 0 on error!
+ /// getSlot returns < 0 on error!
+ ///
int getSlot(const Value *D) const;
inline unsigned getNumPlanes() const { return Table.size(); }
@@ -66,12 +71,20 @@ public:
return Table[Plane];
}
- // If you'd like to deal with a function, use these two methods to get its
- // data into the SlotCalculator!
- //
+ /// incorporateFunction/purgeFunction - If you'd like to deal with a function,
+ /// use these two methods to get its data into the SlotCalculator!
+ ///
void incorporateFunction(const Function *F);
void purgeFunction();
+ /// string_iterator/string_begin/end - Access the list of module-level
+ /// constant strings that have been incorporated. This is only applicable to
+ /// bytecode files.
+ typedef std::vector<const ConstantArray*>::const_iterator string_iterator;
+ string_iterator string_begin() const { return ConstantStrings.begin(); }
+ string_iterator string_end() const { return ConstantStrings.end(); }
+
+
protected:
// getOrCreateSlot - Values can be crammed into here at will... if
// they haven't been inserted already, they get inserted, otherwise