mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
instead of keeping track of Constant/alignment pairs, actually compute the
offset of each entry from the start of the constant pool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26077 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -24,41 +24,38 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class Constant;
|
class Constant;
|
||||||
|
class TargetData;
|
||||||
|
|
||||||
/// MachineConstantPoolEntry - One entry in the constant pool.
|
/// MachineConstantPoolEntry - One entry in the constant pool.
|
||||||
///
|
///
|
||||||
struct MachineConstantPoolEntry {
|
struct MachineConstantPoolEntry {
|
||||||
/// Val - The constant itself.
|
/// Val - The constant itself.
|
||||||
Constant *Val;
|
Constant *Val;
|
||||||
/// Alignment - The alignment of the constant.
|
/// Offset - The offset of the constant from the start of the constant pool.
|
||||||
unsigned Alignment;
|
unsigned Offset;
|
||||||
|
|
||||||
MachineConstantPoolEntry(Constant *V, unsigned A) : Val(V), Alignment(A) {}
|
MachineConstantPoolEntry(Constant *V, unsigned O) : Val(V), Offset(O) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class MachineConstantPool {
|
class MachineConstantPool {
|
||||||
|
const TargetData &TD;
|
||||||
|
unsigned PoolAlignment;
|
||||||
std::vector<MachineConstantPoolEntry> Constants;
|
std::vector<MachineConstantPoolEntry> Constants;
|
||||||
public:
|
public:
|
||||||
|
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; }
|
||||||
|
|
||||||
/// getConstantPoolIndex - Create a new entry in the constant pool or return
|
/// getConstantPoolIndex - Create a new entry in the constant pool or return
|
||||||
/// an existing one. User must specify an alignment in bytes for the object.
|
/// an existing one. User must specify an alignment in bytes for the object.
|
||||||
///
|
///
|
||||||
unsigned getConstantPoolIndex(Constant *C, unsigned Alignment) {
|
unsigned getConstantPoolIndex(Constant *C, unsigned Alignment);
|
||||||
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)
|
|
||||||
if (Constants[i].Val == C && Constants[i].Alignment >= Alignment)
|
|
||||||
return i;
|
|
||||||
Constants.push_back(MachineConstantPoolEntry(C, Alignment));
|
|
||||||
return Constants.size()-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// isEmpty - Return true if this constant pool contains no constants.
|
/// isEmpty - Return true if this constant pool contains no constants.
|
||||||
///
|
///
|
||||||
@ -74,6 +71,7 @@ public:
|
|||||||
void print(std::ostream &OS) const;
|
void print(std::ostream &OS) const;
|
||||||
|
|
||||||
/// dump - Call print(std::cerr) to be called from the debugger.
|
/// dump - Call print(std::cerr) to be called from the debugger.
|
||||||
|
///
|
||||||
void dump() const;
|
void dump() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user