mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-19 06:31:18 +00:00
Use generic section-handling stuff to emit constant pool entries
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dbab2d2272
commit
088ae8393f
@ -366,8 +366,6 @@ namespace llvm {
|
|||||||
const GlobalValue *findGlobalValue(const Constant* CV);
|
const GlobalValue *findGlobalValue(const Constant* CV);
|
||||||
void EmitLLVMUsedList(Constant *List);
|
void EmitLLVMUsedList(Constant *List);
|
||||||
void EmitXXStructorList(Constant *List);
|
void EmitXXStructorList(Constant *List);
|
||||||
void EmitConstantPool(unsigned Alignment, const char *Section,
|
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > &CP);
|
|
||||||
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
|
GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
|
#include "llvm/ADT/DenseSet.h"
|
||||||
#include "llvm/ADT/SmallPtrSet.h"
|
#include "llvm/ADT/SmallPtrSet.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
@ -255,60 +256,50 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
|
|||||||
const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
|
const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
|
||||||
if (CP.empty()) return;
|
if (CP.empty()) return;
|
||||||
|
|
||||||
// Some targets require 4-, 8-, and 16- byte constant literals to be placed
|
// Calculate sections for constant pool entries. We collect entries to go into
|
||||||
// in special sections.
|
// the same section together to reduce amount of section switch statements.
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > FourByteCPs;
|
typedef
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > EightByteCPs;
|
std::multimap<const Section*,
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > SixteenByteCPs;
|
std::pair<MachineConstantPoolEntry, unsigned> > CPMap;
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > OtherCPs;
|
CPMap CPs;
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > TargetCPs;
|
DenseSet<const Section*> Sections;
|
||||||
|
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
||||||
MachineConstantPoolEntry CPE = CP[i];
|
MachineConstantPoolEntry CPE = CP[i];
|
||||||
const Type *Ty = CPE.getType();
|
const Section* S = TAI->SelectSectionForMachineConst(CPE.getType());
|
||||||
if (TAI->getFourByteConstantSection() &&
|
CPs.insert(std::make_pair(S, std::make_pair(CPE, i)));
|
||||||
TM.getTargetData()->getABITypeSize(Ty) == 4)
|
Sections.insert(S);
|
||||||
FourByteCPs.push_back(std::make_pair(CPE, i));
|
|
||||||
else if (TAI->getEightByteConstantSection() &&
|
|
||||||
TM.getTargetData()->getABITypeSize(Ty) == 8)
|
|
||||||
EightByteCPs.push_back(std::make_pair(CPE, i));
|
|
||||||
else if (TAI->getSixteenByteConstantSection() &&
|
|
||||||
TM.getTargetData()->getABITypeSize(Ty) == 16)
|
|
||||||
SixteenByteCPs.push_back(std::make_pair(CPE, i));
|
|
||||||
else
|
|
||||||
OtherCPs.push_back(std::make_pair(CPE, i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Alignment = MCP->getConstantPoolAlignment();
|
// Now print stuff into the calculated sections.
|
||||||
EmitConstantPool(Alignment, TAI->getFourByteConstantSection(), FourByteCPs);
|
for (DenseSet<const Section*>::iterator IS = Sections.begin(),
|
||||||
EmitConstantPool(Alignment, TAI->getEightByteConstantSection(), EightByteCPs);
|
ES = Sections.end(); IS != ES; ++IS) {
|
||||||
EmitConstantPool(Alignment, TAI->getSixteenByteConstantSection(),
|
SwitchToSection(*IS);
|
||||||
SixteenByteCPs);
|
EmitAlignment(MCP->getConstantPoolAlignment());
|
||||||
EmitConstantPool(Alignment, TAI->getConstantPoolSection(), OtherCPs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AsmPrinter::EmitConstantPool(unsigned Alignment, const char *Section,
|
std::pair<CPMap::iterator, CPMap::iterator> II = CPs.equal_range(*IS);
|
||||||
std::vector<std::pair<MachineConstantPoolEntry,unsigned> > &CP) {
|
for (CPMap::iterator I = II.first, E = II.second; I != E; ++I) {
|
||||||
if (CP.empty()) return;
|
CPMap::iterator J = next(I);
|
||||||
|
MachineConstantPoolEntry Entry = I->second.first;
|
||||||
|
unsigned index = I->second.second;
|
||||||
|
|
||||||
SwitchToDataSection(Section);
|
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
|
||||||
EmitAlignment(Alignment);
|
<< index << ":\t\t\t\t\t";
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
|
||||||
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
|
|
||||||
<< CP[i].second << ":\t\t\t\t\t";
|
|
||||||
// O << TAI->getCommentString() << ' ' <<
|
// O << TAI->getCommentString() << ' ' <<
|
||||||
// WriteTypeSymbolic(O, CP[i].first.getType(), 0);
|
// WriteTypeSymbolic(O, CP[i].first.getType(), 0);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
if (CP[i].first.isMachineConstantPoolEntry())
|
if (Entry.isMachineConstantPoolEntry())
|
||||||
EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
|
EmitMachineConstantPoolValue(Entry.Val.MachineCPVal);
|
||||||
else
|
else
|
||||||
EmitGlobalConstant(CP[i].first.Val.ConstVal);
|
EmitGlobalConstant(Entry.Val.ConstVal);
|
||||||
if (i != e-1) {
|
|
||||||
const Type *Ty = CP[i].first.getType();
|
|
||||||
unsigned EntSize =
|
|
||||||
TM.getTargetData()->getABITypeSize(Ty);
|
|
||||||
unsigned ValEnd = CP[i].first.getOffset() + EntSize;
|
|
||||||
// Emit inter-object padding for alignment.
|
// Emit inter-object padding for alignment.
|
||||||
EmitZeros(CP[i+1].first.getOffset()-ValEnd);
|
if (J != E) {
|
||||||
|
const Type *Ty = Entry.getType();
|
||||||
|
unsigned EntSize = TM.getTargetData()->getABITypeSize(Ty);
|
||||||
|
unsigned ValEnd = Entry.getOffset() + EntSize;
|
||||||
|
EmitZeros(J->second.first.getOffset()-ValEnd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user