2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
6 * This file may be distributed and/or modified under the terms of the
7 * GNU General Public License version 2 as published by the Free Software
8 * Foundation and appearing in the file LICENSE.GPL included in the
9 * packaging of this file.
11 * Licensees holding valid libFirm Professional Edition licenses may use
12 * this file in accordance with the libFirm Commercial License.
13 * Agreement provided with the Software.
15 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * @brief Backend node support for generic backend nodes.
23 * @author Sebastian Hack
27 * Backend node support for generic backend nodes.
28 * This file provides Perm, Copy, Spill and Reload nodes.
43 #include "bitfiddle.h"
44 #include "raw_bitset.h"
58 #include "besched_t.h"
64 #define OUT_POS(x) (-((x) + 1))
66 #define get_irn_attr(irn) get_irn_generic_attr(irn)
67 #define get_irn_attr_const(irn) get_irn_generic_attr_const(irn)
70 arch_register_req_t req;
71 arch_irn_flags_t flags;
75 const arch_register_t *reg;
80 /** The generic be nodes attribute type. */
82 be_reg_data_t *reg_data;
85 /** The be_Return nodes attribute type. */
87 be_node_attr_t node_attr; /**< base attributes of every be node. */
88 int num_ret_vals; /**< number of return values */
89 unsigned pop; /**< number of bytes that should be popped */
90 int emit_pop; /**< if set, emit pop bytes, even if pop = 0 */
93 /** The be_IncSP attribute type. */
95 be_node_attr_t node_attr; /**< base attributes of every be node. */
96 int offset; /**< The offset by which the stack shall be expanded/shrinked. */
97 int align; /**< whether stack should be aligned after the
101 /** The be_Frame attribute type. */
103 be_node_attr_t node_attr; /**< base attributes of every be node. */
108 /** The be_Call attribute type. */
110 be_node_attr_t node_attr; /**< base attributes of every be node. */
111 ir_entity *ent; /**< The called entity if this is a static call. */
113 ir_type *call_tp; /**< The call type, copied from the original Call node. */
117 be_node_attr_t node_attr; /**< base attributes of every be node. */
118 ir_entity **in_entities;
119 ir_entity **out_entities;
125 ir_op *op_be_MemPerm;
128 ir_op *op_be_CopyKeep;
134 ir_op *op_be_RegParams;
135 ir_op *op_be_FrameAddr;
136 ir_op *op_be_Barrier;
139 static const ir_op_ops be_node_op_ops;
141 #define N irop_flag_none
142 #define L irop_flag_labeled
143 #define C irop_flag_commutative
144 #define X irop_flag_cfopcode
145 #define I irop_flag_ip_cfopcode
146 #define F irop_flag_fragile
147 #define Y irop_flag_forking
148 #define H irop_flag_highlevel
149 #define c irop_flag_constlike
150 #define K irop_flag_keep
151 #define M irop_flag_uses_memory
153 static int be_reqs_equal(const be_req_t *req1, const be_req_t *req2)
155 if(!reg_reqs_equal(&req1->req, &req2->req))
157 if(req1->flags != req2->flags)
164 * Compare two be node attributes.
166 * @return zero if both attributes are identically
168 static int _node_cmp_attr(const be_node_attr_t *a, const be_node_attr_t *b) {
171 if (ARR_LEN(a->reg_data) != ARR_LEN(b->reg_data))
174 len = ARR_LEN(a->reg_data);
175 for (i = 0; i < len; ++i) {
176 if (a->reg_data[i].reg != b->reg_data[i].reg ||
177 !be_reqs_equal(&a->reg_data[i].in_req, &b->reg_data[i].in_req) ||
178 !be_reqs_equal(&a->reg_data[i].req, &b->reg_data[i].req))
186 * Compare the node attributes of two be_node's.
188 * @return zero if both nodes have identically attributes
190 static int node_cmp_attr(ir_node *a, ir_node *b) {
191 const be_node_attr_t *a_attr = get_irn_attr_const(a);
192 const be_node_attr_t *b_attr = get_irn_attr_const(b);
194 return _node_cmp_attr(a_attr, b_attr);
198 * Compare the attributes of two be_FrameAddr nodes.
200 * @return zero if both nodes have identically attributes
202 static int FrameAddr_cmp_attr(ir_node *a, ir_node *b) {
203 const be_frame_attr_t *a_attr = get_irn_attr_const(a);
204 const be_frame_attr_t *b_attr = get_irn_attr_const(b);
206 if (a_attr->ent != b_attr->ent || a_attr->offset != b_attr->offset)
209 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
213 * Compare the attributes of two be_Return nodes.
215 * @return zero if both nodes have identically attributes
217 static int Return_cmp_attr(ir_node *a, ir_node *b) {
218 const be_return_attr_t *a_attr = get_irn_attr_const(a);
219 const be_return_attr_t *b_attr = get_irn_attr_const(b);
221 if (a_attr->num_ret_vals != b_attr->num_ret_vals)
223 if (a_attr->pop != b_attr->pop)
225 if (a_attr->emit_pop != b_attr->emit_pop)
228 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
232 * Compare the attributes of two be_IncSP nodes.
234 * @return zero if both nodes have identically attributes
236 static int IncSP_cmp_attr(ir_node *a, ir_node *b) {
237 const be_incsp_attr_t *a_attr = get_irn_attr_const(a);
238 const be_incsp_attr_t *b_attr = get_irn_attr_const(b);
240 if (a_attr->offset != b_attr->offset)
243 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
247 * Compare the attributes of two be_Call nodes.
249 * @return zero if both nodes have identically attributes
251 static int Call_cmp_attr(ir_node *a, ir_node *b) {
252 const be_call_attr_t *a_attr = get_irn_attr_const(a);
253 const be_call_attr_t *b_attr = get_irn_attr_const(b);
255 if (a_attr->ent != b_attr->ent ||
256 a_attr->call_tp != b_attr->call_tp)
259 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
262 static INLINE be_req_t *get_be_req(const ir_node *node, int pos)
265 const be_node_attr_t *attr;
268 assert(is_be_node(node));
269 attr = get_irn_attr_const(node);
275 assert(idx < get_irn_arity(node));
277 assert(idx < ARR_LEN(attr->reg_data));
278 rd = &attr->reg_data[idx];
280 return pos < 0 ? &rd->req : &rd->in_req;
283 static INLINE arch_register_req_t *get_req(const ir_node *node, int pos)
285 be_req_t *bereq = get_be_req(node, pos);
290 * Initializes the generic attribute of all be nodes and return ir.
292 static void *init_node_attr(ir_node *node, int max_reg_data)
294 ir_graph *irg = get_irn_irg(node);
295 struct obstack *obst = get_irg_obstack(irg);
296 be_node_attr_t *a = get_irn_attr(node);
298 memset(a, 0, sizeof(get_op_attr_size(get_irn_op(node))));
300 if(max_reg_data >= 0) {
301 a->reg_data = NEW_ARR_D(be_reg_data_t, obst, max_reg_data);
302 memset(a->reg_data, 0, max_reg_data * sizeof(a->reg_data[0]));
304 a->reg_data = NEW_ARR_F(be_reg_data_t, 0);
310 static void add_register_req(ir_node *node)
312 be_node_attr_t *a = get_irn_attr(node);
313 be_reg_data_t regreq;
314 memset(®req, 0, sizeof(regreq));
315 ARR_APP1(be_reg_data_t, a->reg_data, regreq);
319 * Skip Proj nodes and return their Proj numbers.
321 * If *node is a Proj or Proj(Proj) node, skip it.
323 * @param node points to the node to be skipped
325 * @return 0 if *node was no Proj node, its Proj number else.
327 static int redir_proj(const ir_node **node)
329 const ir_node *n = *node;
334 *node = irn = get_Proj_pred(n);
336 assert(get_irn_mode(irn) == mode_T);
337 *node = get_Proj_pred(irn);
339 return get_Proj_proj(n);
345 static be_reg_data_t *retrieve_reg_data(const ir_node *node)
347 const be_node_attr_t *attr;
351 pos = get_Proj_proj(node);
352 node = get_Proj_pred(node);
355 assert(is_be_node(node));
356 attr = get_irn_attr_const(node);
357 assert(pos >= 0 && pos < ARR_LEN(attr->reg_data) && "illegal proj number");
359 return &attr->reg_data[pos];
363 be_node_set_irn_reg(ir_node *irn, const arch_register_t *reg)
365 be_reg_data_t *r = retrieve_reg_data(irn);
369 ir_node *be_new_Spill(const arch_register_class_t *cls, const arch_register_class_t *cls_frame,
370 ir_graph *irg, ir_node *bl, ir_node *frame, ir_node *to_spill)
378 res = new_ir_node(NULL, irg, bl, op_be_Spill, mode_M, 2, in);
379 a = init_node_attr(res, 2);
383 be_node_set_reg_class(res, be_pos_Spill_frame, cls_frame);
384 be_node_set_reg_class(res, be_pos_Spill_val, cls);
388 ir_node *be_new_Reload(const arch_register_class_t *cls, const arch_register_class_t *cls_frame,
389 ir_graph *irg, ir_node *bl, ir_node *frame, ir_node *mem, ir_mode *mode)
396 res = new_ir_node(NULL, irg, bl, op_be_Reload, mode, 2, in);
398 init_node_attr(res, 2);
399 be_node_set_reg_class(res, -1, cls);
400 be_node_set_reg_class(res, be_pos_Reload_frame, cls_frame);
401 be_node_set_flags(res, -1, arch_irn_flags_rematerializable);
405 ir_node *be_get_Reload_mem(const ir_node *irn)
407 assert(be_is_Reload(irn));
408 return get_irn_n(irn, be_pos_Reload_mem);
411 ir_node *be_get_Reload_frame(const ir_node *irn)
413 assert(be_is_Reload(irn));
414 return get_irn_n(irn, be_pos_Reload_frame);
417 ir_node *be_get_Spill_val(const ir_node *irn)
419 assert(be_is_Spill(irn));
420 return get_irn_n(irn, be_pos_Spill_val);
423 ir_node *be_get_Spill_frame(const ir_node *irn)
425 assert(be_is_Spill(irn));
426 return get_irn_n(irn, be_pos_Spill_frame);
429 ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
432 ir_node *irn = new_ir_node(NULL, irg, bl, op_be_Perm, mode_T, n, in);
433 init_node_attr(irn, n);
434 for(i = 0; i < n; ++i) {
435 be_node_set_reg_class(irn, i, cls);
436 be_node_set_reg_class(irn, OUT_POS(i), cls);
442 void be_Perm_reduce(ir_node *perm, int new_size, int *map)
444 int arity = get_irn_arity(perm);
445 be_reg_data_t *old_data = alloca(arity * sizeof(old_data[0]));
446 be_node_attr_t *attr = get_irn_attr(perm);
451 assert(be_is_Perm(perm));
452 assert(new_size <= arity);
454 NEW_ARR_A(ir_node *, new_in, new_size);
456 /* save the old register data */
457 memcpy(old_data, attr->reg_data, arity * sizeof(old_data[0]));
459 /* compose the new in array and set the new register data directly in place */
460 for (i = 0; i < new_size; ++i) {
462 new_in[i] = get_irn_n(perm, idx);
463 attr->reg_data[i] = old_data[idx];
466 set_irn_in(perm, new_size, new_in);
469 ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
472 ir_node *frame = get_irg_frame(irg);
473 const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
475 const arch_register_t *sp = arch_env->sp;
476 be_memperm_attr_t *attr;
479 real_in = alloca((n+1) * sizeof(real_in[0]));
481 memcpy(&real_in[1], in, n * sizeof(real_in[0]));
483 irn = new_ir_node(NULL, irg, bl, op_be_MemPerm, mode_T, n+1, real_in);
485 init_node_attr(irn, n + 1);
486 be_node_set_reg_class(irn, 0, sp->reg_class);
487 for (i = 0; i < n; ++i) {
488 be_node_set_reg_class(irn, i + 1, cls_frame);
489 be_node_set_reg_class(irn, OUT_POS(i), cls_frame);
492 attr = get_irn_attr(irn);
494 attr->in_entities = obstack_alloc(irg->obst, n * sizeof(attr->in_entities[0]));
495 memset(attr->in_entities, 0, n * sizeof(attr->in_entities[0]));
496 attr->out_entities = obstack_alloc(irg->obst, n*sizeof(attr->out_entities[0]));
497 memset(attr->out_entities, 0, n*sizeof(attr->out_entities[0]));
503 ir_node *be_new_Copy(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *op)
507 arch_register_req_t *req;
510 res = new_ir_node(NULL, irg, bl, op_be_Copy, get_irn_mode(op), 1, in);
511 init_node_attr(res, 1);
512 be_node_set_reg_class(res, 0, cls);
513 be_node_set_reg_class(res, OUT_POS(0), cls);
515 req = get_req(res, OUT_POS(0));
517 req->type = arch_register_req_type_should_be_same;
518 req->other_same = 1U << 0;
523 ir_node *be_get_Copy_op(const ir_node *cpy) {
524 return get_irn_n(cpy, be_pos_Copy_op);
527 void be_set_Copy_op(ir_node *cpy, ir_node *op) {
528 set_irn_n(cpy, be_pos_Copy_op, op);
531 ir_node *be_new_Keep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
536 res = new_ir_node(NULL, irg, bl, op_be_Keep, mode_ANY, -1, NULL);
537 init_node_attr(res, -1);
539 for(i = 0; i < n; ++i) {
540 add_irn_n(res, in[i]);
541 add_register_req(res);
542 be_node_set_reg_class(res, i, cls);
549 void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls, ir_node *node)
553 assert(be_is_Keep(keep));
554 n = add_irn_n(keep, node);
555 add_register_req(keep);
556 be_node_set_reg_class(keep, n, cls);
559 /* creates a be_Call */
560 ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *bl, ir_node *mem, ir_node *sp, ir_node *ptr,
561 int n_outs, int n, ir_node *in[], ir_type *call_tp)
564 int real_n = be_pos_Call_first_arg + n;
568 NEW_ARR_A(ir_node *, real_in, real_n);
569 real_in[be_pos_Call_mem] = mem;
570 real_in[be_pos_Call_sp] = sp;
571 real_in[be_pos_Call_ptr] = ptr;
572 memcpy(&real_in[be_pos_Call_first_arg], in, n * sizeof(in[0]));
574 irn = new_ir_node(dbg, irg, bl, op_be_Call, mode_T, real_n, real_in);
575 a = init_node_attr(irn, (n_outs > real_n ? n_outs : real_n));
577 a->call_tp = call_tp;
582 /* Gets the call entity or NULL if this is no static call. */
583 ir_entity *be_Call_get_entity(const ir_node *call) {
584 const be_call_attr_t *a = get_irn_attr_const(call);
585 assert(be_is_Call(call));
589 /* Sets the call entity. */
590 void be_Call_set_entity(ir_node *call, ir_entity *ent) {
591 be_call_attr_t *a = get_irn_attr(call);
592 assert(be_is_Call(call));
596 /* Gets the call type. */
597 ir_type *be_Call_get_type(ir_node *call) {
598 const be_call_attr_t *a = get_irn_attr_const(call);
599 assert(be_is_Call(call));
603 /* Sets the call type. */
604 void be_Call_set_type(ir_node *call, ir_type *call_tp) {
605 be_call_attr_t *a = get_irn_attr(call);
606 assert(be_is_Call(call));
607 a->call_tp = call_tp;
610 void be_Call_set_pop(ir_node *call, unsigned pop) {
611 be_call_attr_t *a = get_irn_attr(call);
615 unsigned be_Call_get_pop(const ir_node *call) {
616 const be_call_attr_t *a = get_irn_attr_const(call);
620 /* Construct a new be_Return. */
621 ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *block, int n_res,
622 unsigned pop, int n, ir_node *in[])
628 res = new_ir_node(dbg, irg, block, op_be_Return, mode_X, -1, NULL);
629 init_node_attr(res, -1);
630 for(i = 0; i < n; ++i) {
631 add_irn_n(res, in[i]);
632 add_register_req(res);
635 a = get_irn_attr(res);
636 a->num_ret_vals = n_res;
643 /* Returns the number of real returns values */
644 int be_Return_get_n_rets(const ir_node *ret) {
645 const be_return_attr_t *a = get_irn_generic_attr_const(ret);
646 return a->num_ret_vals;
649 /* return the number of bytes that should be popped from stack when executing the Return. */
650 unsigned be_Return_get_pop(const ir_node *ret) {
651 const be_return_attr_t *a = get_irn_generic_attr_const(ret);
655 /* return non-zero, if number of popped bytes must be always emitted */
656 int be_Return_get_emit_pop(const ir_node *ret) {
657 const be_return_attr_t *a = get_irn_generic_attr_const(ret);
661 /* return non-zero, if number of popped bytes must be always emitted */
662 void be_Return_set_emit_pop(ir_node *ret, int emit_pop) {
663 be_return_attr_t *a = get_irn_generic_attr(ret);
664 a->emit_pop = emit_pop;
667 int be_Return_append_node(ir_node *ret, ir_node *node) {
670 pos = add_irn_n(ret, node);
671 add_register_req(ret);
676 ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl,
677 ir_node *old_sp, int offset, int align)
684 irn = new_ir_node(NULL, irg, bl, op_be_IncSP, sp->reg_class->mode,
685 sizeof(in) / sizeof(in[0]), in);
686 a = init_node_attr(irn, 1);
690 be_node_set_flags(irn, -1, arch_irn_flags_ignore | arch_irn_flags_modify_sp);
692 /* Set output constraint to stack register. */
693 be_node_set_reg_class(irn, 0, sp->reg_class);
694 be_set_constr_single_reg(irn, BE_OUT_POS(0), sp);
695 be_node_set_irn_reg(irn, sp);
700 ir_node *be_new_AddSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, ir_node *sz)
704 ir_node *in[be_pos_AddSP_last];
705 const arch_register_class_t *cls;
707 in[be_pos_AddSP_old_sp] = old_sp;
708 in[be_pos_AddSP_size] = sz;
710 irn = new_ir_node(NULL, irg, bl, op_be_AddSP, mode_T, be_pos_AddSP_last, in);
711 a = init_node_attr(irn, be_pos_AddSP_last);
713 be_node_set_flags(irn, OUT_POS(pn_be_AddSP_sp),
714 arch_irn_flags_ignore | arch_irn_flags_modify_sp);
716 /* Set output constraint to stack register. */
717 be_set_constr_single_reg(irn, be_pos_AddSP_old_sp, sp);
718 be_node_set_reg_class(irn, be_pos_AddSP_size, arch_register_get_class(sp));
719 be_set_constr_single_reg(irn, OUT_POS(pn_be_AddSP_sp), sp);
720 a->reg_data[pn_be_AddSP_sp].reg = sp;
722 cls = arch_register_get_class(sp);
723 be_node_set_reg_class(irn, OUT_POS(pn_be_AddSP_res), cls);
728 ir_node *be_new_SubSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, ir_node *sz)
732 ir_node *in[be_pos_SubSP_last];
734 in[be_pos_SubSP_old_sp] = old_sp;
735 in[be_pos_SubSP_size] = sz;
737 irn = new_ir_node(NULL, irg, bl, op_be_SubSP, mode_T, be_pos_SubSP_last, in);
738 a = init_node_attr(irn, be_pos_SubSP_last);
740 be_node_set_flags(irn, OUT_POS(pn_be_SubSP_sp),
741 arch_irn_flags_ignore | arch_irn_flags_modify_sp);
743 /* Set output constraint to stack register. */
744 be_set_constr_single_reg(irn, be_pos_SubSP_old_sp, sp);
745 be_node_set_reg_class(irn, be_pos_SubSP_size, arch_register_get_class(sp));
746 be_set_constr_single_reg(irn, OUT_POS(pn_be_SubSP_sp), sp);
747 a->reg_data[pn_be_SubSP_sp].reg = sp;
752 ir_node *be_new_RegParams(ir_graph *irg, ir_node *bl, int n_outs)
757 res = new_ir_node(NULL, irg, bl, op_be_RegParams, mode_T, 0, NULL);
758 init_node_attr(res, -1);
759 for(i = 0; i < n_outs; ++i)
760 add_register_req(res);
765 ir_node *be_RegParams_append_out_reg(ir_node *regparams,
766 const arch_env_t *arch_env,
767 const arch_register_t *reg)
769 ir_graph *irg = get_irn_irg(regparams);
770 ir_node *block = get_nodes_block(regparams);
771 be_node_attr_t *attr = get_irn_attr(regparams);
772 const arch_register_class_t *cls = arch_register_get_class(reg);
773 ir_mode *mode = arch_register_class_mode(cls);
774 int n = ARR_LEN(attr->reg_data);
777 assert(be_is_RegParams(regparams));
778 proj = new_r_Proj(irg, block, regparams, mode, n);
779 add_register_req(regparams);
780 be_set_constr_single_reg(regparams, BE_OUT_POS(n), reg);
781 arch_set_irn_register(arch_env, proj, reg);
783 /* TODO decide, whether we need to set ignore/modify sp flags here? */
788 ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame, ir_graph *irg, ir_node *bl, ir_node *frame, ir_entity *ent)
795 irn = new_ir_node(NULL, irg, bl, op_be_FrameAddr, get_irn_mode(frame), 1, in);
796 a = init_node_attr(irn, 1);
799 be_node_set_reg_class(irn, 0, cls_frame);
800 be_node_set_reg_class(irn, OUT_POS(0), cls_frame);
802 return optimize_node(irn);
805 ir_node *be_get_FrameAddr_frame(const ir_node *node) {
806 assert(be_is_FrameAddr(node));
807 return get_irn_n(node, be_pos_FrameAddr_ptr);
810 ir_entity *be_get_FrameAddr_entity(const ir_node *node)
812 const be_frame_attr_t *attr = get_irn_generic_attr_const(node);
816 ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *src, int n, ir_node *in_keep[], ir_mode *mode)
819 ir_node **in = (ir_node **) alloca((n + 1) * sizeof(in[0]));
822 memcpy(&in[1], in_keep, n * sizeof(in[0]));
823 irn = new_ir_node(NULL, irg, bl, op_be_CopyKeep, mode, n + 1, in);
824 init_node_attr(irn, n + 1);
825 be_node_set_reg_class(irn, OUT_POS(0), cls);
826 be_node_set_reg_class(irn, 0, cls);
831 ir_node *be_new_CopyKeep_single(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *src, ir_node *keep, ir_mode *mode)
833 return be_new_CopyKeep(cls, irg, bl, src, 1, &keep, mode);
836 ir_node *be_get_CopyKeep_op(const ir_node *cpy) {
837 return get_irn_n(cpy, be_pos_CopyKeep_op);
840 void be_set_CopyKeep_op(ir_node *cpy, ir_node *op) {
841 set_irn_n(cpy, be_pos_CopyKeep_op, op);
844 ir_node *be_new_Barrier(ir_graph *irg, ir_node *bl, int n, ir_node *in[])
849 res = new_ir_node(NULL, irg, bl, op_be_Barrier, mode_T, -1, NULL);
850 init_node_attr(res, -1);
851 for(i = 0; i < n; ++i) {
852 add_irn_n(res, in[i]);
853 add_register_req(res);
859 ir_node *be_Barrier_append_node(ir_node *barrier, ir_node *node)
861 ir_graph *irg = get_irn_irg(barrier);
862 ir_node *block = get_nodes_block(barrier);
863 ir_mode *mode = get_irn_mode(node);
864 int n = add_irn_n(barrier, node);
866 ir_node *proj = new_r_Proj(irg, block, barrier, mode, n);
867 add_register_req(barrier);
872 /* Construct a new be_Unwind. */
873 ir_node *be_new_Unwind(dbg_info *dbg, ir_graph *irg, ir_node *block,
874 ir_node *mem, ir_node *sp)
879 in[be_pos_Unwind_mem] = mem;
880 in[be_pos_Unwind_sp] = sp;
881 res = new_ir_node(dbg, irg, block, op_be_Unwind, mode_X, 2, in);
882 init_node_attr(res, -1);
887 int be_has_frame_entity(const ir_node *irn)
889 switch (get_irn_opcode(irn)) {
899 ir_entity *be_get_frame_entity(const ir_node *irn)
901 if (be_has_frame_entity(irn)) {
902 const be_frame_attr_t *a = get_irn_attr_const(irn);
908 int be_get_frame_offset(const ir_node *irn)
910 assert(is_be_node(irn));
911 if (be_has_frame_entity(irn)) {
912 const be_frame_attr_t *a = get_irn_attr_const(irn);
918 void be_set_MemPerm_in_entity(const ir_node *irn, int n, ir_entity *ent)
920 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
922 assert(be_is_MemPerm(irn));
923 assert(n < be_get_MemPerm_entity_arity(irn));
925 attr->in_entities[n] = ent;
928 ir_entity* be_get_MemPerm_in_entity(const ir_node* irn, int n)
930 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
932 assert(be_is_MemPerm(irn));
933 assert(n < be_get_MemPerm_entity_arity(irn));
935 return attr->in_entities[n];
938 void be_set_MemPerm_out_entity(const ir_node *irn, int n, ir_entity *ent)
940 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
942 assert(be_is_MemPerm(irn));
943 assert(n < be_get_MemPerm_entity_arity(irn));
945 attr->out_entities[n] = ent;
948 ir_entity* be_get_MemPerm_out_entity(const ir_node* irn, int n)
950 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
952 assert(be_is_MemPerm(irn));
953 assert(n < be_get_MemPerm_entity_arity(irn));
955 return attr->out_entities[n];
958 int be_get_MemPerm_entity_arity(const ir_node *irn)
960 return get_irn_arity(irn) - 1;
963 void be_set_constr_single_reg(ir_node *node, int pos, const arch_register_t *reg)
965 arch_register_req_t *req = get_req(node, pos);
966 const arch_register_class_t *cls = arch_register_get_class(reg);
967 ir_graph *irg = get_irn_irg(node);
968 struct obstack *obst = get_irg_obstack(irg);
969 unsigned *limited_bitset;
971 assert(req->cls == NULL || req->cls == cls);
972 assert(! (req->type & arch_register_req_type_limited));
973 assert(req->limited == NULL);
975 limited_bitset = rbitset_obstack_alloc(obst, arch_register_class_n_regs(cls));
976 rbitset_set(limited_bitset, arch_register_get_index(reg));
979 req->type |= arch_register_req_type_limited;
980 req->limited = limited_bitset;
983 void be_set_constr_limited(ir_node *node, int pos, const arch_register_req_t *req)
985 ir_graph *irg = get_irn_irg(node);
986 struct obstack *obst = get_irg_obstack(irg);
987 arch_register_req_t *r = get_req(node, pos);
989 assert(arch_register_req_is(req, limited));
990 assert(!(req->type & (arch_register_req_type_should_be_same | arch_register_req_type_must_be_different)));
991 memcpy(r, req, sizeof(r[0]));
992 r->limited = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
995 void be_node_set_flags(ir_node *irn, int pos, arch_irn_flags_t flags)
997 be_req_t *bereq = get_be_req(irn, pos);
998 bereq->flags = flags;
1001 void be_node_add_flags(ir_node *irn, int pos, arch_irn_flags_t flags)
1003 be_req_t *bereq = get_be_req(irn, pos);
1004 bereq->flags |= flags;
1007 void be_node_set_reg_class(ir_node *irn, int pos, const arch_register_class_t *cls)
1009 arch_register_req_t *req = get_req(irn, pos);
1014 req->type = arch_register_req_type_none;
1015 } else if (req->type == arch_register_req_type_none) {
1016 req->type = arch_register_req_type_normal;
1020 void be_node_set_req_type(ir_node *irn, int pos, arch_register_req_type_t type)
1022 arch_register_req_t *req = get_req(irn, pos);
1026 ir_node *be_get_IncSP_pred(ir_node *irn) {
1027 assert(be_is_IncSP(irn));
1028 return get_irn_n(irn, 0);
1031 void be_set_IncSP_pred(ir_node *incsp, ir_node *pred) {
1032 assert(be_is_IncSP(incsp));
1033 set_irn_n(incsp, 0, pred);
1036 void be_set_IncSP_offset(ir_node *irn, int offset)
1038 be_incsp_attr_t *a = get_irn_attr(irn);
1039 assert(be_is_IncSP(irn));
1043 int be_get_IncSP_offset(const ir_node *irn)
1045 const be_incsp_attr_t *a = get_irn_attr_const(irn);
1046 assert(be_is_IncSP(irn));
1050 int be_get_IncSP_align(const ir_node *irn)
1052 const be_incsp_attr_t *a = get_irn_attr_const(irn);
1053 assert(be_is_IncSP(irn));
1057 ir_node *be_spill(const arch_env_t *arch_env, ir_node *block, ir_node *irn)
1059 ir_graph *irg = get_irn_irg(block);
1060 ir_node *frame = get_irg_frame(irg);
1061 const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, irn, -1);
1062 const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
1065 spill = be_new_Spill(cls, cls_frame, irg, block, frame, irn);
1069 ir_node *be_reload(const arch_env_t *arch_env, const arch_register_class_t *cls, ir_node *insert, ir_mode *mode, ir_node *spill)
1072 ir_node *bl = is_Block(insert) ? insert : get_nodes_block(insert);
1073 ir_graph *irg = get_irn_irg(bl);
1074 ir_node *frame = get_irg_frame(irg);
1075 const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
1077 assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M));
1079 reload = be_new_Reload(cls, cls_frame, irg, bl, frame, spill, mode);
1081 if (is_Block(insert)) {
1082 insert = sched_skip(insert, 0, sched_skip_cf_predicator, (void *) arch_env);
1083 sched_add_after(insert, reload);
1085 sched_add_before(insert, reload);
1093 | _ \ ___ __ _ | _ \ ___ __ _ ___
1094 | |_) / _ \/ _` | | |_) / _ \/ _` / __|
1095 | _ < __/ (_| | | _ < __/ (_| \__ \
1096 |_| \_\___|\__, | |_| \_\___|\__, |___/
1103 arch_register_req_t *get_out_reg_req(const ir_node *irn, int out_pos)
1105 const be_node_attr_t *a = get_irn_attr_const(irn);
1107 if(out_pos >= ARR_LEN(a->reg_data)) {
1108 return arch_no_register_req;
1111 return &a->reg_data[out_pos].req.req;
1115 arch_register_req_t *get_in_reg_req(const ir_node *irn, int pos)
1117 const be_node_attr_t *a = get_irn_attr_const(irn);
1119 if(pos >= get_irn_arity(irn) || pos >= ARR_LEN(a->reg_data))
1120 return arch_no_register_req;
1122 return &a->reg_data[pos].in_req.req;
1125 static const arch_register_req_t *
1126 be_node_get_irn_reg_req(const ir_node *irn, int pos)
1131 if (get_irn_mode(irn) == mode_T)
1132 return arch_no_register_req;
1134 out_pos = redir_proj((const ir_node **)&irn);
1135 assert(is_be_node(irn));
1136 return get_out_reg_req(irn, out_pos);
1137 } else if (is_be_node(irn)) {
1139 * For spills and reloads, we return "none" as requirement for frame
1140 * pointer, so every input is ok. Some backends need this (e.g. STA).
1142 if ((be_is_Spill(irn) && pos == be_pos_Spill_frame) ||
1143 (be_is_Reload(irn) && pos == be_pos_Reload_frame))
1144 return arch_no_register_req;
1146 return get_in_reg_req(irn, pos);
1149 return arch_no_register_req;
1152 const arch_register_t *
1153 be_node_get_irn_reg(const ir_node *irn)
1157 if (get_irn_mode(irn) == mode_T)
1159 r = retrieve_reg_data(irn);
1163 static arch_irn_class_t be_node_classify(const ir_node *irn)
1166 switch (get_irn_opcode(irn)) {
1167 #define XXX(a,b) case a: return b
1168 XXX(beo_Spill, arch_irn_class_spill);
1169 XXX(beo_Reload, arch_irn_class_reload);
1170 XXX(beo_Perm, arch_irn_class_perm);
1171 XXX(beo_Copy, arch_irn_class_copy);
1172 XXX(beo_Return, arch_irn_class_branch);
1175 irn = get_Proj_pred(irn);
1177 assert(get_irn_mode(irn) == mode_T);
1178 irn = get_Proj_pred(irn);
1183 return arch_irn_class_normal;
1189 static arch_irn_flags_t be_node_get_flags(const ir_node *node)
1195 pos = OUT_POS(get_Proj_proj(node));
1196 node = skip_Proj_const(node);
1199 bereq = get_be_req(node, pos);
1201 return bereq->flags;
1204 static ir_entity *be_node_get_frame_entity(const ir_node *irn)
1206 return be_get_frame_entity(irn);
1209 static void be_node_set_frame_entity(ir_node *irn, ir_entity *ent)
1213 assert(be_has_frame_entity(irn));
1215 a = get_irn_attr(irn);
1219 static void be_node_set_frame_offset(ir_node *irn, int offset)
1221 if(be_has_frame_entity(irn)) {
1222 be_frame_attr_t *a = get_irn_attr(irn);
1227 static int be_node_get_sp_bias(const ir_node *irn)
1229 if(be_is_IncSP(irn))
1230 return be_get_IncSP_offset(irn);
1232 return -(int)be_Call_get_pop(irn);
1238 ___ ____ _ _ _ _ _ _
1239 |_ _| _ \| \ | | | | | | __ _ _ __ __| | | ___ _ __
1240 | || |_) | \| | | |_| |/ _` | '_ \ / _` | |/ _ \ '__|
1241 | || _ <| |\ | | _ | (_| | | | | (_| | | __/ |
1242 |___|_| \_\_| \_| |_| |_|\__,_|_| |_|\__,_|_|\___|_|
1246 static const arch_irn_ops_t be_node_irn_ops = {
1247 be_node_get_irn_reg_req,
1248 be_node_set_irn_reg,
1249 be_node_get_irn_reg,
1252 be_node_get_frame_entity,
1253 be_node_set_frame_entity,
1254 be_node_set_frame_offset,
1255 be_node_get_sp_bias,
1256 NULL, /* get_inverse */
1257 NULL, /* get_op_estimated_cost */
1258 NULL, /* possible_memory_operand */
1259 NULL, /* perform_memory_operand */
1263 ____ _ _ ___ ____ _ _ _ _ _ _
1264 | _ \| |__ (_) |_ _| _ \| \ | | | | | | __ _ _ __ __| | | ___ _ __
1265 | |_) | '_ \| | | || |_) | \| | | |_| |/ _` | '_ \ / _` | |/ _ \ '__|
1266 | __/| | | | | | || _ <| |\ | | _ | (_| | | | | (_| | | __/ |
1267 |_| |_| |_|_| |___|_| \_\_| \_| |_| |_|\__,_|_| |_|\__,_|_|\___|_|
1272 const arch_register_t *reg;
1273 arch_register_req_t req;
1274 arch_irn_flags_t flags;
1278 arch_env_t *arch_env;
1282 #define get_phi_handler_from_ops(h) container_of(h, phi_handler_t, irn_ops)
1285 phi_attr_t *get_Phi_attr(const ir_node *phi)
1287 phi_attr_t *attr = pmap_get(phi_handler.phi_attrs, (void*) phi);
1289 ir_graph *irg = get_irn_irg(phi);
1290 struct obstack *obst = get_irg_obstack(irg);
1291 attr = obstack_alloc(obst, sizeof(attr[0]));
1292 memset(attr, 0, sizeof(attr[0]));
1293 pmap_insert(phi_handler.phi_attrs, phi, attr);
1300 * Get register class of a Phi.
1303 const arch_register_req_t *get_Phi_reg_req_recursive(const ir_node *phi,
1306 int n = get_irn_arity(phi);
1310 if(*visited && pset_find_ptr(*visited, phi))
1313 for(i = 0; i < n; ++i) {
1314 op = get_irn_n(phi, i);
1315 /* Matze: don't we unnecessary constraint our phis with this?
1316 * we only need to take the regclass IMO*/
1318 return arch_get_register_req(op, BE_OUT_POS(0));
1322 * The operands of that Phi were all Phis themselves.
1323 * We have to start a DFS for a non-Phi argument now.
1326 *visited = pset_new_ptr(16);
1328 pset_insert_ptr(*visited, phi);
1330 for(i = 0; i < n; ++i) {
1331 const arch_register_req_t *req;
1332 op = get_irn_n(phi, i);
1333 req = get_Phi_reg_req_recursive(op, visited);
1342 const arch_register_req_t *phi_get_irn_reg_req(const ir_node *irn, int pos)
1347 if(!mode_is_datab(get_irn_mode(irn)))
1348 return arch_no_register_req;
1350 attr = get_Phi_attr(irn);
1352 if(attr->req.type == arch_register_req_type_none) {
1353 pset *visited = NULL;
1354 const arch_register_req_t *req;
1355 req = get_Phi_reg_req_recursive(irn, &visited);
1357 memcpy(&attr->req, req, sizeof(req[0]));
1358 assert(attr->req.cls != NULL);
1359 attr->req.type = arch_register_req_type_normal;
1368 void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node,
1369 const arch_register_req_t *req)
1374 assert(mode_is_datab(get_irn_mode(node)));
1376 attr = get_Phi_attr(node);
1377 memcpy(&attr->req, req, sizeof(req[0]));
1380 void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node,
1381 arch_irn_flags_t flags)
1386 assert(mode_is_datab(get_irn_mode(node)));
1388 attr = get_Phi_attr(node);
1389 attr->flags = flags;
1392 static void phi_set_irn_reg(ir_node *irn, const arch_register_t *reg)
1394 phi_attr_t *attr = get_Phi_attr(irn);
1398 static const arch_register_t *phi_get_irn_reg(const ir_node *irn)
1400 phi_attr_t *attr = get_Phi_attr(irn);
1404 static arch_irn_class_t phi_classify(const ir_node *irn)
1407 return arch_irn_class_normal;
1410 static arch_irn_flags_t phi_get_flags(const ir_node *irn)
1412 phi_attr_t *attr = get_Phi_attr(irn);
1416 static ir_entity *phi_get_frame_entity(const ir_node *irn)
1422 static void phi_set_frame_entity(ir_node *irn, ir_entity *ent)
1426 panic("phi_set_frame_entity() should not be called");
1429 static void phi_set_frame_offset(ir_node *irn, int bias)
1433 panic("phi_set_frame_offset() should not be called");
1436 static int phi_get_sp_bias(const ir_node *irn)
1442 static const arch_irn_ops_t phi_irn_ops = {
1443 phi_get_irn_reg_req,
1448 phi_get_frame_entity,
1449 phi_set_frame_entity,
1450 phi_set_frame_offset,
1452 NULL, /* get_inverse */
1453 NULL, /* get_op_estimated_cost */
1454 NULL, /* possible_memory_operand */
1455 NULL, /* perform_memory_operand */
1458 void be_phi_handler_new(be_main_env_t *env)
1460 phi_handler.arch_env = env->arch_env;
1461 phi_handler.phi_attrs = pmap_create();
1462 op_Phi->ops.be_ops = &phi_irn_ops;
1465 void be_phi_handler_free(void)
1467 pmap_destroy(phi_handler.phi_attrs);
1468 phi_handler.phi_attrs = NULL;
1469 op_Phi->ops.be_ops = NULL;
1472 void be_phi_handler_reset(void)
1474 if(phi_handler.phi_attrs)
1475 pmap_destroy(phi_handler.phi_attrs);
1476 phi_handler.phi_attrs = pmap_create();
1481 | \ | | ___ __| | ___ | _ \ _ _ _ __ ___ _ __ (_)_ __ __ _
1482 | \| |/ _ \ / _` |/ _ \ | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` |
1483 | |\ | (_) | (_| | __/ | |_| | |_| | | | | | | |_) | | | | | (_| |
1484 |_| \_|\___/ \__,_|\___| |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, |
1489 * Dumps a register requirement to a file.
1491 static void dump_node_req(FILE *f, int idx, const arch_register_req_t *req,
1492 const ir_node *node)
1494 int did_something = 0;
1496 const char *prefix = buf;
1498 snprintf(buf, sizeof(buf), "#%d ", idx);
1499 buf[sizeof(buf) - 1] = '\0';
1504 arch_register_req_format(tmp, sizeof(tmp), req, node);
1505 fprintf(f, "%s", tmp);
1514 * Dumps node register requirements to a file.
1516 static void dump_node_reqs(FILE *f, ir_node *node)
1519 be_node_attr_t *a = get_irn_attr(node);
1520 int len = ARR_LEN(a->reg_data);
1522 fprintf(f, "registers: \n");
1523 for(i = 0; i < len; ++i) {
1524 be_reg_data_t *rd = &a->reg_data[i];
1526 fprintf(f, "#%d: %s\n", i, rd->reg->name);
1529 fprintf(f, "in requirements:\n");
1530 for(i = 0; i < len; ++i) {
1531 dump_node_req(f, i, &a->reg_data[i].in_req.req, node);
1534 fprintf(f, "\nout requirements:\n");
1535 for(i = 0; i < len; ++i) {
1536 dump_node_req(f, i, &a->reg_data[i].req.req, node);
1541 * ir_op-Operation: dump a be node to file
1543 static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
1545 be_node_attr_t *at = get_irn_attr(irn);
1547 assert(is_be_node(irn));
1550 case dump_node_opcode_txt:
1551 fprintf(f, get_op_name(get_irn_op(irn)));
1553 case dump_node_mode_txt:
1554 if(be_is_Perm(irn) || be_is_Copy(irn) || be_is_CopyKeep(irn)) {
1555 fprintf(f, " %s", get_mode_name(get_irn_mode(irn)));
1558 case dump_node_nodeattr_txt:
1559 if(be_is_Call(irn)) {
1560 be_call_attr_t *a = (be_call_attr_t *) at;
1562 fprintf(f, " [%s] ", get_entity_name(a->ent));
1564 if(be_is_IncSP(irn)) {
1565 const be_incsp_attr_t *attr = get_irn_generic_attr_const(irn);
1566 if(attr->offset == BE_STACK_FRAME_SIZE_EXPAND) {
1567 fprintf(f, " [Setup Stackframe] ");
1568 } else if(attr->offset == BE_STACK_FRAME_SIZE_SHRINK) {
1569 fprintf(f, " [Destroy Stackframe] ");
1571 fprintf(f, " [%d] ", attr->offset);
1575 case dump_node_info_txt:
1576 dump_node_reqs(f, irn);
1578 if(be_has_frame_entity(irn)) {
1579 be_frame_attr_t *a = (be_frame_attr_t *) at;
1581 unsigned size = get_type_size_bytes(get_entity_type(a->ent));
1582 ir_fprintf(f, "frame entity: %+F, offset 0x%x (%d), size 0x%x (%d) bytes\n",
1583 a->ent, a->offset, a->offset, size, size);
1588 switch (get_irn_opcode(irn)) {
1591 be_incsp_attr_t *a = (be_incsp_attr_t *) at;
1592 if (a->offset == BE_STACK_FRAME_SIZE_EXPAND)
1593 fprintf(f, "offset: FRAME_SIZE\n");
1594 else if(a->offset == BE_STACK_FRAME_SIZE_SHRINK)
1595 fprintf(f, "offset: -FRAME SIZE\n");
1597 fprintf(f, "offset: %u\n", a->offset);
1602 be_call_attr_t *a = (be_call_attr_t *) at;
1605 fprintf(f, "\ncalling: %s\n", get_entity_name(a->ent));
1611 for(i = 0; i < be_get_MemPerm_entity_arity(irn); ++i) {
1612 ir_entity *in, *out;
1613 in = be_get_MemPerm_in_entity(irn, i);
1614 out = be_get_MemPerm_out_entity(irn, i);
1616 fprintf(f, "\nin[%d]: %s\n", i, get_entity_name(in));
1619 fprintf(f, "\nout[%d]: %s\n", i, get_entity_name(out));
1635 * Copies the backend specific attributes from old node to new node.
1637 static void copy_attr(const ir_node *old_node, ir_node *new_node)
1639 const be_node_attr_t *old_attr = get_irn_attr_const(old_node);
1640 be_node_attr_t *new_attr = get_irn_attr(new_node);
1641 struct obstack *obst = get_irg_obstack(get_irn_irg(new_node));
1644 assert(is_be_node(old_node));
1645 assert(is_be_node(new_node));
1647 memcpy(new_attr, old_attr, get_op_attr_size(get_irn_op(old_node)));
1648 new_attr->reg_data = NULL;
1650 if(old_attr->reg_data != NULL)
1651 len = ARR_LEN(old_attr->reg_data);
1655 if(get_irn_op(old_node)->opar == oparity_dynamic
1656 || be_is_RegParams(old_node)) {
1657 new_attr->reg_data = NEW_ARR_F(be_reg_data_t, len);
1659 new_attr->reg_data = NEW_ARR_D(be_reg_data_t, obst, len);
1663 memcpy(new_attr->reg_data, old_attr->reg_data, len * sizeof(be_reg_data_t));
1664 for(i = 0; i < len; ++i) {
1665 const be_reg_data_t *rd = &old_attr->reg_data[i];
1666 be_reg_data_t *newrd = &new_attr->reg_data[i];
1667 if(arch_register_req_is(&rd->req.req, limited)) {
1668 const arch_register_req_t *req = &rd->req.req;
1669 arch_register_req_t *new_req = &newrd->req.req;
1671 = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
1673 if(arch_register_req_is(&rd->in_req.req, limited)) {
1674 const arch_register_req_t *req = &rd->in_req.req;
1675 arch_register_req_t *new_req = &newrd->in_req.req;
1677 = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
1683 static const ir_op_ops be_node_op_ops = {
1704 int is_be_node(const ir_node *irn)
1706 return get_op_ops(get_irn_op(irn))->be_ops == &be_node_irn_ops;
1709 void be_node_init(void) {
1710 static int inited = 0;
1717 /* Acquire all needed opcodes. */
1718 op_be_Spill = new_ir_op(beo_Spill, "be_Spill", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops);
1719 op_be_Reload = new_ir_op(beo_Reload, "be_Reload", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_frame_attr_t), &be_node_op_ops);
1720 op_be_Perm = new_ir_op(beo_Perm, "be_Perm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1721 op_be_MemPerm = new_ir_op(beo_MemPerm, "be_MemPerm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_memperm_attr_t), &be_node_op_ops);
1722 op_be_Copy = new_ir_op(beo_Copy, "be_Copy", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1723 op_be_Keep = new_ir_op(beo_Keep, "be_Keep", op_pin_state_pinned, K, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1724 op_be_CopyKeep = new_ir_op(beo_CopyKeep, "be_CopyKeep", op_pin_state_pinned, K, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1725 op_be_Call = new_ir_op(beo_Call, "be_Call", op_pin_state_pinned, F|M, oparity_variable, 0, sizeof(be_call_attr_t), &be_node_op_ops);
1726 op_be_Return = new_ir_op(beo_Return, "be_Return", op_pin_state_pinned, X, oparity_dynamic, 0, sizeof(be_return_attr_t), &be_node_op_ops);
1727 op_be_AddSP = new_ir_op(beo_AddSP, "be_AddSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1728 op_be_SubSP = new_ir_op(beo_SubSP, "be_SubSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1729 op_be_IncSP = new_ir_op(beo_IncSP, "be_IncSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_incsp_attr_t), &be_node_op_ops);
1730 op_be_RegParams = new_ir_op(beo_RegParams, "be_RegParams", op_pin_state_pinned, N, oparity_zero, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1731 op_be_FrameAddr = new_ir_op(beo_FrameAddr, "be_FrameAddr", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_frame_attr_t), &be_node_op_ops);
1732 op_be_Barrier = new_ir_op(beo_Barrier, "be_Barrier", op_pin_state_pinned, N, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1733 op_be_Unwind = new_ir_op(beo_Unwind, "be_Unwind", op_pin_state_pinned, X, oparity_zero, 0, sizeof(be_node_attr_t), &be_node_op_ops);
1735 op_be_Spill->ops.node_cmp_attr = FrameAddr_cmp_attr;
1736 op_be_Reload->ops.node_cmp_attr = FrameAddr_cmp_attr;
1737 op_be_Perm->ops.node_cmp_attr = node_cmp_attr;
1738 op_be_MemPerm->ops.node_cmp_attr = node_cmp_attr;
1739 op_be_Copy->ops.node_cmp_attr = node_cmp_attr;
1740 op_be_Keep->ops.node_cmp_attr = node_cmp_attr;
1741 op_be_CopyKeep->ops.node_cmp_attr = node_cmp_attr;
1742 op_be_Call->ops.node_cmp_attr = Call_cmp_attr;
1743 op_be_Return->ops.node_cmp_attr = Return_cmp_attr;
1744 op_be_AddSP->ops.node_cmp_attr = node_cmp_attr;
1745 op_be_SubSP->ops.node_cmp_attr = node_cmp_attr;
1746 op_be_IncSP->ops.node_cmp_attr = IncSP_cmp_attr;
1747 op_be_RegParams->ops.node_cmp_attr = node_cmp_attr;
1748 op_be_FrameAddr->ops.node_cmp_attr = FrameAddr_cmp_attr;
1749 op_be_Barrier->ops.node_cmp_attr = node_cmp_attr;
1750 op_be_Unwind->ops.node_cmp_attr = node_cmp_attr;