* spilled. So in some situations (for example 2 adc-nodes that use the flags of
* a single add node on x86) operations have to be repeated to work correctly.
*/
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
#include "irgwalk.h"
#include "irnode_t.h"
#include "besched_t.h"
#include "benode_t.h"
-static const arch_env_t *arch_env = NULL;
static const arch_register_class_t *flag_class = NULL;
static const arch_register_t *flags_reg = NULL;
static func_rematerialize remat = NULL;
}
/**
- * tests wether we can legally move node node after node after
+ * tests whether we can legally move node node after node after
* (only works for nodes in same block)
*/
static int can_move(ir_node *node, ir_node *after)
assert(get_irn_n_edges_kind(out, EDGE_KIND_DEP) == 0);
foreach_out_edge(out, edge2) {
ir_node *out2 = get_edge_src_irn(edge2);
- /* phi represents a usage at block end */
- if(is_Phi(out2))
+ /* Phi or End represents a usage at block end. */
+ if(is_Phi(out2) || is_End(out2))
continue;
if(is_Sync(out2)) {
const ir_edge_t *edge3;
foreach_out_edge(out2, edge3) {
ir_node *out3 = get_edge_src_irn(edge3);
- /* phi represents a usage at block end */
- if(is_Phi(out3))
+ /* Phi or End represents a usage at block end. */
+ if(is_Phi(out3) || is_End(out3))
continue;
assert(!is_Sync(out3));
if(sched_get_time_step(out3) <= sched_get_time_step(after)) {
static int is_modify_flags(ir_node *node) {
int i, arity;
- if(arch_irn_is(arch_env, node, modify_flags))
+ if (arch_irn_is(node, modify_flags))
return 1;
if(!be_is_Keep(node))
return 0;
for(i = 0; i < arity; ++i) {
ir_node *in = get_irn_n(node, i);
in = skip_Proj(in);
- if(arch_irn_is(arch_env, in, modify_flags))
+ if (arch_irn_is(in, modify_flags))
return 1;
}
continue;
/* spiller can't (correctly) remat flag consumers at the moment */
- assert(!arch_irn_is(arch_env, node, rematerializable));
+ assert(!arch_irn_is(node, rematerializable));
if(skip_Proj(new_flags_needed) != flags_needed) {
if(flags_needed != NULL) {
}
flags_needed = new_flags_needed;
- arch_set_irn_register(arch_env, flags_needed, flags_reg);
+ arch_set_irn_register(flags_needed, flags_reg);
if(is_Proj(flags_needed)) {
pn = get_Proj_proj(flags_needed);
flags_needed = get_Proj_pred(flags_needed);
}
flag_consumers = node;
set_irn_link(flag_consumers, NULL);
- assert(arch_irn_is(arch_env, flags_needed, rematerializable));
+ assert(arch_irn_is(flags_needed, rematerializable));
} else {
/* link all consumers in a list */
set_irn_link(node, flag_consumers);
{
ir_graph *irg = be_get_birg_irg(birg);
- arch_env = be_get_birg_arch_env(birg);
flag_class = flag_cls;
flags_reg = & flag_class->regs[0];
remat = remat_func;