This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Option flag with string arguments
- From: Jozef Lawrynowicz <jozef dot l at mittosystems dot com>
- To: Erick Ochoa <erick dot ochoa at theobroma-systems dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, Christoph Müllner <christoph dot muellner at theobroma-systems dot com>, "Dr. Philipp Tomsich" <philipp dot tomsich at theobroma-systems dot com>
- Date: Thu, 19 Dec 2019 22:01:17 +0000
- Subject: Re: Option flag with string arguments
- References: <880c8375-41c6-eb54-7a3c-79e88c066b33@theobroma-systems.com>
On Thu, 19 Dec 2019 16:47:42 -0500
Erick Ochoa <erick.ochoa@theobroma-systems.com> wrote:
> Hello,
>
> I am working on testing an optimization. I am starting to write
> tests in the GCC testing suite. However, I want to develop some
> fine grain testing for my own sake.
>
> This optimization I am working on, is a variant of struct reordering.
> One way I would like to test my pass is for example, making a test case
> and guaranteeing that my pass is able to detect global variables of
> a specific struct type.
>
> For example, given the following C file
>
> ```
> /* { dg-lto-options {{-flto -fipa-struct-reorg -fipa-struct-reorg-assert-has-structs=astruct_s}} } */
>
> struct astruct_s { _Bool a; };
> struct astruct_s astruct;
>
> int main() { };
> ```
>
> I would like to create the option flag that has a list of string arguments
>
> -fipa-struct-reorg-assert-has-structs=<string>+
>
> such that during the analysis time, I'd be able to have an assertion
> to make sure that my pass has actually collected the types identified by the
> strings.
> I'm not very familiar on the DSL to specify option flags.
> I've looked at gcc/common.opt for some examples and found this one:
>
> ```
> frandom-seed=
> Common Joined RejectNegative Var(common_deferred_options) Defer
> -frandom-seed=<string> Make compile reproducible using <string>.
> ```
>
> Could anyone explain how to specify my flag? Or possibly
> point to some documentation/source that explains Common, Joined, etc...?
Have you looked at the GCC Internals Manual (gccint)? The section on option
specification files is online here:
https://gcc.gnu.org/onlinedocs/gccint/Option-properties.html#Option-properties
Jozef