[lld] r238689 - [Mips] Add a couple of MipsAbiInfoHandler functions to check linked code type
Simon Atanasyan
simon at atanasyan.com
Sun May 31 13:37:22 PDT 2015
Author: atanasyan
Date: Sun May 31 15:37:22 2015
New Revision: 238689
URL: http://llvm.org/viewvc/llvm-project?rev=238689&view=rev
Log:
[Mips] Add a couple of MipsAbiInfoHandler functions to check linked code type
No functional changes.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
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=238689&r1=238688&r2=238689&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.cpp Sun May 31 15:37:22 2015
@@ -424,6 +424,16 @@ static uint32_t selectFpAbiFlag(uint32_t
namespace lld {
namespace elf {
+template <class ELFT> bool MipsAbiInfoHandler<ELFT>::isMicroMips() const {
+ assert(_abiFlags.hasValue());
+ return _abiFlags->_ases & AFL_ASE_MICROMIPS;
+}
+
+template <class ELFT> bool MipsAbiInfoHandler<ELFT>::isMipsR6() const {
+ assert(_abiFlags.hasValue());
+ return _abiFlags->_isa == Arch32r6 || _abiFlags->_isa == Arch64r6;
+}
+
template <class ELFT> uint32_t MipsAbiInfoHandler<ELFT>::getFlags() const {
std::lock_guard<std::mutex> lock(_mutex);
uint32_t flags = 0;
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=238689&r1=238688&r2=238689&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsAbiInfoHandler.h Sun May 31 15:37:22 2015
@@ -44,6 +44,8 @@ public:
MipsAbiInfoHandler() = default;
bool hasMipsAbiSection() const { return _hasAbiSection; }
+ bool isMicroMips() const;
+ bool isMipsR6() const;
uint32_t getFlags() const;
llvm::Optional<Elf_Mips_RegInfo> getRegistersMask() const;
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=238689&r1=238688&r2=238689&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Sun May 31 15:37:22 2015
@@ -311,12 +311,6 @@ private:
/// \brief Owner of all the Atoms created by this pass.
RelocationPassFile _file;
- /// \brief Linked files contain MIPS R6 code.
- bool _isMipsR6 = false;
-
- /// \brief Linked files contain microMIPS code.
- bool _isMicroMips = false;
-
/// \brief Map Atoms and addend to local GOT entries.
typedef std::pair<const Atom *, int64_t> LocalGotMapKeyT;
llvm::DenseMap<LocalGotMapKeyT, GOTAtom *> _gotLocalMap;
@@ -418,6 +412,11 @@ private:
bool mightBeDynamic(const MipsELFDefinedAtom<ELFT> &atom,
Reference::KindValue refKind) const;
bool hasPLTEntry(const Atom *atom) const;
+
+ /// \brief Linked files contain microMIPS code.
+ bool isMicroMips();
+ /// \brief Linked files contain MIPS R6 code.
+ bool isMipsR6();
};
template <typename ELFT>
@@ -430,14 +429,6 @@ RelocationPass<ELFT>::RelocationPass(Mip
template <typename ELFT>
void RelocationPass<ELFT>::perform(std::unique_ptr<SimpleFile> &mf) {
- auto &handler =
- static_cast<MipsTargetHandler<ELFT> &>(this->_ctx.getTargetHandler());
-
- uint32_t elfFlags = handler.getAbiInfoHandler().getFlags();
- _isMicroMips = elfFlags & EF_MIPS_MICROMIPS;
- _isMipsR6 = (elfFlags & EF_MIPS_ARCH) == EF_MIPS_ARCH_32R6 ||
- (elfFlags & EF_MIPS_ARCH) == EF_MIPS_ARCH_64R6;
-
for (const auto &atom : mf->defined())
for (const auto &ref : *atom)
collectReferenceInfo(*cast<MipsELFDefinedAtom<ELFT>>(atom),
@@ -709,6 +700,20 @@ bool RelocationPass<ELFT>::hasPLTEntry(c
return _pltRegMap.count(atom) || _pltMicroMap.count(atom);
}
+template <typename ELFT> bool RelocationPass<ELFT>::isMicroMips() {
+ TargetHandler &handler = this->_ctx.getTargetHandler();
+ return static_cast<MipsTargetHandler<ELFT> &>(handler)
+ .getAbiInfoHandler()
+ .isMicroMips();
+}
+
+template <typename ELFT> bool RelocationPass<ELFT>::isMipsR6() {
+ TargetHandler &handler = this->_ctx.getTargetHandler();
+ return static_cast<MipsTargetHandler<ELFT> &>(handler)
+ .getAbiInfoHandler()
+ .isMipsR6();
+}
+
template <typename ELFT>
bool RelocationPass<ELFT>::requirePLTEntry(const Atom *a) const {
if (!_hasStaticRelocations.count(a))
@@ -761,7 +766,7 @@ const LA25Atom *RelocationPass<ELFT>::ge
template <typename ELFT>
const PLTAtom *RelocationPass<ELFT>::getPLTEntry(const Atom *a) {
// If file contains microMIPS code try to reuse compressed PLT entry...
- if (_isMicroMips) {
+ if (isMicroMips()) {
auto microPLT = _pltMicroMap.find(a);
if (microPLT != _pltMicroMap.end())
return microPLT->second;
@@ -773,7 +778,7 @@ const PLTAtom *RelocationPass<ELFT>::get
return regPLT->second;
// ... and finally prefer to create new compressed PLT entry.
- return _isMicroMips ? getPLTMicroEntry(a) : getPLTRegEntry(a);
+ return isMicroMips() ? getPLTMicroEntry(a) : getPLTRegEntry(a);
}
template <typename ELFT>
@@ -1010,7 +1015,7 @@ const PLTAtom *RelocationPass<ELFT>::get
if (plt != _pltRegMap.end())
return plt->second;
- PLTAAtom *pa = _isMipsR6
+ PLTAAtom *pa = isMipsR6()
? new (_file._alloc) PLTR6Atom(getGOTPLTEntry(a), _file)
: new (_file._alloc) PLTAAtom(getGOTPLTEntry(a), _file);
_pltRegMap[a] = pa;
More information about the llvm-commits
mailing list