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"
57 #include "besched_t.h"
63 #define OUT_POS(x) (-((x) + 1))
65 #define get_irn_attr(irn) get_irn_generic_attr(irn)
66 #define get_irn_attr_const(irn) get_irn_generic_attr_const(irn)
69 arch_register_req_t req;
70 arch_irn_flags_t flags;
74 const arch_register_t *reg;
79 /** The generic be nodes attribute type. */
81 be_reg_data_t *reg_data;
84 /** The be_Return nodes attribute type. */
86 be_node_attr_t node_attr; /**< base attributes of every be node. */
87 int num_ret_vals; /**< number of return values */
88 unsigned pop; /**< number of bytes that should be popped */
89 int emit_pop; /**< if set, emit pop bytes, even if pop = 0 */
92 /** The be_IncSP attribute type. */
94 be_node_attr_t node_attr; /**< base attributes of every be node. */
95 int offset; /**< The offset by which the stack shall be expanded/shrinked. */
96 int align; /**< whether stack should be aligned after the
100 /** The be_Frame attribute type. */
102 be_node_attr_t node_attr; /**< base attributes of every be node. */
107 /** The be_Call attribute type. */
109 be_node_attr_t node_attr; /**< base attributes of every be node. */
110 ir_entity *ent; /**< The called entity if this is a static call. */
112 ir_type *call_tp; /**< The call type, copied from the original Call node. */
116 be_node_attr_t node_attr; /**< base attributes of every be node. */
117 ir_entity **in_entities;
118 ir_entity **out_entities;
124 ir_op *op_be_MemPerm;
127 ir_op *op_be_CopyKeep;
133 ir_op *op_be_RegParams;
134 ir_op *op_be_FrameAddr;
135 ir_op *op_be_Barrier;
138 static const ir_op_ops be_node_op_ops;
140 #define N irop_flag_none
141 #define L irop_flag_labeled
142 #define C irop_flag_commutative
143 #define X irop_flag_cfopcode
144 #define I irop_flag_ip_cfopcode
145 #define F irop_flag_fragile
146 #define Y irop_flag_forking
147 #define H irop_flag_highlevel
148 #define c irop_flag_constlike
149 #define K irop_flag_keep
150 #define M irop_flag_uses_memory
152 static int be_reqs_equal(const be_req_t *req1, const be_req_t *req2)
154 if(!reg_reqs_equal(&req1->req, &req2->req))
156 if(req1->flags != req2->flags)
163 * Compare two be node attributes.
165 * @return zero if both attributes are identically
167 static int _node_cmp_attr(const be_node_attr_t *a, const be_node_attr_t *b) {
170 if (ARR_LEN(a->reg_data) != ARR_LEN(b->reg_data))
173 len = ARR_LEN(a->reg_data);
174 for (i = 0; i < len; ++i) {
175 if (a->reg_data[i].reg != b->reg_data[i].reg ||
176 !be_reqs_equal(&a->reg_data[i].in_req, &b->reg_data[i].in_req) ||
177 !be_reqs_equal(&a->reg_data[i].req, &b->reg_data[i].req))
185 * Compare the node attributes of two be_node's.
187 * @return zero if both nodes have identically attributes
189 static int node_cmp_attr(ir_node *a, ir_node *b) {
190 const be_node_attr_t *a_attr = get_irn_attr_const(a);
191 const be_node_attr_t *b_attr = get_irn_attr_const(b);
193 return _node_cmp_attr(a_attr, b_attr);
197 * Compare the attributes of two be_FrameAddr nodes.
199 * @return zero if both nodes have identically attributes
201 static int FrameAddr_cmp_attr(ir_node *a, ir_node *b) {
202 const be_frame_attr_t *a_attr = get_irn_attr_const(a);
203 const be_frame_attr_t *b_attr = get_irn_attr_const(b);
205 if (a_attr->ent != b_attr->ent || a_attr->offset != b_attr->offset)
208 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
212 * Compare the attributes of two be_Return nodes.
214 * @return zero if both nodes have identically attributes
216 static int Return_cmp_attr(ir_node *a, ir_node *b) {
217 const be_return_attr_t *a_attr = get_irn_attr_const(a);
218 const be_return_attr_t *b_attr = get_irn_attr_const(b);
220 if (a_attr->num_ret_vals != b_attr->num_ret_vals)
222 if (a_attr->pop != b_attr->pop)
224 if (a_attr->emit_pop != b_attr->emit_pop)
227 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
231 * Compare the attributes of two be_IncSP nodes.
233 * @return zero if both nodes have identically attributes
235 static int IncSP_cmp_attr(ir_node *a, ir_node *b) {
236 const be_incsp_attr_t *a_attr = get_irn_attr_const(a);
237 const be_incsp_attr_t *b_attr = get_irn_attr_const(b);
239 if (a_attr->offset != b_attr->offset)
242 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
246 * Compare the attributes of two be_Call nodes.
248 * @return zero if both nodes have identically attributes
250 static int Call_cmp_attr(ir_node *a, ir_node *b) {
251 const be_call_attr_t *a_attr = get_irn_attr_const(a);
252 const be_call_attr_t *b_attr = get_irn_attr_const(b);
254 if (a_attr->ent != b_attr->ent ||
255 a_attr->call_tp != b_attr->call_tp)
258 return _node_cmp_attr(&a_attr->node_attr, &b_attr->node_attr);
261 static INLINE be_req_t *get_be_req(const ir_node *node, int pos)
264 const be_node_attr_t *attr;
267 assert(is_be_node(node));
268 attr = get_irn_attr_const(node);
274 assert(idx < get_irn_arity(node));
276 assert(idx < ARR_LEN(attr->reg_data));
277 rd = &attr->reg_data[idx];
279 return pos < 0 ? &rd->req : &rd->in_req;
282 static INLINE arch_register_req_t *get_req(const ir_node *node, int pos)
284 be_req_t *bereq = get_be_req(node, pos);
289 * Initializes the generic attribute of all be nodes and return ir.
291 static void *init_node_attr(ir_node *node, int max_reg_data)
293 ir_graph *irg = get_irn_irg(node);
294 struct obstack *obst = get_irg_obstack(irg);
295 be_node_attr_t *a = get_irn_attr(node);
297 memset(a, 0, sizeof(get_op_attr_size(get_irn_op(node))));
299 if(max_reg_data >= 0) {
300 a->reg_data = NEW_ARR_D(be_reg_data_t, obst, max_reg_data);
301 memset(a->reg_data, 0, max_reg_data * sizeof(a->reg_data[0]));
303 a->reg_data = NEW_ARR_F(be_reg_data_t, 0);
309 static void add_register_req(ir_node *node)
311 be_node_attr_t *a = get_irn_attr(node);
312 be_reg_data_t regreq;
313 memset(®req, 0, sizeof(regreq));
314 ARR_APP1(be_reg_data_t, a->reg_data, regreq);
318 * Skip Proj nodes and return their Proj numbers.
320 * If *node is a Proj or Proj(Proj) node, skip it.
322 * @param node points to the node to be skipped
324 * @return 0 if *node was no Proj node, its Proj number else.
326 static int redir_proj(const ir_node **node)
328 const ir_node *n = *node;
333 *node = irn = get_Proj_pred(n);
335 assert(get_irn_mode(irn) == mode_T);
336 *node = get_Proj_pred(irn);
338 return get_Proj_proj(n);
344 static be_reg_data_t *retrieve_reg_data(const ir_node *node)
346 const be_node_attr_t *attr;
350 pos = get_Proj_proj(node);
351 node = get_Proj_pred(node);
354 assert(is_be_node(node));
355 attr = get_irn_attr_const(node);
356 assert(pos >= 0 && pos < ARR_LEN(attr->reg_data) && "illegal proj number");
358 return &attr->reg_data[pos];
362 be_node_set_irn_reg(ir_node *irn, const arch_register_t *reg)
364 be_reg_data_t *r = retrieve_reg_data(irn);
368 ir_node *be_new_Spill(const arch_register_class_t *cls, const arch_register_class_t *cls_frame,
369 ir_graph *irg, ir_node *bl, ir_node *frame, ir_node *to_spill)
377 res = new_ir_node(NULL, irg, bl, op_be_Spill, mode_M, 2, in);
378 a = init_node_attr(res, 2);
382 be_node_set_reg_class(res, be_pos_Spill_frame, cls_frame);
383 be_node_set_reg_class(res, be_pos_Spill_val, cls);
387 ir_node *be_new_Reload(const arch_register_class_t *cls, const arch_register_class_t *cls_frame,
388 ir_graph *irg, ir_node *bl, ir_node *frame, ir_node *mem, ir_mode *mode)
395 res = new_ir_node(NULL, irg, bl, op_be_Reload, mode, 2, in);
397 init_node_attr(res, 2);
398 be_node_set_reg_class(res, -1, cls);
399 be_node_set_reg_class(res, be_pos_Reload_frame, cls_frame);
400 be_node_set_flags(res, -1, arch_irn_flags_rematerializable);
404 ir_node *be_get_Reload_mem(const ir_node *irn)
406 assert(be_is_Reload(irn));
407 return get_irn_n(irn, be_pos_Reload_mem);
410 ir_node *be_get_Reload_frame(const ir_node *irn)
412 assert(be_is_Reload(irn));
413 return get_irn_n(irn, be_pos_Reload_frame);
416 ir_node *be_get_Spill_val(const ir_node *irn)
418 assert(be_is_Spill(irn));
419 return get_irn_n(irn, be_pos_Spill_val);
422 ir_node *be_get_Spill_frame(const ir_node *irn)
424 assert(be_is_Spill(irn));
425 return get_irn_n(irn, be_pos_Spill_frame);
428 ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
431 ir_node *irn = new_ir_node(NULL, irg, bl, op_be_Perm, mode_T, n, in);
432 init_node_attr(irn, n);
433 for(i = 0; i < n; ++i) {
434 be_node_set_reg_class(irn, i, cls);
435 be_node_set_reg_class(irn, OUT_POS(i), cls);
441 void be_Perm_reduce(ir_node *perm, int new_size, int *map)
443 int arity = get_irn_arity(perm);
444 be_reg_data_t *old_data = alloca(arity * sizeof(old_data[0]));
445 be_node_attr_t *attr = get_irn_attr(perm);
450 assert(be_is_Perm(perm));
451 assert(new_size <= arity);
453 NEW_ARR_A(ir_node *, new_in, new_size);
455 /* save the old register data */
456 memcpy(old_data, attr->reg_data, arity * sizeof(old_data[0]));
458 /* compose the new in array and set the new register data directly in place */
459 for (i = 0; i < new_size; ++i) {
461 new_in[i] = get_irn_n(perm, idx);
462 attr->reg_data[i] = old_data[idx];
465 set_irn_in(perm, new_size, new_in);
468 ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
471 ir_node *frame = get_irg_frame(irg);
472 const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
474 const arch_register_t *sp = arch_env->sp;
475 be_memperm_attr_t *attr;
478 real_in = alloca((n+1) * sizeof(real_in[0]));
480 memcpy(&real_in[1], in, n * sizeof(real_in[0]));
482 irn = new_ir_node(NULL, irg, bl, op_be_MemPerm, mode_T, n+1, real_in);
484 init_node_attr(irn, n + 1);
485 be_node_set_reg_class(irn, 0, sp->reg_class);
486 for (i = 0; i < n; ++i) {
487 be_node_set_reg_class(irn, i + 1, cls_frame);
488 be_node_set_reg_class(irn, OUT_POS(i), cls_frame);
491 attr = get_irn_attr(irn);
493 attr->in_entities = obstack_alloc(irg->obst, n * sizeof(attr->in_entities[0]));
494 memset(attr->in_entities, 0, n * sizeof(attr->in_entities[0]));
495 attr->out_entities = obstack_alloc(irg->obst, n*sizeof(attr->out_entities[0]));
496 memset(attr->out_entities, 0, n*sizeof(attr->out_entities[0]));
502 ir_node *be_new_Copy(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *op)
506 arch_register_req_t *req;
509 res = new_ir_node(NULL, irg, bl, op_be_Copy, get_irn_mode(op), 1, in);
510 init_node_attr(res, 1);
511 be_node_set_reg_class(res, 0, cls);
512 be_node_set_reg_class(res, OUT_POS(0), cls);
514 req = get_req(res, OUT_POS(0));
516 req->type = arch_register_req_type_should_be_same;
517 req->other_same = 1U << 0;
522 ir_node *be_get_Copy_op(const ir_node *cpy) {
523 return get_irn_n(cpy, be_pos_Copy_op);
526 void be_set_Copy_op(ir_node *cpy, ir_node *op) {
527 set_irn_n(cpy, be_pos_Copy_op, op);
530 ir_node *be_new_Keep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, int n, ir_node *in[])
535 res = new_ir_node(NULL, irg, bl, op_be_Keep, mode_ANY, -1, NULL);
536 init_node_attr(res, -1);
538 for(i = 0; i < n; ++i) {
539 add_irn_n(res, in[i]);
540 add_register_req(res);
541 be_node_set_reg_class(res, i, cls);
548 void be_Keep_add_node(ir_node *keep, const arch_register_class_t *cls, ir_node *node)
552 assert(be_is_Keep(keep));
553 n = add_irn_n(keep, node);
554 add_register_req(keep);
555 be_node_set_reg_class(keep, n, cls);
558 /* creates a be_Call */
559 ir_node *be_new_Call(dbg_info *dbg, ir_graph *irg, ir_node *bl, ir_node *mem, ir_node *sp, ir_node *ptr,
560 int n_outs, int n, ir_node *in[], ir_type *call_tp)
563 int real_n = be_pos_Call_first_arg + n;
567 NEW_ARR_A(ir_node *, real_in, real_n);
568 real_in[be_pos_Call_mem] = mem;
569 real_in[be_pos_Call_sp] = sp;
570 real_in[be_pos_Call_ptr] = ptr;
571 memcpy(&real_in[be_pos_Call_first_arg], in, n * sizeof(in[0]));
573 irn = new_ir_node(dbg, irg, bl, op_be_Call, mode_T, real_n, real_in);
574 a = init_node_attr(irn, (n_outs > real_n ? n_outs : real_n));
576 a->call_tp = call_tp;
581 /* Gets the call entity or NULL if this is no static call. */
582 ir_entity *be_Call_get_entity(const ir_node *call) {
583 const be_call_attr_t *a = get_irn_attr_const(call);
584 assert(be_is_Call(call));
588 /* Sets the call entity. */
589 void be_Call_set_entity(ir_node *call, ir_entity *ent) {
590 be_call_attr_t *a = get_irn_attr(call);
591 assert(be_is_Call(call));
595 /* Gets the call type. */
596 ir_type *be_Call_get_type(ir_node *call) {
597 const be_call_attr_t *a = get_irn_attr_const(call);
598 assert(be_is_Call(call));
602 /* Sets the call type. */
603 void be_Call_set_type(ir_node *call, ir_type *call_tp) {
604 be_call_attr_t *a = get_irn_attr(call);
605 assert(be_is_Call(call));
606 a->call_tp = call_tp;
609 void be_Call_set_pop(ir_node *call, unsigned pop) {
610 be_call_attr_t *a = get_irn_attr(call);
614 unsigned be_Call_get_pop(const ir_node *call) {
615 const be_call_attr_t *a = get_irn_attr_const(call);
619 /* Construct a new be_Return. */
620 ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *block, int n_res,
621 unsigned pop, int n, ir_node *in[])
627 res = new_ir_node(dbg, irg, block, op_be_Return, mode_X, -1, NULL);
628 init_node_attr(res, -1);
629 for(i = 0; i < n; ++i) {
630 add_irn_n(res, in[i]);
631 add_register_req(res);
634 a = get_irn_attr(res);
635 a->num_ret_vals = n_res;
642 /* Returns the number of real returns values */
643 int be_Return_get_n_rets(const ir_node *ret) {
644 const be_return_attr_t *a = get_irn_generic_attr_const(ret);
645 return a->num_ret_vals;
648 /* return the number of bytes that should be popped from stack when executing the Return. */
649 unsigned be_Return_get_pop(const ir_node *ret) {
650 const be_return_attr_t *a = get_irn_generic_attr_const(ret);
654 /* return non-zero, if number of popped bytes must be always emitted */
655 int be_Return_get_emit_pop(const ir_node *ret) {
656 const be_return_attr_t *a = get_irn_generic_attr_const(ret);
660 /* return non-zero, if number of popped bytes must be always emitted */
661 void be_Return_set_emit_pop(ir_node *ret, int emit_pop) {
662 be_return_attr_t *a = get_irn_generic_attr(ret);
663 a->emit_pop = emit_pop;
666 int be_Return_append_node(ir_node *ret, ir_node *node) {
669 pos = add_irn_n(ret, node);
670 add_register_req(ret);
675 ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl,
676 ir_node *old_sp, int offset, int align)
683 irn = new_ir_node(NULL, irg, bl, op_be_IncSP, sp->reg_class->mode,
684 sizeof(in) / sizeof(in[0]), in);
685 a = init_node_attr(irn, 1);
689 be_node_set_flags(irn, -1, arch_irn_flags_ignore | arch_irn_flags_modify_sp);
691 /* Set output constraint to stack register. */
692 be_node_set_reg_class(irn, 0, sp->reg_class);
693 be_set_constr_single_reg(irn, BE_OUT_POS(0), sp);
694 be_node_set_irn_reg(irn, sp);
699 ir_node *be_new_AddSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, ir_node *sz)
703 ir_node *in[be_pos_AddSP_last];
704 const arch_register_class_t *cls;
706 in[be_pos_AddSP_old_sp] = old_sp;
707 in[be_pos_AddSP_size] = sz;
709 irn = new_ir_node(NULL, irg, bl, op_be_AddSP, mode_T, be_pos_AddSP_last, in);
710 a = init_node_attr(irn, be_pos_AddSP_last);
712 be_node_set_flags(irn, OUT_POS(pn_be_AddSP_sp),
713 arch_irn_flags_ignore | arch_irn_flags_modify_sp);
715 /* Set output constraint to stack register. */
716 be_set_constr_single_reg(irn, be_pos_AddSP_old_sp, sp);
717 be_node_set_reg_class(irn, be_pos_AddSP_size, arch_register_get_class(sp));
718 be_set_constr_single_reg(irn, OUT_POS(pn_be_AddSP_sp), sp);
719 a->reg_data[pn_be_AddSP_sp].reg = sp;
721 cls = arch_register_get_class(sp);
722 be_node_set_reg_class(irn, OUT_POS(pn_be_AddSP_res), cls);
727 ir_node *be_new_SubSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, ir_node *sz)
731 ir_node *in[be_pos_SubSP_last];
733 in[be_pos_SubSP_old_sp] = old_sp;
734 in[be_pos_SubSP_size] = sz;
736 irn = new_ir_node(NULL, irg, bl, op_be_SubSP, mode_T, be_pos_SubSP_last, in);
737 a = init_node_attr(irn, be_pos_SubSP_last);
739 be_node_set_flags(irn, OUT_POS(pn_be_SubSP_sp),
740 arch_irn_flags_ignore | arch_irn_flags_modify_sp);
742 /* Set output constraint to stack register. */
743 be_set_constr_single_reg(irn, be_pos_SubSP_old_sp, sp);
744 be_node_set_reg_class(irn, be_pos_SubSP_size, arch_register_get_class(sp));
745 be_set_constr_single_reg(irn, OUT_POS(pn_be_SubSP_sp), sp);
746 a->reg_data[pn_be_SubSP_sp].reg = sp;
751 ir_node *be_new_RegParams(ir_graph *irg, ir_node *bl, int n_outs)
756 res = new_ir_node(NULL, irg, bl, op_be_RegParams, mode_T, 0, NULL);
757 init_node_attr(res, -1);
758 for(i = 0; i < n_outs; ++i)
759 add_register_req(res);
764 ir_node *be_RegParams_append_out_reg(ir_node *regparams,
765 const arch_env_t *arch_env,
766 const arch_register_t *reg)
768 ir_graph *irg = get_irn_irg(regparams);
769 ir_node *block = get_nodes_block(regparams);
770 be_node_attr_t *attr = get_irn_attr(regparams);
771 const arch_register_class_t *cls = arch_register_get_class(reg);
772 ir_mode *mode = arch_register_class_mode(cls);
773 int n = ARR_LEN(attr->reg_data);
776 assert(be_is_RegParams(regparams));
777 proj = new_r_Proj(irg, block, regparams, mode, n);
778 add_register_req(regparams);
779 be_set_constr_single_reg(regparams, BE_OUT_POS(n), reg);
780 arch_set_irn_register(arch_env, proj, reg);
782 /* TODO decide, whether we need to set ignore/modify sp flags here? */
787 ir_node *be_new_FrameAddr(const arch_register_class_t *cls_frame, ir_graph *irg, ir_node *bl, ir_node *frame, ir_entity *ent)
794 irn = new_ir_node(NULL, irg, bl, op_be_FrameAddr, get_irn_mode(frame), 1, in);
795 a = init_node_attr(irn, 1);
798 be_node_set_reg_class(irn, 0, cls_frame);
799 be_node_set_reg_class(irn, OUT_POS(0), cls_frame);
801 return optimize_node(irn);
804 ir_node *be_get_FrameAddr_frame(const ir_node *node) {
805 assert(be_is_FrameAddr(node));
806 return get_irn_n(node, be_pos_FrameAddr_ptr);
809 ir_entity *be_get_FrameAddr_entity(const ir_node *node)
811 const be_frame_attr_t *attr = get_irn_generic_attr_const(node);
815 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)
818 ir_node **in = (ir_node **) alloca((n + 1) * sizeof(in[0]));
821 memcpy(&in[1], in_keep, n * sizeof(in[0]));
822 irn = new_ir_node(NULL, irg, bl, op_be_CopyKeep, mode, n + 1, in);
823 init_node_attr(irn, n + 1);
824 be_node_set_reg_class(irn, OUT_POS(0), cls);
825 be_node_set_reg_class(irn, 0, cls);
830 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)
832 return be_new_CopyKeep(cls, irg, bl, src, 1, &keep, mode);
835 ir_node *be_get_CopyKeep_op(const ir_node *cpy) {
836 return get_irn_n(cpy, be_pos_CopyKeep_op);
839 void be_set_CopyKeep_op(ir_node *cpy, ir_node *op) {
840 set_irn_n(cpy, be_pos_CopyKeep_op, op);
843 ir_node *be_new_Barrier(ir_graph *irg, ir_node *bl, int n, ir_node *in[])
848 res = new_ir_node(NULL, irg, bl, op_be_Barrier, mode_T, -1, NULL);
849 init_node_attr(res, -1);
850 for(i = 0; i < n; ++i) {
851 add_irn_n(res, in[i]);
852 add_register_req(res);
858 ir_node *be_Barrier_append_node(ir_node *barrier, ir_node *node)
860 ir_graph *irg = get_irn_irg(barrier);
861 ir_node *block = get_nodes_block(barrier);
862 ir_mode *mode = get_irn_mode(node);
863 int n = add_irn_n(barrier, node);
865 ir_node *proj = new_r_Proj(irg, block, barrier, mode, n);
866 add_register_req(barrier);
871 /* Construct a new be_Unwind. */
872 ir_node *be_new_Unwind(dbg_info *dbg, ir_graph *irg, ir_node *block,
873 ir_node *mem, ir_node *sp)
878 in[be_pos_Unwind_mem] = mem;
879 in[be_pos_Unwind_sp] = sp;
880 res = new_ir_node(dbg, irg, block, op_be_Unwind, mode_X, 2, in);
881 init_node_attr(res, -1);
886 int be_has_frame_entity(const ir_node *irn)
888 switch (get_irn_opcode(irn)) {
898 ir_entity *be_get_frame_entity(const ir_node *irn)
900 if (be_has_frame_entity(irn)) {
901 const be_frame_attr_t *a = get_irn_attr_const(irn);
907 int be_get_frame_offset(const ir_node *irn)
909 assert(is_be_node(irn));
910 if (be_has_frame_entity(irn)) {
911 const be_frame_attr_t *a = get_irn_attr_const(irn);
917 void be_set_MemPerm_in_entity(const ir_node *irn, int n, ir_entity *ent)
919 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
921 assert(be_is_MemPerm(irn));
922 assert(n < be_get_MemPerm_entity_arity(irn));
924 attr->in_entities[n] = ent;
927 ir_entity* be_get_MemPerm_in_entity(const ir_node* irn, int n)
929 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
931 assert(be_is_MemPerm(irn));
932 assert(n < be_get_MemPerm_entity_arity(irn));
934 return attr->in_entities[n];
937 void be_set_MemPerm_out_entity(const ir_node *irn, int n, ir_entity *ent)
939 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
941 assert(be_is_MemPerm(irn));
942 assert(n < be_get_MemPerm_entity_arity(irn));
944 attr->out_entities[n] = ent;
947 ir_entity* be_get_MemPerm_out_entity(const ir_node* irn, int n)
949 const be_memperm_attr_t *attr = get_irn_attr_const(irn);
951 assert(be_is_MemPerm(irn));
952 assert(n < be_get_MemPerm_entity_arity(irn));
954 return attr->out_entities[n];
957 int be_get_MemPerm_entity_arity(const ir_node *irn)
959 return get_irn_arity(irn) - 1;
962 void be_set_constr_single_reg(ir_node *node, int pos, const arch_register_t *reg)
964 arch_register_req_t *req = get_req(node, pos);
965 const arch_register_class_t *cls = arch_register_get_class(reg);
966 ir_graph *irg = get_irn_irg(node);
967 struct obstack *obst = get_irg_obstack(irg);
968 unsigned *limited_bitset;
970 assert(req->cls == NULL || req->cls == cls);
971 assert(! (req->type & arch_register_req_type_limited));
972 assert(req->limited == NULL);
974 limited_bitset = rbitset_obstack_alloc(obst, arch_register_class_n_regs(cls));
975 rbitset_set(limited_bitset, arch_register_get_index(reg));
978 req->type |= arch_register_req_type_limited;
979 req->limited = limited_bitset;
982 void be_set_constr_limited(ir_node *node, int pos, const arch_register_req_t *req)
984 ir_graph *irg = get_irn_irg(node);
985 struct obstack *obst = get_irg_obstack(irg);
986 arch_register_req_t *r = get_req(node, pos);
988 assert(arch_register_req_is(req, limited));
989 assert(!(req->type & (arch_register_req_type_should_be_same | arch_register_req_type_must_be_different)));
990 memcpy(r, req, sizeof(r[0]));
991 r->limited = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
994 void be_node_set_flags(ir_node *irn, int pos, arch_irn_flags_t flags)
996 be_req_t *bereq = get_be_req(irn, pos);
997 bereq->flags = flags;
1000 void be_node_add_flags(ir_node *irn, int pos, arch_irn_flags_t flags)
1002 be_req_t *bereq = get_be_req(irn, pos);
1003 bereq->flags |= flags;
1006 void be_node_set_reg_class(ir_node *irn, int pos, const arch_register_class_t *cls)
1008 arch_register_req_t *req = get_req(irn, pos);
1013 req->type = arch_register_req_type_none;
1014 } else if (req->type == arch_register_req_type_none) {
1015 req->type = arch_register_req_type_normal;
1019 void be_node_set_req_type(ir_node *irn, int pos, arch_register_req_type_t type)
1021 arch_register_req_t *req = get_req(irn, pos);
1025 ir_node *be_get_IncSP_pred(ir_node *irn) {
1026 assert(be_is_IncSP(irn));
1027 return get_irn_n(irn, 0);
1030 void be_set_IncSP_pred(ir_node *incsp, ir_node *pred) {
1031 assert(be_is_IncSP(incsp));
1032 set_irn_n(incsp, 0, pred);
1035 void be_set_IncSP_offset(ir_node *irn, int offset)
1037 be_incsp_attr_t *a = get_irn_attr(irn);
1038 assert(be_is_IncSP(irn));
1042 int be_get_IncSP_offset(const ir_node *irn)
1044 const be_incsp_attr_t *a = get_irn_attr_const(irn);
1045 assert(be_is_IncSP(irn));
1049 int be_get_IncSP_align(const ir_node *irn)
1051 const be_incsp_attr_t *a = get_irn_attr_const(irn);
1052 assert(be_is_IncSP(irn));
1056 ir_node *be_spill(const arch_env_t *arch_env, ir_node *block, ir_node *irn)
1058 ir_graph *irg = get_irn_irg(block);
1059 ir_node *frame = get_irg_frame(irg);
1060 const arch_register_class_t *cls = arch_get_irn_reg_class(arch_env, irn, -1);
1061 const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
1064 spill = be_new_Spill(cls, cls_frame, irg, block, frame, irn);
1068 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)
1071 ir_node *bl = is_Block(insert) ? insert : get_nodes_block(insert);
1072 ir_graph *irg = get_irn_irg(bl);
1073 ir_node *frame = get_irg_frame(irg);
1074 const arch_register_class_t *cls_frame = arch_get_irn_reg_class(arch_env, frame, -1);
1076 assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M));
1078 reload = be_new_Reload(cls, cls_frame, irg, bl, frame, spill, mode);
1080 if (is_Block(insert)) {
1081 insert = sched_skip(insert, 0, sched_skip_cf_predicator, (void *) arch_env);
1082 sched_add_after(insert, reload);
1084 sched_add_before(insert, reload);
1092 | _ \ ___ __ _ | _ \ ___ __ _ ___
1093 | |_) / _ \/ _` | | |_) / _ \/ _` / __|
1094 | _ < __/ (_| | | _ < __/ (_| \__ \
1095 |_| \_\___|\__, | |_| \_\___|\__, |___/
1102 arch_register_req_t *get_out_reg_req(const ir_node *irn, int out_pos)
1104 const be_node_attr_t *a = get_irn_attr_const(irn);
1106 if(out_pos >= ARR_LEN(a->reg_data)) {
1107 return arch_no_register_req;
1110 return &a->reg_data[out_pos].req.req;
1114 arch_register_req_t *get_in_reg_req(const ir_node *irn, int pos)
1116 const be_node_attr_t *a = get_irn_attr_const(irn);
1118 if(pos >= get_irn_arity(irn) || pos >= ARR_LEN(a->reg_data))
1119 return arch_no_register_req;
1121 return &a->reg_data[pos].in_req.req;
1124 static const arch_register_req_t *
1125 be_node_get_irn_reg_req(const ir_node *irn, int pos)
1130 if (get_irn_mode(irn) == mode_T)
1131 return arch_no_register_req;
1133 out_pos = redir_proj((const ir_node **)&irn);
1134 assert(is_be_node(irn));
1135 return get_out_reg_req(irn, out_pos);
1136 } else if (is_be_node(irn)) {
1138 * For spills and reloads, we return "none" as requirement for frame
1139 * pointer, so every input is ok. Some backends need this (e.g. STA).
1141 if ((be_is_Spill(irn) && pos == be_pos_Spill_frame) ||
1142 (be_is_Reload(irn) && pos == be_pos_Reload_frame))
1143 return arch_no_register_req;
1145 return get_in_reg_req(irn, pos);
1148 return arch_no_register_req;
1151 const arch_register_t *
1152 be_node_get_irn_reg(const ir_node *irn)
1156 if (get_irn_mode(irn) == mode_T)
1158 r = retrieve_reg_data(irn);
1162 static arch_irn_class_t be_node_classify(const ir_node *irn)
1165 switch (get_irn_opcode(irn)) {
1166 #define XXX(a,b) case a: return b
1167 XXX(beo_Spill, arch_irn_class_spill);
1168 XXX(beo_Reload, arch_irn_class_reload);
1169 XXX(beo_Perm, arch_irn_class_perm);
1170 XXX(beo_Copy, arch_irn_class_copy);
1171 XXX(beo_Return, arch_irn_class_branch);
1174 irn = get_Proj_pred(irn);
1176 assert(get_irn_mode(irn) == mode_T);
1177 irn = get_Proj_pred(irn);
1182 return arch_irn_class_normal;
1188 static arch_irn_flags_t be_node_get_flags(const ir_node *node)
1194 pos = OUT_POS(get_Proj_proj(node));
1195 node = skip_Proj_const(node);
1198 bereq = get_be_req(node, pos);
1200 return bereq->flags;
1203 static ir_entity *be_node_get_frame_entity(const ir_node *irn)
1205 return be_get_frame_entity(irn);
1208 static void be_node_set_frame_entity(ir_node *irn, ir_entity *ent)
1212 assert(be_has_frame_entity(irn));
1214 a = get_irn_attr(irn);
1218 static void be_node_set_frame_offset(ir_node *irn, int offset)
1220 if(be_has_frame_entity(irn)) {
1221 be_frame_attr_t *a = get_irn_attr(irn);
1226 static int be_node_get_sp_bias(const ir_node *irn)
1228 if(be_is_IncSP(irn))
1229 return be_get_IncSP_offset(irn);
1231 return -(int)be_Call_get_pop(irn);
1237 ___ ____ _ _ _ _ _ _
1238 |_ _| _ \| \ | | | | | | __ _ _ __ __| | | ___ _ __
1239 | || |_) | \| | | |_| |/ _` | '_ \ / _` | |/ _ \ '__|
1240 | || _ <| |\ | | _ | (_| | | | | (_| | | __/ |
1241 |___|_| \_\_| \_| |_| |_|\__,_|_| |_|\__,_|_|\___|_|
1245 static const arch_irn_ops_t be_node_irn_ops = {
1246 be_node_get_irn_reg_req,
1247 be_node_set_irn_reg,
1248 be_node_get_irn_reg,
1251 be_node_get_frame_entity,
1252 be_node_set_frame_entity,
1253 be_node_set_frame_offset,
1254 be_node_get_sp_bias,
1255 NULL, /* get_inverse */
1256 NULL, /* get_op_estimated_cost */
1257 NULL, /* possible_memory_operand */
1258 NULL, /* perform_memory_operand */
1262 ____ _ _ ___ ____ _ _ _ _ _ _
1263 | _ \| |__ (_) |_ _| _ \| \ | | | | | | __ _ _ __ __| | | ___ _ __
1264 | |_) | '_ \| | | || |_) | \| | | |_| |/ _` | '_ \ / _` | |/ _ \ '__|
1265 | __/| | | | | | || _ <| |\ | | _ | (_| | | | | (_| | | __/ |
1266 |_| |_| |_|_| |___|_| \_\_| \_| |_| |_|\__,_|_| |_|\__,_|_|\___|_|
1271 const arch_register_t *reg;
1272 arch_register_req_t req;
1273 arch_irn_flags_t flags;
1277 arch_env_t *arch_env;
1281 #define get_phi_handler_from_ops(h) container_of(h, phi_handler_t, irn_ops)
1284 phi_attr_t *get_Phi_attr(const ir_node *phi)
1286 phi_attr_t *attr = pmap_get(phi_handler.phi_attrs, (void*) phi);
1288 ir_graph *irg = get_irn_irg(phi);
1289 struct obstack *obst = get_irg_obstack(irg);
1290 attr = obstack_alloc(obst, sizeof(attr[0]));
1291 memset(attr, 0, sizeof(attr[0]));
1292 pmap_insert(phi_handler.phi_attrs, phi, attr);
1299 * Get register class of a Phi.
1302 const arch_register_req_t *get_Phi_reg_req_recursive(const ir_node *phi,
1305 int n = get_irn_arity(phi);
1309 if(*visited && pset_find_ptr(*visited, phi))
1312 for(i = 0; i < n; ++i) {
1313 op = get_irn_n(phi, i);
1314 /* Matze: don't we unnecessary constraint our phis with this?
1315 * we only need to take the regclass IMO*/
1317 return arch_get_register_req(phi_handler.arch_env, op, BE_OUT_POS(0));
1321 * The operands of that Phi were all Phis themselves.
1322 * We have to start a DFS for a non-Phi argument now.
1325 *visited = pset_new_ptr(16);
1327 pset_insert_ptr(*visited, phi);
1329 for(i = 0; i < n; ++i) {
1330 const arch_register_req_t *req;
1331 op = get_irn_n(phi, i);
1332 req = get_Phi_reg_req_recursive(op, visited);
1341 const arch_register_req_t *phi_get_irn_reg_req(const ir_node *irn, int pos)
1346 if(!mode_is_datab(get_irn_mode(irn)))
1347 return arch_no_register_req;
1349 attr = get_Phi_attr(irn);
1351 if(attr->req.type == arch_register_req_type_none) {
1352 pset *visited = NULL;
1353 const arch_register_req_t *req;
1354 req = get_Phi_reg_req_recursive(irn, &visited);
1356 memcpy(&attr->req, req, sizeof(req[0]));
1357 assert(attr->req.cls != NULL);
1358 attr->req.type = arch_register_req_type_normal;
1367 void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node,
1368 const arch_register_req_t *req)
1373 assert(mode_is_datab(get_irn_mode(node)));
1375 attr = get_Phi_attr(node);
1376 memcpy(&attr->req, req, sizeof(req[0]));
1379 void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node,
1380 arch_irn_flags_t flags)
1385 assert(mode_is_datab(get_irn_mode(node)));
1387 attr = get_Phi_attr(node);
1388 attr->flags = flags;
1391 static void phi_set_irn_reg(ir_node *irn, const arch_register_t *reg)
1393 phi_attr_t *attr = get_Phi_attr(irn);
1397 static const arch_register_t *phi_get_irn_reg(const ir_node *irn)
1399 phi_attr_t *attr = get_Phi_attr(irn);
1403 static arch_irn_class_t phi_classify(const ir_node *irn)
1406 return arch_irn_class_normal;
1409 static arch_irn_flags_t phi_get_flags(const ir_node *irn)
1411 phi_attr_t *attr = get_Phi_attr(irn);
1415 static ir_entity *phi_get_frame_entity(const ir_node *irn)
1421 static void phi_set_frame_entity(ir_node *irn, ir_entity *ent)
1425 panic("phi_set_frame_entity() should not be called");
1428 static void phi_set_frame_offset(ir_node *irn, int bias)
1432 panic("phi_set_frame_offset() should not be called");
1435 static int phi_get_sp_bias(const ir_node *irn)
1441 static const arch_irn_ops_t phi_irn_ops = {
1442 phi_get_irn_reg_req,
1447 phi_get_frame_entity,
1448 phi_set_frame_entity,
1449 phi_set_frame_offset,
1451 NULL, /* get_inverse */
1452 NULL, /* get_op_estimated_cost */
1453 NULL, /* possible_memory_operand */
1454 NULL, /* perform_memory_operand */
1457 void be_phi_handler_new(be_main_env_t *env)
1459 phi_handler.arch_env = env->arch_env;
1460 phi_handler.phi_attrs = pmap_create();
1461 op_Phi->ops.be_ops = &phi_irn_ops;
1464 void be_phi_handler_free(void)
1466 pmap_destroy(phi_handler.phi_attrs);
1467 phi_handler.phi_attrs = NULL;
1468 op_Phi->ops.be_ops = NULL;
1471 void be_phi_handler_reset(void)
1473 if(phi_handler.phi_attrs)
1474 pmap_destroy(phi_handler.phi_attrs);
1475 phi_handler.phi_attrs = pmap_create();
1480 | \ | | ___ __| | ___ | _ \ _ _ _ __ ___ _ __ (_)_ __ __ _
1481 | \| |/ _ \ / _` |/ _ \ | | | | | | | '_ ` _ \| '_ \| | '_ \ / _` |
1482 | |\ | (_) | (_| | __/ | |_| | |_| | | | | | | |_) | | | | | (_| |
1483 |_| \_|\___/ \__,_|\___| |____/ \__,_|_| |_| |_| .__/|_|_| |_|\__, |
1488 * Dumps a register requirement to a file.
1490 static void dump_node_req(FILE *f, int idx, const arch_register_req_t *req,
1491 const ir_node *node)
1493 int did_something = 0;
1495 const char *prefix = buf;
1497 snprintf(buf, sizeof(buf), "#%d ", idx);
1498 buf[sizeof(buf) - 1] = '\0';
1503 arch_register_req_format(tmp, sizeof(tmp), req, node);
1504 fprintf(f, "%s", tmp);
1513 * Dumps node register requirements to a file.
1515 static void dump_node_reqs(FILE *f, ir_node *node)
1518 be_node_attr_t *a = get_irn_attr(node);
1519 int len = ARR_LEN(a->reg_data);
1521 fprintf(f, "registers: \n");
1522 for(i = 0; i < len; ++i) {
1523 be_reg_data_t *rd = &a->reg_data[i];
1525 fprintf(f, "#%d: %s\n", i, rd->reg->name);
1528 fprintf(f, "in requirements:\n");
1529 for(i = 0; i < len; ++i) {
1530 dump_node_req(f, i, &a->reg_data[i].in_req.req, node);
1533 fprintf(f, "\nout requirements:\n");
1534 for(i = 0; i < len; ++i) {
1535 dump_node_req(f, i, &a->reg_data[i].req.req, node);
1540 * ir_op-Operation: dump a be node to file
1542 static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
1544 be_node_attr_t *at = get_irn_attr(irn);
1546 assert(is_be_node(irn));
1549 case dump_node_opcode_txt:
1550 fprintf(f, get_op_name(get_irn_op(irn)));
1552 case dump_node_mode_txt:
1553 if(be_is_Perm(irn) || be_is_Copy(irn) || be_is_CopyKeep(irn)) {
1554 fprintf(f, " %s", get_mode_name(get_irn_mode(irn)));
1557 case dump_node_nodeattr_txt:
1558 if(be_is_Call(irn)) {
1559 be_call_attr_t *a = (be_call_attr_t *) at;
1561 fprintf(f, " [%s] ", get_entity_name(a->ent));
1563 if(be_is_IncSP(irn)) {
1564 const be_incsp_attr_t *attr = get_irn_generic_attr_const(irn);
1565 if(attr->offset == BE_STACK_FRAME_SIZE_EXPAND) {
1566 fprintf(f, " [Setup Stackframe] ");
1567 } else if(attr->offset == BE_STACK_FRAME_SIZE_SHRINK) {
1568 fprintf(f, " [Destroy Stackframe] ");
1570 fprintf(f, " [%d] ", attr->offset);
1574 case dump_node_info_txt:
1575 dump_node_reqs(f, irn);
1577 if(be_has_frame_entity(irn)) {
1578 be_frame_attr_t *a = (be_frame_attr_t *) at;
1580 unsigned size = get_type_size_bytes(get_entity_type(a->ent));
1581 ir_fprintf(f, "frame entity: %+F, offset 0x%x (%d), size 0x%x (%d) bytes\n",
1582 a->ent, a->offset, a->offset, size, size);
1587 switch (get_irn_opcode(irn)) {
1590 be_incsp_attr_t *a = (be_incsp_attr_t *) at;
1591 if (a->offset == BE_STACK_FRAME_SIZE_EXPAND)
1592 fprintf(f, "offset: FRAME_SIZE\n");
1593 else if(a->offset == BE_STACK_FRAME_SIZE_SHRINK)
1594 fprintf(f, "offset: -FRAME SIZE\n");
1596 fprintf(f, "offset: %u\n", a->offset);
1601 be_call_attr_t *a = (be_call_attr_t *) at;
1604 fprintf(f, "\ncalling: %s\n", get_entity_name(a->ent));
1610 for(i = 0; i < be_get_MemPerm_entity_arity(irn); ++i) {
1611 ir_entity *in, *out;
1612 in = be_get_MemPerm_in_entity(irn, i);
1613 out = be_get_MemPerm_out_entity(irn, i);
1615 fprintf(f, "\nin[%d]: %s\n", i, get_entity_name(in));
1618 fprintf(f, "\nout[%d]: %s\n", i, get_entity_name(out));
1634 * Copies the backend specific attributes from old node to new node.
1636 static void copy_attr(const ir_node *old_node, ir_node *new_node)
1638 const be_node_attr_t *old_attr = get_irn_attr_const(old_node);
1639 be_node_attr_t *new_attr = get_irn_attr(new_node);
1640 struct obstack *obst = get_irg_obstack(get_irn_irg(new_node));
1643 assert(is_be_node(old_node));
1644 assert(is_be_node(new_node));
1646 memcpy(new_attr, old_attr, get_op_attr_size(get_irn_op(old_node)));
1647 new_attr->reg_data = NULL;
1649 if(old_attr->reg_data != NULL)
1650 len = ARR_LEN(old_attr->reg_data);
1654 if(get_irn_op(old_node)->opar == oparity_dynamic
1655 || be_is_RegParams(old_node)) {
1656 new_attr->reg_data = NEW_ARR_F(be_reg_data_t, len);
1658 new_attr->reg_data = NEW_ARR_D(be_reg_data_t, obst, len);
1662 memcpy(new_attr->reg_data, old_attr->reg_data, len * sizeof(be_reg_data_t));
1663 for(i = 0; i < len; ++i) {
1664 const be_reg_data_t *rd = &old_attr->reg_data[i];
1665 be_reg_data_t *newrd = &new_attr->reg_data[i];
1666 if(arch_register_req_is(&rd->req.req, limited)) {
1667 const arch_register_req_t *req = &rd->req.req;
1668 arch_register_req_t *new_req = &newrd->req.req;
1670 = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
1672 if(arch_register_req_is(&rd->in_req.req, limited)) {
1673 const arch_register_req_t *req = &rd->in_req.req;
1674 arch_register_req_t *new_req = &newrd->in_req.req;
1676 = rbitset_duplicate_obstack_alloc(obst, req->limited, req->cls->n_regs);
1682 static const ir_op_ops be_node_op_ops = {
1703 int is_be_node(const ir_node *irn)
1705 return get_op_ops(get_irn_op(irn))->be_ops == &be_node_irn_ops;
1708 void be_node_init(void) {
1709 static int inited = 0;
1716 /* Acquire all needed opcodes. */
1717 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);
1718 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);
1719 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);
1720 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);
1721 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);
1722 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);
1723 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);
1724 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);
1725 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);
1726 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);
1727 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);
1728 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);
1729 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);
1730 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);
1731 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);
1732 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);
1734 op_be_Spill->ops.node_cmp_attr = FrameAddr_cmp_attr;
1735 op_be_Reload->ops.node_cmp_attr = FrameAddr_cmp_attr;
1736 op_be_Perm->ops.node_cmp_attr = node_cmp_attr;
1737 op_be_MemPerm->ops.node_cmp_attr = node_cmp_attr;
1738 op_be_Copy->ops.node_cmp_attr = node_cmp_attr;
1739 op_be_Keep->ops.node_cmp_attr = node_cmp_attr;
1740 op_be_CopyKeep->ops.node_cmp_attr = node_cmp_attr;
1741 op_be_Call->ops.node_cmp_attr = Call_cmp_attr;
1742 op_be_Return->ops.node_cmp_attr = Return_cmp_attr;
1743 op_be_AddSP->ops.node_cmp_attr = node_cmp_attr;
1744 op_be_SubSP->ops.node_cmp_attr = node_cmp_attr;
1745 op_be_IncSP->ops.node_cmp_attr = IncSP_cmp_attr;
1746 op_be_RegParams->ops.node_cmp_attr = node_cmp_attr;
1747 op_be_FrameAddr->ops.node_cmp_attr = FrameAddr_cmp_attr;
1748 op_be_Barrier->ops.node_cmp_attr = node_cmp_attr;
1749 op_be_Unwind->ops.node_cmp_attr = node_cmp_attr;