1 //===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // The MachineConstantPool class keeps track of constants referenced by a
11 // function which must be spilled to memory. This is used for constants which
12 // are unable to be used directly as operands to instructions, which typically
13 // include floating point and large integer constants.
15 // Instructions reference the address of these constant pool constants through
16 // the use of MO_ConstantPoolIndex values. When emitting assembly or machine
17 // code, these virtual address references are converted to refer to the
18 // address of the function constant pool values.
20 //===----------------------------------------------------------------------===//
22 #ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
23 #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
33 /// MachineConstantPoolEntry - One entry in the constant pool.
35 struct MachineConstantPoolEntry {
36 /// Val - The constant itself.
38 /// Offset - The offset of the constant from the start of the constant pool.
41 MachineConstantPoolEntry(Constant *V, unsigned O) : Val(V), Offset(O) {}
44 class MachineConstantPool {
46 unsigned PoolAlignment;
47 std::vector<MachineConstantPoolEntry> Constants;
49 MachineConstantPool(const TargetData *td) : TD(td), PoolAlignment(1) {}
51 /// getConstantPoolAlignment - Return the log2 of the alignment required by
52 /// the whole constant pool, of which the first element must be aligned.
53 unsigned getConstantPoolAlignment() const { return PoolAlignment; }
55 /// getConstantPoolIndex - Create a new entry in the constant pool or return
56 /// an existing one. User must specify an alignment in bytes for the object.
58 unsigned getConstantPoolIndex(Constant *C, unsigned Alignment);
60 /// isEmpty - Return true if this constant pool contains no constants.
62 bool isEmpty() const { return Constants.empty(); }
64 const std::vector<MachineConstantPoolEntry> &getConstants() const {
68 /// print - Used by the MachineFunction printer to print information about
69 /// constant pool objects. Implemented in MachineFunction.cpp
71 void print(std::ostream &OS) const;
73 /// dump - Call print(std::cerr) to be called from the debugger.
78 } // End llvm namespace