1 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
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.
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.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
16 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
21 class MachineConstantPool {
22 std::vector<Constant*> Constants;
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.
29 unsigned getConstantPoolIndex(Constant *C) {
30 Constants.push_back(C);
31 return Constants.size()-1;
34 const std::vector<Constant*> &getConstants() const { return Constants; }
36 /// print - Used by the MachineFunction printer to print information about
37 /// stack objects. Implemented in MachineFunction.cpp
39 void print(std::ostream &OS) const;
41 /// dump - Call print(std::cerr) to be called from the debugger.