Add the getRelocationType method that I forgot
[oota-llvm.git] / include / llvm / CodeGen / MachineConstantPool.h
index 74b7585a081698d08f717bc305dd985f38d393a5..edfd601faa1ec2b2d0523c6d79e87fd487e5cc9e 100644 (file)
@@ -23,6 +23,9 @@
 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
 
 #include <vector>
+
+namespace llvm {
+
 class Constant;
 
 class MachineConstantPool {
@@ -30,10 +33,15 @@ class MachineConstantPool {
 public:
 
   /// getConstantPoolIndex - Create a new entry in the constant pool or return
-  /// an existing one.  This should eventually allow sharing of duplicate
-  /// objects in the constant pool, but this is adequate for now.
+  /// an existing one.
   ///
   unsigned getConstantPoolIndex(Constant *C) {
+    // Check to see if we already have this constant.
+    //
+    // FIXME, this could be made much more efficient for large constant pools.
+    for (unsigned i = 0, e = Constants.size(); i != e; ++i)
+      if (Constants[i] == C)
+        return i;
     Constants.push_back(C);
     return Constants.size()-1;
   }
@@ -49,4 +57,6 @@ public:
   void dump() const;
 };
 
+} // End llvm namespace
+
 #endif