GCN: Tag '-march=[...]', '-mtune=[...]' as 'Negative' of themselves [PR112669] (was: [gcn][patch] Add -mgpu option and plumb in assembler/linker)

Message ID 87v89rryiv.fsf@euler.schwinge.homeip.net
State Accepted
Headers
Series GCN: Tag '-march=[...]', '-mtune=[...]' as 'Negative' of themselves [PR112669] (was: [gcn][patch] Add -mgpu option and plumb in assembler/linker) |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Thomas Schwinge Nov. 24, 2023, 2:55 p.m. UTC
  Hi!

On 2017-06-21T11:06:24+0100, Andrew Stubbs <ams@codesourcery.com> wrote:
> --- a/gcc/config/gcn/gcn.opt
> +++ b/gcc/config/gcn/gcn.opt

> +march=
> +Target RejectNegative Joined ToLower Enum(gpu_type) Var(gcn_arch) Init(PROCESSOR_CARRIZO)
> +Specify the name of the target GPU.
> +
> +mtune=
> +Target RejectNegative Joined ToLower Enum(gpu_type) Var(gcn_tune) Init(PROCESSOR_CARRIZO)
> +Specify the name of the target GPU.

OK to push the attached
"GCN: Tag '-march=[...]', '-mtune=[...]' as 'Negative' of themselves [PR112669]"?

For reference, see also:

  - [...]
  - commit 718a3eab2906217c70f27077446fa0e8ddb1bf7b "[arm] Mark -marm and -mthumb as being inverse options"
  - commit aebe10d48ccc217273ee8a4e2c3805ed1e173a78 "driver: Also prune joined switches with negation" ['gcc/config/i386/i386.opt']
  - commit 6fdbe41963a7aecad80f27e9805c7e18cbd4ab48 "driver: Also prune joined switches with negation" ['gcc/config/aarch64/aarch64.opt', 'gcc/config/arm/arm.opt']
  - commit 17f2908fcf058e145cff275966e34f8c7f57c2c5 "RISC-V: For '-march' and '-mabi' options, add 'Negative' property mentions itself"
  - commit 69c426b89579312af91035c26fb1e270bfbcad00 "doc/options.texi: Fix the description of 'Negative'"


(..., and yes, GCC/nvptx does need similar treatment...)


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Patch

From 0e03aa39bd5fbae8a5993bf9bf6dad34f9e85c2d Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas_schwinge@mentor.com>
Date: Wed, 22 Nov 2023 17:35:23 +0100
Subject: [PATCH] GCN: Tag '-march=[...]', '-mtune=[...]' as 'Negative' of
 themselves [PR112669]

Certain other command-line flags are mutually exclusive (random example: GCN
'-march=gfx906', '-march=gfx908').  If they're not appropriately marked up,
this does disturb the multilib selection machinery, for example:

    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx906
    gfx906
    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx908
    gfx908
    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx906 -march=gfx908
    .

In the last invocation, '-march=gfx900 -march=gfx906', for example, in
'gcc/gcc.cc:set_multilib_dir' we see both flags -- which there doesn't exist a
matching multilib for, therefore we "fail" to the default ('.').  Tagges as
'Negative', only the last flag survives, and we, for example, get the expected:

    $ build-gcc-offload-amdgcn-amdhsa/gcc/xgcc -print-multi-directory -march=gfx906 -march=gfx908
    gfx908

I quickly found that the same also applies to GCN's '-mtune=[...]', but I've
not otherwise reviewed the GCN options.

	PR target/112669
	gcc/
	* config/gcn/gcn.opt (march=, mtune=): Tag as 'Negative' of
	themselves.
---
 gcc/config/gcn/gcn.opt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/gcn/gcn.opt b/gcc/config/gcn/gcn.opt
index 7a852c51c84..e5db6df92d7 100644
--- a/gcc/config/gcn/gcn.opt
+++ b/gcc/config/gcn/gcn.opt
@@ -44,11 +44,11 @@  EnumValue
 Enum(gpu_type) String(gfx1030) Value(PROCESSOR_GFX1030)
 
 march=
-Target RejectNegative Joined ToLower Enum(gpu_type) Var(gcn_arch) Init(PROCESSOR_FIJI)
+Target RejectNegative Negative(march=) Joined ToLower Enum(gpu_type) Var(gcn_arch) Init(PROCESSOR_FIJI)
 Specify the name of the target GPU.
 
 mtune=
-Target RejectNegative Joined ToLower Enum(gpu_type) Var(gcn_tune) Init(PROCESSOR_FIJI)
+Target RejectNegative Negative(mtune=) Joined ToLower Enum(gpu_type) Var(gcn_tune) Init(PROCESSOR_FIJI)
 Specify the name of the target GPU.
 
 m32
-- 
2.34.1