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