forked from OSchip/llvm-project
[Mips] Delete MipsReginfo structure. Use the Elf_Mips_RegInfo instead.
llvm-svn: 238685
This commit is contained in:
parent
70e21bc83d
commit
3eec407a53
|
@ -61,16 +61,6 @@ static bool matchMipsISA(unsigned base, unsigned ext) {
|
|||
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>::mergeFlags(uint32_t newFlags) {
|
|||
}
|
||||
|
||||
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>;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "ELFReader.h"
|
||||
#include "MipsLinkingContext.h"
|
||||
#include "MipsReginfo.h"
|
||||
#include "MipsRelocationHandler.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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>::MipsReginfoSection(
|
|||
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<ELF64LE>;
|
|||
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>::MipsOptionsSection(
|
|||
_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>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue