]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pass location to md_asm_adjust
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Mon, 12 Jul 2021 06:55:17 +0000 (02:55 -0400)
committerTrevor Saunders <tbsaunde@tbsaunde.org>
Thu, 15 Jul 2021 05:10:47 +0000 (01:10 -0400)
So the hook can use it as the location of diagnostics.

gcc/ChangeLog:

* cfgexpand.c (expand_asm_loc): Adjust.
(expand_asm_stmt): Likewise.
* config/arm/aarch-common-protos.h (arm_md_asm_adjust): Likewise.
* config/arm/aarch-common.c (arm_md_asm_adjust): Likewise.
* config/arm/arm.c (thumb1_md_asm_adjust): Likewise.
* config/avr/avr.c (avr_md_asm_adjust): Likewise.
* config/cris/cris.c (cris_md_asm_adjust): Likewise.
* config/i386/i386.c (ix86_md_asm_adjust): Likewise.
* config/mn10300/mn10300.c (mn10300_md_asm_adjust): Likewise.
* config/nds32/nds32.c (nds32_md_asm_adjust): Likewise.
* config/pdp11/pdp11.c (pdp11_md_asm_adjust): Likewise.
* config/rs6000/rs6000.c (rs6000_md_asm_adjust): Likewise.
* config/s390/s390.c (s390_md_asm_adjust): Likewise.
* config/vax/vax.c (vax_md_asm_adjust): Likewise.
* config/visium/visium.c (visium_md_asm_adjust): Likewise.
* doc/tm.texi: Regenerate.
* target.def: Add location argument to md_asm_adjust.

Signed-off-by: Trevor Saunders <tbsaunde@tbsaunde.org>
16 files changed:
gcc/cfgexpand.c
gcc/config/arm/aarch-common-protos.h
gcc/config/arm/aarch-common.c
gcc/config/arm/arm.c
gcc/config/avr/avr.c
gcc/config/cris/cris.c
gcc/config/i386/i386.c
gcc/config/mn10300/mn10300.c
gcc/config/nds32/nds32.c
gcc/config/pdp11/pdp11.c
gcc/config/rs6000/rs6000.c
gcc/config/s390/s390.c
gcc/config/vax/vax.c
gcc/config/visium/visium.c
gcc/doc/tm.texi
gcc/target.def

index 7dd1225143efb9455f92aaf2db4c6d35c536a654..818328071db6e4b97c28670624c387d732b2be5e 100644 (file)
@@ -2897,7 +2897,8 @@ expand_asm_loc (tree string, int vol, location_t locus)
 
       if (targetm.md_asm_adjust)
        targetm.md_asm_adjust (output_rvec, input_rvec, input_mode,
-                              constraints, clobber_rvec, clobbered_regs);
+                              constraints, clobber_rvec, clobbered_regs,
+                              locus);
 
       asm_op = body;
       nclobbers = clobber_rvec.length ();
@@ -3074,8 +3075,7 @@ expand_asm_stmt (gasm *stmt)
       return;
     }
 
-  /* There are some legacy diagnostics in here, and also avoids an extra
-     parameter to targetm.md_asm_adjust.  */
+  /* There are some legacy diagnostics in here.  */
   save_input_location s_i_l(locus);
 
   unsigned noutputs = gimple_asm_noutputs (stmt);
@@ -3456,7 +3456,8 @@ expand_asm_stmt (gasm *stmt)
   if (targetm.md_asm_adjust)
     after_md_seq
        = targetm.md_asm_adjust (output_rvec, input_rvec, input_mode,
-                                constraints, clobber_rvec, clobbered_regs);
+                                constraints, clobber_rvec, clobbered_regs,
+                                locus);
 
   /* Do not allow the hook to change the output and input count,
      lest it mess up the operand numbering.  */
index b6171e8668deb8104780fae55587c0514a5e6773..6be5fb1e083d7ff130386dfa181b9a0c8fd5437c 100644 (file)
@@ -147,6 +147,7 @@ struct cpu_cost_table
 rtx_insn *arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
                             vec<machine_mode> & /*input_modes*/,
                             vec<const char *> &constraints,
-                            vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs);
+                            vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs,
+                            location_t loc);
 
 #endif /* GCC_AARCH_COMMON_PROTOS_H */
index 0dbdc56f542b788c33b1a392fcf7c23207d4b309..67343fe40250221c8b791f7776c39a2d2287cc35 100644 (file)
@@ -534,7 +534,7 @@ rtx_insn *
 arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
                   vec<machine_mode> & /*input_modes*/,
                   vec<const char *> &constraints, vec<rtx> & /*clobbers*/,
-                  HARD_REG_SET & /*clobbered_regs*/)
+                  HARD_REG_SET & /*clobbered_regs*/, location_t loc)
 {
   bool saw_asm_flag = false;
 
@@ -547,7 +547,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
       con += 4;
       if (strchr (con, ',') != NULL)
        {
-         error ("alternatives not allowed in %<asm%> flag output");
+         error_at (loc, "alternatives not allowed in %<asm%> flag output");
          continue;
        }
 
@@ -608,7 +608,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
          mode = CC_Vmode, code = NE;
          break;
        default:
-         error ("unknown %<asm%> flag output %qs", constraints[i]);
+         error_at (loc, "unknown %<asm%> flag output %qs", constraints[i]);
          continue;
        }
 
@@ -618,7 +618,7 @@ arm_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
       machine_mode dest_mode = GET_MODE (dest);
       if (!SCALAR_INT_MODE_P (dest_mode))
        {
-         error ("invalid type for %<asm%> flag output");
+         error_at (loc, "invalid type for %<asm%> flag output");
          continue;
        }
 
index de37c903450949d2e0faed59498a512c9f187389..6d781e23ee95b557cd16fed0115a17ecca62c3b4 100644 (file)
@@ -333,7 +333,7 @@ static HOST_WIDE_INT arm_constant_alignment (const_tree, HOST_WIDE_INT);
 static rtx_insn *thumb1_md_asm_adjust (vec<rtx> &, vec<rtx> &,
                                       vec<machine_mode> &,
                                       vec<const char *> &, vec<rtx> &,
-                                      HARD_REG_SET &);
+                                      HARD_REG_SET &, location_t);
 \f
 /* Table of machine attributes.  */
 static const struct attribute_spec arm_attribute_table[] =
@@ -34105,7 +34105,7 @@ rtx_insn *
 thumb1_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
                      vec<machine_mode> & /*input_modes*/,
                      vec<const char *> &constraints, vec<rtx> & /*clobbers*/,
-                     HARD_REG_SET & /*clobbered_regs*/)
+                     HARD_REG_SET & /*clobbered_regs*/, location_t /*loc*/)
 {
   for (unsigned i = 0, n = outputs.length (); i < n; ++i)
     if (startswith (constraints[i], "=@cc"))
index c95c436180c7e3e2eadc1bbdb8bc00d8b3cc7143..200701a583c176ddc467fda623d568643ccd03c7 100644 (file)
@@ -14498,7 +14498,8 @@ static rtx_insn *
 avr_md_asm_adjust (vec<rtx> &/*outputs*/, vec<rtx> &/*inputs*/,
                    vec<machine_mode> & /*input_modes*/,
                    vec<const char *> &/*constraints*/,
-                   vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs)
+                   vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs,
+                  location_t /*loc*/)
 {
   clobbers.safe_push (cc_reg_rtx);
   SET_HARD_REG_BIT (clobbered_regs, REG_CC);
index d9213d7ffb672bb7394996ccdf44c3812ca3b62a..f458ea0c53e4db7ae5f9e72091a30ff223d571f9 100644 (file)
@@ -151,7 +151,7 @@ static void cris_function_arg_advance (cumulative_args_t,
                                       const function_arg_info &);
 static rtx_insn *cris_md_asm_adjust (vec<rtx> &, vec<rtx> &,
                                     vec<machine_mode> &, vec<const char *> &,
-                                    vec<rtx> &, HARD_REG_SET &);
+                                    vec<rtx> &, HARD_REG_SET &, location_t);
 
 static void cris_option_override (void);
 
@@ -3507,7 +3507,7 @@ static rtx_insn *
 cris_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &inputs,
                    vec<machine_mode> & /*input_modes*/,
                    vec<const char *> &constraints, vec<rtx> &clobbers,
-                   HARD_REG_SET &clobbered_regs)
+                   HARD_REG_SET &clobbered_regs, location_t /*loc*/)
 {
   /* For the time being, all asms clobber condition codes.
      Revisit when there's a reasonable use for inputs/outputs
index cff269092929d8535219c2904e27320782aa6286..530d35729650142be1165646ed74aa9f9d82ed32 100644 (file)
@@ -21596,7 +21596,7 @@ static rtx_insn *
 ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
                    vec<machine_mode> & /*input_modes*/,
                    vec<const char *> &constraints, vec<rtx> &clobbers,
-                   HARD_REG_SET &clobbered_regs)
+                   HARD_REG_SET &clobbered_regs, location_t loc)
 {
   bool saw_asm_flag = false;
 
@@ -21609,7 +21609,7 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
       con += 4;
       if (strchr (con, ',') != NULL)
        {
-         error ("alternatives not allowed in %<asm%> flag output");
+         error_at (loc, "alternatives not allowed in %<asm%> flag output");
          continue;
        }
 
@@ -21673,7 +21673,7 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
        }
       if (code == UNKNOWN)
        {
-         error ("unknown %<asm%> flag output %qs", constraints[i]);
+         error_at (loc, "unknown %<asm%> flag output %qs", constraints[i]);
          continue;
        }
       if (invert)
@@ -21702,7 +21702,7 @@ ix86_md_asm_adjust (vec<rtx> &outputs, vec<rtx> & /*inputs*/,
       machine_mode dest_mode = GET_MODE (dest);
       if (!SCALAR_INT_MODE_P (dest_mode))
        {
-         error ("invalid type for %<asm%> flag output");
+         error_at (loc, "invalid type for %<asm%> flag output");
          continue;
        }
 
index c1c2e6e3b5cdf589cc6458d245ac650e4fcd902a..6f842a3ad326a15a39071ac77709eeab8b9ddf93 100644 (file)
@@ -2850,7 +2850,7 @@ static rtx_insn *
 mn10300_md_asm_adjust (vec<rtx> & /*outputs*/, vec<rtx> & /*inputs*/,
                       vec<machine_mode> & /*input_modes*/,
                       vec<const char *> & /*constraints*/, vec<rtx> &clobbers,
-                      HARD_REG_SET &clobbered_regs)
+                      HARD_REG_SET &clobbered_regs, location_t /*loc*/)
 {
   clobbers.safe_push (gen_rtx_REG (CCmode, CC_REG));
   SET_HARD_REG_BIT (clobbered_regs, CC_REG);
index 7217d7879b67862e5daf554f33a2496a34edf237..2c9cfcf322a1aa966c1ff181b3ed238191c5ed55 100644 (file)
@@ -4199,7 +4199,8 @@ nds32_md_asm_adjust (vec<rtx> &outputs ATTRIBUTE_UNUSED,
                     vec<rtx> &inputs ATTRIBUTE_UNUSED,
                     vec<machine_mode> &input_modes ATTRIBUTE_UNUSED,
                     vec<const char *> &constraints ATTRIBUTE_UNUSED,
-                    vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs)
+                    vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs,
+                    location_t /*loc*/)
 {
   if (!flag_inline_asm_r15)
     {
index 4cab3aee598b54383dee48f60561193a3448af6f..ced653116a4defd25a758e590d0ef425d62e5555 100644 (file)
@@ -156,7 +156,7 @@ static int pdp11_addr_cost (rtx, machine_mode, addr_space_t, bool);
 static int pdp11_insn_cost (rtx_insn *insn, bool speed);
 static rtx_insn *pdp11_md_asm_adjust (vec<rtx> &, vec<rtx> &,
                                      vec<machine_mode> &, vec<const char *> &,
-                                     vec<rtx> &, HARD_REG_SET &);
+                                     vec<rtx> &, HARD_REG_SET &, location_t);
 static bool pdp11_return_in_memory (const_tree, const_tree);
 static rtx pdp11_function_value (const_tree, const_tree, bool);
 static rtx pdp11_libcall_value (machine_mode, const_rtx);
@@ -2139,7 +2139,7 @@ static rtx_insn *
 pdp11_md_asm_adjust (vec<rtx> & /*outputs*/, vec<rtx> & /*inputs*/,
                     vec<machine_mode> & /*input_modes*/,
                     vec<const char *> & /*constraints*/, vec<rtx> &clobbers,
-                    HARD_REG_SET &clobbered_regs)
+                    HARD_REG_SET &clobbered_regs, location_t /*loc*/)
 {
   clobbers.safe_push (gen_rtx_REG (CCmode, CC_REGNUM));
   SET_HARD_REG_BIT (clobbered_regs, CC_REGNUM);
index ce29b372bd0272c1a44572f115ef9b3e932bdca4..779de9556ffb749fc7eec8d53edc43cd4e331ab4 100644 (file)
@@ -3444,7 +3444,7 @@ static rtx_insn *
 rs6000_md_asm_adjust (vec<rtx> & /*outputs*/, vec<rtx> & /*inputs*/,
                      vec<machine_mode> & /*input_modes*/,
                      vec<const char *> & /*constraints*/, vec<rtx> &clobbers,
-                     HARD_REG_SET &clobbered_regs)
+                     HARD_REG_SET &clobbered_regs, location_t /*loc*/)
 {
   clobbers.safe_push (gen_rtx_REG (SImode, CA_REGNO));
   SET_HARD_REG_BIT (clobbered_regs, CA_REGNO);
index 590dd8f35bc2451092999bbf5daf13bd603d8ae6..800e0abc016bfa93c69c53dd8c34e211c10af72c 100644 (file)
@@ -16771,7 +16771,7 @@ static rtx_insn *
 s390_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &inputs,
                    vec<machine_mode> &input_modes,
                    vec<const char *> &constraints, vec<rtx> & /*clobbers*/,
-                   HARD_REG_SET & /*clobbered_regs*/)
+                   HARD_REG_SET & /*clobbered_regs*/, location_t /*loc*/)
 {
   if (!TARGET_VXE)
     /* Long doubles are stored in FPR pairs - nothing to do.  */
index 3aacd1e5986dd7e33e5fede37628f5db5a182b99..e26ab3b2e8e4f3c11b217cf156552682826fb4f8 100644 (file)
@@ -57,7 +57,7 @@ static bool vax_rtx_costs (rtx, machine_mode, int, int, int *, bool);
 static machine_mode vax_cc_modes_compatible (machine_mode, machine_mode);
 static rtx_insn *vax_md_asm_adjust (vec<rtx> &, vec<rtx> &,
                                    vec<machine_mode> &, vec<const char *> &,
-                                   vec<rtx> &, HARD_REG_SET &);
+                                   vec<rtx> &, HARD_REG_SET &, location_t);
 static rtx vax_function_arg (cumulative_args_t, const function_arg_info &);
 static void vax_function_arg_advance (cumulative_args_t,
                                      const function_arg_info &);
@@ -1181,7 +1181,8 @@ vax_md_asm_adjust (vec<rtx> &outputs ATTRIBUTE_UNUSED,
                   vec<rtx> &inputs ATTRIBUTE_UNUSED,
                   vec<machine_mode> &input_modes ATTRIBUTE_UNUSED,
                   vec<const char *> &constraints ATTRIBUTE_UNUSED,
-                  vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs)
+                  vec<rtx> &clobbers, HARD_REG_SET &clobbered_regs,
+                  location_t /*loc*/)
 {
   clobbers.safe_push (gen_rtx_REG (CCmode, VAX_PSL_REGNUM));
   SET_HARD_REG_BIT (clobbered_regs, VAX_PSL_REGNUM);
index 7eb22485297b6d12be113374cbbe271a19c9cf9d..58e5355e7127de8357fbf55f555cfaa3ad99fa1d 100644 (file)
@@ -190,7 +190,7 @@ static tree visium_build_builtin_va_list (void);
 static rtx_insn *visium_md_asm_adjust (vec<rtx> &, vec<rtx> &,
                                       vec<machine_mode> &,
                                       vec<const char *> &, vec<rtx> &,
-                                      HARD_REG_SET &);
+                                      HARD_REG_SET &, location_t);
 
 static bool visium_legitimate_constant_p (machine_mode, rtx);
 
@@ -795,7 +795,7 @@ static rtx_insn *
 visium_md_asm_adjust (vec<rtx> & /*outputs*/, vec<rtx> & /*inputs*/,
                      vec<machine_mode> & /*input_modes*/,
                      vec<const char *> & /*constraints*/, vec<rtx> &clobbers,
-                     HARD_REG_SET &clobbered_regs)
+                     HARD_REG_SET &clobbered_regs, location_t /*loc*/)
 {
   clobbers.safe_push (gen_rtx_REG (CCmode, FLAGS_REGNUM));
   SET_HARD_REG_BIT (clobbered_regs, FLAGS_REGNUM);
index 2a41ae5fba16f495f9905648287e192cb77685c3..3ad39443eba4a999887ae6d8746d58c1200bebdc 100644 (file)
@@ -11708,11 +11708,12 @@ from shared libraries (DLLs).
 You need not define this macro if it would always evaluate to zero.
 @end defmac
 
-@deftypefn {Target Hook} {rtx_insn *} TARGET_MD_ASM_ADJUST (vec<rtx>& @var{outputs}, vec<rtx>& @var{inputs}, vec<machine_mode>& @var{input_modes}, vec<const char *>& @var{constraints}, vec<rtx>& @var{clobbers}, HARD_REG_SET& @var{clobbered_regs})
+@deftypefn {Target Hook} {rtx_insn *} TARGET_MD_ASM_ADJUST (vec<rtx>& @var{outputs}, vec<rtx>& @var{inputs}, vec<machine_mode>& @var{input_modes}, vec<const char *>& @var{constraints}, vec<rtx>& @var{clobbers}, HARD_REG_SET& @var{clobbered_regs}, location_t @var{loc})
 This target hook may add @dfn{clobbers} to @var{clobbers} and
 @var{clobbered_regs} for any hard regs the port wishes to automatically
 clobber for an asm.  The @var{outputs} and @var{inputs} may be inspected
-to avoid clobbering a register that is already used by the asm.
+to avoid clobbering a register that is already used by the asm.  @var{loc}
+is the source location of the asm.
 
 It may modify the @var{outputs}, @var{inputs}, @var{input_modes}, and
 @var{constraints} as necessary for other pre-processing.  In this case the
index c009671c5837f63f1c5c1addef5bf5d0891cd1d3..2e40448e6c53717c93967c541fb3529c0f5099c5 100644 (file)
@@ -4226,7 +4226,8 @@ DEFHOOK
  "This target hook may add @dfn{clobbers} to @var{clobbers} and\n\
 @var{clobbered_regs} for any hard regs the port wishes to automatically\n\
 clobber for an asm.  The @var{outputs} and @var{inputs} may be inspected\n\
-to avoid clobbering a register that is already used by the asm.\n\
+to avoid clobbering a register that is already used by the asm.  @var{loc}\n\
+is the source location of the asm.\n\
 \n\
 It may modify the @var{outputs}, @var{inputs}, @var{input_modes}, and\n\
 @var{constraints} as necessary for other pre-processing.  In this case the\n\
@@ -4236,7 +4237,7 @@ to @var{input_modes}.",
  rtx_insn *,
  (vec<rtx>& outputs, vec<rtx>& inputs, vec<machine_mode>& input_modes,
   vec<const char *>& constraints, vec<rtx>& clobbers,
-  HARD_REG_SET& clobbered_regs),
+  HARD_REG_SET& clobbered_regs, location_t loc),
  NULL)
 
 /* This target hook allows the backend to specify a calling convention