From fdc1645b20c6235bb359b686d8a5917a62fe9212 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Thu, 21 Sep 2017 14:04:47 +0000 Subject: [PATCH] [mips] Do not pass redundant IsN64 flag to MCELFObjectTargetWriter. NFC Now we pass the 'Is64_' flag to the MCELFObjectTargetWriter ctor iif when we make deal with N64 ABI. So it is redundant to pass additional 'IsN64' flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313878 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFObjectWriter.h | 4 +--- lib/MC/ELFObjectWriter.cpp | 2 +- lib/MC/MCELFObjectTargetWriter.cpp | 12 ++++-------- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 9 ++++----- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h index 2efd37924e2..d32b56a4ba0 100644 --- a/include/llvm/MC/MCELFObjectWriter.h +++ b/include/llvm/MC/MCELFObjectWriter.h @@ -55,11 +55,10 @@ class MCELFObjectTargetWriter { const uint16_t EMachine; const unsigned HasRelocationAddend : 1; const unsigned Is64Bit : 1; - const unsigned IsN64 : 1; protected: MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_, uint16_t EMachine_, - bool HasRelocationAddend, bool IsN64 = false); + bool HasRelocationAddend); public: virtual ~MCELFObjectTargetWriter() = default; @@ -91,7 +90,6 @@ public: uint16_t getEMachine() const { return EMachine; } bool hasRelocationAddend() const { return HasRelocationAddend; } bool is64Bit() const { return Is64Bit; } - bool isN64() const { return IsN64; } /// @} // Instead of changing everyone's API we pack the N64 Type fields diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index c8dd6301194..b37a950908e 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -1108,7 +1108,7 @@ void ELFObjectWriter::writeRelocations(const MCAssembler &Asm, if (is64Bit()) { write(Entry.Offset); - if (TargetObjectWriter->isN64()) { + if (TargetObjectWriter->getEMachine() == ELF::EM_MIPS) { write(uint32_t(Index)); write(TargetObjectWriter->getRSsym(Entry.Type)); diff --git a/lib/MC/MCELFObjectTargetWriter.cpp b/lib/MC/MCELFObjectTargetWriter.cpp index 68fb5e7cbb3..483ee94c0db 100644 --- a/lib/MC/MCELFObjectTargetWriter.cpp +++ b/lib/MC/MCELFObjectTargetWriter.cpp @@ -11,15 +11,11 @@ using namespace llvm; -MCELFObjectTargetWriter::MCELFObjectTargetWriter(bool Is64Bit_, - uint8_t OSABI_, +MCELFObjectTargetWriter::MCELFObjectTargetWriter(bool Is64Bit_, uint8_t OSABI_, uint16_t EMachine_, - bool HasRelocationAddend_, - bool IsN64_) - : OSABI(OSABI_), EMachine(EMachine_), - HasRelocationAddend(HasRelocationAddend_), Is64Bit(Is64Bit_), - IsN64(IsN64_){ -} + bool HasRelocationAddend_) + : OSABI(OSABI_), EMachine(EMachine_), + HasRelocationAddend(HasRelocationAddend_), Is64Bit(Is64Bit_) {} bool MCELFObjectTargetWriter::needsRelocateWithSymbol(const MCSymbol &Sym, unsigned Type) const { diff --git a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp index 5c78799996f..4339eca93f1 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp @@ -55,7 +55,7 @@ raw_ostream &operator<<(raw_ostream &OS, const MipsRelocationEntry &RHS) { class MipsELFObjectWriter : public MCELFObjectTargetWriter { public: - MipsELFObjectWriter(uint8_t OSABI, bool HasRelocationAddend, bool IsN64, + MipsELFObjectWriter(uint8_t OSABI, bool HasRelocationAddend, bool Is64, bool IsLittleEndian); ~MipsELFObjectWriter() override = default; @@ -210,10 +210,9 @@ static void dumpRelocs(const char *Prefix, const Container &Relocs) { #endif MipsELFObjectWriter::MipsELFObjectWriter(uint8_t OSABI, - bool HasRelocationAddend, bool IsN64, + bool HasRelocationAddend, bool Is64, bool IsLittleEndian) - : MCELFObjectTargetWriter(IsN64, OSABI, ELF::EM_MIPS, HasRelocationAddend, - IsN64) {} + : MCELFObjectTargetWriter(Is64, OSABI, ELF::EM_MIPS, HasRelocationAddend) {} unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target, @@ -282,7 +281,7 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx, case FK_TPRel_8: return ELF::R_MIPS_TLS_TPREL64; case FK_GPRel_4: - if (isN64()) { + if (is64Bit()) { unsigned Type = (unsigned)ELF::R_MIPS_NONE; Type = setRType((unsigned)ELF::R_MIPS_GPREL32, Type); Type = setRType2((unsigned)ELF::R_MIPS_64, Type); -- 2.40.0