projects
/
libfirm
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add some localopts for shifting over the mode size
[libfirm]
/
ir
/
ir
/
irpass.c
diff --git
a/ir/ir/irpass.c
b/ir/ir/irpass.c
index
130c57c
..
3626d21
100644
(file)
--- a/
ir/ir/irpass.c
+++ b/
ir/ir/irpass.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 1995-20
09
University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-20
10
University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
*
* This file is part of libFirm.
*
@@
-31,9
+31,13
@@
#include "irgraph_t.h"
#include "irprog_t.h"
#include "irdump.h"
#include "irgraph_t.h"
#include "irprog_t.h"
#include "irdump.h"
-#include "irv
r
fy.h"
+#include "irv
eri
fy.h"
#include "xmalloc.h"
#include "xmalloc.h"
+typedef void (*void_pass_func_irg)(ir_graph *irg);
+typedef int (*int_pass_func_irg)(ir_graph *irg);
+typedef void (*void_pass_func)(void);
+
/*Add a graph pass to a graph pass manager. */
void ir_graph_pass_mgr_add(ir_graph_pass_manager_t *mgr, ir_graph_pass_t *pass)
{
/*Add a graph pass to a graph pass manager. */
void ir_graph_pass_mgr_add(ir_graph_pass_manager_t *mgr, ir_graph_pass_t *pass)
{
@@
-58,7
+62,7
@@
void ir_prog_pass_mgr_add(ir_prog_pass_manager_t *mgr, ir_prog_pass_t *pass)
*/
static int run_wrapper(ir_prog *prog, void *ctx)
{
*/
static int run_wrapper(ir_prog *prog, void *ctx)
{
- ir_graph_pass_manager_t *mgr = ctx;
+ ir_graph_pass_manager_t *mgr =
(ir_graph_pass_manager_t*)
ctx;
(void)prog;
return ir_graph_pass_mgr_run(mgr);
(void)prog;
return ir_graph_pass_mgr_run(mgr);
@@
-85,7
+89,7
@@
void ir_prog_no_dump(ir_prog *prog, void *ctx, unsigned idx)
*/
static void term_wrapper(void *context)
{
*/
static void term_wrapper(void *context)
{
- ir_graph_pass_manager_t *mgr = context;
+ ir_graph_pass_manager_t *mgr =
(ir_graph_pass_manager_t*)
context;
term_graph_pass_mgr(mgr);
}
term_graph_pass_mgr(mgr);
}
@@
-97,6
+101,7
@@
static ir_prog_pass_t *create_wrapper_pass(ir_graph_pass_manager_t *graph_mgr)
/* create a wrapper pass */
ir_prog_pass_t *pass = XMALLOCZ(ir_prog_pass_t);
/* create a wrapper pass */
ir_prog_pass_t *pass = XMALLOCZ(ir_prog_pass_t);
+ pass->kind = k_ir_prog_pass;
pass->run_on_irprog = run_wrapper;
pass->context = graph_mgr;
pass->name = graph_mgr->name;
pass->run_on_irprog = run_wrapper;
pass->context = graph_mgr;
pass->name = graph_mgr->name;
@@
-123,7
+128,7
@@
void ir_prog_pass_mgr_add_graph_pass(
if (! list_empty(&mgr->passes)) {
wrapper = list_entry(mgr->passes.prev, ir_prog_pass_t, list);
if (wrapper->is_wrapper) {
if (! list_empty(&mgr->passes)) {
wrapper = list_entry(mgr->passes.prev, ir_prog_pass_t, list);
if (wrapper->is_wrapper) {
- graph_mgr = wrapper->context;
+ graph_mgr =
(ir_graph_pass_manager_t*)
wrapper->context;
ir_graph_pass_mgr_add(graph_mgr, pass);
++mgr->n_passes;
ir_graph_pass_mgr_add(graph_mgr, pass);
++mgr->n_passes;
@@
-157,19
+162,17
@@
void ir_prog_pass_mgr_add_graph_mgr(
ir_prog_pass_mgr_add(mgr, pass);
}
ir_prog_pass_mgr_add(mgr, pass);
}
-/**
- * Create a suffix for dumping.
- */
-void create_suffix(char *suffix, size_t n, const char *pass_name, unsigned index)
+static void create_suffix(char *suffix, size_t n, const char *pass_name)
{
{
- snprintf(suffix, n, "
-%02u_%s", index
, pass_name);
+ snprintf(suffix, n, "
%s.svg"
, pass_name);
}
/* Run all passes of an ir_graph pass manager. */
int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
{
ir_graph_pass_t *pass;
}
/* Run all passes of an ir_graph pass manager. */
int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
{
ir_graph_pass_t *pass;
- int i, res = 0;
+ size_t i;
+ int res = 0;
ir_graph *rem = current_ir_graph;
/* on all graphs: beware: number of irgs might be changed */
ir_graph *rem = current_ir_graph;
/* on all graphs: beware: number of irgs might be changed */
@@
-194,9
+197,9
@@
int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
if (pass->dump_irg) {
pass->dump_irg(irg, pass->context, idx);
} else {
if (pass->dump_irg) {
pass->dump_irg(irg, pass->context, idx);
} else {
- char
suffix
[1024];
- create_suffix(
suffix, sizeof(suffix), pass->name, idx
);
- dump_ir_
block_graph(irg, suffix
);
+ char
buf
[1024];
+ create_suffix(
buf, sizeof(buf), pass->name
);
+ dump_ir_
graph(irg, buf
);
}
}
++idx;
}
}
++idx;
@@
-211,9
+214,11
@@
int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr)
*/
static int irp_verify_irgs(void)
{
*/
static int irp_verify_irgs(void)
{
- int i, res = 1;
+ int res = 1;
+ size_t i;
+ size_t n_irgs = get_irp_n_irgs();
- for (i =
get_irp_n_irgs() - 1; i >= 0; --
i)
+ for (i =
0; i < n_irgs; ++
i)
res &= irg_verify(get_irp_irg(i), 0);
return res;
}
res &= irg_verify(get_irp_irg(i), 0);
return res;
}
@@
-243,13
+248,13
@@
int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr)
if (pass->dump_irprog) {
pass->dump_irprog(irp, pass->context, idx);
} else {
if (pass->dump_irprog) {
pass->dump_irprog(irp, pass->context, idx);
} else {
- char
suffix
[1024];
- create_suffix(
suffix, sizeof(suffix), pass->name, idx
);
- dump_all_ir_graphs(
dump_ir_block_graph, suffix
);
+ char
buf
[1024];
+ create_suffix(
buf, sizeof(buf), pass->name
);
+ dump_all_ir_graphs(
buf
);
}
}
if (pass->is_wrapper) {
}
}
if (pass->is_wrapper) {
- ir_graph_pass_manager_t *graph_mgr = pass->context;
+ ir_graph_pass_manager_t *graph_mgr =
(ir_graph_pass_manager_t*)
pass->context;
idx += graph_mgr->n_passes;
} else
++idx;
idx += graph_mgr->n_passes;
} else
++idx;
@@
-346,8
+351,9
@@
void ir_prog_pass_mgr_set_run_idx(
/**
* Wrapper for running void function(ir_graph *irg) as an ir_graph pass.
*/
/**
* Wrapper for running void function(ir_graph *irg) as an ir_graph pass.
*/
-static int void_graph_wrapper(ir_graph *irg, void *context) {
- void (*function)(ir_graph *irg) = context;
+static int void_graph_wrapper(ir_graph *irg, void *context)
+{
+ void_pass_func_irg function = (void_pass_func_irg)context;
function(irg);
return 0;
} /* void_graph_wrapper */
function(irg);
return 0;
} /* void_graph_wrapper */
@@
-360,7
+366,7
@@
ir_graph_pass_t *def_graph_pass(
pass->kind = k_ir_graph_pass;
pass->run_on_irg = void_graph_wrapper;
pass->kind = k_ir_graph_pass;
pass->run_on_irg = void_graph_wrapper;
- pass->context = function;
+ pass->context =
(void*)
function;
pass->name = name;
INIT_LIST_HEAD(&pass->list);
pass->name = name;
INIT_LIST_HEAD(&pass->list);
@@
-369,10
+375,11
@@
ir_graph_pass_t *def_graph_pass(
} /* def_graph_pass */
/**
} /* def_graph_pass */
/**
- * Wrapper for running
void
function(ir_graph *irg) as an ir_graph pass.
+ * Wrapper for running
int
function(ir_graph *irg) as an ir_graph pass.
*/
*/
-static int int_graph_wrapper(ir_graph *irg, void *context) {
- int (*function)(ir_graph *irg) = context;
+static int int_graph_wrapper(ir_graph *irg, void *context)
+{
+ int_pass_func_irg function = (int_pass_func_irg)context;
return function(irg);
} /* int_graph_wrapper */
return function(irg);
} /* int_graph_wrapper */
@@
-384,7
+391,7
@@
ir_graph_pass_t *def_graph_pass_ret(
pass->kind = k_ir_graph_pass;
pass->run_on_irg = int_graph_wrapper;
pass->kind = k_ir_graph_pass;
pass->run_on_irg = int_graph_wrapper;
- pass->context = function;
+ pass->context =
(void*)
function;
pass->name = name;
INIT_LIST_HEAD(&pass->list);
pass->name = name;
INIT_LIST_HEAD(&pass->list);
@@
-410,12
+417,18
@@
ir_graph_pass_t *def_graph_pass_constructor(
return pass;
} /* def_graph_pass_constructor */
return pass;
} /* def_graph_pass_constructor */
+/* set the run parallel property */
+void ir_graph_pass_set_parallel(ir_graph_pass_t *pass, int flag)
+{
+ pass->run_parallel = flag != 0;
+} /* ir_graph_pass_set_parallel */
/**
* Wrapper for running void function(void) as an ir_prog pass.
*/
/**
* Wrapper for running void function(void) as an ir_prog pass.
*/
-static int void_prog_wrapper(ir_prog *irp, void *context) {
- void (*function)(void) = context;
+static int void_prog_wrapper(ir_prog *irp, void *context)
+{
+ void_pass_func function = (void_pass_func)context;
(void)irp;
function();
(void)irp;
function();
@@
-431,7
+444,7
@@
ir_prog_pass_t *def_prog_pass(
pass->kind = k_ir_prog_pass;
pass->run_on_irprog = void_prog_wrapper;
pass->kind = k_ir_prog_pass;
pass->run_on_irprog = void_prog_wrapper;
- pass->context = function;
+ pass->context =
(void*)
function;
pass->name = name;
INIT_LIST_HEAD(&pass->list);
pass->name = name;
INIT_LIST_HEAD(&pass->list);
@@
-460,17
+473,18
@@
ir_prog_pass_t *def_prog_pass_constructor(
return pass;
} /* def_prog_pass_constructor */
return pass;
} /* def_prog_pass_constructor */
-struct pass_t {
+
typedef
struct pass_t {
ir_prog_pass_t pass;
void *context;
void (*function)(void *context);
ir_prog_pass_t pass;
void *context;
void (*function)(void *context);
-};
+}
pass_t
;
/**
* Wrapper for the call_function pass.
*/
/**
* Wrapper for the call_function pass.
*/
-static int call_function_wrapper(ir_prog *irp, void *context) {
- struct pass_t *pass = context;
+static int call_function_wrapper(ir_prog *irp, void *context)
+{
+ pass_t *pass = (pass_t*)context;
(void)irp;
pass->function(pass->context);
(void)irp;
pass->function(pass->context);