diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2014-11-20 22:29:55 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2014-11-20 22:29:55 +0000 |
commit | 8489349fdca5fe57991bf6c683fd20c02301b0e0 (patch) | |
tree | 031d67c1ace5d5a66abcb98245e257b2fd9e0323 | |
parent | f2da06b774f4cc6151a6c767d8b5e71925534ff2 (diff) | |
download | bcm5719-llvm-8489349fdca5fe57991bf6c683fd20c02301b0e0.tar.gz bcm5719-llvm-8489349fdca5fe57991bf6c683fd20c02301b0e0.zip |
[Mips] Simplify the code calculates HI16/LO16 relocations
No functional changes.
llvm-svn: 222470
-rw-r--r-- | lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp index 7ff93140f92..09b345ee13e 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); } |