OSDN Git Service

Doxygenify the comments, bringing the file level comments down to be attached
[android-x86/external-llvm.git] / include / llvm / CodeGen / MachineConstantPool.h
1 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// @file This file declares the MachineConstantPool class which is an abstract
11 /// constant pool to keep track of constants referenced by a function.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
16 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
17
18 #include <vector>
19 #include <iosfwd>
20
21 namespace llvm {
22
23 class Constant;
24 class TargetData;
25
26 /// This class is a data container for one entry in a MachineConstantPool.
27 /// It contains a pointer to the value and an offset from the start of
28 /// the constant pool.
29 /// @brief An entry in a MachineConstantPool
30 struct MachineConstantPoolEntry {
31   Constant *Val;   ///< The constant itself.
32   unsigned Offset; ///< The offset of the constant from the start of the pool.
33   MachineConstantPoolEntry(Constant *V, unsigned O) : Val(V), Offset(O) {}
34 };
35   
36 /// The MachineConstantPool class keeps track of constants referenced by a
37 /// function which must be spilled to memory.  This is used for constants which
38 /// are unable to be used directly as operands to instructions, which typically
39 /// include floating point and large integer constants.
40 ///
41 /// Instructions reference the address of these constant pool constants through
42 /// the use of MO_ConstantPoolIndex values.  When emitting assembly or machine
43 /// code, these virtual address references are converted to refer to the
44 /// address of the function constant pool values.
45 /// @brief The machine constant pool.
46 class MachineConstantPool {
47   const TargetData *TD;   ///< The machine's TargetData.
48   unsigned PoolAlignment; ///< The alignment for the pool.
49   std::vector<MachineConstantPoolEntry> Constants; ///< The pool of constants.
50 public:
51   /// @brief The only constructor.
52   MachineConstantPool(const TargetData *td) : TD(td), PoolAlignment(1) {}
53     
54   /// getConstantPoolAlignment - Return the log2 of the alignment required by
55   /// the whole constant pool, of which the first element must be aligned.
56   unsigned getConstantPoolAlignment() const { return PoolAlignment; }
57   
58   /// getConstantPoolIndex - Create a new entry in the constant pool or return
59   /// an existing one.  User must specify an alignment in bytes for the object.
60   unsigned getConstantPoolIndex(Constant *C, unsigned Alignment);
61   
62   /// isEmpty - Return true if this constant pool contains no constants.
63   bool isEmpty() const { return Constants.empty(); }
64
65   const std::vector<MachineConstantPoolEntry> &getConstants() const {
66     return Constants;
67   }
68
69   /// print - Used by the MachineFunction printer to print information about
70   /// constant pool objects.  Implemented in MachineFunction.cpp
71   ///
72   void print(std::ostream &OS) const;
73
74   /// dump - Call print(std::cerr) to be called from the debugger.
75   ///
76   void dump() const;
77 };
78
79 } // End llvm namespace
80
81 #endif