1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/include/llvm/CodeGen/MachineConstantPool.h

73 lines
2.5 KiB
C
Raw Normal View History

2003-01-13 02:01:31 +01:00
//===-- CodeGen/MachineConstantPool.h - Abstract Constant Pool --*- C++ -*-===//
//
// 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.
//
//===----------------------------------------------------------------------===//
//
2003-01-13 02:01:31 +01: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>
#include <iosfwd>
2006-02-09 03:25:42 +01:00
#include <cassert>
namespace llvm {
2003-01-13 02:01:31 +01:00
class Constant;
class MachineConstantPool {
std::vector<std::pair<Constant*,unsigned> > Constants;
2003-01-13 02:01:31 +01:00
public:
/// getConstantPoolIndex - Create a new entry in the constant pool or return
2006-02-09 03:24:25 +01:00
/// an existing one. User must specify an alignment in bytes for the object.
2003-01-13 02:01:31 +01:00
///
2006-02-09 03:24:25 +01:00
unsigned getConstantPoolIndex(Constant *C, unsigned Alignment) {
2006-02-09 03:25:42 +01:00
assert(Alignment && "Alignment must be specified!");
// Check to see if we already have this constant.
//
// FIXME, this could be made much more efficient for large constant pools.
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
2006-02-09 03:24:25 +01:00
if (Constants[i].first == C && Constants[i].second >= Alignment)
return i;
Constants.push_back(std::make_pair(C, Alignment));
2003-01-13 02:01:31 +01:00
return Constants.size()-1;
}
2005-07-11 06:49:33 +02:00
/// isEmpty - Return true if this constant pool contains no constants.
///
bool isEmpty() const { return Constants.empty(); }
const std::vector<std::pair<Constant*,unsigned> > &getConstants() const {
return Constants;
}
2003-01-13 02:01:31 +01: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.
void dump() const;
};
} // End llvm namespace
2003-01-13 02:01:31 +01:00
#endif