Add the getRelocationType method that I forgot
[oota-llvm.git] / include / llvm / CodeGen / MachineConstantPool.h
index 06394ffdc1e2947629dbd39570f37dc8231f7cfd..edfd601faa1ec2b2d0523c6d79e87fd487e5cc9e 100644 (file)
@@ -1,5 +1,12 @@
 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
 // 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
+// 
 // The MachineConstantPool class keeps track of constants referenced by a
 // function which must be spilled to memory.  This is used for constants which
 // are unable to be used directly as operands to instructions, which typically
@@ -16,6 +23,9 @@
 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
 
 #include <vector>
+
+namespace llvm {
+
 class Constant;
 
 class MachineConstantPool {
@@ -23,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;
   }
@@ -42,4 +57,6 @@ public:
   void dump() const;
 };
 
+} // End llvm namespace
+
 #endif