[lld] r238685 - [Mips] Delete MipsReginfo structure. Use the Elf_Mips_RegInfo instead.
Simon Atanasyan
simon at atanasyan.com
Sun May 31 13:36:21 PDT 2015
Author: atanasyan
Date: Sun May 31 15:36:21 2015
New Revision: 238685
URL: http://llvm.org/viewvc/llvm-project?rev=238685&view=rev
Log:
[Mips] Delete MipsReginfo structure. Use the Elf_Mips_RegInfo instead.
Removed:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp?rev=238685&r1=238684&r2=238685&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp Sun May 31 15:36:21 2015
@@ -61,16 +61,6 @@ static bool matchMipsISA(unsigned base,
namespace lld {
namespace elf {
-template <class ELFT> uint32_t MipsAbiInfoHandler<ELFT>::getFlags() const {
- return _flags;
-}
-
-template <class ELFT>
-const llvm::Optional<MipsReginfo> &
-MipsAbiInfoHandler<ELFT>::getRegistersMask() const {
- return _regMask;
-}
-
template <class ELFT>
std::error_code MipsAbiInfoHandler<ELFT>::mergeFlags(uint32_t newFlags) {
// We support two ABI: O32 and N64. The last one does not have
@@ -151,12 +141,18 @@ std::error_code MipsAbiInfoHandler<ELFT>
}
template <class ELFT>
-void MipsAbiInfoHandler<ELFT>::mergeRegistersMask(const MipsReginfo &info) {
+void MipsAbiInfoHandler<ELFT>::mergeRegistersMask(
+ const Elf_Mips_RegInfo &info) {
std::lock_guard<std::mutex> lock(_mutex);
- if (_regMask.hasValue())
- _regMask->merge(info);
- else
+ if (!_regMask.hasValue()) {
_regMask = info;
+ return;
+ }
+ _regMask->ri_gprmask = _regMask->ri_gprmask | info.ri_gprmask;
+ _regMask->ri_cprmask[0] = _regMask->ri_cprmask[0] | info.ri_cprmask[0];
+ _regMask->ri_cprmask[1] = _regMask->ri_cprmask[1] | info.ri_cprmask[1];
+ _regMask->ri_cprmask[2] = _regMask->ri_cprmask[2] | info.ri_cprmask[2];
+ _regMask->ri_cprmask[3] = _regMask->ri_cprmask[3] | info.ri_cprmask[3];
}
template class MipsAbiInfoHandler<ELF32LE>;
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h?rev=238685&r1=238684&r2=238685&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h Sun May 31 15:36:21 2015
@@ -9,8 +9,8 @@
#ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_ABI_INFO_HANDLER_H
#define LLD_READER_WRITER_ELF_MIPS_MIPS_ABI_INFO_HANDLER_H
-#include "MipsReginfo.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/Object/ELFTypes.h"
#include <mutex>
#include <system_error>
@@ -19,21 +19,25 @@ namespace elf {
template <class ELFT> class MipsAbiInfoHandler {
public:
+ typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
+
MipsAbiInfoHandler() = default;
- uint32_t getFlags() const;
- const llvm::Optional<MipsReginfo> &getRegistersMask() const;
+ uint32_t getFlags() const { return _flags; }
+ const llvm::Optional<Elf_Mips_RegInfo> &getRegistersMask() const {
+ return _regMask;
+ }
/// \brief Merge saved ELF header flags and the new set of flags.
std::error_code mergeFlags(uint32_t newFlags);
/// \brief Merge saved and new sets of registers usage masks.
- void mergeRegistersMask(const MipsReginfo &info);
+ void mergeRegistersMask(const Elf_Mips_RegInfo &info);
private:
std::mutex _mutex;
uint32_t _flags = 0;
- llvm::Optional<MipsReginfo> _regMask;
+ llvm::Optional<Elf_Mips_RegInfo> _regMask;
};
} // namespace elf
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h?rev=238685&r1=238684&r2=238685&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFFile.h Sun May 31 15:36:21 2015
@@ -11,7 +11,6 @@
#include "ELFReader.h"
#include "MipsLinkingContext.h"
-#include "MipsReginfo.h"
#include "MipsRelocationHandler.h"
#include "llvm/ADT/STLExtras.h"
Removed: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h?rev=238684&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsReginfo.h (removed)
@@ -1,43 +0,0 @@
-//===- lib/ReaderWriter/ELF/Mips/MipsReginfo.h ----------------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_REGINFO_H
-#define LLD_READER_WRITER_ELF_MIPS_MIPS_REGINFO_H
-
-#include "llvm/Object/ELFTypes.h"
-
-namespace lld {
-namespace elf {
-
-struct MipsReginfo {
- uint32_t _gpRegMask = 0;
- uint32_t _cpRegMask[4];
-
- MipsReginfo() { memset(_cpRegMask, 0, sizeof(_cpRegMask)); }
-
- template <class ElfReginfo> MipsReginfo(const ElfReginfo &elf) {
- _gpRegMask = elf.ri_gprmask;
- _cpRegMask[0] = elf.ri_cprmask[0];
- _cpRegMask[1] = elf.ri_cprmask[1];
- _cpRegMask[2] = elf.ri_cprmask[2];
- _cpRegMask[3] = elf.ri_cprmask[3];
- }
-
- void merge(const MipsReginfo &info) {
- _gpRegMask |= info._gpRegMask;
- _cpRegMask[0] |= info._cpRegMask[0];
- _cpRegMask[1] |= info._cpRegMask[1];
- _cpRegMask[2] |= info._cpRegMask[2];
- _cpRegMask[3] |= info._cpRegMask[3];
- }
-};
-
-} // end namespace elf
-} // end namespace lld
-
-#endif
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.cpp?rev=238685&r1=238684&r2=238685&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.cpp Sun May 31 15:36:21 2015
@@ -17,8 +17,8 @@ namespace elf {
template <class ELFT>
MipsReginfoSection<ELFT>::MipsReginfoSection(
const ELFLinkingContext &ctx, MipsTargetLayout<ELFT> &targetLayout,
- const MipsReginfo ®info)
- : Section<ELFT>(ctx, ".reginfo", "MipsReginfo"),
+ const Elf_Mips_RegInfo ®info)
+ : Section<ELFT>(ctx, ".reginfo", "MipsReginfo"), _reginfo(reginfo),
_targetLayout(targetLayout) {
this->setOrder(MipsTargetLayout<ELFT>::ORDER_MIPS_REGINFO);
this->_entSize = sizeof(Elf_Mips_RegInfo);
@@ -27,13 +27,6 @@ MipsReginfoSection<ELFT>::MipsReginfoSec
this->_alignment = 4;
this->_type = SHT_MIPS_REGINFO;
this->_flags = SHF_ALLOC;
-
- std::memset(&_reginfo, 0, sizeof(_reginfo));
- _reginfo.ri_gprmask = reginfo._gpRegMask;
- _reginfo.ri_cprmask[0] = reginfo._cpRegMask[0];
- _reginfo.ri_cprmask[1] = reginfo._cpRegMask[1];
- _reginfo.ri_cprmask[2] = reginfo._cpRegMask[2];
- _reginfo.ri_cprmask[3] = reginfo._cpRegMask[3];
}
template <class ELFT>
@@ -57,8 +50,8 @@ template class MipsReginfoSection<ELF64L
template <class ELFT>
MipsOptionsSection<ELFT>::MipsOptionsSection(
const ELFLinkingContext &ctx, MipsTargetLayout<ELFT> &targetLayout,
- const MipsReginfo ®info)
- : Section<ELFT>(ctx, ".MIPS.options", "MipsOptions"),
+ const Elf_Mips_RegInfo ®info)
+ : Section<ELFT>(ctx, ".MIPS.options", "MipsOptions"), _reginfo(reginfo),
_targetLayout(targetLayout) {
this->setOrder(MipsTargetLayout<ELFT>::ORDER_MIPS_OPTIONS);
this->_entSize = 1;
@@ -73,13 +66,6 @@ MipsOptionsSection<ELFT>::MipsOptionsSec
_header.size = this->_fsize;
_header.section = 0;
_header.info = 0;
-
- std::memset(&_reginfo, 0, sizeof(_reginfo));
- _reginfo.ri_gprmask = reginfo._gpRegMask;
- _reginfo.ri_cprmask[0] = reginfo._cpRegMask[0];
- _reginfo.ri_cprmask[1] = reginfo._cpRegMask[1];
- _reginfo.ri_cprmask[2] = reginfo._cpRegMask[2];
- _reginfo.ri_cprmask[3] = reginfo._cpRegMask[3];
}
template <class ELFT>
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h?rev=238685&r1=238684&r2=238685&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h Sun May 31 15:36:21 2015
@@ -9,7 +9,6 @@
#ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_SECTION_CHUNKS_H
#define LLD_READER_WRITER_ELF_MIPS_MIPS_SECTION_CHUNKS_H
-#include "MipsReginfo.h"
#include "SectionChunks.h"
namespace lld {
@@ -21,9 +20,11 @@ class MipsLinkingContext;
/// \brief Handle Mips .reginfo section
template <class ELFT> class MipsReginfoSection : public Section<ELFT> {
public:
+ typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
+
MipsReginfoSection(const ELFLinkingContext &ctx,
MipsTargetLayout<ELFT> &targetLayout,
- const MipsReginfo ®info);
+ const Elf_Mips_RegInfo ®info);
StringRef segmentKindToStr() const override { return "REGINFO"; }
bool hasOutputSegment() const override { return true; }
@@ -33,8 +34,6 @@ public:
void finalize() override;
private:
- typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
-
Elf_Mips_RegInfo _reginfo;
MipsTargetLayout<ELFT> &_targetLayout;
};
@@ -42,9 +41,12 @@ private:
/// \brief Handle .MIPS.options section
template <class ELFT> class MipsOptionsSection : public Section<ELFT> {
public:
+ typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
+ typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
+
MipsOptionsSection(const ELFLinkingContext &ctx,
MipsTargetLayout<ELFT> &targetLayout,
- const MipsReginfo ®info);
+ const Elf_Mips_RegInfo ®info);
bool hasOutputSegment() const override { return true; }
@@ -53,9 +55,6 @@ public:
void finalize() override;
private:
- typedef llvm::object::Elf_Mips_Options<ELFT> Elf_Mips_Options;
- typedef llvm::object::Elf_Mips_RegInfo<ELFT> Elf_Mips_RegInfo;
-
Elf_Mips_Options _header;
Elf_Mips_RegInfo _reginfo;
MipsTargetLayout<ELFT> &_targetLayout;
More information about the llvm-commits
mailing list