[lld] r232705 - [Mips] Replace "hand-made" function by the `llvm::SignExtend32()` routine
Simon Atanasyan
simon at atanasyan.com
Wed Mar 18 22:44:04 PDT 2015
Author: atanasyan
Date: Thu Mar 19 00:44:04 2015
New Revision: 232705
URL: http://llvm.org/viewvc/llvm-project?rev=232705&view=rev
Log:
[Mips] Replace "hand-made" function by the `llvm::SignExtend32()` routine
No functional changes.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp?rev=232705&r1=232704&r2=232705&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp Thu Mar 19 00:44:04 2015
@@ -134,12 +134,6 @@ static MipsRelocationParams getRelocatio
}
}
-template <size_t BITS, class T> inline T signExtend(T val) {
- if (val & (T(1) << (BITS - 1)))
- val |= T(-1) << BITS;
- return val;
-}
-
/// \brief R_MIPS_32
/// local/external: word32 S + A (truncate)
static uint32_t reloc32(uint64_t S, int64_t A) { return S + A; }
@@ -168,7 +162,8 @@ static uint32_t reloc26loc(uint64_t P, u
/// \brief LLD_R_MIPS_GLOBAL_26, LLD_R_MICROMIPS_GLOBAL_26_S1
/// external: (sign-extend(A) + S) >> 2
static uint32_t reloc26ext(uint64_t S, int32_t A, uint32_t shift) {
- uint32_t result = shift == 1 ? signExtend<27>(A) : signExtend<28>(A);
+ int32_t result =
+ shift == 1 ? llvm::SignExtend32<27>(A) : llvm::SignExtend32<28>(A);
return (result + S) >> shift;
}
@@ -212,7 +207,7 @@ static uint32_t relocGOTOfst(uint64_t S,
/// external: sign-extend(A) + S - GP
static uint32_t relocGPRel16(uint64_t S, int64_t A, uint64_t GP) {
// We added GP0 to addendum for a local symbol during a Relocation pass.
- int32_t result = signExtend<16>(A) + S - GP;
+ int32_t result = llvm::SignExtend32<16>(A) + S - GP;
return result;
}
@@ -226,28 +221,28 @@ static uint32_t relocGPRel32(uint64_t S,
/// \brief R_MICROMIPS_PC7_S1
static uint32_t relocPc7(uint64_t P, uint64_t S, int64_t A) {
- A = signExtend<8>(A);
+ A = llvm::SignExtend32<8>(A);
int32_t result = S + A - P;
return result >> 1;
}
/// \brief R_MICROMIPS_PC10_S1
static uint32_t relocPc10(uint64_t P, uint64_t S, int64_t A) {
- A = signExtend<11>(A);
+ A = llvm::SignExtend32<11>(A);
int32_t result = S + A - P;
return result >> 1;
}
/// \brief R_MICROMIPS_PC16_S1
static uint32_t relocPc16(uint64_t P, uint64_t S, int64_t A) {
- A = signExtend<17>(A);
+ A = llvm::SignExtend32<17>(A);
int32_t result = S + A - P;
return result >> 1;
}
/// \brief R_MICROMIPS_PC23_S2
static uint32_t relocPc23(uint64_t P, uint64_t S, int64_t A) {
- A = signExtend<25>(A);
+ A = llvm::SignExtend32<25>(A);
int32_t result = S + A - P;
// Check addiupc 16MB range.
More information about the llvm-commits
mailing list