[lld] e3f3d2a - [ELF][test] Improve expression test
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 25 21:11:37 PDT 2022
Author: Fangrui Song
Date: 2022-06-25T21:11:32-07:00
New Revision: e3f3d2abf06b68f9b151f2fab89623e6b8e40c0d
URL: https://github.com/llvm/llvm-project/commit/e3f3d2abf06b68f9b151f2fab89623e6b8e40c0d
DIFF: https://github.com/llvm/llvm-project/commit/e3f3d2abf06b68f9b151f2fab89623e6b8e40c0d.diff
LOG: [ELF][test] Improve expression test
Added:
Modified:
lld/test/ELF/linkerscript/operators.test
lld/test/ELF/linkerscript/symbol-assignexpr.s
Removed:
################################################################################
diff --git a/lld/test/ELF/linkerscript/operators.test b/lld/test/ELF/linkerscript/operators.test
index cbccd45f0922..438229c26edf 100644
--- a/lld/test/ELF/linkerscript/operators.test
+++ b/lld/test/ELF/linkerscript/operators.test
@@ -5,28 +5,32 @@
SECTIONS {
_start = .;
- plus = 1 + 2 + 3;
- minus = 5 - 1;
- div = 6 / 2;
- mod = 20 % 7;
- mul = 1 + 2 * 3;
- nospace = 1+2*6/3;
- braces = 1 + (2 + 3) * 4;
- and = 0xbb & 0xee;
- ternary1 = 1 ? 2 : 3 ? 4 : 5;
- ternary2 = 0 ? 1 : 2;
+ unary =!0 + !0;
+ negate =-1 - 1;
+ not =~0xffff + 4;
+ not_negate = -~5 + 1;
+ multiplicative = 20 / 2 % 7;
+ additive = 1 - 2 + -3 * -2;
+ shift = 2 << 5 >> 1 << 2;
less = 1 < 0 ? 1 : 2;
- lesseq = 1 <= 1 ? 1 : 2;
+ lesseq = 1<<0 <= 1>>0 ? 1 : 2;
greater = 0 > 1 ? 1 : 2;
greatereq = 1 >= 1 ? 1 : 2;
eq = 1 == 1 ? 1 : 2;
neq = 1 != 1 <= 1 ? 1 : 2;
- plusassign = 1;
+ and = 3 & 4 > 0;
+ or = 0xbb & 0xee | 1;
+ logicaland = (0 && 0) + (0&&1)*2 + (1&& 0)*4 + (1 &&1) *8;
+ logicaland2 = 1 & 0 && 1 | 1;
+ logicalor = (0 || 0) + (0||1)*2 + (1|| 0)*4 + (1 ||1) *8;
+ logicalor2 = 0 && 0 || 1 && 1;
+ ternary1 = 0 ? 1 : 2 & 6;
+ ternary2 = 1 ? 2 ? 3 : 4 : 5 ? 6 : 7;
+
+ plusassign =1;
plusassign += 2;
- unary = -1 + 3;
- lshift = 1 << 5;
- rshift = 0xff >> 3;
- precedence1 = 1 | 0xff & 1 << 1 + 1 * 2;
+ braces = 1 + (2 + 3) * 4;
+ precedence1 = 1|0xff&1/1<<1+1*2;
precedence2 = (1 | (0xff & (1 << (1 + (1 * 2)))));
maxpagesize = CONSTANT (MAXPAGESIZE);
commonpagesize = CONSTANT (COMMONPAGESIZE);
@@ -46,46 +50,41 @@ SECTIONS {
log2ceil100000000 = LOG2CEIL(0x100000000);
log2ceil100000001 = LOG2CEIL(0x100000001);
log2ceilmax = LOG2CEIL(0xffffffffffffffff);
- logicaland1 = 0 && 0;
- logicaland2 = 0 && 1;
- logicaland3 = 1 && 0;
- logicaland4 = 1 && 1;
- logicalor1 = 0 || 0;
- logicalor2 = 0 || 1;
- logicalor3 = 1 || 0;
- logicalor4 = 1 || 1;
}
-# CHECK: 00000000000006 A plus
-# CHECK-NEXT: 00000000000004 A minus
-# CHECK-NEXT: 00000000000003 A div
-# CHECK-NEXT: 00000000000006 A mod
-# CHECK-NEXT: 00000000000007 A mul
-# CHECK-NEXT: 00000000000005 A nospace
-# CHECK-NEXT: 00000000000015 A braces
-# CHECK-NEXT: 000000000000aa A and
-# CHECK-NEXT: 00000000000002 A ternary1
-# CHECK-NEXT: 00000000000002 A ternary2
-# CHECK-NEXT: 00000000000002 A less
-# CHECK-NEXT: 00000000000001 A lesseq
-# CHECK-NEXT: 00000000000002 A greater
-# CHECK-NEXT: 00000000000001 A greatereq
-# CHECK-NEXT: 00000000000001 A eq
-# CHECK-NEXT: 00000000000002 A neq
-# CHECK-NEXT: 00000000000003 A plusassign
-# CHECK-NEXT: 00000000000002 A unary
-# CHECK-NEXT: 00000000000020 A lshift
-# CHECK-NEXT: 0000000000001f A rshift
-# CHECK-NEXT: 00000000000009 A precedence1
-# CHECK-NEXT: 00000000000009 A precedence2
-# CHECK-NEXT: 00000000001000 A maxpagesize
-# CHECK-NEXT: 00000000001000 A commonpagesize
-# CHECK-NEXT: 0000000000ffff A datasegmentalign
-# CHECK-NEXT: 0000000000fff0 A datasegmentalign2
-# CHECK-NEXT: 0000000000ffe0 T minus_rel
-# CHECK-NEXT: 0000000000fff0 A minus_abs
-# CHECK-NEXT: 00000000000016 A max
-# CHECK-NEXT: 0000000000000b A min
+# CHECK: 0000000000000002 A unary
+# CHECK-NEXT: fffffffffffffffe A negate
+# CHECK-NEXT: ffffffffffff0004 A not
+# CHECK-NEXT: 0000000000000007 A not_negate
+# CHECK-NEXT: 0000000000000003 A multiplicative
+# CHECK-NEXT: 0000000000000005 A additive
+# CHECK-NEXT: 0000000000000080 A shift
+# CHECK-NEXT: 0000000000000002 A less
+# CHECK-NEXT: 0000000000000001 A lesseq
+# CHECK-NEXT: 0000000000000002 A greater
+# CHECK-NEXT: 0000000000000001 A greatereq
+# CHECK-NEXT: 0000000000000001 A eq
+# CHECK-NEXT: 0000000000000002 A neq
+# CHECK-NEXT: 0000000000000001 A and
+# CHECK-NEXT: 00000000000000ab A or
+# CHECK-NEXT: 0000000000000008 A logicaland
+# CHECK-NEXT: 0000000000000000 A logicaland2
+# CHECK-NEXT: 000000000000000e A logicalor
+# CHECK-NEXT: 0000000000000001 A logicalor2
+# CHECK-NEXT: 0000000000000002 A ternary1
+# CHECK-NEXT: 0000000000000003 A ternary2
+# CHECK-NEXT: 0000000000000003 A plusassign
+# CHECK-NEXT: 0000000000000015 A braces
+# CHECK-NEXT: 0000000000000009 A precedence1
+# CHECK-NEXT: 0000000000000009 A precedence2
+# CHECK-NEXT: 0000000000001000 A maxpagesize
+# CHECK-NEXT: 0000000000001000 A commonpagesize
+# CHECK-NEXT: 000000000000ffff A datasegmentalign
+# CHECK-NEXT: 000000000000fff0 A datasegmentalign2
+# CHECK-NEXT: 000000000000ffe0 T minus_rel
+# CHECK-NEXT: 000000000000fff0 A minus_abs
+# CHECK-NEXT: 0000000000000016 A max
+# CHECK-NEXT: 000000000000000b A min
# CHECK-NEXT: 0000000000000000 A log2ceil0
# CHECK-NEXT: 0000000000000000 A log2ceil1
# CHECK-NEXT: 0000000000000001 A log2ceil2
@@ -94,14 +93,6 @@ SECTIONS {
# CHECK-NEXT: 0000000000000020 A log2ceil100000000
# CHECK-NEXT: 0000000000000021 A log2ceil100000001
# CHECK-NEXT: 0000000000000040 A log2ceilmax
-# CHECK-NEXT: 00000000000000 A logicaland1
-# CHECK-NEXT: 00000000000000 A logicaland2
-# CHECK-NEXT: 00000000000000 A logicaland3
-# CHECK-NEXT: 00000000000001 A logicaland4
-# CHECK-NEXT: 00000000000000 A logicalor1
-# CHECK-NEXT: 00000000000001 A logicalor2
-# CHECK-NEXT: 00000000000001 A logicalor3
-# CHECK-NEXT: 00000000000001 A logicalor4
## Mailformed number error.
# RUN: echo "SECTIONS { . = 0x12Q41; }" > %t.script
diff --git a/lld/test/ELF/linkerscript/symbol-assignexpr.s b/lld/test/ELF/linkerscript/symbol-assignexpr.s
index abbcccb84b83..ed6d746b3e2d 100644
--- a/lld/test/ELF/linkerscript/symbol-assignexpr.s
+++ b/lld/test/ELF/linkerscript/symbol-assignexpr.s
@@ -1,49 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: echo "SECTIONS { \
-# RUN: symbol = CONSTANT(MAXPAGESIZE); \
-# RUN: symbol2 = symbol + 0x1234; \
-# RUN: symbol3 = symbol2; \
-# RUN: symbol4 = symbol + -4; \
-# RUN: symbol5 = symbol - ~0xfffb; \
-# RUN: symbol6 = symbol - ~(0xfff0 + 0xb); \
-# RUN: symbol7 =symbol - ~ 0xfffb + 4; \
-# RUN: symbol8 =~ 0xffff + 4; \
-# RUN: symbol9 =- 4; \
-# RUN: symbol10 = 0xfedcba9876543210; \
-# RUN: symbol11 = ((0x28000 + 0x1fff) & ~(0x1000 + -1)); \
-# RUN: symbol12 = 0x1234; \
-# RUN: symbol12 += 1; \
-# RUN: symbol13 = !1; \
-# RUN: symbol14 = !0; \
-# RUN: symbol15 = 0!=1; \
-# RUN: bar = 0x5678; \
-# RUN: baz = 0x9abc; \
-# RUN: }" > %t.script
-# RUN: ld.lld -o %t -T %t.script %t.o
-# RUN: llvm-nm -p %t | FileCheck %s
-
-# CHECK: 0000000000000000 T _start
-# CHECK-NEXT: 0000000000000001 T foo
-# CHECK-NEXT: 0000000000005678 A bar
-# CHECK-NEXT: 0000000000009abc A baz
-# CHECK-NEXT: 0000000000001000 A symbol
-# CHECK-NEXT: 0000000000002234 A symbol2
-# CHECK-NEXT: 0000000000002234 A symbol3
-# CHECK-NEXT: 0000000000000ffc A symbol4
-# CHECK-NEXT: 0000000000010ffc A symbol5
-# CHECK-NEXT: 0000000000010ffc A symbol6
-# CHECK-NEXT: 0000000000011000 A symbol7
-# CHECK-NEXT: ffffffffffff0004 A symbol8
-# CHECK-NEXT: fffffffffffffffc A symbol9
-# CHECK-NEXT: fedcba9876543210 A symbol10
-# CHECK-NEXT: 0000000000029000 A symbol11
-# CHECK-NEXT: 0000000000001235 A symbol12
-# CHECK-NEXT: 0000000000000000 A symbol13
-# CHECK-NEXT: 0000000000000001 A symbol14
-# CHECK-NEXT: 0000000000000001 A symbol15
-
# RUN: echo "SECTIONS { symbol2 = symbol; }" > %t2.script
# RUN: not ld.lld -o /dev/null -T %t2.script %t.o 2>&1 \
# RUN: | FileCheck -check-prefix=ERR %s
@@ -52,12 +9,3 @@
.global _start
_start:
nop
-
-.global foo
-foo:
- nop
-
-.global bar
-bar = 0x1234
-
-.comm baz,8,8
More information about the llvm-commits
mailing list