Re: [PATCH] Reformat target.def for better parsing.

2021-06-07 Thread Richard Biener via Gcc-patches
On Mon, Jun 7, 2021 at 10:35 AM Martin Liška  wrote:
>
> On 6/7/21 8:14 AM, Richard Biener wrote:
> > Hmm, what's the problem with parsing the strings?  The newlines are
> > only because of our line length limits and hard-coding them looks both
> > error-prone and ugly.
>
> For the future Sphinx conversion, I need to replace content of the hook 
> definitions
> in .def files with RST format (as opposed to the current TEXI format). I did 
> so
> by putting a placeholders in genhooks.c and then parsing of the created .rst 
> file.
>
> When there are no newlines, then I can't split the generated .rst content to 
> multiple lines
> as defined in .def files.
>
> So my patch makes it only consistent as most of the hooks use '\n\' line 
> endings.

Oh - they do.  Yes, it makes sense as a fix then.

Thanks,
Richard.

> Does it make sense?
> Martin
>


Re: [PATCH] Reformat target.def for better parsing.

2021-06-07 Thread Martin Liška

On 6/7/21 8:14 AM, Richard Biener wrote:

Hmm, what's the problem with parsing the strings?  The newlines are
only because of our line length limits and hard-coding them looks both
error-prone and ugly.


For the future Sphinx conversion, I need to replace content of the hook 
definitions
in .def files with RST format (as opposed to the current TEXI format). I did so
by putting a placeholders in genhooks.c and then parsing of the created .rst 
file.

When there are no newlines, then I can't split the generated .rst content to 
multiple lines
as defined in .def files.

So my patch makes it only consistent as most of the hooks use '\n\' line 
endings.

Does it make sense?
Martin



Re: [PATCH] Reformat target.def for better parsing.

2021-06-07 Thread Richard Biener via Gcc-patches
On Sun, Jun 6, 2021 at 7:13 PM Martin Liška  wrote:
>
> Hello.
>
> I'll need to parse output of tm.texi when converted to Sphinx for the future
> conversion. So that I split DEFHOOK documentation entries with newlines.
>
> I'll install the patch if there are no comments?

Hmm, what's the problem with parsing the strings?  The newlines are
only because of our line length limits and hard-coding them looks both
error-prone and ugly.

Richard.

> Thanks,
> Martin
>
> gcc/c-family/ChangeLog:
>
> * c-target.def: Split long lines and replace them
> with '\n\'.
>
> gcc/ChangeLog:
>
> * common/common-target.def: Split long lines and replace them
> with '\n\'.
> * target.def: Likewise.
> * doc/tm.texi: Re-generated.
> ---
>   gcc/c-family/c-target.def|  70 ++---
>   gcc/common/common-target.def |  32 +--
>   gcc/doc/tm.texi  | 364 +-
>   gcc/target.def   | 485 +++
>   4 files changed, 612 insertions(+), 339 deletions(-)
>
> diff --git a/gcc/c-family/c-target.def b/gcc/c-family/c-target.def
> index f2a1b7ef7c5..164f1b31694 100644
> --- a/gcc/c-family/c-target.def
> +++ b/gcc/c-family/c-target.def
> @@ -43,73 +43,73 @@ DEFHOOK
>
>   DEFHOOK
>   (objc_construct_string_object,
> - "Targets may provide a string object type that can be used within\
> - and between C, C++ and their respective Objective-C dialects.\
> - A string object might, for example, embed encoding and length information.\
> - These objects are considered opaque to the compiler and handled as 
> references.\
> - An ideal implementation makes the composition of the string object\
> - match that of the Objective-C @code{NSString} (@code{NXString} for 
> GNUStep),\
> - allowing efficient interworking between C-only and Objective-C code.\
> - If a target implements string objects then this hook should return a\
> - reference to such an object constructed from the normal `C' string\
> - representation provided in @var{string}.\
> - At present, the hook is used by Objective-C only, to obtain a\
> + "Targets may provide a string object type that can be used within\n\
> +and between C, C++ and their respective Objective-C dialects.\n\
> +A string object might, for example, embed encoding and length information.\n\
> +These objects are considered opaque to the compiler and handled as 
> references.\n\
> +An ideal implementation makes the composition of the string object\n\
> +match that of the Objective-C @code{NSString} (@code{NXString} for 
> GNUStep),\n\
> +allowing efficient interworking between C-only and Objective-C code.\n\
> +If a target implements string objects then this hook should return a\n\
> +reference to such an object constructed from the normal `C' string\n\
> +representation provided in @var{string}.\n\
> +At present, the hook is used by Objective-C only, to obtain a\n\
>common-format string object when the target provides one.",
>tree, (tree string),
>NULL)
>
>   DEFHOOK
>   (objc_declare_unresolved_class_reference,
> - "Declare that Objective C class @var{classname} is referenced\
> -  by the current TU.",
> + "Declare that Objective C class @var{classname} is referenced\n\
> +by the current TU.",
>void, (const char *classname),
>NULL)
>
>   DEFHOOK
>   (objc_declare_class_definition,
> - "Declare that Objective C class @var{classname} is defined\
> -  by the current TU.",
> + "Declare that Objective C class @var{classname} is defined\n\
> +by the current TU.",
>void, (const char *classname),
>NULL)
>
>   DEFHOOK
>   (string_object_ref_type_p,
> - "If a target implements string objects then this hook should return\
> - @code{true} if @var{stringref} is a valid reference to such an object.",
> + "If a target implements string objects then this hook should return\n\
> +@code{true} if @var{stringref} is a valid reference to such an object.",
>bool, (const_tree stringref),
>hook_bool_const_tree_false)
>
>   DEFHOOK
>   (check_string_object_format_arg,
> - "If a target implements string objects then this hook should should\
> -  provide a facility to check the function arguments in @var{args_list}\
> -  against the format specifiers in @var{format_arg} where the type of\
> -  @var{format_arg} is one recognized as a valid string reference type.",
> + "If a target implements string objects then this hook should should\n\
> +provide a facility to check the function arguments in @var{args_list}\n\
> +against the format specifiers in @var{format_arg} where the type of\n\
> +@var{format_arg} is one recognized as a valid string reference type.",
>void, (tree format_arg, tree args_list),
>NULL)
>
>   DEFHOOK
>   (c_preinclude,
> - "Define this hook to return the name of a header file to be included at\
> - the start of all compilations, as if it had been included with\
> - @code{#include <@var{file}>}.  If this hook returns @code{NULL}, or is\
> - not defined, or the header is 

[PATCH] Reformat target.def for better parsing.

2021-06-06 Thread Martin Liška

Hello.

I'll need to parse output of tm.texi when converted to Sphinx for the future
conversion. So that I split DEFHOOK documentation entries with newlines.

I'll install the patch if there are no comments?
Thanks,
Martin

gcc/c-family/ChangeLog:

* c-target.def: Split long lines and replace them
with '\n\'.

gcc/ChangeLog:

* common/common-target.def: Split long lines and replace them
with '\n\'.
* target.def: Likewise.
* doc/tm.texi: Re-generated.
---
 gcc/c-family/c-target.def|  70 ++---
 gcc/common/common-target.def |  32 +--
 gcc/doc/tm.texi  | 364 +-
 gcc/target.def   | 485 +++
 4 files changed, 612 insertions(+), 339 deletions(-)

diff --git a/gcc/c-family/c-target.def b/gcc/c-family/c-target.def
index f2a1b7ef7c5..164f1b31694 100644
--- a/gcc/c-family/c-target.def
+++ b/gcc/c-family/c-target.def
@@ -43,73 +43,73 @@ DEFHOOK
 
 DEFHOOK

 (objc_construct_string_object,
- "Targets may provide a string object type that can be used within\
- and between C, C++ and their respective Objective-C dialects.\
- A string object might, for example, embed encoding and length information.\
- These objects are considered opaque to the compiler and handled as 
references.\
- An ideal implementation makes the composition of the string object\
- match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\
- allowing efficient interworking between C-only and Objective-C code.\
- If a target implements string objects then this hook should return a\
- reference to such an object constructed from the normal `C' string\
- representation provided in @var{string}.\
- At present, the hook is used by Objective-C only, to obtain a\
+ "Targets may provide a string object type that can be used within\n\
+and between C, C++ and their respective Objective-C dialects.\n\
+A string object might, for example, embed encoding and length information.\n\
+These objects are considered opaque to the compiler and handled as 
references.\n\
+An ideal implementation makes the composition of the string object\n\
+match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\n\
+allowing efficient interworking between C-only and Objective-C code.\n\
+If a target implements string objects then this hook should return a\n\
+reference to such an object constructed from the normal `C' string\n\
+representation provided in @var{string}.\n\
+At present, the hook is used by Objective-C only, to obtain a\n\
  common-format string object when the target provides one.",
  tree, (tree string),
  NULL)
 
 DEFHOOK

 (objc_declare_unresolved_class_reference,
- "Declare that Objective C class @var{classname} is referenced\
-  by the current TU.",
+ "Declare that Objective C class @var{classname} is referenced\n\
+by the current TU.",
  void, (const char *classname),
  NULL)
 
 DEFHOOK

 (objc_declare_class_definition,
- "Declare that Objective C class @var{classname} is defined\
-  by the current TU.",
+ "Declare that Objective C class @var{classname} is defined\n\
+by the current TU.",
  void, (const char *classname),
  NULL)
 
 DEFHOOK

 (string_object_ref_type_p,
- "If a target implements string objects then this hook should return\
- @code{true} if @var{stringref} is a valid reference to such an object.",
+ "If a target implements string objects then this hook should return\n\
+@code{true} if @var{stringref} is a valid reference to such an object.",
  bool, (const_tree stringref),
  hook_bool_const_tree_false)
 
 DEFHOOK

 (check_string_object_format_arg,
- "If a target implements string objects then this hook should should\
-  provide a facility to check the function arguments in @var{args_list}\
-  against the format specifiers in @var{format_arg} where the type of\
-  @var{format_arg} is one recognized as a valid string reference type.",
+ "If a target implements string objects then this hook should should\n\
+provide a facility to check the function arguments in @var{args_list}\n\
+against the format specifiers in @var{format_arg} where the type of\n\
+@var{format_arg} is one recognized as a valid string reference type.",
  void, (tree format_arg, tree args_list),
  NULL)
 
 DEFHOOK

 (c_preinclude,
- "Define this hook to return the name of a header file to be included at\
- the start of all compilations, as if it had been included with\
- @code{#include <@var{file}>}.  If this hook returns @code{NULL}, or is\
- not defined, or the header is not found, or if the user specifies\
- @option{-ffreestanding} or @option{-nostdinc}, no header is included.\n\
+ "Define this hook to return the name of a header file to be included at\n\
+the start of all compilations, as if it had been included with\n\
+@code{#include <@var{file}>}.  If this hook returns @code{NULL}, or is\n\
+not defined, or the header is not found, or if the user specifies\n\
+@option{-ffreestanding} or @option{-nostdinc}, no