Sfoglia il codice sorgente

gcc: Add the `debug_tree' pragma.

* gcc-plugin/src/starpu.c (handle_pragma_debug_tree): New function.
  (register_pragmas): Register `debug_tree'.

* gcc-plugin/tests/Makefile.am (gcc_tests): Add `debug-tree.c'.

* gcc-plugin/tests/debug-tree.c: New file.
Ludovic Courtès 13 anni fa
parent
commit
3155307fdd
3 ha cambiato i file con 65 aggiunte e 0 eliminazioni
  1. 32 0
      gcc-plugin/src/starpu.c
  2. 1 0
      gcc-plugin/tests/Makefile.am
  3. 32 0
      gcc-plugin/tests/debug-tree.c

+ 32 - 0
gcc-plugin/src/starpu.c

@@ -755,11 +755,43 @@ handle_pragma_unregister (struct cpp_reader *reader)
 			     build_pointer_lookup (pointer)));
 }
 
+/* Handle the `debug_tree' pragma (for debugging purposes.)  */
+
+static void
+handle_pragma_debug_tree (struct cpp_reader *reader)
+{
+  tree args, obj;
+  location_t loc;
+
+  loc = cpp_peek_token (reader, 0)->src_loc;
+
+  args = read_pragma_expressions ("debug_tree", loc);
+  if (args == NULL_TREE)
+    /* Parse error, presumably already handled by the parser.  */
+    return;
+
+  obj = TREE_VALUE (args);
+  args = TREE_CHAIN (args);
+
+  if (obj == error_mark_node)
+    return;
+
+  if (args != NULL_TREE)
+    warning_at (loc, 0, "extraneous arguments ignored");
+
+  inform (loc, "debug_tree:");
+  debug_tree (obj);
+  printf ("\n");
+}
+
 static void
 register_pragmas (void *gcc_data, void *user_data)
 {
   c_register_pragma (STARPU_PRAGMA_NAME_SPACE, "hello",
 		     handle_pragma_hello);
+  c_register_pragma (STARPU_PRAGMA_NAME_SPACE, "debug_tree",
+		     handle_pragma_debug_tree);
+
   c_register_pragma_with_expansion (STARPU_PRAGMA_NAME_SPACE, "initialize",
 				    handle_pragma_initialize);
   c_register_pragma (STARPU_PRAGMA_NAME_SPACE, "wait",

+ 1 - 0
gcc-plugin/tests/Makefile.am

@@ -33,6 +33,7 @@ gcc_tests =					\
   wait-errors.c					\
   heap-allocated.c				\
   heap-allocated-errors.c			\
+  debug-tree.c					\
   shutdown-errors.c
 
 dist_noinst_HEADERS = mocks.h

+ 32 - 0
gcc-plugin/tests/debug-tree.c

@@ -0,0 +1,32 @@
+/* GCC-StarPU
+   Copyright (C) 2012 Institut National de Recherche en Informatique et Automatique
+
+   GCC-StarPU is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   GCC-StarPU is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC-StarPU.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* (instructions compile) */
+
+#pragma starpu debug_tree int			  /* (note "debug_tree") */
+
+int
+foo (void)
+{
+#pragma starpu debug_tree foo			  /* (note "debug_tree")  */
+
+  static int x = 2;
+#pragma starpu debug_tree x			  /* (note "debug_tree") */
+
+  return x;
+}
+
+#pragma starpu debug_tree void int foo /* (note "debug_tree") *//* (warning "extraneous") */