Commit d0a9700e authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Automatically set the original node name during code selection.

Now the original node name is set for all backends, not just ia32.
Further, no code in the backends is needed.
All new nodes, which are reachable from the returned transformed node and do not have a original node yet, automatically get assigned the original node.
parent 763ba23e
......@@ -142,6 +142,13 @@ static void dump_backend_info_hook(void *context, FILE *F, const ir_node *node)
if (lv->sets_valid)
be_dump_liveness_block(lv, F, node);
}
#ifndef NDEBUG
if (!is_Proj(node)) {
char const *const orig = be_get_info(node)->orig_node;
fprintf(F, "orig node = %s\n", orig ? orig : "n/a");
}
#endif
}
void be_info_init(void)
......
......@@ -38,6 +38,9 @@ struct backend_info_t {
const arch_register_req_t **in_reqs;
reg_out_info_t *out_infos;
arch_irn_flags_t flags;
#ifndef NDEBUG
char const *orig_node;
#endif
};
static inline backend_info_t *be_get_info(const ir_node *node)
......
......@@ -19,6 +19,7 @@
#include "debug.h"
#include "execfreq_t.h"
#include "heights.h"
#include "irargs_t.h"
#include "ircons_t.h"
#include "iredges_t.h"
#include "irgmod.h"
......@@ -42,10 +43,40 @@ typedef struct be_transform_env_t {
static be_transform_env_t env;
#ifndef NDEBUG
static void be_set_orig_node_rec(ir_node *const node, char const *const name)
{
if (!is_Proj(node)) {
char const **const orig = &be_get_info(node)->orig_node;
if (*orig)
return;
*orig = name;
}
foreach_irn_in(node, i, in) {
be_set_orig_node_rec(in, name);
}
}
static void be_set_orig_node(ir_node *const new_node, ir_node const *const old_node)
{
if (!is_Proj(old_node)) {
ir_graph *const irg = get_irn_irg(old_node);
struct obstack *const obst = be_get_be_obst(irg);
lc_eoprintf(firm_get_arg_env(), obst, "%+F", old_node);
obstack_1grow(obst, 0);
char const *const name = (char const*)obstack_finish(obst);
be_set_orig_node_rec(new_node, name);
}
}
#endif
void be_set_transformed_node(ir_node *old_node, ir_node *new_node)
{
set_irn_link(old_node, new_node);
mark_irn_visited(old_node);
#ifndef NDEBUG
be_set_orig_node(new_node, old_node);
#endif
}
bool be_is_transformed(const ir_node *node)
......@@ -176,10 +207,9 @@ ir_node *be_transform_node(ir_node *node)
new_node = (ir_node*)get_irn_link(node);
} else {
#ifdef DEBUG_libfirm
be_set_transformed_node(node, NULL);
#else
mark_irn_visited(node);
set_irn_link(node, NULL);
#endif
mark_irn_visited(node);
ir_op *const op = get_irn_op(node);
be_transform_func *const transform = (be_transform_func*)op->ops.generic;
......
......@@ -16,12 +16,6 @@
#include "x86_cconv.h"
#include "x86_x87.h"
#ifdef NDEBUG
#define SET_IA32_ORIG_NODE(n, o) ((void)(n), (void)(o), (void)0)
#else
#define SET_IA32_ORIG_NODE(n, o) set_ia32_orig_node(n, o)
#endif
#define IA32_REGISTER_SIZE 4
typedef struct ia32_irg_data_t {
......
......@@ -151,7 +151,6 @@ carry:;
}
set_irn_mode(res, get_irn_mode(irn));
SET_IA32_ORIG_NODE(res, irn);
/* exchange the add and the sub */
sched_replace(irn, res);
......
......@@ -15,7 +15,6 @@
#include <stdbool.h>
#include <inttypes.h>
#include "irargs_t.h"
#include "irprog_t.h"
#include "irgraph_t.h"
#include "irnode_t.h"
......@@ -255,9 +254,6 @@ void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
}
fprintf(F, "\n");
}
/* dump original ir node name */
char const *orig = get_ia32_attr_const(n)->orig_node;
fprintf(F, "orig node = %s\n", orig ? orig : "n/a");
#endif
break;
}
......@@ -530,25 +526,6 @@ void set_ia32_exc_label_id(ir_node *node, ir_label_t id)
attr->exc_label = id;
}
#ifndef NDEBUG
static const char *ia32_get_old_node_name(const ir_node *irn)
{
ir_graph *irg = get_irn_irg(irn);
struct obstack *obst = be_get_be_obst(irg);
lc_eoprintf(firm_get_arg_env(), obst, "%+F", irn);
obstack_1grow(obst, 0);
return (const char*)obstack_finish(obst);
}
void set_ia32_orig_node(ir_node *node, const ir_node *old)
{
const char *name = ia32_get_old_node_name(old);
ia32_attr_t *attr = get_ia32_attr(node);
attr->orig_node = name;
}
#endif
void ia32_swap_left_right(ir_node *node)
{
ia32_attr_t *attr = get_ia32_attr(node);
......
......@@ -183,13 +183,6 @@ ir_label_t get_ia32_exc_label_id(const ir_node *node);
*/
void set_ia32_exc_label_id(ir_node *node, ir_label_t id);
#ifndef NDEBUG
/**
* Sets the name of the original ir node.
*/
void set_ia32_orig_node(ir_node *node, const ir_node *old);
#endif
/**
* Swaps left/right input of a node (and sets ins_permuted accordingly)
*/
......
......@@ -114,7 +114,6 @@ struct ia32_attr_t {
x86_addr_t addr; /**< address mode specification */
#ifndef NDEBUG
const char *orig_node; /**< holds the name of the original ir node */
ir_entity const *old_frame_ent; /**< frame entity referenced */
unsigned attr_type; /**< bitfield indicating the attribute type */
#endif
......
......@@ -996,7 +996,6 @@ static void peephole_ia32_Lea(ir_node *node)
res = make_add(node, base, imm);
exchange:
arch_set_irn_register(res, oreg);
SET_IA32_ORIG_NODE(res, node);
replace(node, res);
return;
}
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment