mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +00:00
A bit of cleanup: early exit ApplyFixup and cache the Fixup offset. No
functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121195 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2196caab82
commit
52e635ea35
@ -133,6 +133,7 @@ static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// FIXME: This should be in a separate file.
|
// FIXME: This should be in a separate file.
|
||||||
// ELF is an ELF of course...
|
// ELF is an ELF of course...
|
||||||
class ELFARMAsmBackend : public ARMAsmBackend {
|
class ELFARMAsmBackend : public ARMAsmBackend {
|
||||||
@ -160,24 +161,24 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fixme: Raise this to share code between Darwin and ELF.
|
// FIXME: Raise this to share code between Darwin and ELF.
|
||||||
void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
|
void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
|
||||||
unsigned DataSize, uint64_t Value) const {
|
unsigned DataSize, uint64_t Value) const {
|
||||||
// Fixme: 2 for Thumb
|
unsigned NumBytes = 4; // FIXME: 2 for Thumb
|
||||||
unsigned NumBytes = 4;
|
|
||||||
Value = adjustFixupValue(Fixup.getKind(), Value);
|
|
||||||
|
|
||||||
assert((Fixup.getOffset() % NumBytes == 0)
|
Value = adjustFixupValue(Fixup.getKind(), Value);
|
||||||
&& "Offset mod NumBytes is nonzero!");
|
if (!Value) return; // No need to encode nothing.
|
||||||
// For each byte of the fragment that the fixup touches, mask in the
|
|
||||||
// bits from the fixup value.
|
unsigned Offset = Fixup.getOffset();
|
||||||
// The Value has been "split up" into the appropriate bitfields above.
|
assert(Offset % NumBytes == 0 && "Offset mod NumBytes is nonzero!");
|
||||||
for (unsigned i = 0; i != NumBytes; ++i) {
|
|
||||||
Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8));
|
// For each byte of the fragment that the fixup touches, mask in the bits from
|
||||||
}
|
// the fixup value. The Value has been "split up" into the appropriate
|
||||||
|
// bitfields above.
|
||||||
|
for (unsigned i = 0; i != NumBytes; ++i)
|
||||||
|
Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
// FIXME: This should be in a separate file.
|
// FIXME: This should be in a separate file.
|
||||||
class DarwinARMAsmBackend : public ARMAsmBackend {
|
class DarwinARMAsmBackend : public ARMAsmBackend {
|
||||||
MCMachOObjectFormat Format;
|
MCMachOObjectFormat Format;
|
||||||
@ -205,7 +206,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // end anonymous namespace
|
|
||||||
|
|
||||||
static unsigned getFixupKindNumBytes(unsigned Kind) {
|
static unsigned getFixupKindNumBytes(unsigned Kind) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
@ -235,6 +235,7 @@ void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
|
|||||||
for (unsigned i = 0; i != NumBytes; ++i)
|
for (unsigned i = 0; i != NumBytes; ++i)
|
||||||
Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8));
|
Data[Fixup.getOffset() + i] |= uint8_t(Value >> (i * 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,
|
TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user