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 assert(is_ia32_irn(node));
649 const ir_op *op = get_irn_op(node);
650 const ia32_op_attr_t *op_attr = (ia32_op_attr_t*) get_op_attr(op);
651 return op_attr->latency;
654 const ir_switch_table *get_ia32_switch_table(const ir_node *node)
656 const ia32_switch_attr_t *attr = get_ia32_switch_attr_const(node);
660 ia32_condition_code_t get_ia32_condcode(const ir_node *node)
662 const ia32_condcode_attr_t *attr = get_ia32_condcode_attr_const(node);
663 return attr->condition_code;
667 * Sets the condition code of a node
669 void set_ia32_condcode(ir_node *node, ia32_condition_code_t code)
671 ia32_condcode_attr_t *attr = get_ia32_condcode_attr(node);
672 attr->condition_code = code;
676 * Returns the condition code of a node.
678 unsigned get_ia32_copyb_size(const ir_node *node)
680 const ia32_copyb_attr_t *attr = get_ia32_copyb_attr_const(node);
685 * Get the exception label attribute.
687 unsigned get_ia32_exc_label(const ir_node *node)
689 const ia32_attr_t *attr = get_ia32_attr_const(node);
690 return attr->data.has_except_label;
694 * Set the exception label attribute.
696 void set_ia32_exc_label(ir_node *node, unsigned flag)
698 ia32_attr_t *attr = get_ia32_attr(node);
699 attr->data.has_except_label = flag;
703 * Return the exception label id.
705 ir_label_t get_ia32_exc_label_id(const ir_node *node)
707 const ia32_attr_t *attr = get_ia32_attr_const(node);
709 assert(attr->data.has_except_label);
710 return attr->exc_label;
714 * Assign the exception label id.
716 void set_ia32_exc_label_id(ir_node *node, ir_label_t id)
718 ia32_attr_t *attr = get_ia32_attr(node);
720 assert(attr->data.has_except_label);
721 attr->exc_label = id;
726 static const char *ia32_get_old_node_name(const ir_node *irn)
728 ir_graph *irg = get_irn_irg(irn);
729 struct obstack *obst = be_get_be_obst(irg);
731 lc_eoprintf(firm_get_arg_env(), obst, "%+F", irn);
732 obstack_1grow(obst, 0);
733 return (const char*)obstack_finish(obst);
737 * Sets the name of the original ir node.
739 void set_ia32_orig_node(ir_node *node, const ir_node *old)
741 const char *name = ia32_get_old_node_name(old);
742 ia32_attr_t *attr = get_ia32_attr(node);
743 attr->orig_node = name;
748 void ia32_swap_left_right(ir_node *node)
750 ia32_attr_t *attr = get_ia32_attr(node);
751 ir_node *left = get_irn_n(node, n_ia32_binary_left);
752 ir_node *right = get_irn_n(node, n_ia32_binary_right);
754 assert(is_ia32_commutative(node));
755 attr->data.ins_permuted = !attr->data.ins_permuted;
756 set_irn_n(node, n_ia32_binary_left, right);
757 set_irn_n(node, n_ia32_binary_right, left);
761 * Initializes the nodes attributes.
763 static void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
764 const arch_register_req_t **in_reqs,
767 ir_graph *irg = get_irn_irg(node);
768 struct obstack *obst = get_irg_obstack(irg);
769 ia32_attr_t *attr = get_ia32_attr(node);
770 backend_info_t *info;
772 arch_set_irn_flags(node, flags);
773 arch_set_irn_register_reqs_in(node, in_reqs);
776 attr->attr_type |= IA32_ATTR_ia32_attr_t;
779 info = be_get_info(node);
780 info->out_infos = NEW_ARR_DZ(reg_out_info_t, obst, n_res);
783 static void init_ia32_x87_attributes(ir_node *res)
786 ia32_attr_t *attr = get_ia32_attr(res);
787 attr->attr_type |= IA32_ATTR_ia32_x87_attr_t;
789 ir_graph *const irg = get_irn_irg(res);
790 ia32_request_x87_sim(irg);
793 static void init_ia32_asm_attributes(ir_node *res)
796 ia32_attr_t *attr = get_ia32_attr(res);
797 attr->attr_type |= IA32_ATTR_ia32_asm_attr_t;
800 ir_graph *const irg = get_irn_irg(res);
801 ia32_request_x87_sim(irg); /* asm might have fp operands. */
804 static void init_ia32_immediate_attributes(ir_node *res, ir_entity *symconst,
805 int symconst_sign, int no_pic_adjust,
808 ia32_immediate_attr_t *attr = (ia32_immediate_attr_t*)get_irn_generic_attr(res);
811 attr->attr.attr_type |= IA32_ATTR_ia32_immediate_attr_t;
813 attr->symconst = symconst;
814 attr->sc_sign = symconst_sign;
815 attr->no_pic_adjust = no_pic_adjust;
816 attr->offset = offset;
819 static void init_ia32_call_attributes(ir_node* res, unsigned pop,
822 ia32_call_attr_t *attr = (ia32_call_attr_t*)get_irn_generic_attr(res);
825 attr->attr.attr_type |= IA32_ATTR_ia32_call_attr_t;
828 attr->call_tp = call_tp;
831 static void init_ia32_copyb_attributes(ir_node *res, unsigned size)
833 ia32_copyb_attr_t *attr = (ia32_copyb_attr_t*)get_irn_generic_attr(res);
836 attr->attr.attr_type |= IA32_ATTR_ia32_copyb_attr_t;
841 static void init_ia32_condcode_attributes(ir_node *res,
842 ia32_condition_code_t cc)
844 ia32_condcode_attr_t *attr = (ia32_condcode_attr_t*)get_irn_generic_attr(res);
847 attr->attr.attr_type |= IA32_ATTR_ia32_condcode_attr_t;
849 attr->condition_code = cc;
852 static void init_ia32_climbframe_attributes(ir_node *res, unsigned count)
854 ia32_climbframe_attr_t *attr = (ia32_climbframe_attr_t*)get_irn_generic_attr(res);
857 attr->attr.attr_type |= IA32_ATTR_ia32_climbframe_attr_t;
862 static void init_ia32_switch_attributes(ir_node *node,
863 const ir_switch_table *table)
865 ia32_switch_attr_t *attr = (ia32_switch_attr_t*) get_irn_generic_attr(node);
867 attr->attr.attr_type |= IA32_ATTR_ia32_switch_attr_t;
871 be_foreach_out(node, o) {
872 arch_set_irn_register_req_out(node, o, arch_no_register_req);
876 /* default compare operation to compare attributes */
877 static int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b)
879 if (a->data.tp != b->data.tp)
882 if (a->data.am_scale != b->data.am_scale
883 || a->data.am_sc_sign != b->data.am_sc_sign
884 || a->am_offs != b->am_offs
885 || a->am_sc != b->am_sc
886 || a->data.am_sc_no_pic_adjust != b->data.am_sc_no_pic_adjust
887 || a->ls_mode != b->ls_mode)
890 /* nodes with not yet assigned entities shouldn't be CSEd (important for
891 * unsigned int -> double conversions */
892 if (a->data.use_frame && a->frame_ent == NULL)
894 if (b->data.use_frame && b->frame_ent == NULL)
897 if (a->data.use_frame != b->data.use_frame
898 || a->frame_ent != b->frame_ent)
901 if (a->data.has_except_label != b->data.has_except_label)
904 if (a->data.ins_permuted != b->data.ins_permuted)
910 /** Compare nodes attributes for all "normal" nodes. */
911 static int ia32_compare_nodes_attr(const ir_node *a, const ir_node *b)
913 const ia32_attr_t* attr_a = get_ia32_attr_const(a);
914 const ia32_attr_t* attr_b = get_ia32_attr_const(b);
916 return ia32_compare_attr(attr_a, attr_b);
919 /** Compare node attributes for nodes with condition code. */
920 static int ia32_compare_condcode_attr(const ir_node *a, const ir_node *b)
922 const ia32_condcode_attr_t *attr_a;
923 const ia32_condcode_attr_t *attr_b;
925 if (ia32_compare_nodes_attr(a, b))
928 attr_a = get_ia32_condcode_attr_const(a);
929 attr_b = get_ia32_condcode_attr_const(b);
931 if (attr_a->condition_code != attr_b->condition_code)
937 /** Compare node attributes for call nodes. */
938 static int ia32_compare_call_attr(const ir_node *a, const ir_node *b)
940 const ia32_call_attr_t *attr_a;
941 const ia32_call_attr_t *attr_b;
943 if (ia32_compare_nodes_attr(a, b))
946 attr_a = get_ia32_call_attr_const(a);
947 attr_b = get_ia32_call_attr_const(b);
949 if (attr_a->pop != attr_b->pop)
952 if (attr_a->call_tp != attr_b->call_tp)
958 /** Compare node attributes for CopyB nodes. */
959 static int ia32_compare_copyb_attr(const ir_node *a, const ir_node *b)
961 const ia32_copyb_attr_t *attr_a;
962 const ia32_copyb_attr_t *attr_b;
964 if (ia32_compare_nodes_attr(a, b))
967 attr_a = get_ia32_copyb_attr_const(a);
968 attr_b = get_ia32_copyb_attr_const(b);
970 if (attr_a->size != attr_b->size)
977 /** Compare ASM node attributes. */
978 static int ia32_compare_asm_attr(const ir_node *a, const ir_node *b)
980 const ia32_asm_attr_t *attr_a;
981 const ia32_asm_attr_t *attr_b;
983 if (ia32_compare_nodes_attr(a, b))
986 attr_a = get_ia32_asm_attr_const(a);
987 attr_b = get_ia32_asm_attr_const(b);
989 if (attr_a->asm_text != attr_b->asm_text)
996 * Hash function for Immediates
998 static unsigned ia32_hash_Immediate(const ir_node *irn)
1000 const ia32_immediate_attr_t *a = get_ia32_immediate_attr_const(irn);
1002 return hash_ptr(a->symconst) + (a->sc_sign << 16) + a->offset;
1005 /** Compare node attributes for Immediates. */
1006 static int ia32_compare_immediate_attr(const ir_node *a, const ir_node *b)
1008 const ia32_immediate_attr_t *attr_a = get_ia32_immediate_attr_const(a);
1009 const ia32_immediate_attr_t *attr_b = get_ia32_immediate_attr_const(b);
1011 if (attr_a->symconst != attr_b->symconst
1012 || attr_a->sc_sign != attr_b->sc_sign
1013 || attr_a->no_pic_adjust != attr_b->no_pic_adjust
1014 || attr_a->offset != attr_b->offset) {
1021 /** Compare node attributes for x87 nodes. */
1022 static int ia32_compare_x87_attr(const ir_node *a, const ir_node *b)
1024 return ia32_compare_nodes_attr(a, b);
1027 /** Compare node attributes for ClimbFrame nodes. */
1028 static int ia32_compare_climbframe_attr(const ir_node *a, const ir_node *b)
1030 const ia32_climbframe_attr_t *attr_a;
1031 const ia32_climbframe_attr_t *attr_b;
1033 if (ia32_compare_nodes_attr(a, b))
1036 attr_a = get_ia32_climbframe_attr_const(a);
1037 attr_b = get_ia32_climbframe_attr_const(b);
1039 if (attr_a->count != attr_b->count)
1045 /* copies the ia32 attributes */
1046 static void ia32_copy_attr(ir_graph *irg, const ir_node *old_node,
1049 struct obstack *obst = get_irg_obstack(irg);
1050 const ia32_attr_t *attr_old = get_ia32_attr_const(old_node);
1051 ia32_attr_t *attr_new = get_ia32_attr(new_node);
1052 backend_info_t *old_info = be_get_info(old_node);
1053 backend_info_t *new_info = be_get_info(new_node);
1055 /* copy the attributes */
1056 memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
1058 /* copy out flags */
1059 new_info->out_infos =
1060 DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
1061 new_info->in_reqs = old_info->in_reqs;
1062 new_info->flags = old_info->flags;
1065 static void ia32_init_op(ir_op *op, unsigned latency)
1067 ia32_op_attr_t *attr = OALLOCZ(&opcodes_obst, ia32_op_attr_t);
1068 attr->latency = latency;
1069 set_op_attr(op, attr);
1072 /* Include the generated constructor functions */
1073 #include "gen_ia32_new_nodes.c.inl"