the spillslot coalescer is now a general frame entity coalescer for all nodes that...
[libfirm] / ir / be / ia32 / ia32_new_nodes.c
1 /**
2  * This file implements the creation of the achitecture specific firm opcodes
3  * and the coresponding node constructors for the ia32 assembler irg.
4  * @author Christian Wuerdig
5  * $Id$
6  */
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #ifdef HAVE_MALLOC_H
13 #include <malloc.h>
14 #endif
15
16 #ifdef HAVE_ALLOCA_H
17 #include <alloca.h>
18 #endif
19
20 #include <stdlib.h>
21
22 #include "irprog_t.h"
23 #include "irgraph_t.h"
24 #include "irnode_t.h"
25 #include "irmode_t.h"
26 #include "ircons_t.h"
27 #include "iropt_t.h"
28 #include "irop.h"
29 #include "firm_common_t.h"
30 #include "irvrfy_t.h"
31 #include "irprintf.h"
32 #include "iredges.h"
33
34 #include "../bearch.h"
35
36 #include "ia32_nodes_attr.h"
37 #include "ia32_new_nodes.h"
38 #include "gen_ia32_regalloc_if.h"
39 #include "gen_ia32_machine.h"
40
41 /**
42  * Returns the ident of a SymConst.
43  * @param symc  The SymConst
44  * @return The ident of the SymConst
45  */
46 static ident *get_sc_ident(ir_node *symc) {
47         ir_entity *ent;
48         ir_type   *owner;
49         ident     *id;
50
51         switch (get_SymConst_kind(symc)) {
52                 case symconst_addr_name:
53                         return get_SymConst_name(symc);
54
55                 case symconst_addr_ent:
56                         ent   = get_SymConst_entity(symc);
57                         owner = get_entity_owner(ent);
58                         id    = get_entity_ld_ident(ent);
59                         if (owner == get_tls_type()) {
60                                 if (get_entity_visibility(ent) == visibility_external_allocated)
61                                         id = mangle(id, new_id_from_chars("@INDNTPOFF", 10));
62                                 else
63                                         id = mangle(id, new_id_from_chars("@NTPOFF", 7));
64                         }
65                         return id;
66
67                 default:
68                         assert(0 && "Unsupported SymConst");
69         }
70
71         return NULL;
72 }
73
74 /**
75  * returns true if a node has x87 registers
76  */
77 int ia32_has_x87_register(const ir_node *n) {
78         assert(is_ia32_irn(n) && "Need ia32 node.");
79         return is_irn_machine_user(n, 0);
80 }
81
82 /***********************************************************************************
83  *      _                                   _       _             __
84  *     | |                                 (_)     | |           / _|
85  *   __| |_   _ _ __ ___  _ __   ___ _ __   _ _ __ | |_ ___ _ __| |_ __ _  ___ ___
86  *  / _` | | | | '_ ` _ \| '_ \ / _ \ '__| | | '_ \| __/ _ \ '__|  _/ _` |/ __/ _ \
87  * | (_| | |_| | | | | | | |_) |  __/ |    | | | | | ||  __/ |  | || (_| | (_|  __/
88  *  \__,_|\__,_|_| |_| |_| .__/ \___|_|    |_|_| |_|\__\___|_|  |_| \__,_|\___\___|
89  *                       | |
90  *                       |_|
91  ***********************************************************************************/
92
93 /**
94  * Returns a string containing the names of all registers within the limited bitset
95  */
96 static char *get_limited_regs(const arch_register_req_t *req, char *buf, int max) {
97         bitset_t *bs   = bitset_alloca(req->cls->n_regs);
98         char     *p    = buf;
99         int       size = 0;
100         int       i, cnt;
101
102         req->limited(NULL, bs);
103
104         for (i = 0; i < req->cls->n_regs; i++) {
105                 if (bitset_is_set(bs, i)) {
106                         cnt = snprintf(p, max - size, " %s", req->cls->regs[i].name);
107                         if (cnt < 0) {
108                                 fprintf(stderr, "dumper problem, exiting\n");
109                                 exit(1);
110                         }
111
112                         p    += cnt;
113                         size += cnt;
114
115                         if (size >= max)
116                                 break;
117                 }
118         }
119
120         return buf;
121 }
122
123 /**
124  * Dumps the register requirements for either in or out.
125  */
126 static void dump_reg_req(FILE *F, ir_node *n, const ia32_register_req_t **reqs, int inout) {
127         char *dir = inout ? "out" : "in";
128         int   max = inout ? get_ia32_n_res(n) : get_irn_arity(n);
129         char *buf = alloca(1024);
130         int   i;
131
132         memset(buf, 0, 1024);
133
134         if (reqs) {
135                 for (i = 0; i < max; i++) {
136                         fprintf(F, "%sreq #%d =", dir, i);
137
138                         if (reqs[i]->req.type == arch_register_req_type_none) {
139                                 fprintf(F, " n/a");
140                         }
141
142                         if (reqs[i]->req.type & arch_register_req_type_normal) {
143                                 fprintf(F, " %s", reqs[i]->req.cls->name);
144                         }
145
146                         if (reqs[i]->req.type & arch_register_req_type_limited) {
147                                 fprintf(F, " %s", get_limited_regs(&reqs[i]->req, buf, 1024));
148                         }
149
150                         if (reqs[i]->req.type & arch_register_req_type_should_be_same) {
151                                 ir_fprintf(F, " same as %+F", get_irn_n(n, reqs[i]->same_pos));
152                         }
153
154                         if (reqs[i]->req.type & arch_register_req_type_should_be_different) {
155                                 ir_fprintf(F, " different from %+F", get_irn_n(n, reqs[i]->different_pos));
156                         }
157
158                         fprintf(F, "\n");
159                 }
160
161                 fprintf(F, "\n");
162         }
163         else {
164                 fprintf(F, "%sreq = N/A\n", dir);
165         }
166 }
167
168 /**
169  * Dumper interface for dumping ia32 nodes in vcg.
170  * @param n        the node to dump
171  * @param F        the output file
172  * @param reason   indicates which kind of information should be dumped
173  * @return 0 on success or != 0 on failure
174  */
175 static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
176         ir_mode     *mode = NULL;
177         int          bad  = 0;
178         int          i, n_res, am_flav, flags;
179         const ia32_register_req_t **reqs;
180         const arch_register_t     **slots;
181
182         switch (reason) {
183                 case dump_node_opcode_txt:
184                         fprintf(F, "%s", get_irn_opname(n));
185                         break;
186
187                 case dump_node_mode_txt:
188                         mode = get_irn_mode(n);
189
190                         if (is_ia32_Ld(n) || is_ia32_St(n)) {
191                                 mode = get_ia32_ls_mode(n);
192                         }
193
194                         fprintf(F, "[%s]", mode ? get_mode_name(mode) : "?NOMODE?");
195                         break;
196
197                 case dump_node_nodeattr_txt:
198                         if (is_ia32_ImmConst(n) || is_ia32_ImmSymConst(n) || is_ia32_Cnst(n)) {
199                                 char       *pref = is_ia32_ImmSymConst(n) || (get_ia32_op_type(n) == ia32_SymConst) ? "SymC " : "";
200                                 const char *cnst = get_ia32_cnst(n);
201
202                                 fprintf(F, "[%s%s]", pref, cnst ? cnst : "NONE");
203                         }
204
205                         if (! is_ia32_Lea(n)) {
206                                 if (is_ia32_AddrModeS(n)) {
207                                         fprintf(F, "[AM S] ");
208                                 }
209                                 else if (is_ia32_AddrModeD(n)) {
210                                         fprintf(F, "[AM D] ");
211                                 }
212                         }
213
214                         break;
215
216                 case dump_node_info_txt:
217                         n_res = get_ia32_n_res(n);
218                         fprintf(F, "=== IA32 attr begin ===\n");
219
220                         /* dump IN requirements */
221                         if (get_irn_arity(n) > 0) {
222                                 reqs = get_ia32_in_req_all(n);
223                                 dump_reg_req(F, n, reqs, 0);
224                         }
225
226                         /* dump OUT requirements */
227                         if (n_res > 0) {
228                                 reqs = get_ia32_out_req_all(n);
229                                 dump_reg_req(F, n, reqs, 1);
230                         }
231
232                         /* dump assigned registers */
233                         slots = get_ia32_slots(n);
234                         if (slots && n_res > 0) {
235                                 for (i = 0; i < n_res; i++) {
236                                         const arch_register_t *reg;
237
238                                         /* retrieve "real" x87 register */
239                                         if (ia32_has_x87_register(n))
240                                                 reg = get_ia32_attr(n)->x87[i + 2];
241                                         else
242                                                 reg = slots[i];
243
244                                         fprintf(F, "reg #%d = %s\n", i, reg ? arch_register_get_name(reg) : "n/a");
245                                 }
246                                 fprintf(F, "\n");
247                         }
248
249                         /* dump op type */
250                         fprintf(F, "op = ");
251                         switch (get_ia32_op_type(n)) {
252                                 case ia32_Normal:
253                                         fprintf(F, "Normal");
254                                         break;
255                                 case ia32_Const:
256                                         fprintf(F, "Const");
257                                         break;
258                                 case ia32_SymConst:
259                                         fprintf(F, "SymConst");
260                                         break;
261                                 case ia32_AddrModeD:
262                                         fprintf(F, "AM Dest (Load+Store)");
263                                         break;
264                                 case ia32_AddrModeS:
265                                         fprintf(F, "AM Source (Load)");
266                                         break;
267                                 default:
268                                         fprintf(F, "unknown (%d)", get_ia32_op_type(n));
269                                         break;
270                         }
271                         fprintf(F, "\n");
272
273                         /* dump immop type */
274                         fprintf(F, "immediate = ");
275                         switch (get_ia32_immop_type(n)) {
276                                 case ia32_ImmNone:
277                                         fprintf(F, "None");
278                                         break;
279                                 case ia32_ImmConst:
280                                         fprintf(F, "Const");
281                                         break;
282                                 case ia32_ImmSymConst:
283                                         fprintf(F, "SymConst");
284                                         break;
285                                 default:
286                                         fprintf(F, "unknown (%d)", get_ia32_immop_type(n));
287                                         break;
288                         }
289                         fprintf(F, "\n");
290
291                         /* dump supported am */
292                         fprintf(F, "AM support = ");
293                         switch (get_ia32_am_support(n)) {
294                                 case ia32_am_None:
295                                         fprintf(F, "none");
296                                         break;
297                                 case ia32_am_Source:
298                                         fprintf(F, "source only (Load)");
299                                         break;
300                                 case ia32_am_Dest:
301                                         fprintf(F, "dest only (Load+Store)");
302                                         break;
303                                 case ia32_am_Full:
304                                         fprintf(F, "full");
305                                         break;
306                                 default:
307                                         fprintf(F, "unknown (%d)", get_ia32_am_support(n));
308                                         break;
309                         }
310                         fprintf(F, "\n");
311
312                         /* dump am flavour */
313                         fprintf(F, "AM flavour =");
314                         am_flav = get_ia32_am_flavour(n);
315                         if (am_flav == ia32_am_N) {
316                                 fprintf(F, " none");
317                         }
318                         else {
319                                 if (am_flav & ia32_O) {
320                                         fprintf(F, " O");
321                                 }
322                                 if (am_flav & ia32_B) {
323                                         fprintf(F, " B");
324                                 }
325                                 if (am_flav & ia32_I) {
326                                         fprintf(F, " I");
327                                 }
328                                 if (am_flav & ia32_S) {
329                                         fprintf(F, " S");
330                                 }
331                         }
332                         fprintf(F, " (%d)\n", am_flav);
333
334                         /* dump AM offset */
335                         fprintf(F, "AM offset = ");
336                         if (get_ia32_am_offs(n)) {
337                                 fprintf(F, "%s", get_ia32_am_offs(n));
338                         }
339                         else {
340                                 fprintf(F, "n/a");
341                         }
342                         fprintf(F, "\n");
343
344                         /* dump AM symconst */
345                         if(get_ia32_am_sc(n) != NULL) {
346                                 fprintf(F, "AM symconst = %s\n", get_id_str(get_ia32_am_sc(n)));
347                         }
348
349                         /* dump AM scale */
350                         fprintf(F, "AM scale = %d\n", get_ia32_am_scale(n));
351
352                         /* dump pn code */
353                         fprintf(F, "pn_code = %ld (%s)\n", get_ia32_pncode(n), get_pnc_string(get_ia32_pncode(n)));
354
355                         /* dump n_res */
356                         fprintf(F, "n_res = %d\n", get_ia32_n_res(n));
357
358                         /* dump use_frame */
359                         fprintf(F, "use_frame = %d\n", is_ia32_use_frame(n));
360
361                         /* commutative */
362                         fprintf(F, "commutative = %d\n", is_ia32_commutative(n));
363
364                         /* emit cl */
365                         fprintf(F, "emit cl instead of ecx = %d\n", is_ia32_emit_cl(n));
366
367                         /* got lea */
368                         fprintf(F, "got loea = %d\n", is_ia32_got_lea(n));
369
370                         /* got reload */
371                         fprintf(F, "got reload = %d\n", is_ia32_got_reload(n));
372
373                         /* dump latency */
374                         fprintf(F, "latency = %d\n", get_ia32_latency(n));
375
376                         /* dump flags */
377                         fprintf(F, "flags =");
378                         flags = get_ia32_flags(n);
379                         if (flags == arch_irn_flags_none) {
380                                 fprintf(F, " none");
381                         }
382                         else {
383                                 if (flags & arch_irn_flags_dont_spill) {
384                                         fprintf(F, " unspillable");
385                                 }
386                                 if (flags & arch_irn_flags_rematerializable) {
387                                         fprintf(F, " remat");
388                                 }
389                                 if (flags & arch_irn_flags_ignore) {
390                                         fprintf(F, " ignore");
391                                 }
392                                 if (flags & arch_irn_flags_modify_sp) {
393                                         fprintf(F, " modify_sp");
394                                 }
395                         }
396                         fprintf(F, " (%d)\n", flags);
397
398                         /* dump frame entity */
399                         fprintf(F, "frame entity = ");
400                         if (get_ia32_frame_ent(n)) {
401                                 ir_fprintf(F, "%+F", get_ia32_frame_ent(n));
402                         }
403                         else {
404                                 fprintf(F, "n/a");
405                         }
406                         fprintf(F, "\n");
407
408                         /* dump modes */
409                         fprintf(F, "ls_mode = ");
410                         if (get_ia32_ls_mode(n)) {
411                                 ir_fprintf(F, "%+F", get_ia32_ls_mode(n));
412                         }
413                         else {
414                                 fprintf(F, "n/a");
415                         }
416                         fprintf(F, "\n");
417
418                         fprintf(F, "res_mode = ");
419                         if (get_ia32_res_mode(n)) {
420                                 ir_fprintf(F, "%+F", get_ia32_res_mode(n));
421                         }
422                         else {
423                                 fprintf(F, "n/a");
424                         }
425                         fprintf(F, "\n");
426
427 #ifndef NDEBUG
428                         /* dump original ir node name */
429                         fprintf(F, "orig node = ");
430                         if (get_ia32_orig_node(n)) {
431                                 fprintf(F, "%s", get_ia32_orig_node(n));
432                         }
433                         else {
434                                 fprintf(F, "n/a");
435                         }
436                         fprintf(F, "\n");
437 #endif /* NDEBUG */
438
439                         fprintf(F, "=== IA32 attr end ===\n");
440                         /* end of: case dump_node_info_txt */
441                         break;
442         }
443
444         return bad;
445 }
446
447
448
449 /***************************************************************************************************
450  *        _   _                   _       __        _                    _   _               _
451  *       | | | |                 | |     / /       | |                  | | | |             | |
452  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
453  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
454  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
455  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
456  *                                        __/ |
457  *                                       |___/
458  ***************************************************************************************************/
459
460 /**
461  * Returns an ident for the given tarval tv.
462  */
463 static ident *get_ident_for_tv(tarval *tv) {
464         char buf[1024];
465         int len = tarval_snprintf(buf, sizeof(buf), tv);
466         assert(len);
467         return new_id_from_str(buf);
468 }
469
470 /**
471  * Wraps get_irn_generic_attr() as it takes no const ir_node, so we need to do a cast.
472  * Firm was made by people hating const :-(
473  */
474 ia32_attr_t *get_ia32_attr(const ir_node *node) {
475         assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes");
476         return (ia32_attr_t *)get_irn_generic_attr((ir_node *)node);
477 }
478
479 /**
480  * Gets the type of an ia32 node.
481  */
482 ia32_op_type_t get_ia32_op_type(const ir_node *node) {
483         ia32_attr_t *attr = get_ia32_attr(node);
484         return attr->data.tp;
485 }
486
487 /**
488  * Sets the type of an ia32 node.
489  */
490 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp) {
491         ia32_attr_t *attr = get_ia32_attr(node);
492         attr->data.tp     = tp;
493 }
494
495 /**
496  * Gets the immediate op type of an ia32 node.
497  */
498 ia32_immop_type_t get_ia32_immop_type(const ir_node *node) {
499         ia32_attr_t *attr = get_ia32_attr(node);
500         return attr->data.imm_tp;
501 }
502
503 /**
504  * Sets the immediate op type of an ia32 node.
505  */
506 void set_ia32_immop_type(ir_node *node, ia32_immop_type_t tp) {
507         ia32_attr_t *attr = get_ia32_attr(node);
508         attr->data.imm_tp = tp;
509 }
510
511 /**
512  * Gets the supported addrmode of an ia32 node
513  */
514 ia32_am_type_t get_ia32_am_support(const ir_node *node) {
515         ia32_attr_t *attr = get_ia32_attr(node);
516         return attr->data.am_support;
517 }
518
519 /**
520  * Sets the supported addrmode of an ia32 node
521  */
522 void set_ia32_am_support(ir_node *node, ia32_am_type_t am_tp) {
523         ia32_attr_t *attr     = get_ia32_attr(node);
524         attr->data.am_support = am_tp;
525 }
526
527 /**
528  * Gets the addrmode flavour of an ia32 node
529  */
530 ia32_am_flavour_t get_ia32_am_flavour(const ir_node *node) {
531         ia32_attr_t *attr = get_ia32_attr(node);
532         return attr->data.am_flavour;
533 }
534
535 /**
536  * Sets the addrmode flavour of an ia32 node
537  */
538 void set_ia32_am_flavour(ir_node *node, ia32_am_flavour_t am_flavour) {
539         ia32_attr_t *attr     = get_ia32_attr(node);
540         attr->data.am_flavour = am_flavour;
541 }
542
543 /**
544  * Joins all offsets to one string with adds.
545  */
546 char *get_ia32_am_offs(const ir_node *node) {
547         ia32_attr_t *attr = get_ia32_attr(node);
548         static char res[64];
549
550         snprintf(res, sizeof(res), "%+d", attr->am_offs);
551
552         return res;
553 }
554
555 /**
556  * Gets the addressmode offset as int.
557  */
558 int get_ia32_am_offs_int(const ir_node *node) {
559         ia32_attr_t *attr = get_ia32_attr(node);
560         return attr->am_offs;
561 }
562
563 /**
564  * Sets the addressmode offset from an int.
565  */
566 void set_ia32_am_offs_int(ir_node *node, int offset) {
567         ia32_attr_t *attr = get_ia32_attr(node);
568         attr->am_offs = offset;
569 }
570
571 /**
572  * Add an offset for addrmode.
573  */
574 static void extend_ia32_am_offs(ir_node *node, char *offset, char op) {
575         ia32_attr_t *attr = get_ia32_attr(node);
576         int res, o;
577
578         if (offset == NULL || offset[0] == '\0')
579                 return;
580
581         if (offset[0] == '-')
582                 res = sscanf(offset, "%d", &o);
583         else
584                 res = sscanf(offset, "%u", &o);
585         assert(res == 1);
586
587         if (op == '-')
588                 attr->am_offs -= o;
589         else if (op == '+')
590                 attr->am_offs += o;
591         else
592                 assert(0);
593 }
594
595 /**
596  * Add an offset for addrmode.
597  */
598 void add_ia32_am_offs(ir_node *node, const char *offset) {
599         extend_ia32_am_offs(node, (char *)offset, '+');
600 }
601
602 void add_ia32_am_offs_int(ir_node *node, int offset) {
603         ia32_attr_t *attr = get_ia32_attr(node);
604         attr->am_offs += offset;
605 }
606
607 /**
608  * Sub an offset for addrmode.
609  */
610 void sub_ia32_am_offs(ir_node *node, const char *offset) {
611         extend_ia32_am_offs(node, (char *)offset, '-');
612 }
613
614 /**
615  * Returns the symconst ident associated to addrmode.
616  */
617 ident *get_ia32_am_sc(const ir_node *node) {
618         ia32_attr_t *attr = get_ia32_attr(node);
619         return attr->am_sc;
620 }
621
622 /**
623  * Sets the symconst ident associated to addrmode.
624  */
625 void set_ia32_am_sc(ir_node *node, ident *sc) {
626         ia32_attr_t *attr = get_ia32_attr(node);
627         attr->am_sc       = sc;
628 }
629
630 /**
631  * Sets the sign bit for address mode symconst.
632  */
633 void set_ia32_am_sc_sign(ir_node *node) {
634         ia32_attr_t *attr     = get_ia32_attr(node);
635         attr->data.am_sc_sign = 1;
636 }
637
638 /**
639  * Clears the sign bit for address mode symconst.
640  */
641 void clear_ia32_am_sc_sign(ir_node *node) {
642         ia32_attr_t *attr     = get_ia32_attr(node);
643         attr->data.am_sc_sign = 0;
644 }
645
646 /**
647  * Returns the sign bit for address mode symconst.
648  */
649 int is_ia32_am_sc_sign(const ir_node *node) {
650         ia32_attr_t *attr = get_ia32_attr(node);
651         return attr->data.am_sc_sign;
652 }
653
654 /**
655  * Gets the addr mode const.
656  */
657 int get_ia32_am_scale(const ir_node *node) {
658         ia32_attr_t *attr = get_ia32_attr(node);
659         return attr->data.am_scale;
660 }
661
662 /**
663  * Sets the index register scale for addrmode.
664  */
665 void set_ia32_am_scale(ir_node *node, int scale) {
666         ia32_attr_t *attr   = get_ia32_attr(node);
667         attr->data.am_scale = scale;
668 }
669
670 /**
671  * Return the tarval of an immediate operation or NULL in case of SymConst
672  */
673 tarval *get_ia32_Immop_tarval(const ir_node *node) {
674         ia32_attr_t *attr = get_ia32_attr(node);
675     return attr->cnst_val.tv;
676 }
677
678 /**
679  * Sets the attributes of an immediate operation to the specified tarval
680  */
681 void set_ia32_Immop_tarval(ir_node *node, tarval *tv) {
682         ia32_attr_t *attr = get_ia32_attr(node);
683         attr->cnst_val.tv = tv;
684         attr->cnst        = get_ident_for_tv(tv);
685 }
686
687 /**
688  * Gets the string representation of the internal const (tv or symconst)
689  */
690 const char *get_ia32_cnst(const ir_node *node) {
691         ia32_attr_t *attr = get_ia32_attr(node);
692         if (! attr->cnst)
693                 return NULL;
694         return get_id_str(attr->cnst);
695 }
696
697 /**
698  * Sets the string representation of the internal const.
699  */
700 void set_ia32_cnst(ir_node *node, const char *cnst) {
701         ia32_attr_t *attr = get_ia32_attr(node);
702         attr->cnst        = new_id_from_str(cnst);
703 }
704
705 /**
706  * Gets the ident representation of the internal const (tv or symconst)
707  */
708 ident *get_ia32_id_cnst(const ir_node *node) {
709         ia32_attr_t *attr = get_ia32_attr(node);
710         return attr->cnst;
711 }
712
713 /**
714  * Sets the ident representation of the internal const.
715  */
716 void set_ia32_id_cnst(ir_node *node, ident *cnst) {
717         ia32_attr_t *attr = get_ia32_attr(node);
718         attr->cnst        = cnst;
719 }
720
721 /**
722  * Sets the uses_frame flag.
723  */
724 void set_ia32_use_frame(ir_node *node) {
725         ia32_attr_t *attr    = get_ia32_attr(node);
726         attr->data.use_frame = 1;
727 }
728
729 /**
730  * Clears the uses_frame flag.
731  */
732 void clear_ia32_use_frame(ir_node *node) {
733         ia32_attr_t *attr    = get_ia32_attr(node);
734         attr->data.use_frame = 0;
735 }
736
737 /**
738  * Gets the uses_frame flag.
739  */
740 int is_ia32_use_frame(const ir_node *node) {
741         ia32_attr_t *attr = get_ia32_attr(node);
742         return attr->data.use_frame;
743 }
744
745 /**
746  * Sets node to commutative.
747  */
748 void set_ia32_commutative(ir_node *node) {
749         ia32_attr_t *attr         = get_ia32_attr(node);
750         attr->data.is_commutative = 1;
751 }
752
753 /**
754  * Sets node to non-commutative.
755  */
756 void clear_ia32_commutative(ir_node *node) {
757         ia32_attr_t *attr         = get_ia32_attr(node);
758         attr->data.is_commutative = 0;
759 }
760
761 /**
762  * Checks if node is commutative.
763  */
764 int is_ia32_commutative(const ir_node *node) {
765         ia32_attr_t *attr = get_ia32_attr(node);
766         return attr->data.is_commutative;
767 }
768
769 /**
770  * Sets node emit_cl.
771  */
772 void set_ia32_emit_cl(ir_node *node) {
773         ia32_attr_t *attr  = get_ia32_attr(node);
774         attr->data.emit_cl = 1;
775 }
776
777 /**
778  * Clears node emit_cl.
779  */
780 void clear_ia32_emit_cl(ir_node *node) {
781         ia32_attr_t *attr  = get_ia32_attr(node);
782         attr->data.emit_cl = 0;
783 }
784
785 /**
786  * Checks if node needs %cl.
787  */
788 int is_ia32_emit_cl(const ir_node *node) {
789         ia32_attr_t *attr = get_ia32_attr(node);
790         return attr->data.emit_cl;
791 }
792
793 /**
794  * Sets node got_lea.
795  */
796 void set_ia32_got_lea(ir_node *node) {
797         ia32_attr_t *attr  = get_ia32_attr(node);
798         attr->data.got_lea = 1;
799 }
800
801 /**
802  * Clears node got_lea.
803  */
804 void clear_ia32_got_lea(ir_node *node) {
805         ia32_attr_t *attr  = get_ia32_attr(node);
806         attr->data.got_lea = 0;
807 }
808
809 /**
810  * Checks if node got lea.
811  */
812 int is_ia32_got_lea(const ir_node *node) {
813         ia32_attr_t *attr = get_ia32_attr(node);
814         return attr->data.got_lea;
815 }
816
817 /**
818  * Sets node got_reload.
819  */
820 void set_ia32_got_reload(ir_node *node) {
821         ia32_attr_t *attr     = get_ia32_attr(node);
822         attr->data.got_reload = 1;
823 }
824
825 /**
826  * Clears node got_reload.
827  */
828 void clear_ia32_got_reload(ir_node *node) {
829         ia32_attr_t *attr     = get_ia32_attr(node);
830         attr->data.got_reload = 0;
831 }
832
833 /**
834  * Checks if node got reload.
835  */
836 int is_ia32_got_reload(const ir_node *node) {
837         ia32_attr_t *attr = get_ia32_attr(node);
838         return attr->data.got_reload;
839 }
840
841 /**
842  * Gets the mode of the stored/loaded value (only set for Store/Load)
843  */
844 ir_mode *get_ia32_ls_mode(const ir_node *node) {
845         ia32_attr_t *attr = get_ia32_attr(node);
846         return attr->ls_mode;
847 }
848
849 /**
850  * Sets the mode of the stored/loaded value (only set for Store/Load)
851  */
852 void set_ia32_ls_mode(ir_node *node, ir_mode *mode) {
853         ia32_attr_t *attr = get_ia32_attr(node);
854         attr->ls_mode     = mode;
855 }
856
857 /**
858  * Gets the mode of the result.
859  */
860 ir_mode *get_ia32_res_mode(const ir_node *node) {
861         ia32_attr_t *attr = get_ia32_attr(node);
862         return attr->res_mode;
863 }
864
865 /**
866  * Sets the mode of the result.
867  */
868 void set_ia32_res_mode(ir_node *node, ir_mode *mode) {
869         ia32_attr_t *attr = get_ia32_attr(node);
870         attr->res_mode    = mode;
871 }
872
873 /**
874  * Gets the frame entity assigned to this node.
875  */
876 ir_entity *get_ia32_frame_ent(const ir_node *node) {
877         ia32_attr_t *attr = get_ia32_attr(node);
878         return attr->frame_ent;
879 }
880
881 /**
882  * Sets the frame entity for this node.
883  */
884 void set_ia32_frame_ent(ir_node *node, ir_entity *ent) {
885         ia32_attr_t *attr = get_ia32_attr(node);
886         attr->frame_ent   = ent;
887         if(ent != NULL)
888                 set_ia32_use_frame(node);
889         else
890                 clear_ia32_use_frame(node);
891 }
892
893
894 /**
895  * Gets the instruction latency.
896  */
897 unsigned get_ia32_latency(const ir_node *node) {
898         ia32_attr_t *attr = get_ia32_attr(node);
899         return attr->latency;
900 }
901
902 /**
903 * Sets the instruction latency.
904 */
905 void set_ia32_latency(ir_node *node, unsigned latency) {
906         ia32_attr_t *attr = get_ia32_attr(node);
907         attr->latency     = latency;
908 }
909
910 /**
911  * Returns the argument register requirements of an ia32 node.
912  */
913 const ia32_register_req_t **get_ia32_in_req_all(const ir_node *node) {
914         ia32_attr_t *attr = get_ia32_attr(node);
915         return attr->in_req;
916 }
917
918 /**
919  * Sets the argument register requirements of an ia32 node.
920  */
921 void set_ia32_in_req_all(ir_node *node, const ia32_register_req_t **reqs) {
922         ia32_attr_t *attr = get_ia32_attr(node);
923         attr->in_req      = reqs;
924 }
925
926 /**
927  * Returns the result register requirements of an ia32 node.
928  */
929 const ia32_register_req_t **get_ia32_out_req_all(const ir_node *node) {
930         ia32_attr_t *attr = get_ia32_attr(node);
931         return attr->out_req;
932 }
933
934 /**
935  * Sets the result register requirements of an ia32 node.
936  */
937 void set_ia32_out_req_all(ir_node *node, const ia32_register_req_t **reqs) {
938         ia32_attr_t *attr = get_ia32_attr(node);
939         attr->out_req     = reqs;
940 }
941
942 /**
943  * Returns the argument register requirement at position pos of an ia32 node.
944  */
945 const ia32_register_req_t *get_ia32_in_req(const ir_node *node, int pos) {
946         ia32_attr_t *attr = get_ia32_attr(node);
947         return attr->in_req != NULL ? attr->in_req[pos] : NULL;
948 }
949
950 /**
951  * Returns the result register requirement at position pos of an ia32 node.
952  */
953 const ia32_register_req_t *get_ia32_out_req(const ir_node *node, int pos) {
954         ia32_attr_t *attr = get_ia32_attr(node);
955         return attr->out_req != NULL ? attr->out_req[pos] : NULL;
956 }
957
958 /**
959  * Sets the OUT register requirements at position pos.
960  */
961 void set_ia32_req_out(ir_node *node, const ia32_register_req_t *req, int pos) {
962         ia32_attr_t *attr  = get_ia32_attr(node);
963         attr->out_req[pos] = req;
964 }
965
966 /**
967  * Sets the IN register requirements at position pos.
968  */
969 void set_ia32_req_in(ir_node *node, const ia32_register_req_t *req, int pos) {
970         ia32_attr_t *attr = get_ia32_attr(node);
971         attr->in_req[pos] = req;
972 }
973
974 /**
975  * Returns the register flag of an ia32 node.
976  */
977 arch_irn_flags_t get_ia32_flags(const ir_node *node) {
978         ia32_attr_t *attr = get_ia32_attr(node);
979         return attr->data.flags;
980 }
981
982 /**
983  * Sets the register flag of an ia32 node.
984  */
985 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags) {
986         ia32_attr_t *attr = get_ia32_attr(node);
987         attr->data.flags  = flags;
988 }
989
990 /**
991  * Returns the result register slots of an ia32 node.
992  */
993 const arch_register_t **get_ia32_slots(const ir_node *node) {
994         ia32_attr_t *attr = get_ia32_attr(node);
995         return attr->slots;
996 }
997
998 /**
999  * Sets the number of results.
1000  */
1001 void set_ia32_n_res(ir_node *node, int n_res) {
1002         ia32_attr_t *attr = get_ia32_attr(node);
1003         attr->data.n_res  = n_res;
1004 }
1005
1006 /**
1007  * Returns the number of results.
1008  */
1009 int get_ia32_n_res(const ir_node *node) {
1010         ia32_attr_t *attr = get_ia32_attr(node);
1011         return attr->data.n_res;
1012 }
1013
1014 /**
1015  * Returns the flavour of an ia32 node,
1016  */
1017 ia32_op_flavour_t get_ia32_flavour(const ir_node *node) {
1018         ia32_attr_t *attr = get_ia32_attr(node);
1019         return attr->data.op_flav;
1020 }
1021
1022 /**
1023  * Sets the flavour of an ia32 node to flavour_Div/Mod/DivMod/Mul/Mulh.
1024  */
1025 void set_ia32_flavour(ir_node *node, ia32_op_flavour_t op_flav) {
1026         ia32_attr_t *attr  = get_ia32_attr(node);
1027         attr->data.op_flav = op_flav;
1028 }
1029
1030 /**
1031  * Returns the projnum code.
1032  */
1033 long get_ia32_pncode(const ir_node *node) {
1034         ia32_attr_t *attr = get_ia32_attr(node);
1035         return attr->pn_code;
1036 }
1037
1038 /**
1039  * Sets the projnum code
1040  */
1041 void set_ia32_pncode(ir_node *node, long code) {
1042         ia32_attr_t *attr = get_ia32_attr(node);
1043         attr->pn_code     = code;
1044 }
1045
1046 /**
1047  * Sets the flags for the n'th out.
1048  */
1049 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos) {
1050         ia32_attr_t *attr = get_ia32_attr(node);
1051         assert(pos < (int) attr->data.n_res && "Invalid OUT position.");
1052         attr->out_flags[pos] = flags;
1053 }
1054
1055 /**
1056  * Gets the flags for the n'th out.
1057  */
1058 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos) {
1059         ia32_attr_t *attr = get_ia32_attr(node);
1060         return pos < (int)attr->data.n_res ? attr->out_flags[pos] : arch_irn_flags_none;
1061 }
1062
1063 /**
1064  * Get the list of available execution units.
1065  */
1066 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node) {
1067         ia32_attr_t *attr = get_ia32_attr(node);
1068         return attr->exec_units;
1069 }
1070
1071 #ifndef NDEBUG
1072
1073 /**
1074  * Returns the name of the original ir node.
1075  */
1076 const char *get_ia32_orig_node(const ir_node *node) {
1077         ia32_attr_t *attr = get_ia32_attr(node);
1078         return attr->orig_node;
1079 }
1080
1081 /**
1082  * Sets the name of the original ir node.
1083  */
1084 void set_ia32_orig_node(ir_node *node, const char *name) {
1085         ia32_attr_t *attr = get_ia32_attr(node);
1086         attr->orig_node   = name;
1087 }
1088
1089 #endif /* NDEBUG */
1090
1091 /******************************************************************************************************
1092  *                      _       _         _   _           __                  _   _
1093  *                     (_)     | |       | | | |         / _|                | | (_)
1094  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
1095  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
1096  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
1097  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
1098  *     | |
1099  *     |_|
1100  ******************************************************************************************************/
1101
1102 /**
1103  * Gets the type of an ia32_Const.
1104  */
1105 unsigned get_ia32_Const_type(const ir_node *node) {
1106         ia32_attr_t *attr = get_ia32_attr(node);
1107
1108         assert(is_ia32_Cnst(node) && "Need ia32_Const to get type");
1109
1110         return attr->data.tp;
1111 }
1112
1113 /**
1114  * Sets the type of an ia32_Const.
1115  */
1116 void set_ia32_Const_type(ir_node *node, int type) {
1117         ia32_attr_t *attr = get_ia32_attr(node);
1118
1119         assert(is_ia32_Cnst(node) && "Need ia32_Const to set type");
1120         assert((type == ia32_Const || type == ia32_SymConst) && "Unsupported ia32_Const type");
1121
1122         attr->data.tp = type;
1123 }
1124
1125 /**
1126  * Copy the attributes from an ia32_Const to an Immop (Add_i, Sub_i, ...) node
1127  */
1128 void set_ia32_Immop_attr(ir_node *node, ir_node *cnst) {
1129         ia32_attr_t *na = get_ia32_attr(node);
1130         ia32_attr_t *ca = get_ia32_attr(cnst);
1131
1132         switch(get_ia32_Const_type(cnst)) {
1133                 case ia32_Const:
1134                         na->cnst_val.tv = ca->cnst_val.tv;
1135                         na->cnst        = ca->cnst;
1136                         set_ia32_immop_type(node, ia32_ImmConst);
1137                         break;
1138                 case ia32_SymConst:
1139                         na->cnst_val.sc = ca->cnst_val.sc;
1140                         na->cnst        = na->cnst_val.sc;
1141                         set_ia32_immop_type(node, ia32_ImmSymConst);
1142                         break;
1143                 default:
1144                         assert(0 && "Need ia32_Const to set Immop attr");
1145         }
1146 }
1147
1148 /**
1149  * Copy the attributes from Immop to an Immop
1150  */
1151 void copy_ia32_Immop_attr(ir_node *dst, ir_node *src) {
1152         ia32_attr_t *da = get_ia32_attr(dst);
1153         ia32_attr_t *sa = get_ia32_attr(src);
1154
1155         switch(get_ia32_immop_type(src)) {
1156                 case ia32_ImmConst:
1157                         da->cnst_val.tv = sa->cnst_val.tv;
1158                         da->cnst        = sa->cnst;
1159                         set_ia32_immop_type(dst, ia32_ImmConst);
1160                         break;
1161                 case ia32_ImmSymConst:
1162                         da->cnst_val.sc = sa->cnst_val.sc;
1163                         da->cnst        = sa->cnst;
1164                         set_ia32_immop_type(dst, ia32_ImmSymConst);
1165                         break;
1166                 default:
1167                         assert(0 && "Need Immop to copy Immop attr");
1168         }
1169 }
1170
1171 /**
1172  * Copy the attributes from a Firm Const/SymConst to an ia32_Const
1173  */
1174 void set_ia32_Const_attr(ir_node *ia32_cnst, ir_node *cnst) {
1175         ia32_attr_t *attr = get_ia32_attr(ia32_cnst);
1176         ir_mode *mode;
1177
1178         assert(is_ia32_Cnst(ia32_cnst) && "Need ia32_Const to set Const attr");
1179
1180         switch (get_irn_opcode(cnst)) {
1181                 case iro_Const:
1182                         attr->data.tp     = ia32_Const;
1183                         attr->cnst_val.tv = get_Const_tarval(cnst);
1184                         mode = get_tarval_mode(attr->cnst_val.tv);
1185                         if (mode_is_reference(mode) &&
1186                             get_mode_null(mode) == attr->cnst_val.tv) {
1187                                 attr->cnst_val.tv = get_mode_null(mode_Iu);
1188                         }
1189                         attr->cnst        = get_ident_for_tv(attr->cnst_val.tv);
1190                         break;
1191                 case iro_SymConst:
1192                         attr->data.tp     = ia32_SymConst;
1193                         attr->cnst_val.sc = get_sc_ident(cnst);
1194                         attr->cnst        = attr->cnst_val.sc;
1195                         break;
1196                 case iro_Unknown:
1197                         assert(0 && "Unknown Const NYI");
1198                         break;
1199                 default:
1200                         assert(0 && "Cannot create ia32_Const for this opcode");
1201         }
1202 }
1203
1204 /**
1205  * Sets the AddrMode(S|D) attribute
1206  */
1207 void set_ia32_AddrMode(ir_node *node, char direction) {
1208         ia32_attr_t *attr = get_ia32_attr(node);
1209
1210         switch (direction) {
1211                 case 'D':
1212                         attr->data.tp = ia32_AddrModeD;
1213                         break;
1214                 case 'S':
1215                         attr->data.tp = ia32_AddrModeS;
1216                         break;
1217                 default:
1218                         assert(0 && "wrong AM type");
1219         }
1220 }
1221
1222 /**
1223  * Returns whether or not the node is an immediate operation with Const.
1224  */
1225 int is_ia32_ImmConst(const ir_node *node) {
1226         ia32_attr_t *attr = get_ia32_attr(node);
1227         return (attr->data.imm_tp == ia32_ImmConst);
1228 }
1229
1230 /**
1231  * Returns whether or not the node is an immediate operation with SymConst.
1232  */
1233 int is_ia32_ImmSymConst(const ir_node *node) {
1234         ia32_attr_t *attr = get_ia32_attr(node);
1235         return (attr->data.imm_tp == ia32_ImmSymConst);
1236 }
1237
1238 /**
1239  * Returns whether or not the node is an AddrModeS node.
1240  */
1241 int is_ia32_AddrModeS(const ir_node *node) {
1242         ia32_attr_t *attr = get_ia32_attr(node);
1243         return (attr->data.tp == ia32_AddrModeS);
1244 }
1245
1246 /**
1247  * Returns whether or not the node is an AddrModeD node.
1248  */
1249 int is_ia32_AddrModeD(const ir_node *node) {
1250         ia32_attr_t *attr = get_ia32_attr(node);
1251         return (attr->data.tp == ia32_AddrModeD);
1252 }
1253
1254 /**
1255  * Checks if node is a Load or xLoad/vfLoad.
1256  */
1257 int is_ia32_Ld(const ir_node *node) {
1258         int op = get_ia32_irn_opcode(node);
1259         return op == iro_ia32_Load || op == iro_ia32_xLoad || op == iro_ia32_vfld || op == iro_ia32_fld;
1260 }
1261
1262 /**
1263  * Checks if node is a Store or xStore/vfStore.
1264  */
1265 int is_ia32_St(const ir_node *node) {
1266         int op = get_ia32_irn_opcode(node);
1267         return op == iro_ia32_Store || op == iro_ia32_xStore || op == iro_ia32_vfst || op == iro_ia32_fst || op == iro_ia32_fstp;
1268 }
1269
1270 /**
1271  * Checks if node is a Const or xConst/vfConst.
1272  */
1273 int is_ia32_Cnst(const ir_node *node) {
1274         int op = get_ia32_irn_opcode(node);
1275         return op == iro_ia32_Const || op == iro_ia32_xConst || op == iro_ia32_vfConst;
1276 }
1277
1278 /**
1279  * Returns the name of the OUT register at position pos.
1280  */
1281 const char *get_ia32_out_reg_name(const ir_node *node, int pos) {
1282         ia32_attr_t *attr = get_ia32_attr(node);
1283
1284         assert(pos < (int) attr->data.n_res && "Invalid OUT position.");
1285         assert(attr->slots[pos]  && "No register assigned");
1286
1287         return arch_register_get_name(attr->slots[pos]);
1288 }
1289
1290 /**
1291  * Returns the index of the OUT register at position pos within its register class.
1292  */
1293 int get_ia32_out_regnr(const ir_node *node, int pos) {
1294         ia32_attr_t *attr = get_ia32_attr(node);
1295
1296         assert(pos < (int) attr->data.n_res && "Invalid OUT position.");
1297         assert(attr->slots[pos]  && "No register assigned");
1298
1299         return arch_register_get_index(attr->slots[pos]);
1300 }
1301
1302 /**
1303  * Returns the OUT register at position pos.
1304  */
1305 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos) {
1306         ia32_attr_t *attr = get_ia32_attr(node);
1307
1308         assert(pos < (int) attr->data.n_res && "Invalid OUT position.");
1309         assert(attr->slots[pos]  && "No register assigned");
1310
1311         return attr->slots[pos];
1312 }
1313
1314 /**
1315  * Initializes the nodes attributes.
1316  */
1317 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags, const ia32_register_req_t **in_reqs,
1318                                                   const ia32_register_req_t **out_reqs, const be_execution_unit_t ***execution_units,
1319                                                   int n_res, unsigned latency)
1320 {
1321         ia32_attr_t *attr = get_ia32_attr(node);
1322
1323         set_ia32_flags(node, flags);
1324         set_ia32_in_req_all(node, in_reqs);
1325         set_ia32_out_req_all(node, out_reqs);
1326         set_ia32_latency(node, latency);
1327         set_ia32_n_res(node, n_res);
1328
1329         attr->exec_units = execution_units;
1330
1331         attr->out_flags = NEW_ARR_D(int, get_irg_obstack(get_irn_irg(node)), n_res);
1332         memset(attr->out_flags, 0, n_res * sizeof(attr->out_flags[0]));
1333
1334         memset((void *)attr->slots, 0, n_res * sizeof(attr->slots[0]));
1335 }
1336
1337 ir_node *get_ia32_result_proj(const ir_node *node)
1338 {
1339         const ir_edge_t *edge;
1340
1341         foreach_out_edge(node, edge) {
1342                 ir_node *proj = get_edge_src_irn(edge);
1343                 if(get_Proj_proj(proj) == 0) {
1344                         return proj;
1345                 }
1346         }
1347         return NULL;
1348 }
1349
1350 ir_mode *get_ia32_Conv_src_mode(const ir_node *node)
1351 {
1352         if(get_ia32_op_type(node) == ia32_AddrModeS) {
1353                 return get_ia32_ls_mode(node);
1354         }
1355
1356         return get_irn_mode(get_irn_n(node, 2));
1357 }
1358
1359 ir_mode *get_ia32_Conv_tgt_mode(const ir_node *node)
1360 {
1361         return get_irn_mode(node);
1362 }
1363
1364 /***************************************************************************************
1365  *                  _                            _                   _
1366  *                 | |                          | |                 | |
1367  *  _ __   ___   __| | ___    ___ ___  _ __  ___| |_ _ __ _   _  ___| |_ ___  _ __ ___
1368  * | '_ \ / _ \ / _` |/ _ \  / __/ _ \| '_ \/ __| __| '__| | | |/ __| __/ _ \| '__/ __|
1369  * | | | | (_) | (_| |  __/ | (_| (_) | | | \__ \ |_| |  | |_| | (__| || (_) | |  \__ \
1370  * |_| |_|\___/ \__,_|\___|  \___\___/|_| |_|___/\__|_|   \__,_|\___|\__\___/|_|  |___/
1371  *
1372  ***************************************************************************************/
1373
1374 /* default compare operation to compare immediate ops */
1375 int ia32_compare_immop_attr(ia32_attr_t *a, ia32_attr_t *b) {
1376         int equ = 0;
1377
1378         if (a->data.tp != b->data.tp)
1379                 return 1;
1380
1381         if (a->cnst != b->cnst)
1382                 return 1;
1383
1384         if (a->data.use_frame != b->data.use_frame)
1385                 return 1;
1386
1387         if (a->data.use_frame && a->frame_ent != b->frame_ent)
1388                 return 1;
1389
1390         if (a->data.am_flavour != b->data.am_flavour
1391                         || a->data.am_scale != b->data.am_scale
1392                         || a->data.offs_sign != b->data.offs_sign
1393                         || a->data.am_sc_sign != b->data.am_sc_sign
1394                         || a->am_offs != b->am_offs
1395                         || a->am_sc != b->am_sc)
1396                 return 1;
1397
1398         if(a->pn_code != b->pn_code)
1399                 return 1;
1400
1401         return !equ;
1402 }
1403
1404 /* copies the ia32 attributes */
1405 static void ia32_copy_attr(const ir_node *old_node, ir_node *new_node) {
1406         ia32_attr_t *attr_old = get_ia32_attr(old_node);
1407         ia32_attr_t *attr_new = get_ia32_attr(new_node);
1408
1409         /* copy the attributes */
1410         memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
1411
1412         /* copy out flags */
1413         DUP_ARR_D(int, get_irg_obstack(get_irn_irg(new_node)), attr_old->out_flags);
1414 }
1415
1416 /**
1417  * Registers the ia32_copy_attr function for all ia32 opcodes.
1418  */
1419 void ia32_register_copy_attr_func(void) {
1420         unsigned i, f = get_ia32_opcode_first(), l = get_ia32_opcode_last();
1421
1422         for (i = f; i < l; i++) {
1423                 ir_op *op = get_irp_opcode(i);
1424                 op->ops.copy_attr = ia32_copy_attr;
1425         }
1426 }
1427
1428 /* Include the generated constructor functions */
1429 #include "gen_ia32_new_nodes.c.inl"