[lld] r234650 - Replace a macro with an inline function.

Rui Ueyama ruiu at google.com
Fri Apr 10 15:05:11 PDT 2015


Author: ruiu
Date: Fri Apr 10 17:05:11 2015
New Revision: 234650

URL: http://llvm.org/viewvc/llvm-project?rev=234650&view=rev
Log:
Replace a macro with an inline function.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp?rev=234650&r1=234649&r2=234650&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp Fri Apr 10 17:05:11 2015
@@ -20,7 +20,7 @@ using namespace lld::elf;
 using namespace llvm;
 using namespace llvm::support::endian;
 
-#define PAGE(X) ((X) & ~0x0FFFL)
+static int64_t page(int64_t v) { return v & ~int64_t(0xFFF); }
 
 /// \brief Check X is in the interval (-2^(bits-1), 2^bits]
 static bool withinSignedUnsignedRange(int64_t X, int bits) {
@@ -64,7 +64,7 @@ static std::error_code relocR_AARCH64_AB
 /// \brief R_AARCH64_ADR_PREL_PG_HI21 - Page(S+A) - Page(P)
 static void relocR_AARCH64_ADR_PREL_PG_HI21(uint8_t *location, uint64_t P,
                                             uint64_t S, int64_t A) {
-  uint64_t result = (PAGE(S + A) - PAGE(P));
+  uint64_t result = (page(S + A) - page(P));
   result = result >> 12;
   uint32_t immlo = result & 0x3;
   uint32_t immhi = result & 0x1FFFFC;
@@ -210,7 +210,7 @@ static void relocR_AARCH64_LDST128_ABS_L
 
 static void relocR_AARCH64_ADR_GOT_PAGE(uint8_t *location, uint64_t P,
                                         uint64_t S, int64_t A) {
-  uint64_t result = PAGE(S + A) - PAGE(P);
+  uint64_t result = page(S + A) - page(P);
   result >>= 12;
   uint32_t immlo = result & 0x3;
   uint32_t immhi = result & 0x1FFFFC;
@@ -258,7 +258,7 @@ static void relocADD_AARCH64_GOTRELINDEX
 static void relocR_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21(uint8_t *location,
                                                      uint64_t P, uint64_t S,
                                                      int64_t A) {
-  int64_t result = PAGE(S + A) - PAGE(P);
+  int64_t result = page(S + A) - page(P);
   result >>= 12;
   uint32_t immlo = result & 0x3;
   uint32_t immhi = result & 0x1FFFFC;





More information about the llvm-commits mailing list