gcc/gcc44-cloog-dl.patch

212 lines
7.5 KiB
Diff
Raw Normal View History

2009-01-27 16:46:00 +00:00
2009-01-27 Jakub Jelinek <jakub@redhat.com>
* toplev.c (save_argv): No longer static.
* Makefile.in (BACKENDLIBS): Link against -ldl instead of -lcloog -lppl.
2009-01-27 17:31:57 +00:00
(graphite.o): Force -O, remove -fkeep-inline-functions.
2009-01-27 16:46:00 +00:00
* graphite.c: Include <dlfcn.h>. Reference libcloog and libppl symbols
through pointers in cloog_pointers variable.
(init_cloog_pointers): New function.
(gcc_type_for_iv_of_clast_loop): Rename stmt_for argument to stmt_fora.
(graphite_transform_loops): Call init_cloog_pointers.
--- gcc/toplev.c.jj 2008-12-09 23:59:10.000000000 +0100
+++ gcc/toplev.c 2009-01-27 14:33:52.000000000 +0100
@@ -128,7 +128,7 @@ static bool no_backend;
const char *progname;
/* Copy of argument vector to toplev_main. */
-static const char **save_argv;
+const char **save_argv;
/* Name of top-level original source file (what was input to cpp).
This comes from the #-command at the beginning of the actual input.
--- gcc/Makefile.in.jj 2009-01-26 20:50:38.000000000 +0100
+++ gcc/Makefile.in 2009-01-27 14:18:10.000000000 +0100
@@ -915,7 +915,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
# How to link with both our special library facilities
# and the system's installed libraries.
LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY) $(LIBDECNUMBER)
-BACKENDLIBS = $(CLOOGLIBS) $(PPLLIBS) $(GMPLIBS)
+BACKENDLIBS = $(GMPLIBS) $(if $(CLOOGLIBS),-ldl)
# Any system libraries needed just for GNAT.
SYSLIBS = @GNAT_LIBEXC@
2009-01-27 17:31:57 +00:00
@@ -3076,6 +3076,9 @@ $(out_object_file): $(out_file) $(CONFIG
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
$(out_file) $(OUTPUT_OPTION)
+graphite.o : \
+ ALL_CFLAGS := -O $(filter-out -fkeep-inline-functions, $(ALL_CFLAGS))
+
# Build auxiliary files that support ecoff format.
mips-tfile: mips-tfile.o version.o $(LIBDEPS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ mips-tfile.o version.o $(LIBS)
2009-01-27 16:46:00 +00:00
--- gcc/graphite.c.jj 2009-01-24 19:59:02.000000000 +0100
+++ gcc/graphite.c 2009-01-27 14:52:08.000000000 +0100
@@ -59,6 +59,138 @@ along with GCC; see the file COPYING3.
#include "cloog/cloog.h"
#include "graphite.h"
+#include <dlfcn.h>
+#define DYNSYMS \
+ DYNSYM (cloog_block_alloc); \
+ DYNSYM (cloog_block_list_free); \
+ DYNSYM (cloog_block_list_malloc); \
+ DYNSYM (cloog_clast_create); \
+ DYNSYM (cloog_clast_free); \
+ DYNSYM (cloog_domain_free); \
+ DYNSYM (cloog_domain_matrix2domain); \
+ DYNSYM (cloog_initialize); \
+ DYNSYM (cloog_loop_malloc); \
+ DYNSYM (cloog_matrix_alloc); \
+ DYNSYM (cloog_matrix_copy); \
+ DYNSYM (cloog_matrix_free); \
+ DYNSYM (cloog_matrix_print); \
+ DYNSYM (cloog_names_malloc); \
+ DYNSYM (cloog_names_scalarize); \
+ DYNSYM (cloog_options_free); \
+ DYNSYM (cloog_options_malloc); \
+ DYNSYM (cloog_program_dump_cloog); \
+ DYNSYM (cloog_program_extract_scalars); \
+ DYNSYM (cloog_program_free); \
+ DYNSYM (cloog_program_generate); \
+ DYNSYM (cloog_program_malloc); \
+ DYNSYM (cloog_program_print); \
+ DYNSYM (cloog_program_scatter); \
+ DYNSYM (cloog_statement_alloc); \
+ DYNSYM (ppl_finalize); \
+ DYNSYM (pprint); \
+ DYNSYM (stmt_block); \
+ DYNSYM (stmt_for); \
+ DYNSYM (stmt_guard); \
+ DYNSYM (stmt_root); \
+ DYNSYM (stmt_user);
+static struct
+{
+ bool inited;
+ void *h;
+#define DYNSYM(x) __typeof (x) *p_##x
+ DYNSYMS
+#undef DYNSYM
+} cloog_pointers;
+
+#define cloog_block_alloc (*cloog_pointers.p_cloog_block_alloc)
+#define cloog_block_list_free (*cloog_pointers.p_cloog_block_list_free)
+#define cloog_block_list_malloc (*cloog_pointers.p_cloog_block_list_malloc)
+#define cloog_clast_create (*cloog_pointers.p_cloog_clast_create)
+#define cloog_clast_free (*cloog_pointers.p_cloog_clast_free)
+#define cloog_domain_free (*cloog_pointers.p_cloog_domain_free)
+#define cloog_domain_matrix2domain (*cloog_pointers.p_cloog_domain_matrix2domain)
+#define cloog_initialize (*cloog_pointers.p_cloog_initialize)
+#define cloog_loop_malloc (*cloog_pointers.p_cloog_loop_malloc)
+#define cloog_matrix_alloc (*cloog_pointers.p_cloog_matrix_alloc)
+#define cloog_matrix_copy (*cloog_pointers.p_cloog_matrix_copy)
+#define cloog_matrix_free (*cloog_pointers.p_cloog_matrix_free)
+#define cloog_matrix_print (*cloog_pointers.p_cloog_matrix_print)
+#define cloog_names_malloc (*cloog_pointers.p_cloog_names_malloc)
+#define cloog_names_scalarize (*cloog_pointers.p_cloog_names_scalarize)
+#define cloog_options_free (*cloog_pointers.p_cloog_options_free)
+#define cloog_options_malloc (*cloog_pointers.p_cloog_options_malloc)
+#define cloog_program_dump_cloog (*cloog_pointers.p_cloog_program_dump_cloog)
+#define cloog_program_extract_scalars (*cloog_pointers.p_cloog_program_extract_scalars)
+#define cloog_program_free (*cloog_pointers.p_cloog_program_free)
+#define cloog_program_generate (*cloog_pointers.p_cloog_program_generate)
+#define cloog_program_malloc (*cloog_pointers.p_cloog_program_malloc)
+#define cloog_program_print (*cloog_pointers.p_cloog_program_print)
+#define cloog_program_scatter (*cloog_pointers.p_cloog_program_scatter)
+#define cloog_statement_alloc (*cloog_pointers.p_cloog_statement_alloc)
+#define ppl_finalize (*cloog_pointers.p_ppl_finalize)
+#define pprint (*cloog_pointers.p_pprint)
+#define stmt_block (*cloog_pointers.p_stmt_block)
+#define stmt_for (*cloog_pointers.p_stmt_for)
+#define stmt_guard (*cloog_pointers.p_stmt_guard)
+#define stmt_root (*cloog_pointers.p_stmt_root)
+#define stmt_user (*cloog_pointers.p_stmt_user)
+
+#define cloog_finalize (*cloog_pointers.p_ppl_finalize)
+
+static bool
+init_cloog_pointers (void)
+{
+ void *h = NULL;
+ extern const char **save_argv;
+ char *buf, *p;
+ size_t len;
+
+ if (cloog_pointers.inited)
+ return cloog_pointers.h != NULL;
+ len = progname - save_argv[0];
+ buf = XALLOCAVAR (char, len + sizeof "libcloog.so.0");
+ memcpy (buf, save_argv[0], len);
+ strcpy (buf + len, "libcloog.so.0");
+ len += sizeof "libcloog.so.0";
+ p = strstr (buf, "/libexec/");
+ if (p != NULL)
+ {
+ while (1)
+ {
+ char *q = strstr (p + 8, "/libexec/");
+ if (q == NULL)
+ break;
+ p = q;
+ }
+ memmove (p + 4, p + 8, len - (p + 8 - buf));
+ h = dlopen (buf, RTLD_LAZY);
+ if (h == NULL)
+ {
+ len = progname - save_argv[0];
+ memcpy (buf, save_argv[0], len);
+ strcpy (buf + len, "libcloog.so.0");
+ }
+ }
+ if (h == NULL)
+ h = dlopen (buf, RTLD_LAZY);
+ cloog_pointers.h = h;
+ if (h == NULL)
+ return false;
+#define DYNSYM(x) \
+ do \
+ { \
+ union { __typeof (cloog_pointers.p_##x) p; void *q; } u; \
+ u.q = dlsym (h, #x); \
+ if (u.q == NULL) \
+ return false; \
+ cloog_pointers.p_##x = u.p; \
+ } \
+ while (0)
+ DYNSYMS
+#undef DYNSYM
+ return true;
+}
+
static VEC (scop_p, heap) *current_scops;
/* Converts a GMP constant V to a tree and returns it. */
@@ -4019,10 +4151,10 @@ clast_get_body_of_loop (struct clast_stm
STMT. */
static tree
-gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for)
+gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_fora)
{
- struct clast_user_stmt *stmt = clast_get_body_of_loop ((struct clast_stmt *) stmt_for);
- const char *cloog_iv = stmt_for->iterator;
+ struct clast_user_stmt *stmt = clast_get_body_of_loop ((struct clast_stmt *) stmt_fora);
+ const char *cloog_iv = stmt_fora->iterator;
CloogStatement *cs = stmt->statement;
graphite_bb_p gbb = (graphite_bb_p) cloog_statement_usr (cs);
@@ -6061,6 +6193,12 @@ graphite_transform_loops (void)
if (number_of_loops () <= 1)
return;
+ if (!init_cloog_pointers ())
+ {
+ sorry ("Graphite loop optimizations cannot be used");
+ return;
+ }
+
current_scops = VEC_alloc (scop_p, heap, 3);
recompute_all_dominators ();