aboutsummaryrefslogtreecommitdiff
path: root/gas/testsuite
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2023-05-19 09:18:09 +0200
committerJan Beulich <jbeulich@suse.com>2023-05-19 09:18:09 +0200
commit5cc007751cdb8ea713c98294e37cd447c12c9bab (patch)
tree40b097e498c9425d36eccf81af9d0b6148964f8a /gas/testsuite
parent6f5ee7a3e9239cf82142d7abd4b2ad687076cfc1 (diff)
downloadgdb-5cc007751cdb8ea713c98294e37cd447c12c9bab.zip
gdb-5cc007751cdb8ea713c98294e37cd447c12c9bab.tar.gz
gdb-5cc007751cdb8ea713c98294e37cd447c12c9bab.tar.bz2
x86: further adjust extend-to-32bit-address conditions
While a442cac5084e ("ix86: wrap constants") helped address a number of inconsistencies between BFD64 and !BFD64 builds, it has also resulted in certain bogus uses of constants to no longer be warned about. Leverage the md_optimize_expr() hook to adjust when to actually truncate expressions to 32 bits - any involvement of binary expressions (which would be evaluated in 32 bits only when !BFD64) signals the need for doing so. Plain constants (or ones merely subject to unary operators) should remain un-truncated - they would be handled as bignums when !BFD64, and hence are okay to permit. To compensate - slightly extend optimize_imm() (to be honest I never understood why the code being added - or something similar - wasn't there in the first place), - adjust expectations of the disp-imm-32 testcase (there are now warnings, as there should be for any code which won't build [warning- free] when !BFD64, and Disp8/Imm8 are no longer used in the warned about cases).
Diffstat (limited to 'gas/testsuite')
-rw-r--r--gas/testsuite/gas/i386/cst-diag.l43
-rw-r--r--gas/testsuite/gas/i386/cst-diag.s79
-rw-r--r--gas/testsuite/gas/i386/disp-imm-32.d7
-rw-r--r--gas/testsuite/gas/i386/disp-imm-32.e4
-rw-r--r--gas/testsuite/gas/i386/i386.exp1
5 files changed, 131 insertions, 3 deletions
diff --git a/gas/testsuite/gas/i386/cst-diag.l b/gas/testsuite/gas/i386/cst-diag.l
new file mode 100644
index 0000000..0f0eb08
--- /dev/null
+++ b/gas/testsuite/gas/i386/cst-diag.l
@@ -0,0 +1,43 @@
+.*: Assembler messages:
+.*:3: Warning: .*
+.*:4: Warning: .*
+.*:5: (Error|Warning): .*
+.*:6: (Error|Warning): .*
+.*:8: Warning: .*
+.*:9: Warning: .*
+.*:10: (Error|Warning): .*
+.*:11: (Error|Warning): .*
+.*:13: Warning: .*
+.*:14: Warning: .*
+.*:15: (Error|Warning): .*
+.*:16: (Error|Warning): .*
+.*:18: Warning: .*
+.*:19: (Error|Warning): .*
+.*:20: (Error|Warning): .*
+.*:22: (Error|Warning): .*
+.*:23: (Error|Warning): .*
+.*:24: (Error|Warning): .*
+.*:25: (Error|Warning): .*
+.*:30: Warning: .*
+.*:31: Warning: .*
+.*:35: Warning: .*
+.*:36: Warning: .*
+.*:40: Warning: .*
+.*:41: Warning: .*
+.*:46: Warning: .*
+.*:47: Warning: .*
+.*:48: Warning: .*
+.*:50: Warning: .*
+.*:51: Warning: .*
+.*:52: Warning: .*
+.*:55: Warning: .*
+.*:56: Warning: .*
+.*:57: Warning: .*
+.*:59: Warning: .*
+.*:60: Warning: .*
+.*:61: Warning: .*
+.*:64: Warning: .*
+.*:65: Warning: .*
+.*:66: Warning: .*
+GAS LISTING .*
+#pass
diff --git a/gas/testsuite/gas/i386/cst-diag.s b/gas/testsuite/gas/i386/cst-diag.s
new file mode 100644
index 0000000..d34ab3b
--- /dev/null
+++ b/gas/testsuite/gas/i386/cst-diag.s
@@ -0,0 +1,79 @@
+ .text
+const:
+ add $0x101, %cl
+ add $0x10001, %cx
+ add $0x100000001, %ecx
+ add 0x100000001, %ecx
+
+ add $0x100, %cl
+ add $0x10000, %cx
+ add $0x100000000, %ecx
+ add 0x100000000, %ecx
+
+ add $-0x101, %cl
+ add $-0x10001, %cx
+ add $-0x100000001, %ecx
+ add -0x100000001, %ecx
+
+ add $-0x100, %cl
+ add $-0x10000, %cx
+ add $-0x100000000, %ecx
+
+ add $0xffffffffffffff00, %cl
+ add $0xffffffffffff0000, %cx
+ add $0xffffffff00000000, %ecx
+ add 0xffffffff00000000, %ecx
+
+ # The next two might as well not have a disagnostic issued, but if
+ # there is one (as is the case now), then it should be independent
+ # of BFD64.
+ and $~0xff, %cl
+ and $~0xffff, %cx
+ and $~0xffffffff, %ecx
+ and ~0xffffffff, %ecx
+
+ and $0xff+2, %cl
+ and $0xffff+2, %cx
+ and $0xffffffff+2, %ecx
+ and 0xffffffff+2, %ecx
+
+ and $0xff*2, %cl
+ and $0xffff*2, %cx
+ and $0xffffffff*2, %ecx
+ and 0xffffffff*2, %ecx
+
+ .data
+ .byte 0x101
+ .byte -0x100
+ .byte 0xffffffffffffff00
+# .byte ~0xffffffffffffff00
+ .byte ~0xff
+ .byte 0xff+2
+ .byte 0xff*2
+
+ .p2align 4
+ .word 0x10001
+ .word -0x10000
+ .word 0xffffffffffff0000
+# .word ~0xffffffffffff0000
+ .word ~0xffff
+ .word 0xffff+2
+ .word 0xffff*2
+
+ .p2align 4
+ .long 0x100000001
+ .long -0x100000000
+ .long 0xffffffff00000000
+# .long ~0xffffffff00000000
+ .long ~0xffffffff
+# .long 0xffffffff+2
+# .long 0xffffffff*2
+
+ .p2align 4
+ .quad 0x100000001
+ .quad -0x100000000
+ .quad 0xffffffff00000000
+# .quad ~0xffffffff00000000
+ .quad ~0xffffffff
+# .quad 0xffffffff+2
+# .quad 0xffffffff*2
diff --git a/gas/testsuite/gas/i386/disp-imm-32.d b/gas/testsuite/gas/i386/disp-imm-32.d
index dc712b9..aa2e4a0 100644
--- a/gas/testsuite/gas/i386/disp-imm-32.d
+++ b/gas/testsuite/gas/i386/disp-imm-32.d
@@ -1,5 +1,6 @@
#objdump: -dw
#name: i386 displacements / immediates (32-bit)
+#warning_output: disp-imm-32.e
.*: +file format .*
@@ -15,7 +16,7 @@ Disassembly of section .text:
[ ]*[a-f0-9]+: 8b 40 ff mov -0x1\(%eax\),%eax
[ ]*[a-f0-9]+: 62 f1 7c 48 28 40 ff vmovaps -0x40\(%eax\),%zmm0
[ ]*[a-f0-9]+: 83 c1 ff add \$0xffffffff,%ecx
-[ ]*[a-f0-9]+: 8b 40 01 mov 0x1\(%eax\),%eax
-[ ]*[a-f0-9]+: 62 f1 7c 48 28 40 01 vmovaps 0x40\(%eax\),%zmm0
-[ ]*[a-f0-9]+: 83 c1 01 add \$0x1,%ecx
+[ ]*[a-f0-9]+: 8b (40 01 +|80 01 00 00 00) mov 0x1\(%eax\),%eax
+[ ]*[a-f0-9]+: 62 f1 7c 48 28 (40 01|80 40 00 00 00) vmovaps 0x40\(%eax\),%zmm0
+[ ]*[a-f0-9]+: (83 c1 01 +|81 c1 01 00 00 00) add \$0x1,%ecx
#pass
diff --git a/gas/testsuite/gas/i386/disp-imm-32.e b/gas/testsuite/gas/i386/disp-imm-32.e
new file mode 100644
index 0000000..3da95b4
--- /dev/null
+++ b/gas/testsuite/gas/i386/disp-imm-32.e
@@ -0,0 +1,4 @@
+.*: Assembler messages:
+.*:15: Warning: .* shortened to 0x1
+.*:16: Warning: .* shortened to 0x40
+.*:17: Warning: .* shortened to 0x1
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 40e75ac..62796c7 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -100,6 +100,7 @@ if [gas_32_check] then {
run_dump_test "suffix-intel"
run_list_test "suffix-bad"
run_dump_test "immed32"
+ run_list_test "cst-diag" "-al"
run_dump_test "equ"
run_list_test "equ-2" "-al"
run_list_test "equ-bad"