* @author Martin Trapp, Christian Schaefer, Goetz Lindenmaier, Michael Beck
* @version $Id$
*/
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
-#ifdef HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
+#include "pset_new.h"
#include "ident.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irhooks.h"
#include "irtools.h"
+#include "beinfo.h"
+
/* some constants fixing the positions of nodes predecessors
in the in array */
#define CALL_PARAM_OFFSET 2
edges_notify_edge(res, i - 1, res->in[i], NULL, irg);
hook_new_node(irg, res);
+ if (get_irg_phase_state(irg) == phase_backend) {
+ be_info_new_node(res);
+ }
return res;
}
_mark_irn_visited(node);
}
-int (irn_not_visited)(const ir_node *node) {
- return _irn_not_visited(node);
-}
-
int (irn_visited)(const ir_node *node) {
return _irn_visited(node);
}
+int (irn_visited_else_mark)(ir_node *node) {
+ return _irn_visited_else_mark(node);
+}
+
void (set_irn_link)(ir_node *node, void *link) {
_set_irn_link(node, link);
}
node->attr.except.pin_state = state;
}
-#ifdef DO_HEAPANALYSIS
-/* Access the abstract interpretation information of a node.
- Returns NULL if no such information is available. */
-struct abstval *get_irn_abst_value(ir_node *n) {
- return n->av;
-}
-/* Set the abstract interpretation information of a node. */
-void set_irn_abst_value(ir_node *n, struct abstval *os) {
- n->av = os;
-}
-struct section *firm_get_irn_section(ir_node *n) {
- return n->sec;
-}
-void firm_set_irn_section(ir_node *n, struct section *s) {
- n->sec = s;
-}
-#else
-/* Dummies needed for firmjni. */
-struct abstval *get_irn_abst_value(ir_node *n) {
- (void) n;
- return NULL;
-}
-void set_irn_abst_value(ir_node *n, struct abstval *os) {
- (void) n;
- (void) os;
-}
-struct section *firm_get_irn_section(ir_node *n) {
- (void) n;
- return NULL;
-}
-void firm_set_irn_section(ir_node *n, struct section *s) {
- (void) n;
- (void) s;
-}
-#endif /* DO_HEAPANALYSIS */
-
-
/* Outputs a unique number for this node */
long get_irn_node_nr(const ir_node *node) {
assert(node);
end->in[1 + END_KEEPALIVE_OFFSET + idx] = old;
edges_notify_edge(end, idx, old, NULL, irg);
}
+ /* now n - 1 keeps, 1 block input */
ARR_RESIZE(ir_node *, end->in, (n - 1) + 1 + END_KEEPALIVE_OFFSET);
}
-void
-free_End(ir_node *end) {
+/* remove Bads, NoMems and doublets from the keep-alive set */
+void remove_End_Bads_and_doublets(ir_node *end) {
+ pset_new_t keeps;
+ int idx, n = get_End_n_keepalives(end);
+ ir_graph *irg;
+
+ if (n <= 0)
+ return;
+
+ irg = get_irn_irg(end);
+ pset_new_init(&keeps);
+
+ for (idx = n - 1; idx >= 0; --idx) {
+ ir_node *ka = get_End_keepalive(end, idx);
+
+ if (is_Bad(ka) || is_NoMem(ka) || pset_new_contains(&keeps, ka)) {
+ /* remove the edge */
+ edges_notify_edge(end, idx, NULL, ka, irg);
+
+ if (idx != n - 1) {
+ /* exchange with the last one */
+ ir_node *old = end->in[1 + END_KEEPALIVE_OFFSET + n - 1];
+ edges_notify_edge(end, n - 1, NULL, old, irg);
+ end->in[1 + END_KEEPALIVE_OFFSET + idx] = old;
+ edges_notify_edge(end, idx, old, NULL, irg);
+ }
+ --n;
+ } else {
+ pset_new_insert(&keeps, ka);
+ }
+ }
+ /* n keeps, 1 block input */
+ ARR_RESIZE(ir_node *, end->in, n + 1 + END_KEEPALIVE_OFFSET);
+
+ pset_new_destroy(&keeps);
+}
+
+void free_End(ir_node *end) {
assert(is_End(end));
end->kind = k_BAD;
DEL_ARR_F(end->in);
void set_Call_callee_arr(ir_node *node, const int n, ir_entity ** arr) {
assert(is_Call(node));
if (node->attr.call.callee_arr == NULL || get_Call_n_callees(node) != n) {
- ir_graph *irg = get_irn_irg(node);
- node->attr.call.callee_arr = NEW_ARR_D(ir_entity *, irg->obst, n);
+ node->attr.call.callee_arr = NEW_ARR_D(ir_entity *, current_ir_graph->obst, n);
}
memcpy(node->attr.call.callee_arr, arr, n * sizeof(ir_entity *));
}