diff mbox series

Rename ASM_INPUT_P to ASM_BASIC_P

Message ID mpt5xrkln74.fsf@arm.com
State New
Headers show
Series Rename ASM_INPUT_P to ASM_BASIC_P | expand

Commit Message

Richard Sandiford Aug. 28, 2024, 2:46 p.m. UTC
ASM_INPUT_P is so named because it causes the eventual rtl insn
pattern to be a top-level ASM_INPUT rather than an ASM_OPERANDS.
However, this name has caused confusion, partly due to earlier
documentation.  The name also sounds related to ASM_INPUTS but
is for a different piece of state.

This patch renames it to ASM_BASIC_P, with the inverse meaning
an extended asm.  ("Basic asm" is the term used in extend.texi.)

Tested on aarch64-linux-gnu (all languages, as usual, but that's
especially relevant here).  OK to install?

Richard


gcc/
	* doc/generic.texi (ASM_BASIC_P): Document.
	* tree.h (ASM_INPUT_P): Rename to...
	(ASM_BASIC_P): ...this.
	(ASM_VOLATILE_P, ASM_INLINE_P): Reindent.
	* gimplify.cc (gimplify_asm_expr): Update after above renaming.
	* tree-core.h (tree_base): Likewise.

gcc/c/
	* c-typeck.cc (build_asm_expr): Rename ASM_INPUT_P to ASM_BASIC_P.

gcc/cp/
	* pt.cc (tsubst_stmt): Rename ASM_INPUT_P to ASM_BASIC_P.
	* parser.cc (cp_parser_asm_definition): Likewise.

gcc/d/
	* toir.cc (IRVisitor): Rename ASM_INPUT_P to ASM_BASIC_P.

gcc/jit/
	* jit-playback.cc (playback::block::add_extended_asm):  Rename
	ASM_INPUT_P to ASM_BASIC_P.

gcc/m2/
	* gm2-gcc/m2block.cc (flush_pending_note): Rename ASM_INPUT_P
	to ASM_BASIC_P.
	* gm2-gcc/m2statement.cc (m2statement_BuildAsm): Likewise.
---
 gcc/c/c-typeck.cc             |  2 +-
 gcc/cp/parser.cc              |  2 +-
 gcc/cp/pt.cc                  |  2 +-
 gcc/d/toir.cc                 |  5 ++---
 gcc/doc/generic.texi          | 16 +++++++++++-----
 gcc/gimplify.cc               |  2 +-
 gcc/jit/jit-playback.cc       |  2 +-
 gcc/m2/gm2-gcc/m2block.cc     |  2 +-
 gcc/m2/gm2-gcc/m2statement.cc |  2 +-
 gcc/tree-core.h               |  2 +-
 gcc/tree.h                    |  6 +++---
 11 files changed, 24 insertions(+), 19 deletions(-)

Comments

Richard Biener Aug. 29, 2024, 9:09 a.m. UTC | #1
On Wed, Aug 28, 2024 at 4:47 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>
> ASM_INPUT_P is so named because it causes the eventual rtl insn
> pattern to be a top-level ASM_INPUT rather than an ASM_OPERANDS.
> However, this name has caused confusion, partly due to earlier
> documentation.  The name also sounds related to ASM_INPUTS but
> is for a different piece of state.
>
> This patch renames it to ASM_BASIC_P, with the inverse meaning
> an extended asm.  ("Basic asm" is the term used in extend.texi.)
>
> Tested on aarch64-linux-gnu (all languages, as usual, but that's
> especially relevant here).  OK to install?

OK if there are no objections this week.

Richard.

> Richard
>
>
> gcc/
>         * doc/generic.texi (ASM_BASIC_P): Document.
>         * tree.h (ASM_INPUT_P): Rename to...
>         (ASM_BASIC_P): ...this.
>         (ASM_VOLATILE_P, ASM_INLINE_P): Reindent.
>         * gimplify.cc (gimplify_asm_expr): Update after above renaming.
>         * tree-core.h (tree_base): Likewise.
>
> gcc/c/
>         * c-typeck.cc (build_asm_expr): Rename ASM_INPUT_P to ASM_BASIC_P.
>
> gcc/cp/
>         * pt.cc (tsubst_stmt): Rename ASM_INPUT_P to ASM_BASIC_P.
>         * parser.cc (cp_parser_asm_definition): Likewise.
>
> gcc/d/
>         * toir.cc (IRVisitor): Rename ASM_INPUT_P to ASM_BASIC_P.
>
> gcc/jit/
>         * jit-playback.cc (playback::block::add_extended_asm):  Rename
>         ASM_INPUT_P to ASM_BASIC_P.
>
> gcc/m2/
>         * gm2-gcc/m2block.cc (flush_pending_note): Rename ASM_INPUT_P
>         to ASM_BASIC_P.
>         * gm2-gcc/m2statement.cc (m2statement_BuildAsm): Likewise.
> ---
>  gcc/c/c-typeck.cc             |  2 +-
>  gcc/cp/parser.cc              |  2 +-
>  gcc/cp/pt.cc                  |  2 +-
>  gcc/d/toir.cc                 |  5 ++---
>  gcc/doc/generic.texi          | 16 +++++++++++-----
>  gcc/gimplify.cc               |  2 +-
>  gcc/jit/jit-playback.cc       |  2 +-
>  gcc/m2/gm2-gcc/m2block.cc     |  2 +-
>  gcc/m2/gm2-gcc/m2statement.cc |  2 +-
>  gcc/tree-core.h               |  2 +-
>  gcc/tree.h                    |  6 +++---
>  11 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
> index 094e41fa202..58b2724b39e 100644
> --- a/gcc/c/c-typeck.cc
> +++ b/gcc/c/c-typeck.cc
> @@ -11672,7 +11672,7 @@ build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
>
>    /* asm statements without outputs, including simple ones, are treated
>       as volatile.  */
> -  ASM_INPUT_P (args) = simple;
> +  ASM_BASIC_P (args) = simple;
>    ASM_VOLATILE_P (args) = (noutputs == 0);
>    ASM_INLINE_P (args) = is_inline;
>
> diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
> index 28ebf2beb60..58dd81d02f0 100644
> --- a/gcc/cp/parser.cc
> +++ b/gcc/cp/parser.cc
> @@ -23126,7 +23126,7 @@ cp_parser_asm_definition (cp_parser* parser)
>               if (TREE_CODE (temp) == CLEANUP_POINT_EXPR)
>                 temp = TREE_OPERAND (temp, 0);
>
> -             ASM_INPUT_P (temp) = 1;
> +             ASM_BASIC_P (temp) = 1;
>             }
>         }
>        else
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 24a6241d3a5..9ab635027e1 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -18930,7 +18930,7 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl)
>         tree asm_expr = tmp;
>         if (TREE_CODE (asm_expr) == CLEANUP_POINT_EXPR)
>           asm_expr = TREE_OPERAND (asm_expr, 0);
> -       ASM_INPUT_P (asm_expr) = ASM_INPUT_P (t);
> +       ASM_BASIC_P (asm_expr) = ASM_BASIC_P (t);
>        }
>        break;
>
> diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc
> index 9f5531ce5cd..a6848f2ffa2 100644
> --- a/gcc/d/toir.cc
> +++ b/gcc/d/toir.cc
> @@ -1491,10 +1491,9 @@ public:
>                        outputs, inputs, clobbers, labels);
>      SET_EXPR_LOCATION (exp, make_location_t (s->loc));
>
> -    /* If the extended syntax was not used, mark the ASM_EXPR as being an
> -       ASM_INPUT expression instead of an ASM_OPERAND with no operands.  */
> +    /* Record whether the basic rather than extended syntax was used.  */
>      if (s->args == NULL && s->clobbers == NULL)
> -      ASM_INPUT_P (exp) = 1;
> +      ASM_BASIC_P (exp) = 1;
>
>      /* All asm statements are assumed to have a side effect.  As a future
>         optimization, this could be unset when building in release mode.  */
> diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
> index c596b7d44b2..3de394fd6e0 100644
> --- a/gcc/doc/generic.texi
> +++ b/gcc/doc/generic.texi
> @@ -2095,11 +2095,17 @@ asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
>  @end smallexample
>  The first string is the @code{ASM_STRING}, containing the instruction
>  template.  The next two strings are the output and inputs, respectively;
> -this statement has no clobbers.  As this example indicates, ``plain''
> -assembly statements are merely a special case of extended assembly
> -statements; they have no cv-qualifiers, outputs, inputs, or clobbers.
> -All of the strings will be @code{NUL}-terminated, and will contain no
> -embedded @code{NUL}-characters.
> +this statement has no clobbers.  All of the strings will be
> +@code{NUL}-terminated, and will contain no embedded @code{NUL}-characters.
> +
> +@code{ASM_BASIC_P} indicates whether the assembly statement used the
> +``basic'' syntax (as for the first example above) or whether it used
> +the extended syntax (as for the second example above).  In many cases
> +this information could be inferred from other accessors, but the flag
> +is necessary to distinguish extended statements that have no operands
> +from basic statements.  A key difference between the two is that
> +@code{%} substitution is applied to @code{ASM_STRING} for extended
> +statements but not for basic statements.
>
>  If the assembly statement is declared @code{volatile}, or if the
>  statement was not an extended assembly statement, and is therefore
> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
> index 26a216e151d..3c84cfce5f7 100644
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -7340,7 +7340,7 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
>                                ASM_VOLATILE_P (expr)
>                                || noutputs == 0
>                                || labels);
> -      gimple_asm_set_input (stmt, ASM_INPUT_P (expr));
> +      gimple_asm_set_input (stmt, ASM_BASIC_P (expr));
>        gimple_asm_set_inline (stmt, ASM_INLINE_P (expr));
>
>        gimplify_seq_add_stmt (pre_p, stmt);
> diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
> index 501d5700873..3e717752fea 100644
> --- a/gcc/jit/jit-playback.cc
> +++ b/gcc/jit/jit-playback.cc
> @@ -2458,7 +2458,7 @@ playback::block::add_extended_asm (location *loc,
>    /* asm statements without outputs, including simple ones, are treated
>       as volatile.  */
>    ASM_VOLATILE_P (asm_stmt) = (outputs->length () == 0);
> -  ASM_INPUT_P (asm_stmt) = 0; /* extended asm stmts are not "simple".  */
> +  ASM_BASIC_P (asm_stmt) = 0;
>    ASM_INLINE_P (asm_stmt) = is_inline;
>    if (is_volatile)
>      ASM_VOLATILE_P (asm_stmt) = 1;
> diff --git a/gcc/m2/gm2-gcc/m2block.cc b/gcc/m2/gm2-gcc/m2block.cc
> index b456a1b3df7..517c1d2af4d 100644
> --- a/gcc/m2/gm2-gcc/m2block.cc
> +++ b/gcc/m2/gm2-gcc/m2block.cc
> @@ -711,7 +711,7 @@ flush_pending_note (void)
>        tree note = build_stmt (pending_location, ASM_EXPR, string, NULL_TREE,
>                                NULL_TREE, NULL_TREE, NULL_TREE);
>
> -      ASM_INPUT_P (note) = false;
> +      ASM_BASIC_P (note) = false;
>        ASM_VOLATILE_P (note) = false;
>  #else
>        tree note = build_empty_stmt (pending_location);
> diff --git a/gcc/m2/gm2-gcc/m2statement.cc b/gcc/m2/gm2-gcc/m2statement.cc
> index dd7f2529f5d..8b51febd12f 100644
> --- a/gcc/m2/gm2-gcc/m2statement.cc
> +++ b/gcc/m2/gm2-gcc/m2statement.cc
> @@ -519,7 +519,7 @@ m2statement_BuildAsm (location_t location, tree instr, bool isVolatile,
>
>    /* ASM statements without outputs, including simple ones, are treated
>       as volatile.  */
> -  ASM_INPUT_P (args) = isSimple;
> +  ASM_BASIC_P (args) = isSimple;
>    ASM_VOLATILE_P (args) = isVolatile;
>
>    add_stmt (location, args);
> diff --git a/gcc/tree-core.h b/gcc/tree-core.h
> index 27c569c7702..1ebf1a2dd6d 100644
> --- a/gcc/tree-core.h
> +++ b/gcc/tree-core.h
> @@ -1214,7 +1214,7 @@ struct GTY(()) tree_base {
>         TRY_CATCH_IS_CLEANUP in
>             TRY_CATCH_EXPR
>
> -       ASM_INPUT_P in
> +       ASM_BASIC_P in
>             ASM_EXPR
>
>         TYPE_REF_CAN_ALIAS_ALL in
> diff --git a/gcc/tree.h b/gcc/tree.h
> index c501019717f..b12b61d318e 100644
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -1431,11 +1431,11 @@ class auto_suppress_location_wrappers
>  /* Nonzero if the asm is a basic asm, zero if it is an extended asm.
>     Basic asms use a plain ASM_INPUT insn pattern whereas extended asms
>     use an ASM_OPERANDS insn pattern.  */
> -#define ASM_INPUT_P(NODE) (ASM_EXPR_CHECK (NODE)->base.static_flag)
> -#define ASM_VOLATILE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.public_flag)
> +#define ASM_BASIC_P(NODE)      (ASM_EXPR_CHECK (NODE)->base.static_flag)
> +#define ASM_VOLATILE_P(NODE)   (ASM_EXPR_CHECK (NODE)->base.public_flag)
>  /* Nonzero if we want to consider this asm as minimum length and cost
>     for inlining decisions.  */
> -#define ASM_INLINE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.protected_flag)
> +#define ASM_INLINE_P(NODE)     (ASM_EXPR_CHECK (NODE)->base.protected_flag)
>
>  /* COND_EXPR accessors.  */
>  #define COND_EXPR_COND(NODE)   (TREE_OPERAND (COND_EXPR_CHECK (NODE), 0))
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 094e41fa202..58b2724b39e 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -11672,7 +11672,7 @@  build_asm_expr (location_t loc, tree string, tree outputs, tree inputs,
 
   /* asm statements without outputs, including simple ones, are treated
      as volatile.  */
-  ASM_INPUT_P (args) = simple;
+  ASM_BASIC_P (args) = simple;
   ASM_VOLATILE_P (args) = (noutputs == 0);
   ASM_INLINE_P (args) = is_inline;
 
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 28ebf2beb60..58dd81d02f0 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -23126,7 +23126,7 @@  cp_parser_asm_definition (cp_parser* parser)
 	      if (TREE_CODE (temp) == CLEANUP_POINT_EXPR)
 		temp = TREE_OPERAND (temp, 0);
 
-	      ASM_INPUT_P (temp) = 1;
+	      ASM_BASIC_P (temp) = 1;
 	    }
 	}
       else
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 24a6241d3a5..9ab635027e1 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -18930,7 +18930,7 @@  tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	tree asm_expr = tmp;
 	if (TREE_CODE (asm_expr) == CLEANUP_POINT_EXPR)
 	  asm_expr = TREE_OPERAND (asm_expr, 0);
-	ASM_INPUT_P (asm_expr) = ASM_INPUT_P (t);
+	ASM_BASIC_P (asm_expr) = ASM_BASIC_P (t);
       }
       break;
 
diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc
index 9f5531ce5cd..a6848f2ffa2 100644
--- a/gcc/d/toir.cc
+++ b/gcc/d/toir.cc
@@ -1491,10 +1491,9 @@  public:
 		       outputs, inputs, clobbers, labels);
     SET_EXPR_LOCATION (exp, make_location_t (s->loc));
 
-    /* If the extended syntax was not used, mark the ASM_EXPR as being an
-       ASM_INPUT expression instead of an ASM_OPERAND with no operands.  */
+    /* Record whether the basic rather than extended syntax was used.  */
     if (s->args == NULL && s->clobbers == NULL)
-      ASM_INPUT_P (exp) = 1;
+      ASM_BASIC_P (exp) = 1;
 
     /* All asm statements are assumed to have a side effect.  As a future
        optimization, this could be unset when building in release mode.  */
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi
index c596b7d44b2..3de394fd6e0 100644
--- a/gcc/doc/generic.texi
+++ b/gcc/doc/generic.texi
@@ -2095,11 +2095,17 @@  asm ("fsinx %1,%0" : "=f" (result) : "f" (angle));
 @end smallexample
 The first string is the @code{ASM_STRING}, containing the instruction
 template.  The next two strings are the output and inputs, respectively;
-this statement has no clobbers.  As this example indicates, ``plain''
-assembly statements are merely a special case of extended assembly
-statements; they have no cv-qualifiers, outputs, inputs, or clobbers.
-All of the strings will be @code{NUL}-terminated, and will contain no
-embedded @code{NUL}-characters.
+this statement has no clobbers.  All of the strings will be
+@code{NUL}-terminated, and will contain no embedded @code{NUL}-characters.
+
+@code{ASM_BASIC_P} indicates whether the assembly statement used the
+``basic'' syntax (as for the first example above) or whether it used
+the extended syntax (as for the second example above).  In many cases
+this information could be inferred from other accessors, but the flag
+is necessary to distinguish extended statements that have no operands
+from basic statements.  A key difference between the two is that
+@code{%} substitution is applied to @code{ASM_STRING} for extended
+statements but not for basic statements.
 
 If the assembly statement is declared @code{volatile}, or if the
 statement was not an extended assembly statement, and is therefore
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 26a216e151d..3c84cfce5f7 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -7340,7 +7340,7 @@  gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 			       ASM_VOLATILE_P (expr)
 			       || noutputs == 0
 			       || labels);
-      gimple_asm_set_input (stmt, ASM_INPUT_P (expr));
+      gimple_asm_set_input (stmt, ASM_BASIC_P (expr));
       gimple_asm_set_inline (stmt, ASM_INLINE_P (expr));
 
       gimplify_seq_add_stmt (pre_p, stmt);
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 501d5700873..3e717752fea 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -2458,7 +2458,7 @@  playback::block::add_extended_asm (location *loc,
   /* asm statements without outputs, including simple ones, are treated
      as volatile.  */
   ASM_VOLATILE_P (asm_stmt) = (outputs->length () == 0);
-  ASM_INPUT_P (asm_stmt) = 0; /* extended asm stmts are not "simple".  */
+  ASM_BASIC_P (asm_stmt) = 0;
   ASM_INLINE_P (asm_stmt) = is_inline;
   if (is_volatile)
     ASM_VOLATILE_P (asm_stmt) = 1;
diff --git a/gcc/m2/gm2-gcc/m2block.cc b/gcc/m2/gm2-gcc/m2block.cc
index b456a1b3df7..517c1d2af4d 100644
--- a/gcc/m2/gm2-gcc/m2block.cc
+++ b/gcc/m2/gm2-gcc/m2block.cc
@@ -711,7 +711,7 @@  flush_pending_note (void)
       tree note = build_stmt (pending_location, ASM_EXPR, string, NULL_TREE,
                               NULL_TREE, NULL_TREE, NULL_TREE);
 
-      ASM_INPUT_P (note) = false;
+      ASM_BASIC_P (note) = false;
       ASM_VOLATILE_P (note) = false;
 #else
       tree note = build_empty_stmt (pending_location);
diff --git a/gcc/m2/gm2-gcc/m2statement.cc b/gcc/m2/gm2-gcc/m2statement.cc
index dd7f2529f5d..8b51febd12f 100644
--- a/gcc/m2/gm2-gcc/m2statement.cc
+++ b/gcc/m2/gm2-gcc/m2statement.cc
@@ -519,7 +519,7 @@  m2statement_BuildAsm (location_t location, tree instr, bool isVolatile,
 
   /* ASM statements without outputs, including simple ones, are treated
      as volatile.  */
-  ASM_INPUT_P (args) = isSimple;
+  ASM_BASIC_P (args) = isSimple;
   ASM_VOLATILE_P (args) = isVolatile;
 
   add_stmt (location, args);
diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 27c569c7702..1ebf1a2dd6d 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -1214,7 +1214,7 @@  struct GTY(()) tree_base {
        TRY_CATCH_IS_CLEANUP in
            TRY_CATCH_EXPR
 
-       ASM_INPUT_P in
+       ASM_BASIC_P in
            ASM_EXPR
 
        TYPE_REF_CAN_ALIAS_ALL in
diff --git a/gcc/tree.h b/gcc/tree.h
index c501019717f..b12b61d318e 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1431,11 +1431,11 @@  class auto_suppress_location_wrappers
 /* Nonzero if the asm is a basic asm, zero if it is an extended asm.
    Basic asms use a plain ASM_INPUT insn pattern whereas extended asms
    use an ASM_OPERANDS insn pattern.  */
-#define ASM_INPUT_P(NODE) (ASM_EXPR_CHECK (NODE)->base.static_flag)
-#define ASM_VOLATILE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.public_flag)
+#define ASM_BASIC_P(NODE)	(ASM_EXPR_CHECK (NODE)->base.static_flag)
+#define ASM_VOLATILE_P(NODE)	(ASM_EXPR_CHECK (NODE)->base.public_flag)
 /* Nonzero if we want to consider this asm as minimum length and cost
    for inlining decisions.  */
-#define ASM_INLINE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.protected_flag)
+#define ASM_INLINE_P(NODE)	(ASM_EXPR_CHECK (NODE)->base.protected_flag)
 
 /* COND_EXPR accessors.  */
 #define COND_EXPR_COND(NODE)	(TREE_OPERAND (COND_EXPR_CHECK (NODE), 0))