From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id EC3793858404 for ; Tue, 10 Oct 2023 04:13:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC3793858404 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-690f7d73a3aso4635104b3a.0 for ; Mon, 09 Oct 2023 21:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1696911193; x=1697515993; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I+r2OOd09JbCXZKD13x8DNc/mixN3aexjhHoxIM1Zmk=; b=LMW7ZfSkRysOTOjuZ5GVzG/afRQzKW6xiYzN4rORSdUkcj7mRKnta8nbtYJ212vtOb DXW6M3/TbuLUa7QtMgw0fV6Rac3WC+9q/dMWFkzuzl92LcZGIaZGU6Q6l3/qkOy/Le6h B5R2+vAIFOaahouJl8YDsz1BDRLW71aYj2yANrdlMoXzEy7vvLGmI2AM9J41hdyAwdcc 7A9N66IlicCuxKJq8tr4Ad7kGfLEaCPmW+uj73l12FncD09NJ+4XYPV1oFuLx1cNA5Me uSRx96ZBDGbIgsZps+rYLWLhkQx138uDyJ4CzchcrUt7upd6mtU3OHWCm1AYh0dALrVc VPPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696911193; x=1697515993; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I+r2OOd09JbCXZKD13x8DNc/mixN3aexjhHoxIM1Zmk=; b=w0TzK6yHkBEr6NEXfxYtivm0rxfTkuGAib2nYbHczNjxnxHLA61qIC5NruL/d/4NSV 524Fb3vf8pNvqk6EjYAJ+MXn5UTi9ctrZMrM+RVgB/Oh87Z9kYKTyfHqdqvL2JRRfvRL dA2lG5kKJ7UuSdeQknNjs04mqphvRZlTGK5ndyf3uOdGSiQFaX6wDbN1D6zzNoDnCFQM p5BG+m74jJHCd3+i4XD8XxjDimI9gwFYwieGyRcXQWuZp6abv2Xed8PULIjMpn1VNIMp Kl2/U1lKFKFeH0nZnLqbC0DsujDUHxDsz052I73Llql93dfaCxTylgAc3xINV9i7xeKV tw3Q== X-Gm-Message-State: AOJu0YwURBnhmRc7QO8mgNqcldTaWcyUyPtToNeQFxmULNimD2p1t4gz lDLyvNY7bVLDgoPuVXnhKEu6Cz/frQEQYRVDq6seZVEA+iSBuiFAo/fjlk+YOSNbkkNkB1hQW9Y iVU8t5oFwC69mdfndN+BsRYR6utqM35mGhqXtZa+1vJH8+A6PE44CdIjxxyfA4zHNN28ivdM+6T iKehnMLg== X-Google-Smtp-Source: AGHT+IHWb1aUsUiLXRBnHsDncIVi9XV6rYouzpngHexyyT+y9CcOW0/LmaVQhTOI0akI7gC3nuUVqQ== X-Received: by 2002:a05:6a20:7343:b0:14c:3218:c1bd with SMTP id v3-20020a056a20734300b0014c3218c1bdmr19948200pzc.11.1696911193174; Mon, 09 Oct 2023 21:13:13 -0700 (PDT) Received: from SiX1E.. ([12.44.202.61]) by smtp.gmail.com with ESMTPSA id f12-20020a170902ab8c00b001c444106bcasm10501093plr.46.2023.10.09.21.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 21:13:12 -0700 (PDT) From: Kito Cheng To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com, rdapp@ventanamicro.com, juzhe.zhong@rivai.ai Cc: Kito Cheng Subject: [PATCH v2 1/4] options: Define TARGET__P and TARGET__OPTS_P macro for Mask and InverseMask Date: Mon, 9 Oct 2023 21:13:02 -0700 Message-Id: <20231010041305.9111-2-kito.cheng@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010041305.9111-1-kito.cheng@sifive.com> References: <20231010041305.9111-1-kito.cheng@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: We TARGET__P marcro to test a Mask and InverseMask with user specified target_variable, however we may want to test with specific gcc_options variable rather than target_variable. Like RISC-V has defined lots of Mask with TargetVariable, which is not easy to use, because that means we need to known which Mask are associate with which TargetVariable, so take a gcc_options variable is a better interface for such use case. gcc/ChangeLog: * doc/options.texi (Mask): Document TARGET__P and TARGET__OPTS_P. (InverseMask): Ditto. * opth-gen.awk (Mask): Generate TARGET__P and TARGET__OPTS_P macro. (InverseMask): Ditto. --- gcc/doc/options.texi | 23 ++++++++++++++++------- gcc/opth-gen.awk | 13 ++++++++++++- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi index 1f7c15b8eb4..715f0a1479c 100644 --- a/gcc/doc/options.texi +++ b/gcc/doc/options.texi @@ -404,18 +404,27 @@ You may also specify @code{Var} to select a variable other than The options-processing script will automatically allocate a unique bit for the option. If the option is attached to @samp{target_flags} or @code{Var} which is defined by @code{TargetVariable}, the script will set the macro -@code{MASK_@var{name}} to the appropriate bitmask. It will also declare a -@code{TARGET_@var{name}} macro that has the value 1 when the option is active -and 0 otherwise. If you use @code{Var} to attach the option to a different variable -which is not defined by @code{TargetVariable}, the bitmask macro with be -called @code{OPTION_MASK_@var{name}}. +@code{MASK_@var{name}} to the appropriate bitmask. It will also declare a +@code{TARGET_@var{name}}, @code{TARGET_@var{name}_P} and +@code{TARGET_@var{name}_OPTS_P}: @code{TARGET_@var{name}} macros that has the +value 1 when the option is active and 0 otherwise, @code{TARGET_@var{name}_P} is +similar to @code{TARGET_@var{name}} but take an argument as @samp{target_flags} +or @code{TargetVariable}, and @code{TARGET_@var{name}_OPTS_P} also similar to +@code{TARGET_@var{name}} but take an argument as @code{gcc_options}. +If you use @code{Var} to attach the option to a different variable which is not +defined by @code{TargetVariable}, the bitmask macro with be called +@code{OPTION_MASK_@var{name}}. @item InverseMask(@var{othername}) @itemx InverseMask(@var{othername}, @var{thisname}) The option is the inverse of another option that has the @code{Mask(@var{othername})} property. If @var{thisname} is given, -the options-processing script will declare a @code{TARGET_@var{thisname}} -macro that is 1 when the option is active and 0 otherwise. +the options-processing script will declare @code{TARGET_@var{thisname}}, +@code{TARGET_@var{name}_P} and @code{TARGET_@var{name}_OPTS_P} macros: +@code{TARGET_@var{thisname}} is 1 when the option is active and 0 otherwise, +@code{TARGET_@var{name}_P} is similar to @code{TARGET_@var{name}} but take an +argument as @samp{target_flags}, and and @code{TARGET_@var{name}_OPTS_P} also +similar to @code{TARGET_@var{name}} but take an argument as @code{gcc_options}. @item Enum(@var{name}) The option's argument is a string from the set of strings associated diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index c4398be2f3a..26551575d55 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -439,6 +439,10 @@ for (i = 0; i < n_target_vars; i++) { print "#define TARGET_" other_masks[i "," j] \ " ((" target_vars[i] " & MASK_" other_masks[i "," j] ") != 0)" + print "#define TARGET_" other_masks[i "," j] "_P(" target_vars[i] ")" \ + " (((" target_vars[i] ") & MASK_" other_masks[i "," j] ") != 0)" + print "#define TARGET_" other_masks[i "," j] "_OPTS_P(opts)" \ + " (((opts->x_" target_vars[i] ") & MASK_" other_masks[i "," j] ") != 0)" } } print "" @@ -469,15 +473,22 @@ for (i = 0; i < n_opts; i++) { " ((" vname " & " mask original_name ") != 0)" print "#define TARGET_" name "_P(" vname ")" \ " (((" vname ") & " mask original_name ") != 0)" + print "#define TARGET_" name "_OPTS_P(opts)" \ + " (((opts->x_" vname ") & " mask original_name ") != 0)" print "#define TARGET_EXPLICIT_" name "_P(opts)" \ " ((opts->x_" vname "_explicit & " mask original_name ") != 0)" print "#define SET_TARGET_" name "(opts) opts->x_" vname " |= " mask original_name } } for (i = 0; i < n_extra_masks; i++) { - if (extra_mask_macros[extra_masks[i]] == 0) + if (extra_mask_macros[extra_masks[i]] == 0) { print "#define TARGET_" extra_masks[i] \ " ((target_flags & MASK_" extra_masks[i] ") != 0)" + print "#define TARGET_" extra_masks[i] "_P(target_flags)" \ + " (((target_flags) & " extra_masks[i] ") != 0)" + print "#define TARGET_" extra_masks[i] "_OPTS_P(opts)" \ + " (((opts->x_target_flags) & MASK_" extra_masks[i] ") != 0)" + } } print "" -- 2.34.1