[PATCH] D24860: [ELF] - Linkerscript: Implemented >> and <<
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 23 06:10:29 PDT 2016
Replace 1 with 0+1 so that we test the precedence.
LGTM with that.
On September 23, 2016 8:45:52 AM EDT, George Rimar <grimar at accesssoftek.com> wrote:
>grimar created this revision.
>grimar added reviewers: ruiu, rafael.
>grimar added subscribers: llvm-commits, grimar, evgeny777.
>
>Found this operators used in the wild here:
>https://searchcode.com/file/103745382/board/bf561-ezkit/u-boot.lds.S
>
>```
> __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
> __fixup_entries = (. - _FIXUP_TABLE_)>>2;
>```
>
>https://reviews.llvm.org/D24860
>
>Files:
> ELF/LinkerScript.cpp
> test/ELF/linkerscript/locationcounter.s
>
>Index: test/ELF/linkerscript/locationcounter.s
>===================================================================
>--- test/ELF/linkerscript/locationcounter.s
>+++ test/ELF/linkerscript/locationcounter.s
>@@ -42,6 +42,11 @@
> # RUN: .plusassign : { *(.plusassign) } \
> # RUN: . = ((. + 0x1fff) & ~(0x1000 + -1)); \
> # RUN: .unary : { *(.unary) } \
>+# RUN: . = 0x30000 + (1 << 5); \
>+# RUN: .shiftl : { *(.shiftl) } \
>+# RUN: . = 0x30000 + (1024 >> 2); \
>+# RUN: .shiftr : { *(.shiftr) } \
>+
> # RUN: }" > %t.script
> # RUN: ld.lld %t --script %t.script -o %t2
> # RUN: llvm-objdump -section-headers %t2 | FileCheck %s
>@@ -65,6 +70,8 @@
> # CHECK: .datasegmentalign {{.*}} 0000000000200000
> # CHECK: .plusassign {{.*}} 0000000000028000
> # CHECK: .unary {{.*}} 000000000002a000
>+# CHECK: .shiftl {{.*}} 0000000000030020
>+# CHECK: .shiftr {{.*}} 0000000000030100
>
> ## Mailformed number error.
> # RUN: echo "SECTIONS { \
>@@ -174,3 +181,9 @@
>
> .section .unary, "a"
> .quad 0
>+
>+.section .shiftl, "a"
>+.quad 0
>+
>+.section .shiftr, "a"
>+.quad 0
>Index: ELF/LinkerScript.cpp
>===================================================================
>--- ELF/LinkerScript.cpp
>+++ ELF/LinkerScript.cpp
>@@ -1081,10 +1081,12 @@
>
> static int precedence(StringRef Op) {
> return StringSwitch<int>(Op)
>- .Case("*", 4)
>- .Case("/", 4)
>- .Case("+", 3)
>- .Case("-", 3)
>+ .Case("*", 5)
>+ .Case("/", 5)
>+ .Case("+", 4)
>+ .Case("-", 4)
>+ .Case("<<", 3)
>+ .Case(">>", 3)
> .Case("<", 2)
> .Case(">", 2)
> .Case(">=", 2)
>@@ -1361,6 +1363,10 @@
> return [=](uint64_t Dot) { return L(Dot) + R(Dot); };
> if (Op == "-")
> return [=](uint64_t Dot) { return L(Dot) - R(Dot); };
>+ if (Op == "<<")
>+ return [=](uint64_t Dot) { return L(Dot) << R(Dot); };
>+ if (Op == ">>")
>+ return [=](uint64_t Dot) { return L(Dot) >> R(Dot); };
> if (Op == "<")
> return [=](uint64_t Dot) { return L(Dot) < R(Dot); };
> if (Op == ">")
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160923/f8dc7a1a/attachment.html>
More information about the llvm-commits
mailing list