]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl.def (ASM_INPUT): Add location.
authorAlexandre Oliva <aoliva@redhat.com>
Fri, 9 Mar 2007 07:36:43 +0000 (07:36 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Fri, 9 Mar 2007 07:36:43 +0000 (07:36 +0000)
* rtl.def (ASM_INPUT): Add location.
* rtl.h (ASM_INPUT_SOURCE_LOCATION): New.
(ASM_INPUT_SOURCE_FILE, ASM_INPUT_SOURCE_LINE): New.
(decode_asm_operands): Add loc operand.
(gen_rtx_ASM_INPUT, gen_rtx_ASM_INPUT_loc): Define.
* stmt.c (expand_asm): Rename to...
(expand_asm_loc): ... this.  Add locus argument.  Pass it on to
gen_rtx_ASM_INPUT_loc.
(expand_asm_expr): Adjust.
* recog.c (decode_asm_operands): Add loc operand.
(check_asm_operands, extract_insn): Adjust.
* reload1.c (maybe_fix_stack_asms): Likewise.
* final.c (asm_insn_count): Likewise.
(final_scan_insn): Output # line before and after asm.

From-SVN: r122742

gcc/ChangeLog
gcc/final.c
gcc/recog.c
gcc/reload1.c
gcc/rtl.def
gcc/rtl.h
gcc/stmt.c

index 48e94f62997a4a029e674067b9ac399dca32fd52..6c55f65339c69b423ee3e0499a0a5fe1394564a5 100644 (file)
@@ -1,3 +1,20 @@
+2007-03-09  Alexandre Oliva  <aoliva@redhat.com>
+
+       * rtl.def (ASM_INPUT): Add location.
+       * rtl.h (ASM_INPUT_SOURCE_LOCATION): New.
+       (ASM_INPUT_SOURCE_FILE, ASM_INPUT_SOURCE_LINE): New.
+       (decode_asm_operands): Add loc operand.
+       (gen_rtx_ASM_INPUT, gen_rtx_ASM_INPUT_loc): Define.
+       * stmt.c (expand_asm): Rename to...
+       (expand_asm_loc): ... this.  Add locus argument.  Pass it on to
+       gen_rtx_ASM_INPUT_loc.
+       (expand_asm_expr): Adjust.
+       * recog.c (decode_asm_operands): Add loc operand.
+       (check_asm_operands, extract_insn): Adjust.
+       * reload1.c (maybe_fix_stack_asms): Likewise.
+       * final.c (asm_insn_count): Likewise.
+       (final_scan_insn): Output # line before and after asm.
+
 2007-03-09  Daniel Berlin  <dberlin@dberlin.org>
 
        * tree-ssa-structalias.c (variable_info): Remove
index bd96444ea485483633d5fe732d41b822120b09ef..d7d1dafe2a4b00f8daa71e2b78cc86869f090c9a 100644 (file)
@@ -1,6 +1,6 @@
 /* Convert RTL to assembler code and output it, for GNU compiler.
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -1357,7 +1357,7 @@ asm_insn_count (rtx body)
   if (GET_CODE (body) == ASM_INPUT)
     template = XSTR (body, 0);
   else
-    template = decode_asm_operands (body, NULL, NULL, NULL, NULL);
+    template = decode_asm_operands (body, NULL, NULL, NULL, NULL, NULL);
 
   for (; *template; template++)
     if (IS_ASM_LOGICAL_LINE_SEPARATOR (*template) || *template == '\n')
@@ -2068,12 +2068,25 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
 
            if (string[0])
              {
+               location_t loc;
+
                if (! app_on)
                  {
                    fputs (ASM_APP_ON, file);
                    app_on = 1;
                  }
+#ifdef USE_MAPPED_LOCATION
+               loc = ASM_INPUT_SOURCE_LOCATION (body);
+#else
+               loc.file = ASM_INPUT_SOURCE_FILE (body);
+               loc.line = ASM_INPUT_SOURCE_LINE (body);
+#endif
+               if (loc.file && loc.line)
+                 fprintf (asm_out_file, "%s %i \"%s\" 1\n",
+                          ASM_COMMENT_START, loc.line, loc.file);
                fprintf (asm_out_file, "\t%s\n", string);
+               if (loc.file && loc.line)
+                 fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
              }
            break;
          }
@@ -2084,12 +2097,13 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
            unsigned int noperands = asm_noperands (body);
            rtx *ops = alloca (noperands * sizeof (rtx));
            const char *string;
+           location_t loc;
 
            /* There's no telling what that did to the condition codes.  */
            CC_STATUS_INIT;
 
            /* Get out the operand values.  */
-           string = decode_asm_operands (body, ops, NULL, NULL, NULL);
+           string = decode_asm_operands (body, ops, NULL, NULL, NULL, &loc);
            /* Inhibit dieing on what would otherwise be compiler bugs.  */
            insn_noperands = noperands;
            this_is_asm_operands = insn;
@@ -2106,7 +2120,12 @@ final_scan_insn (rtx insn, FILE *file, int optimize ATTRIBUTE_UNUSED,
                    fputs (ASM_APP_ON, file);
                    app_on = 1;
                  }
+               if (loc.file && loc.line)
+                 fprintf (asm_out_file, "%s %i \"%s\" 1\n",
+                          ASM_COMMENT_START, loc.line, loc.file);
                output_asm_insn (string, ops);
+               if (loc.file && loc.line)
+                 fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
              }
 
            this_is_asm_operands = 0;
index a7dc869e7ee1d478061a2200f0ec5d52d5919188..af5387a03372eed37d1aa48dbaef521fa04a5407 100644 (file)
@@ -1,6 +1,6 @@
 /* Subroutines used by or related to instruction recognition.
    Copyright (C) 1987, 1988, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
-   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -140,7 +140,7 @@ check_asm_operands (rtx x)
   operands = alloca (noperands * sizeof (rtx));
   constraints = alloca (noperands * sizeof (char *));
 
-  decode_asm_operands (x, operands, NULL, constraints, NULL);
+  decode_asm_operands (x, operands, NULL, constraints, NULL, NULL);
 
   for (i = 0; i < noperands; i++)
     {
@@ -1492,15 +1492,16 @@ asm_noperands (rtx body)
 
 const char *
 decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
-                    const char **constraints, enum machine_mode *modes)
+                    const char **constraints, enum machine_mode *modes,
+                    location_t *loc)
 {
   int i;
   int noperands;
-  const char *template = 0;
+  rtx asmop = 0;
 
   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
     {
-      rtx asmop = SET_SRC (body);
+      asmop = SET_SRC (body);
       /* Single output operand: BODY is (set OUTPUT (asm_operands ....)).  */
 
       noperands = ASM_OPERANDS_INPUT_LENGTH (asmop) + 1;
@@ -1527,11 +1528,10 @@ decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
        constraints[0] = ASM_OPERANDS_OUTPUT_CONSTRAINT (asmop);
       if (modes)
        modes[0] = GET_MODE (SET_DEST (body));
-      template = ASM_OPERANDS_TEMPLATE (asmop);
     }
   else if (GET_CODE (body) == ASM_OPERANDS)
     {
-      rtx asmop = body;
+      asmop = body;
       /* No output operands: BODY is (asm_operands ....).  */
 
       noperands = ASM_OPERANDS_INPUT_LENGTH (asmop);
@@ -1549,13 +1549,12 @@ decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
          if (modes)
            modes[i] = ASM_OPERANDS_INPUT_MODE (asmop, i);
        }
-      template = ASM_OPERANDS_TEMPLATE (asmop);
     }
   else if (GET_CODE (body) == PARALLEL
           && GET_CODE (XVECEXP (body, 0, 0)) == SET
           && GET_CODE (SET_SRC (XVECEXP (body, 0, 0))) == ASM_OPERANDS)
     {
-      rtx asmop = SET_SRC (XVECEXP (body, 0, 0));
+      asmop = SET_SRC (XVECEXP (body, 0, 0));
       int nparallel = XVECLEN (body, 0); /* Includes CLOBBERs.  */
       int nin = ASM_OPERANDS_INPUT_LENGTH (asmop);
       int nout = 0;            /* Does not include CLOBBERs.  */
@@ -1591,15 +1590,13 @@ decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
          if (modes)
            modes[i + nout] = ASM_OPERANDS_INPUT_MODE (asmop, i);
        }
-
-      template = ASM_OPERANDS_TEMPLATE (asmop);
     }
   else if (GET_CODE (body) == PARALLEL
           && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
     {
       /* No outputs, but some CLOBBERs.  */
 
-      rtx asmop = XVECEXP (body, 0, 0);
+      asmop = XVECEXP (body, 0, 0);
       int nin = ASM_OPERANDS_INPUT_LENGTH (asmop);
 
       for (i = 0; i < nin; i++)
@@ -1614,10 +1611,19 @@ decode_asm_operands (rtx body, rtx *operands, rtx **operand_locs,
            modes[i] = ASM_OPERANDS_INPUT_MODE (asmop, i);
        }
 
-      template = ASM_OPERANDS_TEMPLATE (asmop);
     }
 
-  return template;
+  if (loc)
+    {
+#ifdef USE_MAPPED_LOCATION
+      *loc = ASM_OPERANDS_SOURCE_LOCATION (asmop);
+#else
+      loc->file = ASM_OPERANDS_SOURCE_FILE (asmop);
+      loc->line = ASM_OPERANDS_SOURCE_LINE (asmop);
+#endif
+    }
+
+  return ASM_OPERANDS_TEMPLATE (asmop);
 }
 
 /* Check if an asm_operand matches its constraints.
@@ -2086,7 +2092,7 @@ extract_insn (rtx insn)
          decode_asm_operands (body, recog_data.operand,
                               recog_data.operand_loc,
                               recog_data.constraints,
-                              recog_data.operand_mode);
+                              recog_data.operand_mode, NULL);
          if (noperands > 0)
            {
              const char *p =  recog_data.constraints[0];
index c469fb0761836d752cb5b343a0e1d199649a00d0..2aad6b0c15ab5e4e32af083621b44b8ea2af83b6 100644 (file)
@@ -1365,7 +1365,7 @@ maybe_fix_stack_asms (void)
 
       /* Get the operand values and constraints out of the insn.  */
       decode_asm_operands (pat, recog_data.operand, recog_data.operand_loc,
-                          constraints, operand_mode);
+                          constraints, operand_mode, NULL);
 
       /* For every operand, see what registers are allowed.  */
       for (i = 0; i < noperands; i++)
index 7a04d88735cb2a5b1c10ab78c2e7879a8b935a4d..a49f1649e8a79b3ffdd52f8a5dc4824089914fdc 100644 (file)
@@ -168,15 +168,15 @@ DEF_RTL_EXPR(COND_EXEC, "cond_exec", "ee", RTX_EXTRA)
 /* Several operations to be done in parallel (perhaps under COND_EXEC).  */
 DEF_RTL_EXPR(PARALLEL, "parallel", "E", RTX_EXTRA)
 
+#ifdef USE_MAPPED_LOCATION
 /* A string that is passed through to the assembler as input.
      One can obviously pass comments through by using the
      assembler comment syntax.
      These occur in an insn all by themselves as the PATTERN.
      They also appear inside an ASM_OPERANDS
      as a convenient way to hold a string.  */
-DEF_RTL_EXPR(ASM_INPUT, "asm_input", "s", RTX_EXTRA)
+DEF_RTL_EXPR(ASM_INPUT, "asm_input", "si", RTX_EXTRA)
 
-#ifdef USE_MAPPED_LOCATION
 /* An assembler instruction with operands.
    1st operand is the instruction template.
    2nd operand is the constraint for the output.
@@ -190,6 +190,14 @@ DEF_RTL_EXPR(ASM_INPUT, "asm_input", "s", RTX_EXTRA)
    6th is the source line number.  */
 DEF_RTL_EXPR(ASM_OPERANDS, "asm_operands", "ssiEEi", RTX_EXTRA)
 #else
+/* A string that is passed through to the assembler as input.
+     One can obviously pass comments through by using the
+     assembler comment syntax.
+     These occur in an insn all by themselves as the PATTERN.
+     They also appear inside an ASM_OPERANDS
+     as a convenient way to hold a string.  */
+DEF_RTL_EXPR(ASM_INPUT, "asm_input", "ssi", RTX_EXTRA)
+
 /* An assembler instruction with operands.
    1st operand is the instruction template.
    2nd operand is the constraint for the output.
index 41d50d4755fbb20374eded947ef1a6bc6d120187..5c39efeecf06cf2415639e9945e46a3d682ef618 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1090,9 +1090,12 @@ do {                                                                     \
   GET_MODE (XCVECEXP (RTX, 4, N, ASM_OPERANDS))
 #ifdef USE_MAPPED_LOCATION
 #define ASM_OPERANDS_SOURCE_LOCATION(RTX) XCUINT (RTX, 5, ASM_OPERANDS)
+#define ASM_INPUT_SOURCE_LOCATION(RTX) XCUINT (RTX, 1, ASM_INPUT)
 #else
 #define ASM_OPERANDS_SOURCE_FILE(RTX) XCSTR (RTX, 5, ASM_OPERANDS)
 #define ASM_OPERANDS_SOURCE_LINE(RTX) XCINT (RTX, 6, ASM_OPERANDS)
+#define ASM_INPUT_SOURCE_FILE(RTX) XCSTR (RTX, 1, ASM_INPUT)
+#define ASM_INPUT_SOURCE_LINE(RTX) XCINT (RTX, 2, ASM_INPUT)
 #endif
 
 /* 1 if RTX is a mem that is statically allocated in read-only memory.  */
@@ -1767,7 +1770,7 @@ extern void free_reg_info (void);
 /* recog.c */
 extern int asm_noperands (rtx);
 extern const char *decode_asm_operands (rtx, rtx *, rtx **, const char **,
-                                       enum machine_mode *);
+                                       enum machine_mode *, location_t *);
 
 extern enum reg_class reg_preferred_class (int);
 extern enum reg_class reg_alternate_class (int);
@@ -1864,7 +1867,17 @@ extern GTY(()) rtx return_address_pointer_rtx;
 
 #ifndef GENERATOR_FILE
 #include "genrtl.h"
-#ifndef USE_MAPPED_LOCATION
+#undef gen_rtx_ASM_INPUT
+#ifdef USE_MAPPED_LOCATION
+#define gen_rtx_ASM_INPUT(MODE, ARG0)                          \
+  gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), 0)
+#define gen_rtx_ASM_INPUT_loc(MODE, ARG0, LOC)                 \
+  gen_rtx_fmt_si (ASM_INPUT, (MODE), (ARG0), (LOC))
+#else
+#define gen_rtx_ASM_INPUT(MODE, ARG0)                          \
+  gen_rtx_fmt_ssi (ASM_INPUT, (MODE), (ARG0), NULL, 0)
+#define gen_rtx_ASM_INPUT_loc(MODE, ARG0, LOC)                 \
+  gen_rtx_fmt_ssi (ASM_INPUT, (MODE), (ARG0), (LOC).file, (LOC).line)
 #undef gen_rtx_ASM_OPERANDS
 #define gen_rtx_ASM_OPERANDS(MODE, ARG0, ARG1, ARG2, ARG3, ARG4, LOC) \
   gen_rtx_fmt_ssiEEsi (ASM_OPERANDS, (MODE), (ARG0), (ARG1), (ARG2), (ARG3), (ARG4), (LOC).file, (LOC).line)
index 9b4e24f4c0591614ee419f6ccd3538da890ddbfe..20ce1aa4d50c78b2d95acd7a23766a1930bec6d4 100644 (file)
@@ -1,6 +1,6 @@
 /* Expands front end tree to back end RTL for GCC
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -260,15 +260,16 @@ n_occurrences (int c, const char *s)
    insn is volatile; don't optimize it.  */
 
 static void
-expand_asm (tree string, int vol)
+expand_asm_loc (tree string, int vol, location_t locus)
 {
   rtx body;
 
   if (TREE_CODE (string) == ADDR_EXPR)
     string = TREE_OPERAND (string, 0);
 
-  body = gen_rtx_ASM_INPUT (VOIDmode,
-                           ggc_strdup (TREE_STRING_POINTER (string)));
+  body = gen_rtx_ASM_INPUT_loc (VOIDmode,
+                               ggc_strdup (TREE_STRING_POINTER (string)),
+                               locus);
 
   MEM_VOLATILE_P (body) = vol;
 
@@ -1094,7 +1095,7 @@ expand_asm_expr (tree exp)
 
   if (ASM_INPUT_P (exp))
     {
-      expand_asm (ASM_STRING (exp), ASM_VOLATILE_P (exp));
+      expand_asm_loc (ASM_STRING (exp), ASM_VOLATILE_P (exp), input_location);
       return;
     }