summaryrefslogtreecommitdiffhomepage
path: root/ir/be/betranshlp.c
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2016-04-26 06:56:08 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2016-04-26 07:56:17 +0200
commitd0a9700ef62439b23f1fd67031547ddd797870ab (patch)
tree2b9354462a21cff52a3954d3c154c6d135554a19 /ir/be/betranshlp.c
parent763ba23e178651a12d8b1cc181bd7712234c598b (diff)
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.
Diffstat (limited to 'ir/be/betranshlp.c')
-rw-r--r--ir/be/betranshlp.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/ir/be/betranshlp.c b/ir/be/betranshlp.c
index 114c141..97773a4 100644
--- a/ir/be/betranshlp.c
+++ b/ir/be/betranshlp.c
@@ -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;