mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
simplify this code now that each constant pool entry is not separately allocated
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3029f92051
commit
239862ce99
@ -419,18 +419,19 @@ namespace {
|
|||||||
// save CurBlock and CurByte here.
|
// save CurBlock and CurByte here.
|
||||||
unsigned char *SavedCurBlock, *SavedCurByte;
|
unsigned char *SavedCurBlock, *SavedCurByte;
|
||||||
|
|
||||||
// ConstantPoolAddresses - Contains the location for each entry in the
|
|
||||||
// constant pool.
|
|
||||||
std::vector<void*> ConstantPoolAddresses;
|
|
||||||
|
|
||||||
/// Relocations - These are the relocations that the function needs, as
|
/// Relocations - These are the relocations that the function needs, as
|
||||||
/// emitted.
|
/// emitted.
|
||||||
std::vector<MachineRelocation> Relocations;
|
std::vector<MachineRelocation> Relocations;
|
||||||
|
|
||||||
|
/// ConstantPool - The constant pool for the current function.
|
||||||
|
///
|
||||||
|
MachineConstantPool *ConstantPool;
|
||||||
|
|
||||||
|
/// ConstantPoolBase - A pointer to the first entry in the constant pool.
|
||||||
|
///
|
||||||
|
void *ConstantPoolBase;
|
||||||
public:
|
public:
|
||||||
JITEmitter(JIT &jit)
|
JITEmitter(JIT &jit) : MemMgr(jit.getJITInfo().needsGOT()) {
|
||||||
:MemMgr(jit.getJITInfo().needsGOT())
|
|
||||||
{
|
|
||||||
TheJIT = &jit;
|
TheJIT = &jit;
|
||||||
DEBUG(std::cerr <<
|
DEBUG(std::cerr <<
|
||||||
(MemMgr.isManagingGOT() ? "JIT is managing GOT\n"
|
(MemMgr.isManagingGOT() ? "JIT is managing GOT\n"
|
||||||
@ -562,7 +563,6 @@ void JITEmitter::finishFunction(MachineFunction &F) {
|
|||||||
<< ": " << CurByte-CurBlock << " bytes of text, "
|
<< ": " << CurByte-CurBlock << " bytes of text, "
|
||||||
<< Relocations.size() << " relocations\n");
|
<< Relocations.size() << " relocations\n");
|
||||||
Relocations.clear();
|
Relocations.clear();
|
||||||
ConstantPoolAddresses.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
|
void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
|
||||||
@ -572,14 +572,14 @@ void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
|
|||||||
unsigned Size = Constants.back().Offset;
|
unsigned Size = Constants.back().Offset;
|
||||||
Size += TheJIT->getTargetData().getTypeSize(Constants.back().Val->getType());
|
Size += TheJIT->getTargetData().getTypeSize(Constants.back().Val->getType());
|
||||||
|
|
||||||
void *Addr = MemMgr.allocateConstant(Size,
|
ConstantPoolBase = MemMgr.allocateConstant(Size,
|
||||||
1 << MCP->getConstantPoolAlignment());
|
1 << MCP->getConstantPoolAlignment());
|
||||||
|
ConstantPool = MCP;
|
||||||
// FIXME: Can eliminate ConstantPoolAddresses!
|
|
||||||
|
// Initialize the memory for all of the constant pool entries.
|
||||||
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
|
||||||
void *CAddr = (char*)Addr+Constants[i].Offset;
|
void *CAddr = (char*)ConstantPoolBase+Constants[i].Offset;
|
||||||
TheJIT->InitializeMemory(Constants[i].Val, CAddr);
|
TheJIT->InitializeMemory(Constants[i].Val, CAddr);
|
||||||
ConstantPoolAddresses.push_back(CAddr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,9 +615,10 @@ void JITEmitter::emitWordAt(unsigned W, unsigned *Ptr) {
|
|||||||
// method.
|
// method.
|
||||||
//
|
//
|
||||||
uint64_t JITEmitter::getConstantPoolEntryAddress(unsigned ConstantNum) {
|
uint64_t JITEmitter::getConstantPoolEntryAddress(unsigned ConstantNum) {
|
||||||
assert(ConstantNum < ConstantPoolAddresses.size() &&
|
assert(ConstantNum < ConstantPool->getConstants().size() &&
|
||||||
"Invalid ConstantPoolIndex!");
|
"Invalid ConstantPoolIndex!");
|
||||||
return (intptr_t)ConstantPoolAddresses[ConstantNum];
|
return (intptr_t)ConstantPoolBase +
|
||||||
|
ConstantPool->getConstants()[ConstantNum].Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* JITEmitter::allocateGlobal(unsigned size, unsigned alignment)
|
unsigned char* JITEmitter::allocateGlobal(unsigned size, unsigned alignment)
|
||||||
|
Loading…
Reference in New Issue
Block a user