fixed include structure (files should include all needed headers - not more and not less)
[r13523]
* PURPOSE.
*/
-#ifndef _BE_MAIN_H
-#define _BE_MAIN_H
+/**
+ * @file
+ * @brief Generic backend types and interfaces.
+ * @author Sebastian Hack
+ * @version $Id$
+ */
+#ifndef FIRM_BE_MAIN_H
+#define FIRM_BE_MAIN_H
#include <stdio.h>
#include "irarch.h"
typedef struct be_main_env_t be_main_env_t;
typedef struct be_options_t be_options_t;
-#endif /* _BE_MAIN_H */
+#endif /* FIRM_BE_MAIN_H */
* @date 11.9.2006
* @version $Id$
*/
-#ifndef __BE_DBGOUT_H__
-#define __BE_DBGOUT_H__
+#ifndef FIRM_BE_BE_DBGOUT_H
+#define FIRM_BE_BE_DBGOUT_H
#include "obst.h"
#include "beabi_t.h"
/** Opens a stabs handler. */
dbg_handle *be_stabs_open(FILE *out);
-#endif /* __BE_DBGOUT_H__ */
+#endif /* FIRM_BE_BE_DBGOUT_H */
*/
/**
- * Internal backend global data structures.
- * @author Sebastian Hack
- * @date 8.12.2004
+ * @file
+ * @brief Internal backend global data structures.
+ * @author Sebastian Hack
+ * @version $Id$
*/
-
-#ifndef FIRM_BE_T_H
-#define FIRM_BE_T_H
+#ifndef FIRM_BE_BE_T_H
+#define FIRM_BE_BE_T_H
#include "firm_types.h"
#include "obst.h"
int be_put_ignore_regs(const be_irg_t *birg, const arch_register_class_t *cls,
bitset_t *bs);
-#endif
+#endif /* FIRM_BE_BE_T_H */
-/**
- * @file becopyheur4.c
- * @brief ABI lowering
- * @author Sebastian Hack
- * @date 7.3.2005
- * @version $Id$
- * @license
- *
- * Copyrigth (C) 1995-2007 University of Karlsruhe. All right reserved.
+/*
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
- *
+ */
+
+/**
+ * @file
+ * @brief Backend ABI implementation.
+ * @author Sebastian Hack
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
*/
/**
- * Backend ABI implementation.
+ * @file
+ * @brief Backend ABI implementation.
+ * @author Sebastian Hack
+ * @version $Id$
*/
-#ifndef FIRM_BEABI_H
-#define FIRM_BEABI_H
+#ifndef FIRM_BE_BEABI_H
+#define FIRM_BE_BEABI_H
#include "firm_types.h"
*/
int be_abi_omit_fp(const be_abi_irg_t *abi);
-#endif /* _BEABI_H */
+#endif /* FIRM_BE_BEABI_H */
*/
/**
- * Type declarations for the ABI module.
+ * @file
+ * @brief Type declarations for the ABI module.
+ * @author Sebastian Hack
+ * @version $Id$
*/
-
-#ifndef _BEABI_T_H_
-#define _BEABI_T_H_
+#ifndef FIRM_BE_BEABI_T_H
+#define FIRM_BE_BEABI_T_H
typedef struct _be_abi_call_flags_bits_t be_abi_call_flags_bits_t;
typedef union _be_abi_call_flags_t be_abi_call_flags_t;
typedef struct _be_abi_irg_t be_abi_irg_t;
typedef struct _be_stack_layout_t be_stack_layout_t;
-#endif /* _BEABI_T_H_ */
+#endif /* FIRM_BE_BEABI_T_H */
*/
/**
- * Processor architecture specification.
- * @author Sebastian Hack
- * @date 11.2.2005
- *
- * $Id$
+ * @file
+ * @brief Processor architecture specification.
+ * @author Sebastian Hack
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
* PURPOSE.
*/
-#ifndef _FIRM_BEARCH_H_
-#define _FIRM_BEARCH_H_
+/**
+ * @file
+ * @brief Processor architecture specification.
+ * @author Sebastian Hack
+ * @version $Id$
+ */
+#ifndef FIRM_BE_BEARCH_H
+#define FIRM_BE_BEARCH_H
#include "firm_types.h"
#include "bitset.h"
*/
void be_register_isa_if(const char *name, const arch_isa_if_t *isa);
-#endif /* _FIRM_BEARCH_H_ */
+#endif /* FIRM_BE_BEARCH_H */
* PURPOSE.
*/
-#ifndef FIRM_BEARCH_T_H
-#define FIRM_BEARCH_T_H
+/**
+ * @file
+ * @brief Processor architecture specification - internal data structures.
+ * @author Sebastian Hack
+ * @version $Id$
+ */
+#ifndef FIRM_BE_BEARCH_T_H
+#define FIRM_BE_BEARCH_T_H
#include "bearch.h"
*/
#define arch_env_get_isa(env) ((env)->isa)
-#endif
+#endif /* FIRM_BE_BEARCH_T_H */
* PURPOSE.
*/
-/*
- * Author: Matthias Braun, Christoph Mallon
- * Date: 27.09.2006
- * Copyright: (c) Universitaet Karlsruhe
- * License: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE.
- * CVS-Id: $Id$
+/**
+ * @file
+ * @brief Block-scheduling strategies.
+ * @author Matthias Braun, Christoph Mallon
+ * @date 27.09.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
* PURPOSE.
*/
-/*
- * Block schedule calculator
- *
- * $Id$
+/**
+ * @file
+ * @brief Block schedule calculation.
+ * @author Matthias Braun, Christoph Mallon
+ * @date 27.09.2006
+ * @version $Id$
*/
-#ifndef _BEBLOCKSCHED_H
-#define _BEBLOCKSCHED_H
-
-#include "firm_config.h"
+#ifndef FIRM_BE_BEBLOCKSCHED_H
+#define FIRM_BE_BEBLOCKSCHED_H
-#include "obst.h"
#include "execfreq.h"
#include "irnode.h"
#include "irgraph.h"
ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs);
-#endif /* _BEBLOCKSCHED_H */
+#endif /* FIRM_BE_BEBLOCKSCHED_H */
*/
/**
- * Chordal register allocation.
- * @author Sebastian Hack
- * @date 8.12.2004
- * @cvs-id $Id$
- *
- * Copyright (C) Universitaet Karlsruhe
- * Released under the GPL
+ * @file
+ * @brief Chordal register allocation.
+ * @author Sebastian Hack
+ * @date 08.12.2004
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "beinsn_t.h"
#include "bestatevent.h"
#include "beirg_t.h"
-
+#include "bera.h"
#include "bechordal_t.h"
#include "bechordal_draw.h"
+#include "bemodule.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
* PURPOSE.
*/
-
/**
- * Chordal register allocation.
- * @author Sebastian Hack
- * @date 14.12.2004
+ * @file
+ * @brief Chordal register allocation.
+ * @author Sebastian Hack
+ * @date 14.12.2004
+ * @version $Id$
*/
+#ifndef FIRM_BE_BECHORDAL_H
+#define FIRM_BE_BECHORDAL_H
-#ifndef __BECHORDAL_H
-#define __BECHORDAL_H
-
-#include "bearch_t.h"
-#include "bera.h"
-
-typedef struct be_chordal_env_t be_chordal_env_t;
+typedef struct be_chordal_env_t be_chordal_env_t;
+typedef struct be_ra_chordal_opts_t be_ra_chordal_opts_t;
+typedef struct border_t border_t;
-#endif
+#endif /* FIRM_BE_BECHORDAL_H */
* PURPOSE.
*/
-
/**
- * @file bechordal_draw.c
- * @date 12.05.2005
- * @author Sebastian Hack
- *
- * Paint chordal graphs.
- *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * @file
+ * @brief Paint chordal graphs.
+ * @author Sebastian Hack
+ * @date 12.05.2005
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "irgwalk.h"
#include "irprintf.h"
#include "iredges_t.h"
+#include "irtools.h"
#include "belive_t.h"
#include "bechordal_t.h"
#include "besched_t.h"
#include "bechordal_draw.h"
+#include "beirg_t.h"
typedef struct {
- be_chordal_env_t *env;
- plotter_t inh;
- const color_t *color;
- int width;
+ be_chordal_env_t *env;
+ plotter_t inh;
+ const color_t *color;
+ int width;
} base_plotter_t;
#define decl_self(type, from) \
type *self = (type *) from
-static void set_color(plotter_t *_self, const color_t *color)
-{
- decl_self(base_plotter_t, _self);
- self->color = color;
+static void set_color(plotter_t *_self, const color_t *color) {
+ decl_self(base_plotter_t, _self);
+ self->color = color;
}
-static const color_t *get_color(const plotter_t *_self)
-{
- decl_self(const base_plotter_t, _self);
- return self->color;
+static const color_t *get_color(const plotter_t *_self) {
+ decl_self(const base_plotter_t, _self);
+ return self->color;
}
-static void set_width(plotter_t *_self, int width)
-{
- decl_self(base_plotter_t, _self);
- self->width = width;
+static void set_width(plotter_t *_self, int width) {
+ decl_self(base_plotter_t, _self);
+ self->width = width;
}
-static int get_width(const plotter_t *_self)
-{
- decl_self(const base_plotter_t, _self);
- return self->width;
+static int get_width(const plotter_t *_self) {
+ decl_self(const base_plotter_t, _self);
+ return self->width;
}
-static void plotter_default_free(plotter_t *self)
-{
+static void plotter_default_free(plotter_t *self) {
}
typedef struct {
- base_plotter_t inh;
- const char *filename;
- FILE *f;
+ base_plotter_t inh;
+ const char *filename;
+ FILE *f;
} ps_plotter_t;
static void ps_begin(plotter_t *_self, const rect_t *vis)
{
- FILE *f;
- decl_self(ps_plotter_t, _self);
+ FILE *f;
+ decl_self(ps_plotter_t, _self);
- f = self->f = fopen(self->filename, "wt");
- fprintf(f, "%%!PS-Adobe-2.0\n");
- fprintf(f, "%%%%BoundingBox: %d %d %d %d\n", vis->x, vis->y, vis->w, vis->h);
+ f = self->f = fopen(self->filename, "wt");
+ fprintf(f, "%%!PS-Adobe-2.0\n");
+ fprintf(f, "%%%%BoundingBox: %d %d %d %d\n", vis->x, vis->y, vis->w, vis->h);
#if 0
- fprintf(f, "/mainfont /Courier findfont %f scalefont def\n", 10.0);
- fprintf(f, "mainfont setfont\n");
-#endif
+ fprintf(f, "/mainfont /Courier findfont %f scalefont def\n", 10.0);
+ fprintf(f, "mainfont setfont\n");
+#endif /* if 0 */
}
static void ps_setcolor(plotter_t *_self, const color_t *color)
{
- decl_self(ps_plotter_t, _self);
- set_color(_self, color);
+ decl_self(ps_plotter_t, _self);
+ set_color(_self, color);
- fprintf(self->f, "%.2f %.2f %.2f setrgbcolor\n",
- color->r, color->g, color->b);
+ fprintf(self->f, "%.2f %.2f %.2f setrgbcolor\n",
+ color->r, color->g, color->b);
}
static void ps_line(plotter_t *_self, int x1, int y1, int x2, int y2)
{
- decl_self(ps_plotter_t, _self);
+ decl_self(ps_plotter_t, _self);
- fprintf(self->f, "%d %d moveto\n", x1, y1);
- fprintf(self->f, "%d %d lineto\n", x2, y2);
- fprintf(self->f, "stroke\n");
+ fprintf(self->f, "%d %d moveto\n", x1, y1);
+ fprintf(self->f, "%d %d lineto\n", x2, y2);
+ fprintf(self->f, "stroke\n");
}
static void ps_box(plotter_t *_self, const rect_t *rect)
{
- decl_self(ps_plotter_t, _self);
+ decl_self(ps_plotter_t, _self);
- fprintf(self->f, "%d %d %d %d rectstroke\n",
- rect->x, rect->y, rect->w, rect->h);
+ fprintf(self->f, "%d %d %d %d rectstroke\n",
+ rect->x, rect->y, rect->w, rect->h);
}
void ps_text(plotter_t *_self, int x, int y, const char *str)
{
- decl_self(ps_plotter_t, _self);
+ decl_self(ps_plotter_t, _self);
- fprintf(self->f, "%d %d moveto\n", x, y);
- fprintf(self->f, "(%s) show\n", str);
+ fprintf(self->f, "%d %d moveto\n", x, y);
+ fprintf(self->f, "(%s) show\n", str);
}
static void ps_finish(plotter_t *_self)
{
- decl_self(ps_plotter_t, _self);
- fclose(self->f);
+ decl_self(ps_plotter_t, _self);
+ fclose(self->f);
}
const plotter_if_t ps_plotter_vtab = {
- ps_begin,
- ps_setcolor,
- get_color,
- set_width,
- get_width,
- ps_line,
- ps_box,
- ps_text,
- ps_finish,
- plotter_default_free
+ ps_begin,
+ ps_setcolor,
+ get_color,
+ set_width,
+ get_width,
+ ps_line,
+ ps_box,
+ ps_text,
+ ps_finish,
+ plotter_default_free
};
plotter_t *new_plotter_ps(const char *filename)
{
- ps_plotter_t *ps_plotter = xmalloc(sizeof(*ps_plotter));
- plotter_t *p = (plotter_t *) ps_plotter;
+ ps_plotter_t *ps_plotter = xmalloc(sizeof(*ps_plotter));
+ plotter_t *p = (plotter_t *) ps_plotter;
- ps_plotter->filename = filename;
- p->vtab = &ps_plotter_vtab;
- return p;
+ ps_plotter->filename = filename;
+ p->vtab = &ps_plotter_vtab;
+ return p;
}
/*
*/
+/* chriswue: the following seems to be unused and can be deleted? */
#if 0
typedef struct {
- base_plotter_t inh;
- const char *filename;
- FILE *f;
+ base_plotter_t inh;
+ const char *filename;
+ FILE *f;
} tikz_plotter_t;
static void tikz_begin(plotter_t *_self, const rect_t *vis)
{
- FILE *f;
- decl_self(tikz_plotter_t, _self);
+ FILE *f;
+ decl_self(tikz_plotter_t, _self);
- f = self->f = fopen(self->filename, "wt");
- fprintf(f, "\\begin{tikzpicture}\n");
+ f = self->f = fopen(self->filename, "wt");
+ fprintf(f, "\\begin{tikzpicture}\n");
}
static void tikz_setcolor(plotter_t *_self, const color_t *color)
{
- set_color(_self, color);
+ set_color(_self, color);
}
static void tikz_line(plotter_t *_self, int x1, int y1, int x2, int y2)
{
- decl_self(tikz_plotter_t, _self);
- fprintf(self->f, "\t\\draw (%d,%d) -- (%d,%d);\n", x1, y1, x2, y2);
+ decl_self(tikz_plotter_t, _self);
+ fprintf(self->f, "\t\\draw (%d,%d) -- (%d,%d);\n", x1, y1, x2, y2);
}
static void tikz_box(plotter_t *_self, const rect_t *rect)
{
- decl_self(tikz_plotter_t, _self);
+ decl_self(tikz_plotter_t, _self);
- fprintf(self->f, "\t\\draw (%d,%d) rectangle (%d, %d)\n",
- rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
+ fprintf(self->f, "\t\\draw (%d,%d) rectangle (%d, %d)\n",
+ rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
}
void tikz_text(plotter_t *_self, int x, int y, const char *str)
{
- decl_self(tikz_plotter_t, _self);
- fprintf(self->f, "\t\\draw (%d,%d) node {%s};\n", x, y, str);
+ decl_self(tikz_plotter_t, _self);
+ fprintf(self->f, "\t\\draw (%d,%d) node {%s};\n", x, y, str);
}
static void tikz_finish(plotter_t *_self)
{
- decl_self(tikz_plotter_t, _self);
- fclose(self->f);
+ decl_self(tikz_plotter_t, _self);
+ fclose(self->f);
}
-#endif
+#endif /* if 0 */
extern void plotter_free(plotter_t *self)
{
- self->vtab->free(self);
- free(self);
+ self->vtab->free(self);
+ free(self);
}
const draw_chordal_opts_t draw_chordal_def_opts = {
- 10, 10, 30, 8, 10, 10
+ 10, 10, 30, 8, 10, 10
};
typedef struct _draw_chordal_env_t {
- const be_chordal_env_t *chordal_env;
- const arch_env_t *arch_env;
- const arch_register_class_t *cls;
- pmap *block_dims;
- plotter_t *plotter;
- const draw_chordal_opts_t *opts;
-
- struct obstack obst;
- int max_color;
+ const be_chordal_env_t *chordal_env;
+ const arch_env_t *arch_env;
+ const arch_register_class_t *cls;
+ pmap *block_dims;
+ plotter_t *plotter;
+ const draw_chordal_opts_t *opts;
+ struct obstack obst;
+ int max_color;
} draw_chordal_env_t;
struct block_dims {
- int max_step;
- int min_step;
- int max_color;
- rect_t box;
- rect_t subtree_box;
+ int max_step;
+ int min_step;
+ int max_color;
+ rect_t box;
+ rect_t subtree_box;
};
-#undef min
-static INLINE int min(int a, int b)
-{
- return a < b ? a : b;
-}
-
-#undef max
-static INLINE int max(int a, int b)
-{
- return a > b ? a : b;
-}
-
-#define doz(a, b) max((a) - (b), 0)
+#define doz(a, b) MAX((a) - (b), 0)
static void block_dims_walker(ir_node *block, void *data)
{
- draw_chordal_env_t *env = data;
- border_t *b;
- struct list_head *head = get_block_border_head(env->chordal_env, block);
- const draw_chordal_opts_t *opts = env->opts;
- struct block_dims *dims = obstack_alloc(&env->obst, sizeof(*dims));
+ draw_chordal_env_t *env = data;
+ struct list_head *head = get_block_border_head(env->chordal_env, block);
+ const draw_chordal_opts_t *opts = env->opts;
+ struct block_dims *dims = obstack_alloc(&env->obst, sizeof(*dims));
+ border_t *b;
- memset(dims, 0, sizeof(*dims));
- dims->min_step = INT_MAX;
+ memset(dims, 0, sizeof(*dims));
+ dims->min_step = INT_MAX;
list_for_each_entry_reverse(border_t, b, head, list) {
- ir_node *irn = b->irn;
- const arch_register_t *reg = arch_get_irn_register(env->arch_env, irn);
- int col = arch_register_get_index(reg);
+ ir_node *irn = b->irn;
+ const arch_register_t *reg = arch_get_irn_register(env->arch_env, irn);
+ int col = arch_register_get_index(reg);
- dims->max_step = max(dims->max_step, b->step);
- dims->max_color = max(dims->max_color, col);
- env->max_color = max(env->max_color, col);
- }
+ dims->max_step = MAX(dims->max_step, b->step);
+ dims->max_color = MAX(dims->max_color, col);
+ env->max_color = MAX(env->max_color, col);
+ }
- dims->min_step = 1;
+ dims->min_step = 1;
#if 1
- dims->box.w = (dims->max_color + 2) * opts->h_inter_gap;
- dims->box.h = dims->max_step * opts->v_inter_gap;
-#else
- dims->box.w = dims->box.h = 10;
-#endif
+ dims->box.w = (dims->max_color + 2) * opts->h_inter_gap;
+ dims->box.h = dims->max_step * opts->v_inter_gap;
+#else /* ! if 1 */
+ dims->box.w = dims->box.h = 10;
+#endif /* if 1 */
- pmap_insert(env->block_dims, block, dims);
+ pmap_insert(env->block_dims, block, dims);
}
static void layout(const draw_chordal_env_t *env, ir_node *bl, int x)
{
- const draw_chordal_opts_t *opts = env->opts;
- struct block_dims *dims = pmap_get(env->block_dims, bl);
- ir_node *sub;
- rect_t *rect = &dims->subtree_box;
- int h_space = 0, v_space = 0;
+ const draw_chordal_opts_t *opts = env->opts;
+ struct block_dims *dims = pmap_get(env->block_dims, bl);
+ rect_t *rect = &dims->subtree_box;
+ int h_space = 0;
+ int v_space = 0;
+ ir_node *sub;
- memset(rect, 0, sizeof(*rect));
- rect->x = x;
+ memset(rect, 0, sizeof(*rect));
+ rect->x = x;
- dominates_for_each(bl, sub) {
- struct block_dims *bl_dim = pmap_get(env->block_dims, sub);
+ dominates_for_each(bl, sub) {
+ struct block_dims *bl_dim = pmap_get(env->block_dims, sub);
- layout(env, sub, rect->x + rect->w);
+ layout(env, sub, rect->x + rect->w);
- rect->w += h_space + bl_dim->subtree_box.w;
- rect->h = max(rect->h, bl_dim->subtree_box.h);
+ rect->w += h_space + bl_dim->subtree_box.w;
+ rect->h = MAX(rect->h, bl_dim->subtree_box.h);
- h_space = opts->h_gap;
- v_space = opts->v_gap;
- }
+ h_space = opts->h_gap;
+ v_space = opts->v_gap;
+ }
- rect->w = max(rect->w, dims->box.w + opts->h_gap);
+ rect->w = MAX(rect->w, dims->box.w + opts->h_gap);
- dims->box.x = x + doz(rect->w, dims->box.w) / 2;
- dims->box.y = rect->h + v_space;
+ dims->box.x = x + doz(rect->w, dims->box.w) / 2;
+ dims->box.y = rect->h + v_space;
- rect->h += dims->box.h + v_space;
+ rect->h += dims->box.h + v_space;
}
static void set_y(const draw_chordal_env_t *env, ir_node *bl, int up)
{
- const draw_chordal_opts_t *opts = env->opts;
- struct block_dims *dims = pmap_get(env->block_dims, bl);
- int max_height = dims->subtree_box.h - dims->box.h - opts->v_gap;
- ir_node *sub;
+ const draw_chordal_opts_t *opts = env->opts;
+ struct block_dims *dims = pmap_get(env->block_dims, bl);
+ int max_height = dims->subtree_box.h - dims->box.h - opts->v_gap;
+ ir_node *sub;
- dominates_for_each(bl, sub) {
- struct block_dims *bl_dim = pmap_get(env->block_dims, sub);
- int height_diff = max_height - bl_dim->subtree_box.h;
+ dominates_for_each(bl, sub) {
+ struct block_dims *bl_dim = pmap_get(env->block_dims, sub);
+ int height_diff = max_height - bl_dim->subtree_box.h;
- set_y(env, sub, up + height_diff);
- }
+ set_y(env, sub, up + height_diff);
+ }
- dims->subtree_box.y += up;
- dims->box.y += up;
+ dims->subtree_box.y += up;
+ dims->box.y += up;
}
static color_t *reg_to_color(const draw_chordal_env_t *env,
- ir_node *rel_bl, ir_node *irn, color_t *color)
+ ir_node *rel_bl, ir_node *irn, color_t *color)
{
- int phi_arg = 0;
- const ir_edge_t *edge;
+ int phi_arg = 0;
+ const ir_edge_t *edge;
- foreach_out_edge(irn, edge)
- phi_arg |= is_Phi(edge->src);
+ foreach_out_edge(irn, edge)
+ phi_arg |= is_Phi(edge->src);
#if 1
- color->r = is_Phi(irn) ? 0.5 : 0.0;
- color->g = phi_arg ? 0.5 : 0.0;
- color->b = 0.0;
-#else
- {
- int live_in = is_live_in(rel_bl, irn);
- int live_out = is_live_out(rel_bl, irn);
-
- color->r = live_in;
- color->g = live_out;
- color->b = 0.0;
- }
-#endif
-
- return color;
-
+ color->r = is_Phi(irn) ? 0.5 : 0.0;
+ color->g = phi_arg ? 0.5 : 0.0;
+ color->b = 0.0;
+#else /* ! if 1 */
+ {
+ int live_in = is_live_in(rel_bl, irn);
+ int live_out = is_live_out(rel_bl, irn);
+
+ color->r = live_in;
+ color->g = live_out;
+ color->b = 0.0;
+ }
+#endif /* if 1 */
+
+ return color;
}
static void draw_block(ir_node *bl, void *data)
{
- static const color_t black = { 0, 0, 0 };
-
- const draw_chordal_env_t *env = data;
- const be_lv_t *lv = be_get_birg_liveness(env->chordal_env->birg);
- pset *live_in = be_lv_pset_put_in(lv, bl, pset_new_ptr_default());
- ir_node *irn;
- border_t *b;
- struct list_head *head = get_block_border_head(env->chordal_env, bl);
- ir_node *dom = get_Block_idom(bl);
- const draw_chordal_opts_t *opts = env->opts;
- struct block_dims *dims = pmap_get(env->block_dims, bl);
- char buf[64];
+ static const color_t black = { 0, 0, 0 };
+ const draw_chordal_env_t *env = data;
+ const be_lv_t *lv = be_get_birg_liveness(env->chordal_env->birg);
+ pset *live_in = be_lv_pset_put_in(lv, bl, pset_new_ptr_default());
+ struct list_head *head = get_block_border_head(env->chordal_env, bl);
+ ir_node *dom = get_Block_idom(bl);
+ const draw_chordal_opts_t *opts = env->opts;
+ struct block_dims *dims = pmap_get(env->block_dims, bl);
+ char buf[64];
+ ir_node *irn;
+ border_t *b;
ir_snprintf(buf, sizeof(buf), "%F", bl);
env->plotter->vtab->box(env->plotter, &dims->box);
#if 0
- env->plotter->vtab->text(env->plotter, dims->box.x, dims->box.y, buf);
+ env->plotter->vtab->text(env->plotter, dims->box.x, dims->box.y, buf);
#endif
- list_for_each_entry(border_t, b, head, list) {
- if(b->is_def) {
- const arch_register_t *reg = arch_get_irn_register(env->arch_env, b->irn);
- int col = arch_register_get_index(reg);
- int live_out = be_is_live_out(lv, bl, b->irn);
- int x = (col + 1) * opts->h_inter_gap;
- int ystart = (b->step) * opts->v_inter_gap;
- int ystop = (b->other_end->step)
- * opts->v_inter_gap + (live_out ? 0 : opts->v_inter_gap / 2);
-
- color_t color;
- reg_to_color(env, bl, b->irn, &color);
-
- x += dims->box.x;
- ystart += dims->box.y;
- ystop += dims->box.y;
-
- env->plotter->vtab->set_color(env->plotter, &color);
- env->plotter->vtab->line(env->plotter, x, ystart, x, ystop);
-
- env->plotter->vtab->line(env->plotter, x - 2, ystart, x + 2, ystart);
- env->plotter->vtab->line(env->plotter, x - 2, ystop, x + 2, ystop);
- }
- }
-
- if(dom) {
- struct block_dims *dom_dims = pmap_get(env->block_dims, dom);
-
- for(irn = pset_first(live_in); irn; irn = pset_next(live_in)) {
- if(arch_irn_has_reg_class(env->arch_env, irn, -1, env->cls)) {
- const arch_register_t *reg = arch_get_irn_register(env->arch_env, irn);
- int col = arch_register_get_index(reg);
- int x = (col + 1) * opts->h_inter_gap;
-
- color_t color;
- reg_to_color(env, bl, irn, &color);
-
- env->plotter->vtab->set_color(env->plotter, &color);
- env->plotter->vtab->line(env->plotter,
- dims->box.x + x,
- dims->box.y + dims->box.h,
- dom_dims->box.x + x,
- dom_dims->box.y);
- }
- }
- }
-
- del_pset(live_in);
+ list_for_each_entry(border_t, b, head, list) {
+ if (b->is_def) {
+ const arch_register_t *reg = arch_get_irn_register(env->arch_env, b->irn);
+ int col = arch_register_get_index(reg);
+ int live_out = be_is_live_out(lv, bl, b->irn);
+ int x = (col + 1) * opts->h_inter_gap;
+ int ystart = (b->step) * opts->v_inter_gap;
+ int ystop = (b->other_end->step) * opts->v_inter_gap + (live_out ? 0 : opts->v_inter_gap / 2);
+
+ color_t color;
+ reg_to_color(env, bl, b->irn, &color);
+
+ x += dims->box.x;
+ ystart += dims->box.y;
+ ystop += dims->box.y;
+
+ env->plotter->vtab->set_color(env->plotter, &color);
+ env->plotter->vtab->line(env->plotter, x, ystart, x, ystop);
+
+ env->plotter->vtab->line(env->plotter, x - 2, ystart, x + 2, ystart);
+ env->plotter->vtab->line(env->plotter, x - 2, ystop, x + 2, ystop);
+ }
+ }
+
+ if (dom) {
+ struct block_dims *dom_dims = pmap_get(env->block_dims, dom);
+
+ for (irn = pset_first(live_in); irn; irn = pset_next(live_in)) {
+ if (arch_irn_has_reg_class(env->arch_env, irn, -1, env->cls)) {
+ const arch_register_t *reg = arch_get_irn_register(env->arch_env, irn);
+ int col = arch_register_get_index(reg);
+ int x = (col + 1) * opts->h_inter_gap;
+ color_t color;
+
+ reg_to_color(env, bl, irn, &color);
+
+ env->plotter->vtab->set_color(env->plotter, &color);
+ env->plotter->vtab->line(env->plotter,
+ dims->box.x + x,
+ dims->box.y + dims->box.h,
+ dom_dims->box.x + x,
+ dom_dims->box.y);
+ }
+ }
+ }
+
+ del_pset(live_in);
}
static void draw(draw_chordal_env_t *env, const rect_t *start_box)
{
- plotter_t *p = env->plotter;
- rect_t bbox;
+ plotter_t *p = env->plotter;
+ rect_t bbox;
- bbox.x = bbox.y = 0;
- bbox.w = start_box->w + 2 * env->opts->x_margin;
- bbox.h = start_box->h + 2 * env->opts->y_margin;
+ bbox.x = bbox.y = 0;
+ bbox.w = start_box->w + 2 * env->opts->x_margin;
+ bbox.h = start_box->h + 2 * env->opts->y_margin;
- be_assure_liveness(env->chordal_env->birg);
+ be_assure_liveness(env->chordal_env->birg);
- p->vtab->begin(p, &bbox);
- irg_block_walk_graph(env->chordal_env->irg, draw_block, NULL, env);
- p->vtab->finish(p);
+ p->vtab->begin(p, &bbox);
+ irg_block_walk_graph(env->chordal_env->irg, draw_block, NULL, env);
+ p->vtab->finish(p);
}
-void draw_interval_tree(const draw_chordal_opts_t *opts,
- const be_chordal_env_t *chordal_env,
- plotter_t *plotter)
-{
- draw_chordal_env_t env;
- struct block_dims *start_dims;
- ir_node *start_block = get_irg_start_block(chordal_env->irg);
-
- env.arch_env = chordal_env->birg->main_env->arch_env;
- env.opts = opts;
- env.block_dims = pmap_create();
- env.plotter = plotter;
- env.cls = chordal_env->cls;
- env.max_color = 0;
- env.chordal_env = chordal_env;
- obstack_init(&env.obst);
-
- irg_block_walk_graph(chordal_env->irg, block_dims_walker, NULL, &env);
- layout(&env, start_block, opts->x_margin);
- set_y(&env, start_block, opts->y_margin);
- start_dims = pmap_get(env.block_dims, start_block);
- draw(&env, &start_dims->subtree_box);
-
- pmap_destroy(env.block_dims);
- obstack_free(&env.obst, NULL);
+void draw_interval_tree(const draw_chordal_opts_t *opts, const be_chordal_env_t *chordal_env, plotter_t *plotter) {
+ draw_chordal_env_t env;
+ struct block_dims *start_dims;
+ ir_node *start_block = get_irg_start_block(chordal_env->irg);
+
+ env.arch_env = chordal_env->birg->main_env->arch_env;
+ env.opts = opts;
+ env.block_dims = pmap_create();
+ env.plotter = plotter;
+ env.cls = chordal_env->cls;
+ env.max_color = 0;
+ env.chordal_env = chordal_env;
+ obstack_init(&env.obst);
+
+ irg_block_walk_graph(chordal_env->irg, block_dims_walker, NULL, &env);
+ layout(&env, start_block, opts->x_margin);
+ set_y(&env, start_block, opts->y_margin);
+ start_dims = pmap_get(env.block_dims, start_block);
+ draw(&env, &start_dims->subtree_box);
+
+ pmap_destroy(env.block_dims);
+ obstack_free(&env.obst, NULL);
}
* PURPOSE.
*/
-
/**
- * @file bechordal_draw.h
- * @date 13.05.2005
- * @author Sebastian Hack
- *
- * Drawing chordal graphs.
- *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * @file
+ * @brief Paint chordal graphs.
+ * @author Sebastian Hack
+ * @date 12.05.2005
+ * @version $Id$
*/
+#ifndef FIRM_BE_BECHORDAL_DRAW_H
+#define FIRM_BE_BECHORDAL_DRAW_H
-#ifndef _BECHORDAL_DRAW_H
-#define _BECHORDAL_DRAW_H
+#include "bechordal.h"
-#include "bearch_t.h"
-
-typedef struct _plotter_t plotter_t;
-typedef struct _plotter_if_t plotter_if_t;
-typedef struct _rect_t rect_t;
+typedef struct _plotter_t plotter_t;
+typedef struct _plotter_if_t plotter_if_t;
+typedef struct _rect_t rect_t;
typedef struct _draw_chordal_opts_t draw_chordal_opts_t;
-typedef struct _color_t color_t;
+typedef struct _color_t color_t;
struct _color_t {
- double r, g, b;
+ double r, g, b;
};
struct _rect_t {
- int x, y, w, h;
+ int x, y, w, h;
};
struct _plotter_if_t {
- void (*begin)(plotter_t *self, const rect_t *visible_area);
-
- void (*set_color)(plotter_t *self, const color_t * color);
- const color_t * (*get_color)(const plotter_t *self);
- void (*set_width)(plotter_t *self, int width);
- int (*get_width)(const plotter_t *self);
- void (*line)(plotter_t *self, int x1, int y1, int x2, int y2);
- void (*box)(plotter_t *self, const rect_t *rect);
- void (*text)(plotter_t *self, int x, int y, const char *str);
-
- void (*finish)(plotter_t *self);
- void (*free)(plotter_t *self);
+ void (*begin)(plotter_t *self, const rect_t *visible_area);
+
+ void (*set_color)(plotter_t *self, const color_t * color);
+ const color_t *(*get_color)(const plotter_t *self);
+ void (*set_width)(plotter_t *self, int width);
+ int (*get_width)(const plotter_t *self);
+ void (*line)(plotter_t *self, int x1, int y1, int x2, int y2);
+ void (*box)(plotter_t *self, const rect_t *rect);
+ void (*text)(plotter_t *self, int x, int y, const char *str);
+
+ void (*finish)(plotter_t *self);
+ void (*free)(plotter_t *self);
};
extern void plotter_free(plotter_t *self);
struct _plotter_t {
- const plotter_if_t *vtab;
+ const plotter_if_t *vtab;
};
struct _draw_chordal_opts_t {
- int h_gap;
- int h_inter_gap;
- int v_gap;
- int v_inter_gap;
- int x_margin;
- int y_margin;
+ int h_gap;
+ int h_inter_gap;
+ int v_gap;
+ int v_inter_gap;
+ int x_margin;
+ int y_margin;
};
extern const draw_chordal_opts_t draw_chordal_def_opts;
extern plotter_t *new_plotter_ps(const char *filename);
-extern void draw_interval_tree(
- const draw_chordal_opts_t *opts,
- const be_chordal_env_t *chordal_env,
- plotter_t *plotter);
+extern void draw_interval_tree(const draw_chordal_opts_t *opts, const be_chordal_env_t *chordal_env, plotter_t *plotter);
-#endif /* _BECHORDAL_DRAW_H */
+#endif /* FIRM_BE_BECHORDAL_DRAW_H */
*/
/**
- * @file bechordal_main.c
- * @date 29.11.2005
- * @author Sebastian Hack
- * @cvs-id $Id$
- *
- * Copyright (C) 2005-2006 Universitaet Karlsruhe
- * Released under the GPL
- *
- * Driver for the chordal register allocator.
+ * @file
+ * @brief Driver for the chordal register allocator.
+ * @author Sebastian Hack
+ * @date 29.11.2005
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include <stdlib.h>
#include <time.h>
#include "obst.h"
#include "bestat.h"
#include "bemodule.h"
#include "be_t.h"
+#include "bera.h"
+#include "beirg_t.h"
#include "bespillbelady.h"
#include "bespillmorgan.h"
* PURPOSE.
*/
-
/**
- * Internal data structures for the chordal register allocator.
- * @author Sebastian Hack
- * @date 25.1.2005
+ * @file
+ * @brief Internal data structures for the chordal register allocator.
+ * @author Sebastian Hack
+ * @date 25.01.2005
+ * @version $Id$
*/
+#ifndef FIRM_BE_BECHORDAL_T_H
+#define FIRM_BE_BECHORDAL_T_H
-#ifndef _BECHORDAL_T_H
-#define _BECHORDAL_T_H
-
-#include "firm_types.h"
-#include "firm_config.h"
-
-#include <stdlib.h>
-
-#include "bitset.h"
#include "list.h"
-#include "obst.h"
-#include "pset.h"
#include "pmap.h"
-#include "set.h"
-
-#include "execfreq.h"
+#include "irnode.h"
+#include "bitset.h"
+#include "obst.h"
+#include "debug.h"
-#include "be_t.h"
-#include "beifg.h"
-#include "bera.h"
-#include "bearch_t.h"
#include "bechordal.h"
-#include "belive.h"
-#include "beirg_t.h"
-
-typedef struct be_ra_chordal_opts_t be_ra_chordal_opts_t;
-typedef struct border_t border_t;
+#include "beirg.h"
+#include "beifg.h"
/** Defines an invalid register index. */
#define NO_COLOR (-1)
ir_node *irn; /**< The node. */
unsigned step; /**< The number equal to the interval border. */
unsigned pressure; /**< The pressure at this interval border. (The border itself is counting). */
- unsigned is_def : 1; /**< Does this border denote a use or a def. */
+ unsigned is_def : 1; /**< Does this border denote a use or a def. */
unsigned is_real : 1; /**< Is the def/use real? Or is it just
inserted at block beginnings or ends
to ensure that inside a block, each
void be_pre_spill_prepare_constr(be_chordal_env_t *cenv);
-#endif /* _BECHORDAL_T_H */
+#endif /* FIRM_BE_BECHORDAL_T_H */
*/
/**
- * Author: Daniel Grund
- * Date: 12.04.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
-
+ * @file
+ * @brief First simple copy minimization heuristics.
+ * @author Daniel Grund
+ * @date 12.04.2005
+ * @version $Id$
+ *
* Heuristic for minimizing copies using a queue which holds 'qnodes' not yet
* examined. A qnode has a 'target color', nodes out of the opt unit and
* a 'conflict graph'. 'Conflict graph' = "Interference graph' + 'conflict edges'
#endif
#include "debug.h"
+#include "bitset.h"
+#include "raw_bitset.h"
#include "xmalloc.h"
+
#include "becopyopt_t.h"
#include "becopystat.h"
#include "benodesets.h"
-#include "bitset.h"
-#include "raw_bitset.h"
-#include "xmalloc.h"
+#include "bera.h"
+#include "beirg_t.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
*/
typedef struct _node_stat_t {
ir_node *irn;
- int new_color;
- int pinned_local :1;
+ int new_color;
+ int pinned_local :1;
} node_stat_t;
/**
* Represents a node in the optimization queue.
*/
typedef struct _qnode_t {
- struct list_head queue; /**< chaining of unit_t->queue */
- const unit_t *ou; /**< the opt unit this qnode belongs to */
- int color; /**< target color */
- set *conflicts; /**< contains conflict_t's. All internal conflicts */
- int mis_costs; /**< costs of nodes/copies in the mis. */
- int mis_size; /**< size of the array below */
- ir_node **mis; /**< the nodes of unit_t->nodes[] being part of the max independent set */
- set *changed_nodes; /**< contains node_stat_t's. */
+ struct list_head queue; /**< chaining of unit_t->queue */
+ const unit_t *ou; /**< the opt unit this qnode belongs to */
+ int color; /**< target color */
+ set *conflicts; /**< contains conflict_t's. All internal conflicts */
+ int mis_costs; /**< costs of nodes/copies in the mis. */
+ int mis_size; /**< size of the array below */
+ ir_node **mis; /**< the nodes of unit_t->nodes[] being part of the max independent set */
+ set *changed_nodes; /**< contains node_stat_t's. */
} qnode_t;
static pset *pinned_global; /**< optimized nodes should not be altered any more */
static INLINE int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b)
{
- if(env->ifg)
+ if (env->ifg)
return be_ifg_connected(env->ifg, a, b);
else
return values_interfere(env->birg->lv, a, b);
*/
/**
- * More experiments on coalescing.
- * @author Sebastian Hack
- * @date 14.04.2006
+ * @file
+ * @brief More experiments on coalescing.
+ * @author Sebastian Hack
+ * @date 14.04.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "becopyopt.h"
#include "becopyopt_t.h"
#include "bechordal_t.h"
+#include "beirg_t.h"
#define DUMP_BEFORE 1
#define DUMP_AFTER 2
int co_solve_heuristic_new(copy_opt_t *co)
{
- char buf[256];
+ char buf[256];
co2_t env;
- FILE *f;
+ FILE *f;
phase_init(&env.ph, "co2", co->cenv->birg->irg, PHASE_DEFAULT_GROWTH, co2_irn_init, NULL);
env.touched = NULL;
*/
/**
- * More experiments on coalescing.
- * @author Sebastian Hack
- * @date 25.07.2006
+ * @file
+ * @brief More experiments on coalescing with Java implementation.
+ * @author Sebastian Hack
+ * @date 25.07.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
*/
/**
- * @file becopyheur4.c
- * @brief Simple copy minimization heuristics.
- * @author 27.04.2007
- * @version $Id$
- * @license
- *
- * Copyrigth (C) 1995-2007 University of Karlsruhe. All right reserved.
- *
- * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
- *
- * @summary
+ * @file
+ * @brief Simple copy minimization heuristics.
+ * @author Christian Wuerdig
+ * @date 27.04.2007
+ * @version $Id$
*
* This is the C implementation of the mst algorithm
* originally written in Java by Sebastian Hack.
* (also known as "heur3" :)
* Performs simple copy minimization.
*/
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include "xmalloc.h"
#include "pdeq.h"
#include "irprintf.h"
+#include "irbitset.h"
#include "bearch.h"
#include "beifg.h"
#include "be_t.h"
#include "becopyopt_t.h"
-#include "irbitset.h"
#define COL_COST_INFEASIBLE DBL_MAX
#define AFF_NEIGHBOUR_FIX_BENEFIT 128.0
*/
/**
- * Author: Daniel Grund
- * Date: 28.02.2006
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- *
- * Common stuff used by all ILP fomulations.
- *
+ * @file
+ * @brief Common stuff used by all ILP formulations.
+ * @author Daniel Grund
+ * @date 28.02.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
*/
/**
- * Author: Daniel Grund
- * Date: 28.02.2006
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- *
+ * @file
+ * @brief ILP based copy minimization.
+ * @author Daniel Grund
+ * @date 28.02.2006
+ * @version $Id$
*
* ILP formalization using G=(V, E, Q):
* - 2 class of variables: coloring vars x_ic and equal color vars y_ij
*
* x_nc, y_ij \in N, w_ij \in R^+
*/
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
*/
/**
- * Author: Daniel Grund
- * Date: 28.02.2006
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- *
- * Common stuff used by all ILP fomulations.
- *
+ * @file
+ * @brief Common stuff used by all ILP formulations.
+ * @author Daniel Grund
+ * @date 28.02.2006
+ * @version $Id$
*/
-
-#ifndef _BECOPYILP_T_H
-#define _BECOPYILP_T_H
+#ifndef FIRM_BE_BECOPYILP_T_H
+#define FIRM_BE_BECOPYILP_T_H
#include "firm_config.h"
-#include "irnode_t.h"
+#include "irnode.h"
#include "pset.h"
#include "becopyopt_t.h"
-#include "xmalloc.h"
/******************************************************************************
_____ _ _ _ _
struct _coloring_suffix_t {
coloring_suffix_t *next;
- ir_node *irn;
+ ir_node *irn;
};
typedef struct _size_red_t {
- copy_opt_t *co;
- pset *all_removed; /**< All nodes removed during problem size reduction */
- coloring_suffix_t *col_suff; /**< Coloring suffix. Reverse would be a PEO prefix */
- struct obstack ob;
+ copy_opt_t *co;
+ pset *all_removed; /**< All nodes removed during problem size reduction */
+ coloring_suffix_t *col_suff; /**< Coloring suffix. Reverse would be a PEO prefix */
+ struct obstack ob;
} size_red_t;
/**
* Is this necessary?
*/
static INLINE int co_ilp_get_costs(copy_opt_t *co, ir_node *root, ir_node *arg) {
- int i;
+ int i;
unit_t *curr;
/* search optimization unit for phi */
list_for_each_entry(unit_t, curr, &co->units, units)
if (curr->nodes[0] == root) {
- for (i=1; i<curr->node_count; ++i)
+ for (i = 1; i < curr->node_count; ++i)
if (curr->nodes[i] == arg)
return curr->costs[i];
typedef void(*ilp_callback)(ilp_env_t*);
struct _ilp_env_t {
- const copy_opt_t *co; /**< the copy opt problem */
- size_red_t *sr; /**< problem size reduction. removes simple nodes */
- lpp_t *lp; /**< the linear programming problem */
- void *env;
- ilp_callback build;
- ilp_callback apply;
+ const copy_opt_t *co; /**< the copy opt problem */
+ size_red_t *sr; /**< problem size reduction. removes simple nodes */
+ lpp_t *lp; /**< the linear programming problem */
+ void *env;
+ ilp_callback build;
+ ilp_callback apply;
};
ilp_env_t *new_ilp_env(copy_opt_t *co, ilp_callback build, ilp_callback apply, void *env);
#define name_cdd_sorted(buf, char1, int1, int2) \
name_cdd(buf, char1, MIN(int1, int2), MAX(int1, int2))
-#endif // WITH_ILP
+#endif /* WITH_ILP */
-#endif
+#endif /* FIRM_BE_BECOPYILP_T_H */
*/
/**
- * Author: Daniel Grund
- * Date: 12.04.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * @file
+ * @brief Copy minimization driver.
+ * @author Daniel Grund
+ * @date 12.04.2005
+ * @version $Id$
+ *
+ * Main file for the optimization reducing the copies needed for:
+ * - Phi coalescing
+ * - Register-constrained nodes
+ * - Two-address code instructions
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "bestatevent.h"
#include "beirg_t.h"
#include "error.h"
+#include "bera.h"
#include <libcore/lc_timing.h>
#include <libcore/lc_opts.h>
*/
/**
- * Author: Daniel Grund
- * Date: 11.04.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * @file
+ * @brief Copy minimization driver.
+ * @author Daniel Grund
+ * @date 11.04.2005
+ * @version $Id$
*
* Main file for the optimization reducing the copies needed for:
* - Phi coalescing
* - Register-constrained nodes
* - Two-address code instructions
*/
-#ifndef _BECOPYOPT_H
-#define _BECOPYOPT_H
+#ifndef FIRM_BE_BECOPYOPT_H
+#define FIRM_BE_BECOPYOPT_H
#include <stdio.h>
-#include "firm_types.h"
+#include "irnode.h"
#include "bechordal.h"
/**
typedef struct _copy_opt_t copy_opt_t;
-typedef int(*cost_fct_t)(const copy_opt_t *, ir_node*, ir_node*, int);
+typedef int(*cost_fct_t)(const copy_opt_t *, ir_node *, ir_node *, int);
/** A coalescing algorithm. */
typedef int (co_algo_t)(copy_opt_t *);
*/
int co_gs_is_optimizable(copy_opt_t *co, ir_node *irn);
-#endif /* _BECOPYOPT_H */
+#endif /* FIRM_BE_BECOPYOPT_H */
*/
/**
- * Author: Daniel Grund
- * Date: 12.04.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- *
- * Internal header for copy optimization problem.
+ * @file
+ * @brief Internal header for copy optimization problem.
+ * @author Daniel Grund
+ * @date 12.04.2005
+ * @version $Id$
*/
-
-#ifndef _BECOPYOPT_T_H
-#define _BECOPYOPT_T_H
+#ifndef FIRM_BE_BECOPYOPT_T_H
+#define FIRM_BE_BECOPYOPT_T_H
#include "obst.h"
#include "list.h"
+#include "set.h"
+
#include "bearch_t.h"
#include "bechordal_t.h"
#include "becopyopt.h"
* Data representing the problem of copy minimization.
*/
struct _copy_opt_t {
- be_chordal_env_t *cenv;
+ be_chordal_env_t *cenv;
const arch_register_class_t *cls;
- const arch_env_t *aenv;
- ir_graph *irg;
- char *name; /**< ProgName__IrgName__RegClassName */
- cost_fct_t get_costs; /**< function ptr used to get costs for copies */
+ const arch_env_t *aenv;
+ ir_graph *irg;
+ char *name; /**< ProgName__IrgName__RegClassName */
+ cost_fct_t get_costs; /**< function ptr used to get costs for copies */
/** Representation as optimization units */
- struct list_head units; /**< all units to optimize in specific order */
+ struct list_head units; /**< all units to optimize in specific order */
/** Representation in graph structure. Only build on demand */
struct obstack obst;
- set *nodes;
+ set *nodes;
};
/* Helpers */
#define MIS_HEUR_TRIGGER 8
typedef struct _unit_t {
- struct list_head units; /**< chain for all units */
- copy_opt_t *co; /**< the copy opt this unit belongs to */
- int node_count; /**< size of the nodes array */
- ir_node **nodes; /**< [0] is the root-node, others are non interfering args of it. */
- int *costs; /**< costs[i] are incurred, if nodes[i] has a different color */
- int inevitable_costs; /**< sum of costs of all args interfering with root */
- int all_nodes_costs; /**< sum of all costs[i] */
- int min_nodes_costs; /**< a lower bound for the costs in costs[], determined by a max independent set */
- int sort_key; /**< maximum costs. controls the order of ou's in the struct list_head units. */
+ struct list_head units; /**< chain for all units */
+ copy_opt_t *co; /**< the copy opt this unit belongs to */
+ int node_count; /**< size of the nodes array */
+ ir_node **nodes; /**< [0] is the root-node, others are non interfering args of it. */
+ int *costs; /**< costs[i] are incurred, if nodes[i] has a different color */
+ int inevitable_costs; /**< sum of costs of all args interfering with root */
+ int all_nodes_costs; /**< sum of all costs[i] */
+ int min_nodes_costs; /**< a lower bound for the costs in costs[], determined by a max independent set */
+ int sort_key; /**< maximum costs. controls the order of ou's in the struct list_head units. */
/* for heuristic */
- struct list_head queue; /**< list of qn's sorted by weight of qn-mis */
+ struct list_head queue; /**< list of qn's sorted by weight of qn-mis */
} unit_t;
typedef struct _affinity_node_t affinity_node_t;
struct _neighb_t {
- neighb_t *next; /** the next neighbour entry*/
- ir_node *irn; /** the neighbour itself */
- int costs; /** the costs of the edge (affinity_node_t->irn, neighb_t->irn) */
+ neighb_t *next; /** the next neighbour entry*/
+ ir_node *irn; /** the neighbour itself */
+ int costs; /** the costs of the edge (affinity_node_t->irn, neighb_t->irn) */
};
struct _affinity_node_t {
- ir_node *irn; /** a node with affinity edges */
- int degree; /** number of affinity edges in the linked list below */
- neighb_t *neighbours; /** a linked list of all affinity neighbours */
- void *data; /** stuff that is attachable. */
+ ir_node *irn; /** a node with affinity edges */
+ int degree; /** number of affinity edges in the linked list below */
+ neighb_t *neighbours; /** a linked list of all affinity neighbours */
+ void *data; /** stuff that is attachable. */
};
#define co_gs_foreach_neighb(aff_node, neighb) for (neighb = aff_node->neighbours; neighb; neighb = neighb->next)
-#endif
+#endif /* FIRM_BE_BECOPYOPT_T_H */
*/
/**
- * Author: Daniel Grund
- * Date: 19.04.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * @file
+ * @brief Copy node statistics.
+ * @author Daniel Grund
+ * @date 19.04.2005
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "becopystat.h"
#include "beirg_t.h"
#include "bemodule.h"
+#include "bera.h"
#define DEBUG_LVL SET_LEVEL_1
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
*/
/**
- * Author: Daniel Grund
- * Date: 11.04.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- * CVS-Id: $Id$
+ * @file
+ * @brief Copy node statistics.
+ * @author Daniel Grund
+ * @date 11.04.2005
+ * @version $Id$
*/
-#ifndef _BECOPYSTAT_H
-#define _BECOPYSTAT_H
+#ifndef FIRM_BE_BECOPYSTAT_H
+#define FIRM_BE_BECOPYSTAT_H
#include "firm_config.h"
#include "irgraph.h"
*/
void co_compare_solvers(be_chordal_env_t *chordal_env);
-#endif /* _BECOPYSTAT_H */
+#endif /* FIRM_BE_BECOPYSTAT_H */
/**
* @file
+ * @brief Algorithms for computing normal and iterated dominance frontiers.
* @author Sebastian Hack, Daniel Grund
- * @date: 04.05.2005
+ * @date 04.05.2005
* @version $Id$
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "bedomfront.h"
-
#include "obst.h"
#include "pmap.h"
#include "pdeq.h"
#include "array.h"
#include "irgraph.h"
#include "iredges_t.h"
+#include "irnodeset.h"
+
+#include "bedomfront.h"
/**
* The dominance frontier for a graph.
waitq_put(worklist, block);
}
- while(!pdeq_empty(worklist)) {
- int i;
- ir_node *block = waitq_get(worklist);
- ir_node **domfront = be_get_dominance_frontier(domfronts, block);
- int domfront_len = ARR_LEN(domfront);
+ while(! pdeq_empty(worklist)) {
+ int i;
+ ir_node *block = waitq_get(worklist);
+ ir_node **domfront = be_get_dominance_frontier(domfronts, block);
+ int domfront_len = ARR_LEN(domfront);
for (i = 0; i < domfront_len; ++i) {
ir_node *y = domfront[i];
* @author Sebastian Hack, Daniel Grund
* @date: 04.05.2005
* @version $Id$
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
-#ifndef _FIRM_BE_DOMFRONT_H_
-#define _FIRM_BE_DOMFRONT_H_
+#ifndef FIRM_BE_BEDOMFRONT_H
+#define FIRM_BE_BEDOMFRONT_H
-#include "irnodeset.h"
+#include "irnode.h"
+#include "irgraph.h"
/*
* Forward type declaration.
* @param block The block whose dominance frontier you want.
* @return A list containing the all blocks in the dominance frontier of @p block.
*/
-ir_node **be_get_dominance_frontier(const be_dom_front_info_t *info,
- ir_node *block);
+ir_node **be_get_dominance_frontier(const be_dom_front_info_t *info, ir_node *block);
-#endif
+#endif /* FIRM_BE_BEDOMFRONT_H */
#include <libcore/lc_timing.h>
#include "bitset.h"
-
#include "irgwalk.h"
#include "irnode_t.h"
#include "irprintf.h"
#include "beifg_t.h"
#include "beifg_impl.h"
#include "irphase_t.h"
-#include "bechordal.h"
#include "error.h"
#include "xmalloc.h"
#include "becopystat.h"
#include "becopyopt.h"
#include "beirg_t.h"
+#include "bemodule.h"
/** Defines values for the ifg performance test */
#define BE_CH_PERFORMANCETEST_MIN_NODES (50)
typedef struct _coloring_t coloring_t;
struct _coloring_t {
- ir_phase ph;
+ ir_phase ph;
const arch_env_t *arch_env;
- ir_graph *irg;
+ ir_graph *irg;
};
size_t (be_ifg_nodes_iter_size)(const be_ifg_t *ifg)
#ifndef _BEIFG_H
#define _BEIFG_H
-#include "becopyopt.h"
+#include <stdio.h>
+
+#include "irnode.h"
-#include "firm_types.h"
+#include "becopyopt.h"
+#include "beirg.h"
typedef struct _be_ifg_impl_t be_ifg_impl_t;
typedef struct _be_ifg_t be_ifg_t;
*/
/**
- * @file beifg_clique.c
- * @date 18.11.2005
- * @author Sebastian Hack
- *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * @file
+ * @brief Clique calculation for chordal ifg.
+ * @author Sebastian Hack
+ * @date 18.11.2005
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "irgwalk.h"
#include "irbitset.h"
+#include "bearch_t.h"
#include "be_t.h"
#include "bera.h"
#include "beifg_t.h"
static void find_neighbour_walker(ir_node *bl, void *data)
{
- ifg_clique_t *ifg = data;
- struct list_head *head = get_block_border_head(ifg->env, bl);
- border_t *b;
- int was_def = 0;
- nodeset *live = new_nodeset(ifg->env->cls->n_regs);
+ ifg_clique_t *ifg = data;
+ struct list_head *head = get_block_border_head(ifg->env, bl);
+ int was_def = 0;
+ nodeset *live = new_nodeset(ifg->env->cls->n_regs);
+ border_t *b;
assert(is_Block(bl) && "There is no block to work on.");
#include "irgraph_t.h"
#include "irgwalk.h"
+#include "bearch_t.h"
#include "be_t.h"
#include "bera.h"
#include "beifg_t.h"
*/
/**
- * @file beifg_std.c
- * @date 18.11.2005
- * @author Sebastian Hack
- *
- * Copyright (C) 2005 Universitaet Karlsruhe
- * Released under the GPL
+ * @file
+ * @brief Default ifg implementation.
+ * @author Sebastian Hack
+ * @date 18.11.2005
+ * @version $Id$
*/
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "irnodeset.h"
#include "irgraph_t.h"
#include "irgwalk.h"
+#include "irtools.h"
+#include "bearch_t.h"
#include "be_t.h"
#include "belive_t.h"
#include "bera.h"
#include "beifg_t.h"
#include "bechordal_t.h"
-
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
+#include "beirg_t.h"
+#include "bera.h"
typedef struct _ifg_std_t ifg_std_t;
struct _ifg_std_t {
- const be_ifg_impl_t *impl;
+ const be_ifg_impl_t *impl;
const be_chordal_env_t *env;
};
static int ifg_std_connected(const void *self, const ir_node *a, const ir_node *b)
{
const ifg_std_t *ifg = self;
- be_lv_t *lv = ifg->env->birg->lv;
+ be_lv_t *lv = ifg->env->birg->lv;
return values_interfere(lv, a, b);
}
typedef struct _nodes_iter_t {
const be_chordal_env_t *env;
- struct obstack obst;
- int n;
- int curr;
- ir_node **nodes;
+ struct obstack obst;
+ int n;
+ int curr;
+ ir_node **nodes;
} nodes_iter_t;
static void nodes_walker(ir_node *bl, void *data)
{
- nodes_iter_t *it = data;
+ nodes_iter_t *it = data;
struct list_head *head = get_block_border_head(it->env, bl);
-
- border_t *b;
+ border_t *b;
foreach_border_head(head, b) {
- if(b->is_def && b->is_real) {
+ if (b->is_def && b->is_real) {
obstack_ptr_grow(&it->obst, b->irn);
it->n++;
}
};
struct _be_ifg_t {
- const be_ifg_impl_t *impl;
+ const be_ifg_impl_t *impl;
const be_chordal_env_t *env;
};
*/
/**
- * Scheduling algorithms.
+ * @file
+ * @brief ILP based instruction scheduling.
+ * @author Christian Wuerdig
+ * @date 22.10.2006
+ * @version $Id$
+ *
* An ILP scheduler based on
* "ILP-based Instruction Scheduling for IA-64"
* by Daniel Kaestner and Sebastian Winkel
* extended with register pressure constraints by Christian Wuerdig
- *
- * @date 22.10.2005
- * @author Christian Wuerdig
- * @cvs-id $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "beutil.h"
#include "bestat.h"
#include "beirg_t.h"
+#include "benodesets.h"
typedef struct _ilpsched_options_t {
unsigned regpress;
/**
* @file
- * @brief
+ * @brief Backend IRG modification routines.
+ * @author Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
+ * @date 04.05.2005
+ * @version $Id$
+ *
* This file contains the following IRG modifications for be routines:
* - insertion of Perm nodes
* - empty block elimination
* - a simple dead node elimination (set inputs of unreachable nodes to BAD)
- *
- * @author Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
- * @date 04.05.2005
- * @version $Id$
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "beutil.h"
#include "beinsn_t.h"
#include "bessaconstr.h"
-
+#include "beirg_t.h"
#include "beirgmod.h"
+#include "bemodule.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
*/
/**
- * Author: Christian Wuerdig
- * Date: 2005/12/14
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- * CVS-Id: $Id$
- *
- * Performs lowering of perm nodes and spill/reload optimization.
+ * @file
+ * @brief Performs lowering of perm nodes and spill/reload optimization.
+ * @author Christian Wuerdig
+ * @date 14.12.2005
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "debug.h"
#include "irhooks.h"
#include "xmalloc.h"
+#include "irnodeset.h"
+#include "irgmod.h"
+#include "iredges_t.h"
+#include "irgwalk.h"
#include "bearch_t.h"
#include "belower.h"
#include "besched_t.h"
#include "bestat.h"
#include "bessaconstr.h"
-#include "irnodeset.h"
-
-#include "irgmod.h"
-#include "iredges_t.h"
-#include "irgwalk.h"
+#include "benodesets.h"
#undef KEEP_ALIVE_COPYKEEP_HACK
*/
/**
- * Backend driver.
- * @author Sebastian Hack
- * @date 25.11.2004
- * @cvsid $Id$
+ * @file
+ * @brief Main Backend driver.
+ * @author Sebastian Hack
+ * @date 25.11.2004
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "beverify.h"
#include "beprofile.h"
#include "be_dbgout.h"
+#include "beirg_t.h"
#ifdef WITH_ILP
#include "beilpsched.h"
* PURPOSE.
*/
-/** vim: set sw=4 ts=4:
- * @file bepressurestat.c
- * @date 2006-04-06
- * @author Adam M. Szalkowski
- *
- * Register Pressure Statistics
- *
- * Copyright (C) 2006 Universitaet Karlsruhe
- * Released under the GPL
+/**
+ * @file
+ * @brief Register Pressure Statistics.
+ * @author Adam M. Szalkowski
+ * @date 06.04.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "phiclass.h"
#include "iredges.h"
#include "execfreq.h"
+#include "irtools.h"
#include <libcore/lc_bitset.h>
#include "beutil.h"
#include "bespillremat.h"
#include "bespill.h"
-
-#include "bechordal_t.h"
+#include "beirg_t.h"
#define MAXPRESSURE 128
const arch_register_class_t *cls;
const be_lv_t *lv;
unsigned int *stat;
- DEBUG_ONLY(firm_dbg_module_t * dbg);
+ DEBUG_ONLY(firm_dbg_module_t *dbg);
} regpressure_ana_t;
-static INLINE int
-has_reg_class(const regpressure_ana_t * ra, const ir_node * irn)
+static INLINE int has_reg_class(const regpressure_ana_t *ra, const ir_node *irn)
{
return arch_irn_consider_in_reg_alloc(ra->arch_env, ra->cls, irn);
}
-static INLINE int
-regpressure(pset * live)
-{
+static INLINE int regpressure(pset *live) {
int pressure = pset_count(live);
-
- return (pressure>MAXPRESSURE)?MAXPRESSURE:pressure;
+ return MIN(pressure, MAXPRESSURE);
}
static void
-regpressureanawalker(ir_node * bb, void * data)
+regpressureanawalker(ir_node *bb, void *data)
{
- regpressure_ana_t *ra = data;
- pset *live = pset_new_ptr_default();
- const ir_node *irn;
- unsigned int *stat = ra->stat;
- int i;
- const be_lv_t *lv = ra->lv;
-
- be_lv_foreach(lv, bb, be_lv_state_end, i) {
- ir_node *value = be_lv_get_irn(lv, bb, i);
- if (has_reg_class(ra, value)) {
- pset_insert_ptr(live, value);
- }
- }
- stat[regpressure(live)]++;
-
- sched_foreach_reverse(bb, irn) {
-
- if(is_Phi(irn)) break;
-
- if(has_reg_class(ra, irn)) {
- pset_remove_ptr(live, irn);
- }
-
- for(i=get_irn_arity(irn)-1; i>=0; --i) {
- ir_node *arg = get_irn_n(irn, i);
-
- if(has_reg_class(ra, arg)) {
- pset_insert_ptr(live, arg);
- }
- }
-
- if(!is_Proj(irn)) stat[regpressure(live)]++;
- }
+ regpressure_ana_t *ra = data;
+ pset *live = pset_new_ptr_default();
+ const ir_node *irn;
+ unsigned int *stat = ra->stat;
+ int i;
+ const be_lv_t *lv = ra->lv;
+
+ be_lv_foreach(lv, bb, be_lv_state_end, i) {
+ ir_node *value = be_lv_get_irn(lv, bb, i);
+ if (has_reg_class(ra, value)) {
+ pset_insert_ptr(live, value);
+ }
+ }
+ stat[regpressure(live)]++;
+
+ sched_foreach_reverse(bb, irn) {
+
+ if (is_Phi(irn)) break;
+
+ if (has_reg_class(ra, irn)) {
+ pset_remove_ptr(live, irn);
+ }
+
+ for (i = get_irn_arity(irn) - 1; i >= 0; --i) {
+ ir_node *arg = get_irn_n(irn, i);
+
+ if (has_reg_class(ra, arg)) {
+ pset_insert_ptr(live, arg);
+ }
+ }
+
+ if (! is_Proj(irn))
+ stat[regpressure(live)]++;
+ }
}
-void
-be_analyze_regpressure(be_irg_t *birg, const arch_register_class_t *cls,
- const char * suffix)
+void be_analyze_regpressure(be_irg_t *birg, const arch_register_class_t *cls, const char *suffix)
{
- regpressure_ana_t ra;
- unsigned int stat[MAXPRESSURE+1];
- unsigned int i;
- char fname[256];
- FILE *f;
- ir_graph *irg = be_get_birg_irg(birg);
+ regpressure_ana_t ra;
+ unsigned int stat[MAXPRESSURE+1];
+ unsigned int i;
+ char fname[256];
+ FILE *f;
+ ir_graph *irg = be_get_birg_irg(birg);
- ir_snprintf(fname, sizeof(fname), "%F_%s%s_pressure.stat", irg, cls->name, suffix);
- f = fopen(fname, "w");
- assert(f);
+ ir_snprintf(fname, sizeof(fname), "%F_%s%s_pressure.stat", irg, cls->name, suffix);
+ f = fopen(fname, "w");
+ assert(f);
- be_assure_liveness(birg);
+ be_assure_liveness(birg);
- FIRM_DBG_REGISTER(ra.dbg, "firm.be.regpressureana");
+ FIRM_DBG_REGISTER(ra.dbg, "firm.be.regpressureana");
- ra.arch_env = birg->main_env->arch_env;
- ra.lv = be_get_birg_liveness(birg);
- ra.cls = cls;
- ra.stat = stat;
+ ra.arch_env = birg->main_env->arch_env;
+ ra.lv = be_get_birg_liveness(birg);
+ ra.cls = cls;
+ ra.stat = stat;
- memset(stat, 0, sizeof(stat));
+ memset(stat, 0, sizeof(stat));
- irg_block_walk_graph(irg, regpressureanawalker, NULL, &ra);
+ irg_block_walk_graph(irg, regpressureanawalker, NULL, &ra);
- for(i=0; i<=MAXPRESSURE; ++i) {
- fprintf(f,"%d\n",stat[i]);
- }
+ for (i = 0; i <= MAXPRESSURE; ++i) {
+ fprintf(f, "%d\n", stat[i]);
+ }
- fclose(f);
+ fclose(f);
}
/**
* @file
+ * @brief Main spill driver.
* @author Daniel Grund, Sebastian Hack, Matthias Braun
* @date 29.09.2005
* @version $Id$
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "bespilloptions.h"
#include "bestatevent.h"
#include "bessaconstr.h"
+#include "beirg_t.h"
+#include "bera.h"
-// only rematerialise when costs are less than REMAT_COST_LIMIT
-// TODO determine a good value here...
+/* only rematerialise when costs are less than REMAT_COST_LIMIT */
+/* TODO determine a good value here... */
#define REMAT_COST_LIMIT 10
typedef struct _reloader_t reloader_t;
#include "pset.h"
#include "debug.h"
-#include "bechordal.h"
#include "be_t.h"
#include "bearch_t.h"
*/
/**
- * Author: Daniel Grund, Matthias Braun
- * Date: 20.09.2005
- * Copyright: (c) Universitaet Karlsruhe
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- *
+ * @file
+ * @brief Beladys spillalgorithm.
+ * @author Daniel Grund, Matthias Braun
+ * @date 20.09.2005
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "bechordal_t.h"
#include "bespilloptions.h"
#include "beloopana.h"
+#include "beirg_t.h"
+#include "bemodule.h"
#define DBG_SPILL 1
#define DBG_WSETS 2
#ifndef BESPILLBELADY_H_
#define BESPILLBELADY_H_
-#include "be_t.h"
-#include "bechordal.h"
-
-#include "bearch_t.h"
+#include "beirg.h"
+#include "bearch.h"
#include "bespill.h"
/**
* PURPOSE.
*/
-/*
- * Author: Matthias Braun
- * Date: 05.05.2006
- * Copyright: (c) Universitaet Karlsruhe
- * License: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE.
- *
+/**
+ * @file
+ * @brief Morgans spill algorithm.
+ * @author Matthias Braun
+ * @date 05.05.2006
+ * @version $Id$
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "bespillmorgan.h"
-
-#include "bechordal_t.h"
-#include "bespill.h"
-#include "belive_t.h"
-#include "beabi.h"
#include "irgwalk.h"
-#include "besched.h"
-#include "beutil.h"
#include "irloop_t.h"
#include "irgraph_t.h"
#include "irprintf.h"
#include "obst.h"
+#include "bespillmorgan.h"
+#include "bechordal_t.h"
+#include "bespill.h"
+#include "belive_t.h"
+#include "beabi.h"
#include "bespillbelady.h"
#include "beverify.h"
#include "benodesets.h"
#include "bespilloptions.h"
+#include "besched.h"
+#include "beutil.h"
+#include "bemodule.h"
+#include "beirg_t.h"
#define DBG_LIVE 1
#define DBG_LOOPANA 2
}
void be_spill_morgan(be_irg_t *birg, const arch_register_class_t *cls) {
- ir_graph *irg = be_get_birg_irg(birg);
+ ir_graph *irg = be_get_birg_irg(birg);
morgan_env_t env;
be_assure_liveness(birg);
env.arch = birg->main_env->arch_env;
- env.irg = irg;
- env.cls = cls;
- env.lv = be_get_birg_liveness(birg);
+ env.irg = irg;
+ env.cls = cls;
+ env.lv = be_get_birg_liveness(birg);
env.senv = be_new_spill_env(birg);
DEBUG_ONLY(be_set_spill_env_dbg_module(env.senv, dbg);)
env.registers_available = env.cls->n_regs - be_put_ignore_regs(birg, env.cls, NULL);
- env.loop_attr_set = new_set(loop_attr_cmp, 5);
+ env.loop_attr_set = new_set(loop_attr_cmp, 5);
env.block_attr_set = new_set(block_attr_cmp, 20);
- /*-- Part1: Analysis --*/
+ /* -- Part1: Analysis -- */
/* construct control flow loop tree */
- if(! (get_irg_loopinfo_state(irg) & loopinfo_cf_consistent)) {
+ if (! (get_irg_loopinfo_state(irg) & loopinfo_cf_consistent)) {
construct_cf_backedges(irg);
}
irg_block_walk_graph(irg, construct_block_livethrough_unused, construct_loop_edges, &env);
construct_loop_livethrough_unused(&env, get_irg_loop(irg));
- /*-- Part2: Transformation --*/
+ /* -- Part2: Transformation -- */
/* spill unused livethrough values around loops and blocks where
* the pressure is too high
be_insert_spills_reloads(env.senv);
/* Verify the result */
- if(birg->main_env->options->vrfy_option == BE_VRFY_WARN) {
+ if (birg->main_env->options->vrfy_option == BE_VRFY_WARN) {
be_verify_schedule(birg);
} else if (birg->main_env->options->vrfy_option == BE_VRFY_ASSERT) {
assert(be_verify_schedule(birg));
#ifndef BESPILLMORGAN_H_
#define BESPILLMORGAN_H_
-#include "be_t.h"
-#include "bechordal.h"
+#include "beirg.h"
+#include "bearch.h"
void be_spill_morgan(be_irg_t *birg, const arch_register_class_t *cls);
#ifndef BESPILL_OPTIONS_H_
#define BESPILL_OPTIONS_H_
-#include "bechordal.h"
+#include "bearch.h"
+#include "beirg.h"
extern int be_coalesce_spill_slots;
extern int be_do_remats;
#include "bepressurestat.h"
#include "beprofile.h"
#include "bespilloptions.h"
-
+#include "bera.h"
#include "bechordal_t.h"
+#include "bemodule.h"
#include <libcore/lc_opts.h>
#include <libcore/lc_opts_enum.h>
return result;
}
-static int
-values_interfere_in_block(const spill_ilp_t * si, const ir_node * bb, const ir_node * a, const ir_node * b)
+static
+int values_interfere_in_block(const spill_ilp_t *si, const ir_node *bb, const ir_node *a, const ir_node *b)
{
const ir_edge_t *edge;
- if(get_nodes_block(a) != bb && get_nodes_block(b) != bb) {
+ if (get_nodes_block(a) != bb && get_nodes_block(b) != bb) {
/* both values are live in, so they interfere */
return 1;
}
/* ensure a dominates b */
- if(value_dominates(b,a)) {
- const ir_node * t;
+ if (value_dominates(b, a)) {
+ const ir_node *t;
t = b;
b = a;
a = t;
/* the following code is stolen from bera.c */
- if(be_is_live_end(si->lv, bb, a))
+ if (be_is_live_end(si->lv, bb, a))
return 1;
foreach_out_edge(a, edge) {
const ir_node *user = edge->src;
- if(get_nodes_block(user) == bb
- && !is_Phi(user)
+ if (get_nodes_block(user) == bb
+ && ! is_Phi(user)
&& b != user
- && !pset_find_ptr(si->inverse_ops, user)
+ && ! pset_find_ptr(si->inverse_ops, user)
&& value_dominates(b, user))
return 1;
}
#ifndef BESPILLREMAT_H_
#define BESPILLREMAT_H_
-#include "bechordal.h"
void be_spill_remat(be_irg_t *birg, const arch_register_class_t *cls);
#include "bestatevent.h"
#include "bespilloptions.h"
#include "bemodule.h"
+#include "bera.h"
+#include "beirg_t.h"
#define DBG_COALESCING 1
#define DBG_INTERFERENCES 2
interferences[i] = bitset_alloca(spillcount);
}
- // construct interferences
- for(i = 0; i < spillcount; ++i) {
+ /* construct interferences */
+ for (i = 0; i < spillcount; ++i) {
ir_node *spill1 = spilllist[i]->spill;
- if(is_NoMem(spill1))
+
+ if (is_NoMem(spill1))
continue;
for(i2 = i+1; i2 < spillcount; ++i2) {
ir_node *spill2 = spilllist[i2]->spill;
- if(is_NoMem(spill2))
+
+ if (is_NoMem(spill2))
continue;
- if(values_interfere(lv, spill1, spill2)) {
- DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n",
- i, i2));
+ if (values_interfere(lv, spill1, spill2)) {
+ DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n", i, i2));
bitset_set(interferences[i], i2);
bitset_set(interferences[i2], i);
}
}
}
- // sort affinity edges
+ /* sort affinity edges */
affinity_edge_count = ARR_LEN(env->affinity_edges);
qsort(env->affinity_edges, affinity_edge_count, sizeof(env->affinity_edges[0]), cmp_affinity);
//dump_interference_graph(env, interferences, "before");
- // try to merge affine nodes
+ /* try to merge affine nodes */
for(i = 0; i < affinity_edge_count; ++i) {
const affinity_edge_t *edge = env->affinity_edges[i];
int s1 = uf_find(spillslot_unionfind, edge->slot1);
int s2 = uf_find(spillslot_unionfind, edge->slot2);
/* test if values interfere */
- if(bitset_is_set(interferences[s1], s2)) {
+ if (bitset_is_set(interferences[s1], s2)) {
assert(bitset_is_set(interferences[s2], s1));
continue;
}
ir_type *frame = get_irg_frame_type(irg);
ir_entity *res = frame_alloc_area(frame, slot->size, slot->align, 0);
- // adjust size of the entity type...
+ /* adjust size of the entity type... */
ir_type *enttype = get_entity_type(res);
set_type_size_bytes(enttype, slot->size);
be_fec_env_t *be_new_frame_entity_coalescer(be_irg_t *birg)
{
const arch_env_t *arch_env = birg->main_env->arch_env;
-
- be_fec_env_t *env = xmalloc(sizeof(env[0]));
+ be_fec_env_t *env = xmalloc(sizeof(env[0]));
be_assure_liveness(birg);
obstack_init(&env->obst);
- env->arch_env = arch_env;
- env->birg = birg;
- env->spills = new_set(cmp_spill, 10);
- env->reloads = NEW_ARR_F(ir_node*, 0);
+ env->arch_env = arch_env;
+ env->birg = birg;
+ env->spills = new_set(cmp_spill, 10);
+ env->reloads = NEW_ARR_F(ir_node*, 0);
env->affinity_edges = NEW_ARR_F(affinity_edge_t*, 0);
- env->memperms = new_set(cmp_memperm, 10);
+ env->memperms = new_set(cmp_memperm, 10);
return env;
}
#include "besched_t.h"
#include "benodesets.h"
#include "bestatevent.h"
+#include "beirg_t.h"
+#include "bera.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
*/
static void collect_phis_walker(ir_node *irn, void *data) {
be_chordal_env_t *env = data;
- if(is_Phi(irn) && chordal_has_class(env, irn)) {
+ if (is_Phi(irn) && chordal_has_class(env, irn)) {
ir_node *bl = get_nodes_block(irn);
set_irn_link(irn, get_irn_link(bl));
set_irn_link(bl, irn);
DBG((dbg, LEVEL_1, " for %+F(%s) -- %+F(%s)\n", phi, phi_reg->name, arg, arg_reg->name));
- if(values_interfere(lv, phi, arg)) {
+ if (values_interfere(lv, phi, arg)) {
/*
Insert a duplicate in arguments block,
make it the new phi arg,
*/
/**
- * Provides several statistic functions for the backend.
- * @author Christian Wuerdig
- * $Id$
+ * @file
+ * @brief Provides several statistic functions for the backend.
+ * @author Christian Wuerdig
+ * @version $Id$
*/
-
-#ifndef _BESTAT_H_
-#define _BESTAT_H_
+#ifndef FIRM_BE_BESTAT_H_
+#define FIRM_BE_BESTAT_H_
#include "firm_config.h"
-#include "be_t.h"
-#include "benodesets.h"
+
+#include "irnode.h"
+#include "irgraph.h"
+#include "irnodeset.h"
+
+#include "beirg.h"
#include "bestatevent.h"
+#include "bearch.h"
enum {
STAT_TAG_FILE = 0, /**< tag for source file name */
*/
double be_estimate_irg_costs(ir_graph *irg, const arch_env_t *arch_env, ir_exec_freq *execfreqs);
-#endif /* _BESTAT_H_ */
+#endif /* FIRM_BE_BESTAT_H_ */
#include "besched_t.h"
#include "benode_t.h"
#include "beirg_t.h"
+#include "bera.h"
static int my_values_interfere(const ir_node *a, const ir_node *b);
#ifndef BEVERIFY_H_
#define BEVERIFY_H_
-#include "bechordal.h"
+#include "irgraph.h"
+
+#include "beirg.h"
+#include "bearch.h"
/**
* Verifies, that the register pressure for a given register class doesn't exceed the limit