[PATCH] D19419: [ELF] - Implemented comparsion operators for linkerscript

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 14:57:59 PDT 2016


grimar added inline comments.

================
Comment at: ELF/LinkerScript.cpp:51-61
@@ -50,7 +50,13 @@
   return StringSwitch<int>(Op)
-      .Case("*", 4)
-      .Case("/", 3)
-      .Case("+", 2)
-      .Case("-", 2)
-      .Case("&", 1)
+      .Case("*", 6)
+      .Case("/", 5)
+      .Case("+", 4)
+      .Case("-", 3)
+      .Case("&", 2)
+      .Case("<", 1)
+      .Case(">", 1)
+      .Case(">=", 1)
+      .Case("<=", 1)
+      .Case("==", 0)
+      .Case("!=", 0)
       .Default(-1);
----------------
grimar wrote:
> ruiu wrote:
> > ruiu wrote:
> > > These operator precedences are not correct. * and / should have the same precedence, and so are + and -. & has lower precedence over comparison operators.
> > > 
> > > https://www.sourceware.org/binutils/docs-2.10/ld_3.html#SEC45
> > Also, please don't use precedence 0. We pass 0 as the minimum precedence in parseExpr. It doesn't expect that there is an operator with precedence 0.
> Yes, I messed up these accidentally :( will fix.
I used c++ precedence for added ones, btw: http://en.cppreference.com/w/cpp/language/operator_precedence.
It is a bit different about == and !=.
And I just missed that & should have lower precedence than them all.


http://reviews.llvm.org/D19419





More information about the llvm-commits mailing list