mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
make getFixupKindInfo return a const reference, allowing
the tables to be const. Teach MCCodeEmitter to handle the target-indep kinds so that we don't crash on them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95924 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9637dd50f4
commit
8d31de6268
@ -56,7 +56,7 @@ public:
|
||||
virtual unsigned getNumFixupKinds() const = 0;
|
||||
|
||||
/// getFixupKindInfo - Get information on a fixup kind.
|
||||
virtual MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const = 0;
|
||||
virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
|
||||
|
||||
/// @}
|
||||
|
||||
|
@ -552,7 +552,7 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
|
||||
|
||||
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
|
||||
MCFixup &F = Fixups[i];
|
||||
MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
|
||||
const MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
|
||||
for (unsigned j = 0; j != Info.TargetSize; ++j) {
|
||||
unsigned Index = F.getOffset() * 8 + Info.TargetOffset + j;
|
||||
assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
|
||||
@ -599,7 +599,7 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
|
||||
|
||||
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
|
||||
MCFixup &F = Fixups[i];
|
||||
MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
|
||||
const MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
|
||||
OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
|
||||
<< ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
|
||||
}
|
||||
|
@ -16,3 +16,15 @@ MCCodeEmitter::MCCodeEmitter() {
|
||||
|
||||
MCCodeEmitter::~MCCodeEmitter() {
|
||||
}
|
||||
|
||||
const MCFixupKindInfo &MCCodeEmitter::getFixupKindInfo(MCFixupKind Kind) const {
|
||||
static const MCFixupKindInfo Builtins[] = {
|
||||
{ "FK_Data_1", 0, 8 },
|
||||
{ "FK_Data_2", 0, 16 },
|
||||
{ "FK_Data_4", 0, 32 },
|
||||
{ "FK_Data_8", 0, 64 }
|
||||
};
|
||||
|
||||
assert(Kind <= 3 && "Unknown fixup kind");
|
||||
return Builtins[Kind];
|
||||
}
|
||||
|
@ -45,16 +45,19 @@ public:
|
||||
~X86MCCodeEmitter() {}
|
||||
|
||||
unsigned getNumFixupKinds() const {
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
|
||||
static MCFixupKindInfo Infos[] = {
|
||||
const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
|
||||
const static MCFixupKindInfo Infos[] = {
|
||||
{ "reloc_pcrel_4byte", 0, 4 * 8 },
|
||||
{ "reloc_pcrel_1byte", 0, 1 * 8 }
|
||||
};
|
||||
|
||||
assert(Kind >= FirstTargetFixupKind && Kind < MaxTargetFixupKind &&
|
||||
if (Kind < FirstTargetFixupKind)
|
||||
return MCCodeEmitter::getFixupKindInfo(Kind);
|
||||
|
||||
assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
|
||||
"Invalid kind!");
|
||||
return Infos[Kind - FirstTargetFixupKind];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user