x86: further adjust extend-to-32bit-address conditions
authorJan Beulich <jbeulich@suse.com>
Fri, 19 May 2023 07:18:09 +0000 (09:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 May 2023 07:18:09 +0000 (09:18 +0200)
commit5cc007751cdb8ea713c98294e37cd447c12c9bab
tree40b097e498c9425d36eccf81af9d0b6148964f8a
parent6f5ee7a3e9239cf82142d7abd4b2ad687076cfc1
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).
gas/config/tc-i386-intel.c
gas/config/tc-i386.c
gas/config/tc-i386.h
gas/testsuite/gas/i386/cst-diag.l [new file with mode: 0644]
gas/testsuite/gas/i386/cst-diag.s [new file with mode: 0644]
gas/testsuite/gas/i386/disp-imm-32.d
gas/testsuite/gas/i386/disp-imm-32.e [new file with mode: 0644]
gas/testsuite/gas/i386/i386.exp