mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-11 11:34:02 +00:00
Tidy up. MCAsmBackend naming conventions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
160fee7349
commit
ec3433852d
@ -99,10 +99,10 @@ public:
|
||||
|
||||
/// @}
|
||||
|
||||
/// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
|
||||
/// applyFixup - Apply the \arg Value for given \arg Fixup into the provided
|
||||
/// data fragment, at the offset specified by the fixup and following the
|
||||
/// fixup kind as appropriate.
|
||||
virtual void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
virtual void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const = 0;
|
||||
|
||||
/// @}
|
||||
@ -110,11 +110,11 @@ public:
|
||||
/// @name Target Relaxation Interfaces
|
||||
/// @{
|
||||
|
||||
/// MayNeedRelaxation - Check whether the given instruction may need
|
||||
/// mayNeedRelaxation - Check whether the given instruction may need
|
||||
/// relaxation.
|
||||
///
|
||||
/// \param Inst - The instruction to test.
|
||||
virtual bool MayNeedRelaxation(const MCInst &Inst) const = 0;
|
||||
virtual bool mayNeedRelaxation(const MCInst &Inst) const = 0;
|
||||
|
||||
/// fixupNeedsRelaxation - Target specific predicate for whether a given
|
||||
/// fixup requires the associated instruction to be relaxed.
|
||||
@ -129,20 +129,20 @@ public:
|
||||
/// \param Inst - The instruction to relax, which may be the same as the
|
||||
/// output.
|
||||
/// \parm Res [output] - On return, the relaxed instruction.
|
||||
virtual void RelaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
|
||||
virtual void relaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
|
||||
|
||||
/// @}
|
||||
|
||||
/// WriteNopData - Write an (optimal) nop sequence of Count bytes to the given
|
||||
/// writeNopData - Write an (optimal) nop sequence of Count bytes to the given
|
||||
/// output. If the target cannot generate such a sequence, it should return an
|
||||
/// error.
|
||||
///
|
||||
/// \return - True on success.
|
||||
virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
|
||||
virtual bool writeNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
|
||||
|
||||
/// HandleAssemblerFlag - Handle any target-specific assembler flags.
|
||||
/// handleAssemblerFlag - Handle any target-specific assembler flags.
|
||||
/// By default, do nothing.
|
||||
virtual void HandleAssemblerFlag(MCAssemblerFlag Flag) {}
|
||||
virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -405,7 +405,7 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCAsmLayout &Layout,
|
||||
// bytes left to fill use the the Value and ValueSize to fill the rest.
|
||||
// If we are aligning with nops, ask that target to emit the right data.
|
||||
if (AF.hasEmitNops()) {
|
||||
if (!Asm.getBackend().WriteNopData(Count, OW))
|
||||
if (!Asm.getBackend().writeNopData(Count, OW))
|
||||
report_fatal_error("unable to write nop sequence of " +
|
||||
Twine(Count) + " bytes");
|
||||
break;
|
||||
@ -615,7 +615,7 @@ void MCAssembler::Finish() {
|
||||
ie3 = DF->fixup_end(); it3 != ie3; ++it3) {
|
||||
MCFixup &Fixup = *it3;
|
||||
uint64_t FixedValue = handleFixup(Layout, *DF, Fixup);
|
||||
getBackend().ApplyFixup(Fixup, DF->getContents().data(),
|
||||
getBackend().applyFixup(Fixup, DF->getContents().data(),
|
||||
DF->getContents().size(), FixedValue);
|
||||
}
|
||||
}
|
||||
@ -625,7 +625,7 @@ void MCAssembler::Finish() {
|
||||
ie3 = IF->fixup_end(); it3 != ie3; ++it3) {
|
||||
MCFixup &Fixup = *it3;
|
||||
uint64_t FixedValue = handleFixup(Layout, *IF, Fixup);
|
||||
getBackend().ApplyFixup(Fixup, IF->getCode().data(),
|
||||
getBackend().applyFixup(Fixup, IF->getCode().data(),
|
||||
IF->getCode().size(), FixedValue);
|
||||
}
|
||||
}
|
||||
@ -658,7 +658,7 @@ bool MCAssembler::fragmentNeedsRelaxation(const MCInstFragment *IF,
|
||||
// If this inst doesn't ever need relaxation, ignore it. This occurs when we
|
||||
// are intentionally pushing out inst fragments, or because we relaxed a
|
||||
// previous instruction to one that doesn't need relaxation.
|
||||
if (!getBackend().MayNeedRelaxation(IF->getInst()))
|
||||
if (!getBackend().mayNeedRelaxation(IF->getInst()))
|
||||
return false;
|
||||
|
||||
for (MCInstFragment::const_fixup_iterator it = IF->fixup_begin(),
|
||||
@ -682,7 +682,7 @@ bool MCAssembler::relaxInstruction(MCAsmLayout &Layout,
|
||||
// Relax the fragment.
|
||||
|
||||
MCInst Relaxed;
|
||||
getBackend().RelaxInstruction(IF.getInst(), Relaxed);
|
||||
getBackend().relaxInstruction(IF.getInst(), Relaxed);
|
||||
|
||||
// Encode the new instruction.
|
||||
//
|
||||
|
@ -140,7 +140,7 @@ void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
|
||||
|
||||
void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
|
||||
// Let the target do whatever target specific stuff it needs to do.
|
||||
getAssembler().getBackend().HandleAssemblerFlag(Flag);
|
||||
getAssembler().getBackend().handleAssemblerFlag(Flag);
|
||||
// Do any generic stuff we need to do.
|
||||
switch (Flag) {
|
||||
case MCAF_SyntaxUnified: return; // no-op here.
|
||||
|
@ -172,7 +172,7 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst) {
|
||||
MCLineEntry::Make(this, getCurrentSection());
|
||||
|
||||
// If this instruction doesn't need relaxation, just emit it as data.
|
||||
if (!getAssembler().getBackend().MayNeedRelaxation(Inst)) {
|
||||
if (!getAssembler().getBackend().mayNeedRelaxation(Inst)) {
|
||||
EmitInstToData(Inst);
|
||||
return;
|
||||
}
|
||||
@ -181,9 +181,9 @@ void MCObjectStreamer::EmitInstruction(const MCInst &Inst) {
|
||||
// possible and emit it as data.
|
||||
if (getAssembler().getRelaxAll()) {
|
||||
MCInst Relaxed;
|
||||
getAssembler().getBackend().RelaxInstruction(Inst, Relaxed);
|
||||
while (getAssembler().getBackend().MayNeedRelaxation(Relaxed))
|
||||
getAssembler().getBackend().RelaxInstruction(Relaxed, Relaxed);
|
||||
getAssembler().getBackend().relaxInstruction(Inst, Relaxed);
|
||||
while (getAssembler().getBackend().mayNeedRelaxation(Relaxed))
|
||||
getAssembler().getBackend().relaxInstruction(Relaxed, Relaxed);
|
||||
EmitInstToData(Relaxed);
|
||||
return;
|
||||
}
|
||||
|
@ -120,18 +120,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool MayNeedRelaxation(const MCInst &Inst) const;
|
||||
bool mayNeedRelaxation(const MCInst &Inst) const;
|
||||
|
||||
bool fixupNeedsRelaxation(const MCFixup &Fixup,
|
||||
uint64_t Value,
|
||||
const MCInstFragment *DF,
|
||||
const MCAsmLayout &Layout) const;
|
||||
|
||||
void RelaxInstruction(const MCInst &Inst, MCInst &Res) const;
|
||||
void relaxInstruction(const MCInst &Inst, MCInst &Res) const;
|
||||
|
||||
bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
|
||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const;
|
||||
|
||||
void HandleAssemblerFlag(MCAssemblerFlag Flag) {
|
||||
void handleAssemblerFlag(MCAssemblerFlag Flag) {
|
||||
switch (Flag) {
|
||||
default: break;
|
||||
case MCAF_Code16:
|
||||
@ -156,7 +156,7 @@ static unsigned getRelaxedOpcode(unsigned Op) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ARMAsmBackend::MayNeedRelaxation(const MCInst &Inst) const {
|
||||
bool ARMAsmBackend::mayNeedRelaxation(const MCInst &Inst) const {
|
||||
if (getRelaxedOpcode(Inst.getOpcode()) != Inst.getOpcode())
|
||||
return true;
|
||||
return false;
|
||||
@ -176,7 +176,7 @@ bool ARMAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup,
|
||||
return Offset > 254 || Offset < -256;
|
||||
}
|
||||
|
||||
void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
void ARMAsmBackend::relaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
unsigned RelaxedOp = getRelaxedOpcode(Inst.getOpcode());
|
||||
|
||||
// Sanity check w/ diagnostic if we get here w/ a bogus instruction.
|
||||
@ -194,7 +194,7 @@ void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
Res.setOpcode(RelaxedOp);
|
||||
}
|
||||
|
||||
bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
bool ARMAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
const uint16_t Thumb1_16bitNopEncoding = 0x46c0; // using MOV r8,r8
|
||||
const uint16_t Thumb2_16bitNopEncoding = 0xbf00; // NOP
|
||||
const uint32_t ARMv4_NopEncoding = 0xe1a0000; // using MOV r0,r0
|
||||
@ -471,7 +471,7 @@ public:
|
||||
uint8_t _OSABI)
|
||||
: ARMAsmBackend(T, TT), OSABI(_OSABI) { }
|
||||
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const;
|
||||
|
||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||
@ -480,7 +480,7 @@ public:
|
||||
};
|
||||
|
||||
// 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 NumBytes = 4; // FIXME: 2 for Thumb
|
||||
Value = adjustFixupValue(Fixup.getKind(), Value);
|
||||
@ -509,7 +509,7 @@ public:
|
||||
Subtype);
|
||||
}
|
||||
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const;
|
||||
|
||||
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
||||
@ -562,7 +562,7 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
|
||||
}
|
||||
}
|
||||
|
||||
void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
|
||||
void DarwinARMAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
||||
unsigned DataSize, uint64_t Value) const {
|
||||
unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
|
||||
Value = adjustFixupValue(Fixup.getKind(), Value);
|
||||
|
@ -50,16 +50,16 @@ public:
|
||||
return 2;
|
||||
}
|
||||
|
||||
bool MayNeedRelaxation(const MCInst &Inst) const;
|
||||
bool mayNeedRelaxation(const MCInst &Inst) const;
|
||||
|
||||
bool fixupNeedsRelaxation(const MCFixup &Fixup,
|
||||
uint64_t Value,
|
||||
const MCInstFragment *DF,
|
||||
const MCAsmLayout &Layout) const;
|
||||
|
||||
void RelaxInstruction(const MCInst &Inst, MCInst &Res) const;
|
||||
void relaxInstruction(const MCInst &Inst, MCInst &Res) const;
|
||||
|
||||
bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
|
||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const;
|
||||
|
||||
unsigned getPointerSize() const {
|
||||
return 4;
|
||||
@ -75,7 +75,7 @@ static unsigned getRelaxedOpcode(unsigned Op) {
|
||||
}
|
||||
}
|
||||
|
||||
bool MBlazeAsmBackend::MayNeedRelaxation(const MCInst &Inst) const {
|
||||
bool MBlazeAsmBackend::mayNeedRelaxation(const MCInst &Inst) const {
|
||||
if (getRelaxedOpcode(Inst.getOpcode()) == Inst.getOpcode())
|
||||
return false;
|
||||
|
||||
@ -98,12 +98,12 @@ bool MBlazeAsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup,
|
||||
return int64_t(Value) != int64_t(int8_t(Value));
|
||||
}
|
||||
|
||||
void MBlazeAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
void MBlazeAsmBackend::relaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
Res = Inst;
|
||||
Res.setOpcode(getRelaxedOpcode(Inst.getOpcode()));
|
||||
}
|
||||
|
||||
bool MBlazeAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
bool MBlazeAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
if ((Count % 4) != 0)
|
||||
return false;
|
||||
|
||||
@ -121,7 +121,7 @@ public:
|
||||
ELFMBlazeAsmBackend(const Target &T, uint8_t _OSABI)
|
||||
: MBlazeAsmBackend(T), OSABI(_OSABI) { }
|
||||
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const;
|
||||
|
||||
MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
|
||||
@ -129,7 +129,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void ELFMBlazeAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
|
||||
void ELFMBlazeAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
||||
unsigned DataSize, uint64_t Value) const {
|
||||
unsigned Size = getFixupKindSize(Fixup.getKind());
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
/// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
|
||||
/// data fragment, at the offset specified by the fixup and following the
|
||||
/// fixup kind as appropriate.
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const {
|
||||
MCFixupKind Kind = Fixup.getKind();
|
||||
Value = adjustFixupValue((unsigned)Kind, Value);
|
||||
@ -155,7 +155,7 @@ public:
|
||||
/// relaxation.
|
||||
///
|
||||
/// \param Inst - The instruction to test.
|
||||
bool MayNeedRelaxation(const MCInst &Inst) const {
|
||||
bool mayNeedRelaxation(const MCInst &Inst) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public:
|
||||
/// \param Inst - The instruction to relax, which may be the same
|
||||
/// as the output.
|
||||
/// \parm Res [output] - On return, the relaxed instruction.
|
||||
void RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
void relaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
}
|
||||
|
||||
/// @}
|
||||
@ -186,7 +186,7 @@ public:
|
||||
/// it should return an error.
|
||||
///
|
||||
/// \return - True on success.
|
||||
bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
return Infos[Kind - FirstTargetFixupKind];
|
||||
}
|
||||
|
||||
bool MayNeedRelaxation(const MCInst &Inst) const {
|
||||
bool mayNeedRelaxation(const MCInst &Inst) const {
|
||||
// FIXME.
|
||||
return false;
|
||||
}
|
||||
@ -92,17 +92,17 @@ public:
|
||||
const MCInstFragment *DF,
|
||||
const MCAsmLayout &Layout) const {
|
||||
// FIXME.
|
||||
assert(0 && "RelaxInstruction() unimplemented");
|
||||
assert(0 && "relaxInstruction() unimplemented");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
void relaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
// FIXME.
|
||||
assert(0 && "RelaxInstruction() unimplemented");
|
||||
assert(0 && "relaxInstruction() unimplemented");
|
||||
}
|
||||
|
||||
bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
// FIXME: Zero fill for now. That's not right, but at least will get the
|
||||
// section size right.
|
||||
for (uint64_t i = 0; i != Count; ++i)
|
||||
@ -126,7 +126,7 @@ namespace {
|
||||
public:
|
||||
DarwinPPCAsmBackend(const Target &T) : PPCAsmBackend(T) { }
|
||||
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const {
|
||||
assert(0 && "UNIMP");
|
||||
}
|
||||
@ -152,7 +152,7 @@ namespace {
|
||||
ELFPPCAsmBackend(const Target &T, uint8_t OSABI) :
|
||||
PPCAsmBackend(T), OSABI(OSABI) { }
|
||||
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const {
|
||||
Value = adjustFixupValue(Fixup.getKind(), Value);
|
||||
if (!Value) return; // Doesn't change encoding.
|
||||
|
@ -91,7 +91,7 @@ public:
|
||||
return Infos[Kind - FirstTargetFixupKind];
|
||||
}
|
||||
|
||||
void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||
uint64_t Value) const {
|
||||
unsigned Size = 1 << getFixupKindLog2Size(Fixup.getKind());
|
||||
|
||||
@ -109,16 +109,16 @@ public:
|
||||
Data[Fixup.getOffset() + i] = uint8_t(Value >> (i * 8));
|
||||
}
|
||||
|
||||
bool MayNeedRelaxation(const MCInst &Inst) const;
|
||||
bool mayNeedRelaxation(const MCInst &Inst) const;
|
||||
|
||||
bool fixupNeedsRelaxation(const MCFixup &Fixup,
|
||||
uint64_t Value,
|
||||
const MCInstFragment *DF,
|
||||
const MCAsmLayout &Layout) const;
|
||||
|
||||
void RelaxInstruction(const MCInst &Inst, MCInst &Res) const;
|
||||
void relaxInstruction(const MCInst &Inst, MCInst &Res) const;
|
||||
|
||||
bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
|
||||
bool writeNopData(uint64_t Count, MCObjectWriter *OW) const;
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
@ -223,7 +223,7 @@ static unsigned getRelaxedOpcode(unsigned Op) {
|
||||
return getRelaxedOpcodeBranch(Op);
|
||||
}
|
||||
|
||||
bool X86AsmBackend::MayNeedRelaxation(const MCInst &Inst) const {
|
||||
bool X86AsmBackend::mayNeedRelaxation(const MCInst &Inst) const {
|
||||
// Branches can always be relaxed.
|
||||
if (getRelaxedOpcodeBranch(Inst.getOpcode()) != Inst.getOpcode())
|
||||
return true;
|
||||
@ -263,7 +263,7 @@ bool X86AsmBackend::fixupNeedsRelaxation(const MCFixup &Fixup,
|
||||
|
||||
// FIXME: Can tblgen help at all here to verify there aren't other instructions
|
||||
// we can relax?
|
||||
void X86AsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
void X86AsmBackend::relaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
// The only relaxations X86 does is from a 1byte pcrel to a 4byte pcrel.
|
||||
unsigned RelaxedOp = getRelaxedOpcode(Inst.getOpcode());
|
||||
|
||||
@ -279,10 +279,10 @@ void X86AsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
|
||||
Res.setOpcode(RelaxedOp);
|
||||
}
|
||||
|
||||
/// WriteNopData - Write optimal nops to the output file for the \arg Count
|
||||
/// writeNopData - Write optimal nops to the output file for the \arg Count
|
||||
/// bytes. This returns the number of bytes written. It may return 0 if
|
||||
/// the \arg Count is more than the maximum optimal nops.
|
||||
bool X86AsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
bool X86AsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
|
||||
static const uint8_t Nops[10][10] = {
|
||||
// nop
|
||||
{0x90},
|
||||
|
Loading…
x
Reference in New Issue
Block a user