From 8489349fdca5fe57991bf6c683fd20c02301b0e0 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Thu, 20 Nov 2014 22:29:55 +0000 Subject: [PATCH] [Mips] Simplify the code calculates HI16/LO16 relocations No functional changes. llvm-svn: 222470 --- .../ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp index 7ff9314..09b345e 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp @@ -59,14 +59,8 @@ static void reloc26ext(uint32_t &ins, uint64_t S, int32_t A) { /// _gp_disp : hi16 (AHL + GP - P) - (short)(AHL + GP - P) (verify) static void relocHi16(uint32_t &ins, uint64_t P, uint64_t S, int64_t AHL, bool isGPDisp) { - int32_t result = 0; - - if (isGPDisp) - result = (AHL + S - P) - (int16_t)(AHL + S - P); - else - result = (AHL + S) - (int16_t)(AHL + S); - - applyReloc(ins, result >> 16, 0xffff); + int32_t result = isGPDisp ? AHL + S - P : AHL + S; + applyReloc(ins, (result + 0x8000) >> 16, 0xffff); } /// \brief R_MIPS_LO16, R_MIPS_TLS_DTPREL_LO16, R_MIPS_TLS_TPREL_LO16, @@ -75,13 +69,7 @@ static void relocHi16(uint32_t &ins, uint64_t P, uint64_t S, int64_t AHL, /// _gp_disp : lo16 AHL + GP - P + 4 (verify) static void relocLo16(uint32_t &ins, uint64_t P, uint64_t S, int64_t AHL, bool isGPDisp) { - int32_t result = 0; - - if (isGPDisp) - result = AHL + S - P + 4; - else - result = AHL + S; - + int32_t result = isGPDisp ? AHL + S - P + 4 : AHL + S; applyReloc(ins, result, 0xffff); } -- 2.7.4