2003-01-13 01:01:31 +00:00
|
|
|
//===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// 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.
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2005-04-21 20:39:54 +00:00
|
|
|
//
|
2003-01-13 01:01:31 +00:00
|
|
|
// 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
|
|
|
|
// include floating point and large integer constants.
|
|
|
|
//
|
|
|
|
// Instructions reference the address of these constant pool constants through
|
|
|
|
// the use of MO_ConstantPoolIndex values. When emitting assembly or machine
|
|
|
|
// code, these virtual address references are converted to refer to the
|
|
|
|
// address of the function constant pool values.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
|
|
|
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
|
|
|
|
|
|
|
#include <vector>
|
2005-12-28 06:47:33 +00:00
|
|
|
#include <iosfwd>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2003-01-13 01:01:31 +00:00
|
|
|
class Constant;
|
2006-02-09 04:44:32 +00:00
|
|
|
class TargetData;
|
2003-01-13 01:01:31 +00:00
|
|
|
|
2006-02-09 04:21:49 +00:00
|
|
|
/// MachineConstantPoolEntry - One entry in the constant pool.
|
|
|
|
///
|
|
|
|
struct MachineConstantPoolEntry {
|
|
|
|
/// Val - The constant itself.
|
|
|
|
Constant *Val;
|
2006-02-09 04:44:32 +00:00
|
|
|
/// Offset - The offset of the constant from the start of the constant pool.
|
|
|
|
unsigned Offset;
|
2006-02-09 04:21:49 +00:00
|
|
|
|
2006-02-09 04:44:32 +00:00
|
|
|
MachineConstantPoolEntry(Constant *V, unsigned O) : Val(V), Offset(O) {}
|
2006-02-09 04:21:49 +00:00
|
|
|
};
|
|
|
|
|
2003-01-13 01:01:31 +00:00
|
|
|
class MachineConstantPool {
|
2006-02-09 04:44:32 +00:00
|
|
|
const TargetData &TD;
|
|
|
|
unsigned PoolAlignment;
|
2006-02-09 04:21:49 +00:00
|
|
|
std::vector<MachineConstantPoolEntry> Constants;
|
2003-01-13 01:01:31 +00:00
|
|
|
public:
|
2006-02-09 04:44:32 +00:00
|
|
|
MachineConstantPool(const TargetData &td) : TD(td), PoolAlignment(1) {}
|
|
|
|
|
|
|
|
/// getConstantPoolAlignment - Return the log2 of the alignment required by
|
|
|
|
/// the whole constant pool, of which the first element must be aligned.
|
|
|
|
unsigned getConstantPoolAlignment() const { return PoolAlignment; }
|
|
|
|
|
2003-01-13 01:01:31 +00:00
|
|
|
/// getConstantPoolIndex - Create a new entry in the constant pool or return
|
2006-02-09 02:24:25 +00:00
|
|
|
/// an existing one. User must specify an alignment in bytes for the object.
|
2003-01-13 01:01:31 +00:00
|
|
|
///
|
2006-02-09 04:44:32 +00:00
|
|
|
unsigned getConstantPoolIndex(Constant *C, unsigned Alignment);
|
|
|
|
|
2005-07-11 04:49:33 +00:00
|
|
|
/// isEmpty - Return true if this constant pool contains no constants.
|
|
|
|
///
|
|
|
|
bool isEmpty() const { return Constants.empty(); }
|
|
|
|
|
2006-02-09 04:21:49 +00:00
|
|
|
const std::vector<MachineConstantPoolEntry> &getConstants() const {
|
2006-01-31 22:23:14 +00:00
|
|
|
return Constants;
|
|
|
|
}
|
2003-01-13 01:01:31 +00:00
|
|
|
|
|
|
|
/// print - Used by the MachineFunction printer to print information about
|
|
|
|
/// stack objects. Implemented in MachineFunction.cpp
|
|
|
|
///
|
|
|
|
void print(std::ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - Call print(std::cerr) to be called from the debugger.
|
2006-02-09 04:44:32 +00:00
|
|
|
///
|
2003-01-13 01:01:31 +00:00
|
|
|
void dump() const;
|
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2003-01-13 01:01:31 +00:00
|
|
|
#endif
|