2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Handling of ia32 specific firm opcodes.
9 * @author Christian Wuerdig
11 * This file implements the creation of the architecture specific firm opcodes
12 * and the corresponding node constructors for the ia32 assembler irg.
21 #include "irgraph_t.h"
27 #include "irverify_t.h"
31 #include "raw_bitset.h"
37 #include "bearch_ia32_t.h"
38 #include "ia32_common_transform.h"
39 #include "ia32_nodes_attr.h"
40 #include "ia32_new_nodes.h"
41 #include "gen_ia32_regalloc_if.h"
43 struct obstack opcodes_obst;
46 * Dumper interface for dumping ia32 nodes in vcg.
47 * @param n the node to dump
48 * @param F the output file
49 * @param reason indicates which kind of information should be dumped
50 * @return 0 on success or != 0 on failure
52 static void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
57 case dump_node_opcode_txt:
58 fprintf(F, "%s", get_irn_opname(n));
60 if (is_ia32_Immediate(n) || is_ia32_Const(n)) {
61 const ia32_immediate_attr_t *attr
62 = get_ia32_immediate_attr_const(n);
69 fputs(get_entity_name(attr->symconst), F);
71 if (attr->offset != 0 || attr->symconst == NULL) {
72 if (attr->offset > 0 && attr->symconst != NULL) {
75 fprintf(F, "%ld", attr->offset);
76 if (attr->no_pic_adjust) {
77 fputs("(no_pic_adjust)", F);
82 const ia32_attr_t *attr = get_ia32_attr_const(n);
84 if (attr->am_sc != NULL || attr->am_offs != 0)
87 if (attr->am_sc != NULL) {
88 if (attr->data.am_sc_sign) {
91 fputs(get_entity_name(attr->am_sc), F);
92 if (attr->data.am_sc_no_pic_adjust) {
93 fputs("(no_pic_adjust)", F);
96 if (attr->am_offs != 0) {
97 if (attr->am_offs > 0 && attr->am_sc != NULL) {
100 fprintf(F, "%d", attr->am_offs);
103 if (attr->am_sc != NULL || attr->am_offs != 0)
108 case dump_node_mode_txt:
109 mode = get_ia32_ls_mode(n);
111 fprintf(F, "[%s]", get_mode_name(mode));
114 case dump_node_nodeattr_txt:
115 if (! is_ia32_Lea(n)) {
116 switch (get_ia32_op_type(n)) {
117 case ia32_Normal: break;
118 case ia32_AddrModeS: fprintf(F, "[AM S] "); break;
119 case ia32_AddrModeD: fprintf(F, "[AM D] "); break;
124 case dump_node_info_txt:
125 arch_dump_reqs_and_registers(F, n);
129 switch (get_ia32_op_type(n)) {
131 fprintf(F, "Normal");
134 fprintf(F, "AM Dest (Load+Store)");
137 fprintf(F, "AM Source (Load)");
140 fprintf(F, "unknown (%d)", (int)get_ia32_op_type(n));
145 /* dump supported am */
146 fprintf(F, "AM support = ");
147 switch (get_ia32_am_support(n)) {
148 case ia32_am_none: fputs("none\n", F); break;
149 case ia32_am_unary: fputs("source (unary)\n", F); break;
150 case ia32_am_binary: fputs("source (binary)\n", F); break;
153 fprintf(F, "unknown (%d)\n", (int)get_ia32_am_support(n));
158 if (get_ia32_am_offs_int(n) != 0) {
159 fprintf(F, "AM offset = %d\n", get_ia32_am_offs_int(n));
162 /* dump AM symconst */
163 if (get_ia32_am_sc(n) != NULL) {
164 ir_entity *ent = get_ia32_am_sc(n);
165 ident *id = get_entity_ld_ident(ent);
166 fprintf(F, "AM symconst = %s\n", get_id_str(id));
170 fprintf(F, "AM scale = %u\n", get_ia32_am_scale(n));
173 if (is_ia32_CMovcc(n) || is_ia32_Setcc(n) || is_ia32_Jcc(n)) {
174 const ia32_attr_t *attr = get_ia32_attr_const(n);
175 fprintf(F, "condition_code = 0x%X\n", (unsigned)get_ia32_condcode(n));
176 fprintf(F, "ins_permuted = %u\n", (unsigned)attr->data.ins_permuted);
178 else if (is_ia32_CopyB(n) || is_ia32_CopyB_i(n)) {
179 fprintf(F, "size = %u\n", get_ia32_copyb_size(n));
182 fprintf(F, "use_frame = %d\n", is_ia32_use_frame(n));
183 fprintf(F, "commutative = %d\n", is_ia32_commutative(n));
184 fprintf(F, "need stackent = %d\n", is_ia32_need_stackent(n));
185 fprintf(F, "is reload = %d\n", is_ia32_is_reload(n));
186 fprintf(F, "latency = %u\n", get_ia32_latency(n));
188 /* dump frame entity */
189 fprintf(F, "frame entity = ");
190 if (get_ia32_frame_ent(n)) {
191 ir_fprintf(F, "%+F", get_ia32_frame_ent(n));
199 fprintf(F, "ls_mode = ");
200 if (get_ia32_ls_mode(n)) {
201 ir_fprintf(F, "%+F", get_ia32_ls_mode(n));
209 /* dump original ir node name */
210 char const *orig = get_ia32_attr_const(n)->orig_node;
211 fprintf(F, "orig node = %s\n", orig ? orig : "n/a");
220 ia32_attr_t *get_ia32_attr(ir_node *node)
222 assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes");
223 return (ia32_attr_t *)get_irn_generic_attr(node);
226 const ia32_attr_t *get_ia32_attr_const(const ir_node *node)
228 assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes");
229 return (const ia32_attr_t*) get_irn_generic_attr_const(node);
232 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node)
234 ia32_attr_t *attr = get_ia32_attr(node);
235 ia32_x87_attr_t *x87_attr = CAST_IA32_ATTR(ia32_x87_attr_t, attr);
239 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node)
241 const ia32_attr_t *attr = get_ia32_attr_const(node);
242 const ia32_x87_attr_t *x87_attr = CONST_CAST_IA32_ATTR(ia32_x87_attr_t, attr);
246 const ia32_asm_attr_t *get_ia32_asm_attr_const(const ir_node *node)
248 const ia32_attr_t *attr = get_ia32_attr_const(node);
249 const ia32_asm_attr_t *asm_attr = CONST_CAST_IA32_ATTR(ia32_asm_attr_t, attr);
254 ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node)
256 ia32_attr_t *attr = get_ia32_attr(node);
257 ia32_immediate_attr_t *imm_attr = CAST_IA32_ATTR(ia32_immediate_attr_t, attr);
262 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node)
264 const ia32_attr_t *attr = get_ia32_attr_const(node);
265 const ia32_immediate_attr_t *imm_attr = CONST_CAST_IA32_ATTR(ia32_immediate_attr_t, attr);
270 ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node)
272 ia32_attr_t *attr = get_ia32_attr(node);
273 ia32_condcode_attr_t *cc_attr = CAST_IA32_ATTR(ia32_condcode_attr_t, attr);
278 const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node)
280 const ia32_attr_t *attr = get_ia32_attr_const(node);
281 const ia32_condcode_attr_t *cc_attr = CONST_CAST_IA32_ATTR(ia32_condcode_attr_t, attr);
286 ia32_switch_attr_t *get_ia32_switch_attr(ir_node *node)
288 ia32_attr_t *attr = get_ia32_attr(node);
289 ia32_switch_attr_t *switch_attr = CAST_IA32_ATTR(ia32_switch_attr_t, attr);
293 const ia32_switch_attr_t *get_ia32_switch_attr_const(const ir_node *node)
295 const ia32_attr_t *attr = get_ia32_attr_const(node);
296 const ia32_switch_attr_t *switch_attr = CONST_CAST_IA32_ATTR(ia32_switch_attr_t, attr);
300 ia32_call_attr_t *get_ia32_call_attr(ir_node *node)
302 ia32_attr_t *attr = get_ia32_attr(node);
303 ia32_call_attr_t *call_attr = CAST_IA32_ATTR(ia32_call_attr_t, attr);
308 const ia32_call_attr_t *get_ia32_call_attr_const(const ir_node *node)
310 const ia32_attr_t *attr = get_ia32_attr_const(node);
311 const ia32_call_attr_t *call_attr = CONST_CAST_IA32_ATTR(ia32_call_attr_t, attr);
316 ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node)
318 ia32_attr_t *attr = get_ia32_attr(node);
319 ia32_copyb_attr_t *copyb_attr = CAST_IA32_ATTR(ia32_copyb_attr_t, attr);
324 const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node)
326 const ia32_attr_t *attr = get_ia32_attr_const(node);
327 const ia32_copyb_attr_t *copyb_attr = CONST_CAST_IA32_ATTR(ia32_copyb_attr_t, attr);
332 ia32_climbframe_attr_t *get_ia32_climbframe_attr(ir_node *node)
334 ia32_attr_t *attr = get_ia32_attr(node);
335 ia32_climbframe_attr_t *climbframe_attr = CAST_IA32_ATTR(ia32_climbframe_attr_t, attr);
337 return climbframe_attr;
340 const ia32_climbframe_attr_t *get_ia32_climbframe_attr_const(const ir_node *node)
342 const ia32_attr_t *attr = get_ia32_attr_const(node);
343 const ia32_climbframe_attr_t *climbframe_attr = CONST_CAST_IA32_ATTR(ia32_climbframe_attr_t, attr);
345 return climbframe_attr;
349 * Gets the type of an ia32 node.
351 ia32_op_type_t get_ia32_op_type(const ir_node *node)
353 const ia32_attr_t *attr = get_ia32_attr_const(node);
354 return (ia32_op_type_t)attr->data.tp;
358 * Sets the type of an ia32 node.
360 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp)
362 ia32_attr_t *attr = get_ia32_attr(node);
366 ia32_am_type_t get_ia32_am_support(const ir_node *node)
368 const ia32_attr_t *attr = get_ia32_attr_const(node);
369 return (ia32_am_type_t)attr->data.am_arity;
373 * Sets the supported address mode of an ia32 node
375 void set_ia32_am_support(ir_node *node, ia32_am_type_t arity)
377 ia32_attr_t *attr = get_ia32_attr(node);
378 attr->data.am_arity = arity;
382 * Gets the address mode offset as int.
384 int get_ia32_am_offs_int(const ir_node *node)
386 const ia32_attr_t *attr = get_ia32_attr_const(node);
387 return attr->am_offs;
391 * Sets the address mode offset from an int.
393 void set_ia32_am_offs_int(ir_node *node, int offset)
395 ia32_attr_t *attr = get_ia32_attr(node);
396 attr->am_offs = offset;
399 void add_ia32_am_offs_int(ir_node *node, int offset)
401 ia32_attr_t *attr = get_ia32_attr(node);
402 attr->am_offs += offset;
406 * Returns the symconst entity associated to address mode.
408 ir_entity *get_ia32_am_sc(const ir_node *node)
410 const ia32_attr_t *attr = get_ia32_attr_const(node);
415 * Sets the symconst entity associated to address mode.
417 void set_ia32_am_sc(ir_node *node, ir_entity *entity)
419 ia32_attr_t *attr = get_ia32_attr(node);
420 attr->am_sc = entity;
424 * Sets the sign bit for address mode symconst.
426 void set_ia32_am_sc_sign(ir_node *node)
428 ia32_attr_t *attr = get_ia32_attr(node);
429 attr->data.am_sc_sign = 1;
433 * Clears the sign bit for address mode symconst.
435 void clear_ia32_am_sc_sign(ir_node *node)
437 ia32_attr_t *attr = get_ia32_attr(node);
438 attr->data.am_sc_sign = 0;
442 * Returns the sign bit for address mode symconst.
444 int is_ia32_am_sc_sign(const ir_node *node)
446 const ia32_attr_t *attr = get_ia32_attr_const(node);
447 return attr->data.am_sc_sign;
450 void set_ia32_am_tls_segment(ir_node *node, bool value)
452 ia32_attr_t *attr = get_ia32_attr(node);
453 attr->data.am_tls_segment = value;
456 bool get_ia32_am_tls_segment(const ir_node *node)
458 const ia32_attr_t *attr = get_ia32_attr_const(node);
459 return attr->data.am_tls_segment;
463 * Gets the addr mode const.
465 unsigned get_ia32_am_scale(const ir_node *node)
467 const ia32_attr_t *attr = get_ia32_attr_const(node);
468 return attr->data.am_scale;
472 * Sets the index register scale for address mode.
474 void set_ia32_am_scale(ir_node *node, unsigned scale)
476 ia32_attr_t *attr = get_ia32_attr(node);
477 assert(scale <= 3 && "AM scale out of range [0 ... 3]");
478 attr->data.am_scale = scale;
481 void ia32_copy_am_attrs(ir_node *to, const ir_node *from)
483 set_ia32_ls_mode(to, get_ia32_ls_mode(from));
484 set_ia32_am_scale(to, get_ia32_am_scale(from));
485 set_ia32_am_sc(to, get_ia32_am_sc(from));
486 if (is_ia32_am_sc_sign(from))
487 set_ia32_am_sc_sign(to);
488 add_ia32_am_offs_int(to, get_ia32_am_offs_int(from));
489 set_ia32_frame_ent(to, get_ia32_frame_ent(from));
490 if (is_ia32_use_frame(from))
491 set_ia32_use_frame(to);
495 * Sets the uses_frame flag.
497 void set_ia32_use_frame(ir_node *node)
499 ia32_attr_t *attr = get_ia32_attr(node);
500 attr->data.use_frame = 1;
504 * Clears the uses_frame flag.
506 void clear_ia32_use_frame(ir_node *node)
508 ia32_attr_t *attr = get_ia32_attr(node);
509 attr->data.use_frame = 0;
513 * Gets the uses_frame flag.
515 int is_ia32_use_frame(const ir_node *node)
517 const ia32_attr_t *attr = get_ia32_attr_const(node);
518 return attr->data.use_frame;
522 * Sets node to commutative.
524 void set_ia32_commutative(ir_node *node)
526 ia32_attr_t *attr = get_ia32_attr(node);
527 attr->data.is_commutative = 1;
531 * Sets node to non-commutative.
533 void clear_ia32_commutative(ir_node *node)
535 ia32_attr_t *attr = get_ia32_attr(node);
536 attr->data.is_commutative = 0;
540 * Checks if node is commutative.
542 int is_ia32_commutative(const ir_node *node)
544 const ia32_attr_t *attr = get_ia32_attr_const(node);
545 return attr->data.is_commutative;
548 void set_ia32_need_stackent(ir_node *node)
550 ia32_attr_t *attr = get_ia32_attr(node);
551 attr->data.need_stackent = 1;
554 void clear_ia32_need_stackent(ir_node *node)
556 ia32_attr_t *attr = get_ia32_attr(node);
557 attr->data.need_stackent = 0;
560 int is_ia32_need_stackent(const ir_node *node)
562 const ia32_attr_t *attr = get_ia32_attr_const(node);
563 return attr->data.need_stackent;
566 void set_ia32_is_reload(ir_node *node)
568 ia32_attr_t *attr = get_ia32_attr(node);
569 attr->data.is_reload = 1;
572 int is_ia32_is_reload(const ir_node *node)
574 const ia32_attr_t *attr = get_ia32_attr_const(node);
575 return attr->data.is_reload;
578 void set_ia32_is_spill(ir_node *node)
580 ia32_attr_t *attr = get_ia32_attr(node);
581 attr->data.is_spill = 1;
584 int is_ia32_is_spill(const ir_node *node)
586 const ia32_attr_t *attr = get_ia32_attr_const(node);
587 return attr->data.is_spill;
590 void set_ia32_is_remat(ir_node *node)
592 ia32_attr_t *attr = get_ia32_attr(node);
593 attr->data.is_remat = 1;
596 int is_ia32_is_remat(const ir_node *node)
598 const ia32_attr_t *attr = get_ia32_attr_const(node);
599 return attr->data.is_remat;
603 * Gets the mode of the stored/loaded value (only set for Store/Load)
605 ir_mode *get_ia32_ls_mode(const ir_node *node)
607 const ia32_attr_t *attr = get_ia32_attr_const(node);
608 return attr->ls_mode;
612 * Sets the mode of the stored/loaded value (only set for Store/Load)
614 void set_ia32_ls_mode(ir_node *node, ir_mode *mode)
616 ia32_attr_t *attr = get_ia32_attr(node);
617 attr->ls_mode = mode;
621 * Gets the frame entity assigned to this node.
623 ir_entity *get_ia32_frame_ent(const ir_node *node)
625 const ia32_attr_t *attr = get_ia32_attr_const(node);
626 return attr->frame_ent;
630 * Sets the frame entity for this node.
632 void set_ia32_frame_ent(ir_node *node, ir_entity *ent)
634 ia32_attr_t *attr = get_ia32_attr(node);
635 attr->frame_ent = ent;
637 set_ia32_use_frame(node);
639 clear_ia32_use_frame(node);
644 * Gets the instruction latency.
646 unsigned get_ia32_latency(const ir_node *node)
648 const ir_op *op = get_irn_op(node);
649 const ia32_op_attr_t *op_attr = (ia32_op_attr_t*) get_op_attr(op);
650 return op_attr->latency;
653 const ir_switch_table *get_ia32_switch_table(const ir_node *node)
655 const ia32_switch_attr_t *attr = get_ia32_switch_attr_const(node);
659 ia32_condition_code_t get_ia32_condcode(const ir_node *node)
661 const ia32_condcode_attr_t *attr = get_ia32_condcode_attr_const(node);
662 return attr->condition_code;
666 * Sets the condition code of a node
668 void set_ia32_condcode(ir_node *node, ia32_condition_code_t code)
670 ia32_condcode_attr_t *attr = get_ia32_condcode_attr(node);
671 attr->condition_code = code;
675 * Returns the condition code of a node.
677 unsigned get_ia32_copyb_size(const ir_node *node)
679 const ia32_copyb_attr_t *attr = get_ia32_copyb_attr_const(node);
684 * Get the exception label attribute.
686 unsigned get_ia32_exc_label(const ir_node *node)
688 const ia32_attr_t *attr = get_ia32_attr_const(node);
689 return attr->data.has_except_label;
693 * Set the exception label attribute.
695 void set_ia32_exc_label(ir_node *node, unsigned flag)
697 ia32_attr_t *attr = get_ia32_attr(node);
698 attr->data.has_except_label = flag;
702 * Return the exception label id.
704 ir_label_t get_ia32_exc_label_id(const ir_node *node)
706 const ia32_attr_t *attr = get_ia32_attr_const(node);
708 assert(attr->data.has_except_label);
709 return attr->exc_label;
713 * Assign the exception label id.
715 void set_ia32_exc_label_id(ir_node *node, ir_label_t id)
717 ia32_attr_t *attr = get_ia32_attr(node);
719 assert(attr->data.has_except_label);
720 attr->exc_label = id;
725 static const char *ia32_get_old_node_name(const ir_node *irn)
727 ir_graph *irg = get_irn_irg(irn);
728 struct obstack *obst = be_get_be_obst(irg);
730 lc_eoprintf(firm_get_arg_env(), obst, "%+F", irn);
731 obstack_1grow(obst, 0);
732 return (const char*)obstack_finish(obst);
736 * Sets the name of the original ir node.
738 void set_ia32_orig_node(ir_node *node, const ir_node *old)
740 const char *name = ia32_get_old_node_name(old);
741 ia32_attr_t *attr = get_ia32_attr(node);
742 attr->orig_node = name;
747 void ia32_swap_left_right(ir_node *node)
749 ia32_attr_t *attr = get_ia32_attr(node);
750 ir_node *left = get_irn_n(node, n_ia32_binary_left);
751 ir_node *right = get_irn_n(node, n_ia32_binary_right);
753 assert(is_ia32_commutative(node));
754 attr->data.ins_permuted = !attr->data.ins_permuted;
755 set_irn_n(node, n_ia32_binary_left, right);
756 set_irn_n(node, n_ia32_binary_right, left);
760 * Initializes the nodes attributes.
762 static void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
763 const arch_register_req_t **in_reqs,
766 ir_graph *irg = get_irn_irg(node);
767 struct obstack *obst = get_irg_obstack(irg);
768 ia32_attr_t *attr = get_ia32_attr(node);
769 backend_info_t *info;
771 arch_set_irn_flags(node, flags);
772 arch_set_irn_register_reqs_in(node, in_reqs);
775 attr->attr_type |= IA32_ATTR_ia32_attr_t;
778 info = be_get_info(node);
779 info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
782 static void init_ia32_x87_attributes(ir_node *res)
785 ia32_attr_t *attr = get_ia32_attr(res);
786 attr->attr_type |= IA32_ATTR_ia32_x87_attr_t;
788 ir_graph *const irg = get_irn_irg(res);
789 ia32_request_x87_sim(irg);
792 static void init_ia32_asm_attributes(ir_node *res)
795 ia32_attr_t *attr = get_ia32_attr(res);
796 attr->attr_type |= IA32_ATTR_ia32_asm_attr_t;
799 ir_graph *const irg = get_irn_irg(res);
800 ia32_request_x87_sim(irg); /* asm might have fp operands. */
803 static void init_ia32_immediate_attributes(ir_node *res, ir_entity *symconst,
804 int symconst_sign, int no_pic_adjust,
807 ia32_immediate_attr_t *attr = (ia32_immediate_attr_t*)get_irn_generic_attr(res);
810 attr->attr.attr_type |= IA32_ATTR_ia32_immediate_attr_t;
812 attr->symconst = symconst;
813 attr->sc_sign = symconst_sign;
814 attr->no_pic_adjust = no_pic_adjust;
815 attr->offset = offset;
818 static void init_ia32_call_attributes(ir_node* res, unsigned pop,
821 ia32_call_attr_t *attr = (ia32_call_attr_t*)get_irn_generic_attr(res);
824 attr->attr.attr_type |= IA32_ATTR_ia32_call_attr_t;
827 attr->call_tp = call_tp;
830 static void init_ia32_copyb_attributes(ir_node *res, unsigned size)
832 ia32_copyb_attr_t *attr = (ia32_copyb_attr_t*)get_irn_generic_attr(res);
835 attr->attr.attr_type |= IA32_ATTR_ia32_copyb_attr_t;
840 static void init_ia32_condcode_attributes(ir_node *res,
841 ia32_condition_code_t cc)
843 ia32_condcode_attr_t *attr = (ia32_condcode_attr_t*)get_irn_generic_attr(res);
846 attr->attr.attr_type |= IA32_ATTR_ia32_condcode_attr_t;
848 attr->condition_code = cc;
851 static void init_ia32_climbframe_attributes(ir_node *res, unsigned count)
853 ia32_climbframe_attr_t *attr = (ia32_climbframe_attr_t*)get_irn_generic_attr(res);
856 attr->attr.attr_type |= IA32_ATTR_ia32_climbframe_attr_t;
861 static void init_ia32_switch_attributes(ir_node *node,
862 const ir_switch_table *table)
864 ia32_switch_attr_t *attr = (ia32_switch_attr_t*) get_irn_generic_attr(node);
866 attr->attr.attr_type |= IA32_ATTR_ia32_switch_attr_t;
870 be_foreach_out(node, o) {
871 arch_set_irn_register_req_out(node, o, arch_no_register_req);
875 /* default compare operation to compare attributes */
876 static int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b)
878 if (a->data.tp != b->data.tp)
881 if (a->data.am_scale != b->data.am_scale
882 || a->data.am_sc_sign != b->data.am_sc_sign
883 || a->am_offs != b->am_offs
884 || a->am_sc != b->am_sc
885 || a->data.am_sc_no_pic_adjust != b->data.am_sc_no_pic_adjust
886 || a->ls_mode != b->ls_mode)
889 /* nodes with not yet assigned entities shouldn't be CSEd (important for
890 * unsigned int -> double conversions */
891 if (a->data.use_frame && a->frame_ent == NULL)
893 if (b->data.use_frame && b->frame_ent == NULL)
896 if (a->data.use_frame != b->data.use_frame
897 || a->frame_ent != b->frame_ent)
900 if (a->data.has_except_label != b->data.has_except_label)
903 if (a->data.ins_permuted != b->data.ins_permuted)
909 /** Compare nodes attributes for all "normal" nodes. */
910 static int ia32_compare_nodes_attr(const ir_node *a, const ir_node *b)
912 const ia32_attr_t* attr_a = get_ia32_attr_const(a);
913 const ia32_attr_t* attr_b = get_ia32_attr_const(b);
915 return ia32_compare_attr(attr_a, attr_b);
918 /** Compare node attributes for nodes with condition code. */
919 static int ia32_compare_condcode_attr(const ir_node *a, const ir_node *b)
921 const ia32_condcode_attr_t *attr_a;
922 const ia32_condcode_attr_t *attr_b;
924 if (ia32_compare_nodes_attr(a, b))
927 attr_a = get_ia32_condcode_attr_const(a);
928 attr_b = get_ia32_condcode_attr_const(b);
930 if (attr_a->condition_code != attr_b->condition_code)
936 /** Compare node attributes for call nodes. */
937 static int ia32_compare_call_attr(const ir_node *a, const ir_node *b)
939 const ia32_call_attr_t *attr_a;
940 const ia32_call_attr_t *attr_b;
942 if (ia32_compare_nodes_attr(a, b))
945 attr_a = get_ia32_call_attr_const(a);
946 attr_b = get_ia32_call_attr_const(b);
948 if (attr_a->pop != attr_b->pop)
951 if (attr_a->call_tp != attr_b->call_tp)
957 /** Compare node attributes for CopyB nodes. */
958 static int ia32_compare_copyb_attr(const ir_node *a, const ir_node *b)
960 const ia32_copyb_attr_t *attr_a;
961 const ia32_copyb_attr_t *attr_b;
963 if (ia32_compare_nodes_attr(a, b))
966 attr_a = get_ia32_copyb_attr_const(a);
967 attr_b = get_ia32_copyb_attr_const(b);
969 if (attr_a->size != attr_b->size)
976 /** Compare ASM node attributes. */
977 static int ia32_compare_asm_attr(const ir_node *a, const ir_node *b)
979 const ia32_asm_attr_t *attr_a;
980 const ia32_asm_attr_t *attr_b;
982 if (ia32_compare_nodes_attr(a, b))
985 attr_a = get_ia32_asm_attr_const(a);
986 attr_b = get_ia32_asm_attr_const(b);
988 if (attr_a->asm_text != attr_b->asm_text)
995 * Hash function for Immediates
997 static unsigned ia32_hash_Immediate(const ir_node *irn)
999 const ia32_immediate_attr_t *a = get_ia32_immediate_attr_const(irn);
1001 return hash_ptr(a->symconst) + (a->sc_sign << 16) + a->offset;
1004 /** Compare node attributes for Immediates. */
1005 static int ia32_compare_immediate_attr(const ir_node *a, const ir_node *b)
1007 const ia32_immediate_attr_t *attr_a = get_ia32_immediate_attr_const(a);
1008 const ia32_immediate_attr_t *attr_b = get_ia32_immediate_attr_const(b);
1010 if (attr_a->symconst != attr_b->symconst
1011 || attr_a->sc_sign != attr_b->sc_sign
1012 || attr_a->no_pic_adjust != attr_b->no_pic_adjust
1013 || attr_a->offset != attr_b->offset) {
1020 /** Compare node attributes for x87 nodes. */
1021 static int ia32_compare_x87_attr(const ir_node *a, const ir_node *b)
1023 return ia32_compare_nodes_attr(a, b);
1026 /** Compare node attributes for ClimbFrame nodes. */
1027 static int ia32_compare_climbframe_attr(const ir_node *a, const ir_node *b)
1029 const ia32_climbframe_attr_t *attr_a;
1030 const ia32_climbframe_attr_t *attr_b;
1032 if (ia32_compare_nodes_attr(a, b))
1035 attr_a = get_ia32_climbframe_attr_const(a);
1036 attr_b = get_ia32_climbframe_attr_const(b);
1038 if (attr_a->count != attr_b->count)
1044 /* copies the ia32 attributes */
1045 static void ia32_copy_attr(ir_graph *irg, const ir_node *old_node,
1048 struct obstack *obst = get_irg_obstack(irg);
1049 const ia32_attr_t *attr_old = get_ia32_attr_const(old_node);
1050 ia32_attr_t *attr_new = get_ia32_attr(new_node);
1051 backend_info_t *old_info = be_get_info(old_node);
1052 backend_info_t *new_info = be_get_info(new_node);
1054 /* copy the attributes */
1055 memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
1057 /* copy out flags */
1058 new_info->out_infos =
1059 DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
1060 new_info->in_reqs = old_info->in_reqs;
1061 new_info->flags = old_info->flags;
1064 static void ia32_init_op(ir_op *op, unsigned latency)
1066 ia32_op_attr_t *attr = OALLOCZ(&opcodes_obst, ia32_op_attr_t);
1067 attr->latency = latency;
1068 set_op_attr(op, attr);
1071 /* Include the generated constructor functions */
1072 #include "gen_ia32_new_nodes.c.inl"