06394ffdc1e2947629dbd39570f37dc8231f7cfd
[oota-llvm.git] / include / llvm / CodeGen / MachineConstantPool.h
1 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
2 // 
3 // The MachineConstantPool class keeps track of constants referenced by a
4 // function which must be spilled to memory.  This is used for constants which
5 // are unable to be used directly as operands to instructions, which typically
6 // include floating point and large integer constants.
7 //
8 // Instructions reference the address of these constant pool constants through
9 // the use of MO_ConstantPoolIndex values.  When emitting assembly or machine
10 // code, these virtual address references are converted to refer to the
11 // address of the function constant pool values.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
16 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
17
18 #include <vector>
19 class Constant;
20
21 class MachineConstantPool {
22   std::vector<Constant*> Constants;
23 public:
24
25   /// getConstantPoolIndex - Create a new entry in the constant pool or return
26   /// an existing one.  This should eventually allow sharing of duplicate
27   /// objects in the constant pool, but this is adequate for now.
28   ///
29   unsigned getConstantPoolIndex(Constant *C) {
30     Constants.push_back(C);
31     return Constants.size()-1;
32   }
33
34   const std::vector<Constant*> &getConstants() const { return Constants; }
35
36   /// print - Used by the MachineFunction printer to print information about
37   /// stack objects.  Implemented in MachineFunction.cpp
38   ///
39   void print(std::ostream &OS) const;
40
41   /// dump - Call print(std::cerr) to be called from the debugger.
42   void dump() const;
43 };
44
45 #endif