f58c3a95d45627a7ddd9547e389d85c5e72bb416
[libfirm] / ir / be / ia32 / ia32_new_nodes.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Handling of ia32 specific firm opcodes.
23  * @author      Christian Wuerdig
24  * @version     $Id$
25  *
26  * This file implements the creation of the achitecture specific firm opcodes
27  * and the corresponding node constructors for the ia32 assembler irg.
28  */
29 #include "config.h"
30
31 #include <stdlib.h>
32
33 #include "irprog_t.h"
34 #include "irgraph_t.h"
35 #include "irnode_t.h"
36 #include "irmode_t.h"
37 #include "ircons_t.h"
38 #include "iropt_t.h"
39 #include "irop.h"
40 #include "firm_common_t.h"
41 #include "irvrfy_t.h"
42 #include "irprintf.h"
43 #include "iredges.h"
44 #include "error.h"
45 #include "raw_bitset.h"
46 #include "xmalloc.h"
47
48 #include "../bearch_t.h"
49
50 #include "bearch_ia32_t.h"
51 #include "ia32_nodes_attr.h"
52 #include "ia32_new_nodes.h"
53 #include "gen_ia32_regalloc_if.h"
54 #include "gen_ia32_machine.h"
55
56 /***********************************************************************************
57  *      _                                   _       _             __
58  *     | |                                 (_)     | |           / _|
59  *   __| |_   _ _ __ ___  _ __   ___ _ __   _ _ __ | |_ ___ _ __| |_ __ _  ___ ___
60  *  / _` | | | | '_ ` _ \| '_ \ / _ \ '__| | | '_ \| __/ _ \ '__|  _/ _` |/ __/ _ \
61  * | (_| | |_| | | | | | | |_) |  __/ |    | | | | | ||  __/ |  | || (_| | (_|  __/
62  *  \__,_|\__,_|_| |_| |_| .__/ \___|_|    |_|_| |_|\__\___|_|  |_| \__,_|\___\___|
63  *                       | |
64  *                       |_|
65  ***********************************************************************************/
66
67 /**
68  * Dumps the register requirements for either in or out.
69  */
70 static void dump_reg_req(FILE *F, ir_node *n, const arch_register_req_t **reqs,
71                          int inout) {
72         char *dir = inout ? "out" : "in";
73         int   max = inout ? get_ia32_n_res(n) : get_irn_arity(n);
74         char  buf[1024];
75         int   i;
76
77         memset(buf, 0, sizeof(buf));
78
79         if (reqs) {
80                 for (i = 0; i < max; i++) {
81                         fprintf(F, "%sreq #%d =", dir, i);
82
83                         if (reqs[i]->type == arch_register_req_type_none) {
84                                 fprintf(F, " n/a");
85                         }
86
87                         if (reqs[i]->type & arch_register_req_type_normal) {
88                                 fprintf(F, " %s", reqs[i]->cls->name);
89                         }
90
91                         if (reqs[i]->type & arch_register_req_type_limited) {
92                                 fprintf(F, " %s",
93                                         arch_register_req_format(buf, sizeof(buf), reqs[i], n));
94                         }
95
96                         if (reqs[i]->type & arch_register_req_type_should_be_same) {
97                                 unsigned other = reqs[i]->other_same;
98                                 int i;
99
100                                 ir_fprintf(F, " same as");
101                                 for (i = 0; 1U << i <= other; ++i) {
102                                         if (other & (1U << i)) {
103                                                 ir_fprintf(F, " %+F", get_irn_n(n, i));
104                                         }
105                                 }
106                         }
107
108                         if (reqs[i]->type & arch_register_req_type_must_be_different) {
109                                 unsigned other = reqs[i]->other_different;
110                                 int i;
111
112                                 ir_fprintf(F, " different from");
113                                 for (i = 0; 1U << i <= other; ++i) {
114                                         if (other & (1U << i)) {
115                                                 ir_fprintf(F, " %+F", get_irn_n(n, i));
116                                         }
117                                 }
118                         }
119
120                         fprintf(F, "\n");
121                 }
122
123                 fprintf(F, "\n");
124         }
125         else {
126                 fprintf(F, "%sreq = N/A\n", dir);
127         }
128 }
129
130 /**
131  * Dumper interface for dumping ia32 nodes in vcg.
132  * @param n        the node to dump
133  * @param F        the output file
134  * @param reason   indicates which kind of information should be dumped
135  * @return 0 on success or != 0 on failure
136  */
137 static int ia32_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
138         ir_mode     *mode = NULL;
139         int          bad  = 0;
140         int          i, n_res, flags;
141         const arch_register_req_t **reqs;
142         const arch_register_t     **slots;
143
144         switch (reason) {
145                 case dump_node_opcode_txt:
146                         fprintf(F, "%s", get_irn_opname(n));
147
148                         if(is_ia32_Immediate(n) || is_ia32_Const(n)) {
149                                 const ia32_immediate_attr_t *attr
150                                         = get_ia32_immediate_attr_const(n);
151
152                                 fputc(' ', F);
153                                 if(attr->symconst) {
154                                         if(attr->sc_sign) {
155                                                 fputc('-', F);
156                                         }
157                                         fputs(get_entity_name(attr->symconst), F);
158                                 }
159                                 if(attr->offset != 0 || attr->symconst == NULL) {
160                                         if(attr->offset > 0 && attr->symconst != NULL) {
161                                                 fputc('+', F);
162                                         }
163                                         fprintf(F, "%ld", attr->offset);
164                                 }
165                         }
166                         else {
167                                 const ia32_attr_t *attr = get_ia32_attr_const(n);
168
169                                 if(attr->am_sc != NULL || attr->am_offs != 0)
170                                         fputs(" [", F);
171
172                                 if(attr->am_sc != NULL) {
173                                         if(attr->data.am_sc_sign) {
174                                                 fputc('-', F);
175                                         }
176                                         fputs(get_entity_name(attr->am_sc), F);
177                                 }
178                                 if(attr->am_offs != 0) {
179                                         if(attr->am_offs > 0 && attr->am_sc != NULL) {
180                                                 fputc('+', F);
181                                         }
182                                         fprintf(F, "%d", attr->am_offs);
183                                 }
184
185                                 if(attr->am_sc != NULL || attr->am_offs != 0)
186                                         fputc(']', F);
187                         }
188                         break;
189
190                 case dump_node_mode_txt:
191                         if (is_ia32_Ld(n) || is_ia32_St(n)) {
192                                 mode = get_ia32_ls_mode(n);
193                                 fprintf(F, "[%s]", mode ? get_mode_name(mode) : "?NOMODE?");
194                         }
195                         break;
196
197                 case dump_node_nodeattr_txt:
198                         if (! is_ia32_Lea(n)) {
199                                 if (is_ia32_AddrModeS(n)) {
200                                         fprintf(F, "[AM S] ");
201                                 } else if (is_ia32_AddrModeD(n)) {
202                                         fprintf(F, "[AM D] ");
203                                 }
204                         }
205
206                         break;
207
208                 case dump_node_info_txt:
209                         n_res = get_ia32_n_res(n);
210                         fprintf(F, "=== IA32 attr begin ===\n");
211
212                         /* dump IN requirements */
213                         if (get_irn_arity(n) > 0) {
214                                 reqs = get_ia32_in_req_all(n);
215                                 dump_reg_req(F, n, reqs, 0);
216                         }
217
218                         /* dump OUT requirements */
219                         if (n_res > 0) {
220                                 reqs = get_ia32_out_req_all(n);
221                                 dump_reg_req(F, n, reqs, 1);
222                         }
223
224                         /* dump assigned registers */
225                         slots = get_ia32_slots(n);
226                         if (slots && n_res > 0) {
227                                 for (i = 0; i < n_res; i++) {
228                                         const arch_register_t *reg;
229
230                                         reg = slots[i];
231
232                                         fprintf(F, "reg #%d = %s\n", i, reg ? arch_register_get_name(reg) : "n/a");
233                                 }
234                                 fprintf(F, "\n");
235                         }
236
237                         /* dump op type */
238                         fprintf(F, "op = ");
239                         switch (get_ia32_op_type(n)) {
240                                 case ia32_Normal:
241                                         fprintf(F, "Normal");
242                                         break;
243                                 case ia32_AddrModeD:
244                                         fprintf(F, "AM Dest (Load+Store)");
245                                         break;
246                                 case ia32_AddrModeS:
247                                         fprintf(F, "AM Source (Load)");
248                                         break;
249                                 default:
250                                         fprintf(F, "unknown (%d)", get_ia32_op_type(n));
251                                         break;
252                         }
253                         fprintf(F, "\n");
254
255                         /* dump supported am */
256                         fprintf(F, "AM support = ");
257                         switch (get_ia32_am_support(n)) {
258                                 case ia32_am_none:   fputs("none\n",            F); break;
259                                 case ia32_am_unary:  fputs("source (unary)\n",  F); break;
260                                 case ia32_am_binary: fputs("source (binary)\n", F); break;
261
262                                 default:
263                                         fprintf(F, "unknown (%d)\n", get_ia32_am_support(n));
264                                         break;
265                         }
266
267                         /* dump AM offset */
268                         if(get_ia32_am_offs_int(n) != 0) {
269                                 fprintf(F, "AM offset = %d\n", get_ia32_am_offs_int(n));
270                         }
271
272                         /* dump AM symconst */
273                         if(get_ia32_am_sc(n) != NULL) {
274                                 ir_entity *ent = get_ia32_am_sc(n);
275                                 ident *id = get_entity_ld_ident(ent);
276                                 fprintf(F, "AM symconst = %s\n", get_id_str(id));
277                         }
278
279                         /* dump AM scale */
280                         fprintf(F, "AM scale = %d\n", get_ia32_am_scale(n));
281
282                         /* dump pn code */
283                         if (is_ia32_SwitchJmp(n)) {
284                                 fprintf(F, "pn_code = %ld\n", get_ia32_condcode(n));
285                         } else if (is_ia32_CMov(n) || is_ia32_Set(n) || is_ia32_Jcc(n)) {
286                                 ia32_attr_t *attr = get_ia32_attr(n);
287                                 long pnc = get_ia32_condcode(n);
288                                 fprintf(F, "pn_code = 0x%lX (%s)\n", pnc, get_pnc_string(pnc & pn_Cmp_True));
289                                 fprintf(F, "ins_permuted = %u \n", attr->data.ins_permuted);
290                                 fprintf(F, "cmp_unsigned = %u \n", attr->data.cmp_unsigned);
291                         }
292                         else if (is_ia32_CopyB(n) || is_ia32_CopyB_i(n)) {
293                                 fprintf(F, "size = %u\n", get_ia32_copyb_size(n));
294                         }
295
296                         fprintf(F, "n_res = %d\n", get_ia32_n_res(n));
297                         fprintf(F, "use_frame = %d\n", is_ia32_use_frame(n));
298                         fprintf(F, "commutative = %d\n", is_ia32_commutative(n));
299                         fprintf(F, "need stackent = %d\n", is_ia32_need_stackent(n));
300                         fprintf(F, "is reload = %d\n", is_ia32_is_reload(n));
301                         fprintf(F, "latency = %d\n", get_ia32_latency(n));
302
303                         /* dump flags */
304                         fprintf(F, "flags =");
305                         flags = get_ia32_flags(n);
306                         if (flags == arch_irn_flags_none) {
307                                 fprintf(F, " none");
308                         }
309                         else {
310                                 if (flags & arch_irn_flags_dont_spill) {
311                                         fprintf(F, " unspillable");
312                                 }
313                                 if (flags & arch_irn_flags_rematerializable) {
314                                         fprintf(F, " remat");
315                                 }
316                                 if (flags & arch_irn_flags_ignore) {
317                                         fprintf(F, " ignore");
318                                 }
319                                 if (flags & arch_irn_flags_modify_sp) {
320                                         fprintf(F, " modify_sp");
321                                 }
322                                 if (flags & arch_irn_flags_modify_flags) {
323                                         fprintf(F, " modify_flags");
324                                 }
325                         }
326                         fprintf(F, " (%d)\n", flags);
327
328                         /* dump frame entity */
329                         fprintf(F, "frame entity = ");
330                         if (get_ia32_frame_ent(n)) {
331                                 ir_fprintf(F, "%+F", get_ia32_frame_ent(n));
332                         }
333                         else {
334                                 fprintf(F, "n/a");
335                         }
336                         fprintf(F, "\n");
337
338                         /* dump modes */
339                         fprintf(F, "ls_mode = ");
340                         if (get_ia32_ls_mode(n)) {
341                                 ir_fprintf(F, "%+F", get_ia32_ls_mode(n));
342                         }
343                         else {
344                                 fprintf(F, "n/a");
345                         }
346                         fprintf(F, "\n");
347
348 #ifndef NDEBUG
349                         /* dump original ir node name */
350                         fprintf(F, "orig node = ");
351                         if (get_ia32_orig_node(n)) {
352                                 fprintf(F, "%s", get_ia32_orig_node(n));
353                         }
354                         else {
355                                 fprintf(F, "n/a");
356                         }
357                         fprintf(F, "\n");
358 #endif /* NDEBUG */
359
360                         fprintf(F, "=== IA32 attr end ===\n");
361                         /* end of: case dump_node_info_txt */
362                         break;
363         }
364
365         return bad;
366 }
367
368
369
370 /***************************************************************************************************
371  *        _   _                   _       __        _                    _   _               _
372  *       | | | |                 | |     / /       | |                  | | | |             | |
373  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
374  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
375  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
376  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
377  *                                        __/ |
378  *                                       |___/
379  ***************************************************************************************************/
380
381 ia32_attr_t *get_ia32_attr(ir_node *node) {
382         assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes");
383         return (ia32_attr_t *)get_irn_generic_attr(node);
384 }
385
386 const ia32_attr_t *get_ia32_attr_const(const ir_node *node) {
387         assert(is_ia32_irn(node) && "need ia32 node to get ia32 attributes");
388         return (const ia32_attr_t*) get_irn_generic_attr_const(node);
389 }
390
391 ia32_x87_attr_t *get_ia32_x87_attr(ir_node *node) {
392         ia32_attr_t     *attr     = get_ia32_attr(node);
393         ia32_x87_attr_t *x87_attr = CAST_IA32_ATTR(ia32_x87_attr_t, attr);
394         return x87_attr;
395 }
396
397 const ia32_x87_attr_t *get_ia32_x87_attr_const(const ir_node *node) {
398         const ia32_attr_t     *attr     = get_ia32_attr_const(node);
399         const ia32_x87_attr_t *x87_attr = CONST_CAST_IA32_ATTR(ia32_x87_attr_t, attr);
400         return x87_attr;
401 }
402
403 const ia32_asm_attr_t *get_ia32_asm_attr_const(const ir_node *node) {
404         const ia32_attr_t     *attr     = get_ia32_attr_const(node);
405         const ia32_asm_attr_t *asm_attr = CONST_CAST_IA32_ATTR(ia32_asm_attr_t, attr);
406
407         return asm_attr;
408 }
409
410 ia32_immediate_attr_t *get_ia32_immediate_attr(ir_node *node) {
411         ia32_attr_t           *attr      = get_ia32_attr(node);
412         ia32_immediate_attr_t *imm_attr  = CAST_IA32_ATTR(ia32_immediate_attr_t, attr);
413
414         return imm_attr;
415 }
416
417 const ia32_immediate_attr_t *get_ia32_immediate_attr_const(const ir_node *node)
418 {
419         const ia32_attr_t           *attr     = get_ia32_attr_const(node);
420         const ia32_immediate_attr_t *imm_attr = CONST_CAST_IA32_ATTR(ia32_immediate_attr_t, attr);
421
422         return imm_attr;
423 }
424
425 ia32_condcode_attr_t *get_ia32_condcode_attr(ir_node *node) {
426         ia32_attr_t          *attr    = get_ia32_attr(node);
427         ia32_condcode_attr_t *cc_attr = CAST_IA32_ATTR(ia32_condcode_attr_t, attr);
428
429         return cc_attr;
430 }
431
432 const ia32_condcode_attr_t *get_ia32_condcode_attr_const(const ir_node *node) {
433         const ia32_attr_t          *attr    = get_ia32_attr_const(node);
434         const ia32_condcode_attr_t *cc_attr = CONST_CAST_IA32_ATTR(ia32_condcode_attr_t, attr);
435
436         return cc_attr;
437 }
438
439 ia32_call_attr_t *get_ia32_call_attr(ir_node *node)
440 {
441         ia32_attr_t      *attr      = get_ia32_attr(node);
442         ia32_call_attr_t *call_attr = CAST_IA32_ATTR(ia32_call_attr_t, attr);
443
444         return call_attr;
445 }
446
447 const ia32_call_attr_t *get_ia32_call_attr_const(const ir_node *node)
448 {
449         const ia32_attr_t      *attr      = get_ia32_attr_const(node);
450         const ia32_call_attr_t *call_attr = CONST_CAST_IA32_ATTR(ia32_call_attr_t, attr);
451
452         return call_attr;
453 }
454
455 ia32_copyb_attr_t *get_ia32_copyb_attr(ir_node *node) {
456         ia32_attr_t       *attr       = get_ia32_attr(node);
457         ia32_copyb_attr_t *copyb_attr = CAST_IA32_ATTR(ia32_copyb_attr_t, attr);
458
459         return copyb_attr;
460 }
461
462 const ia32_copyb_attr_t *get_ia32_copyb_attr_const(const ir_node *node) {
463         const ia32_attr_t       *attr       = get_ia32_attr_const(node);
464         const ia32_copyb_attr_t *copyb_attr = CONST_CAST_IA32_ATTR(ia32_copyb_attr_t, attr);
465
466         return copyb_attr;
467 }
468
469 /**
470  * Gets the type of an ia32 node.
471  */
472 ia32_op_type_t get_ia32_op_type(const ir_node *node) {
473         const ia32_attr_t *attr = get_ia32_attr_const(node);
474         return attr->data.tp;
475 }
476
477 /**
478  * Sets the type of an ia32 node.
479  */
480 void set_ia32_op_type(ir_node *node, ia32_op_type_t tp) {
481         ia32_attr_t *attr = get_ia32_attr(node);
482         attr->data.tp     = tp;
483 }
484
485 ia32_am_type_t get_ia32_am_support(const ir_node *node)
486 {
487         const ia32_attr_t *attr = get_ia32_attr_const(node);
488         return attr->data.am_arity;
489 }
490
491 /**
492  * Sets the supported address mode of an ia32 node
493  */
494 void set_ia32_am_support(ir_node *node, ia32_am_type_t arity)
495 {
496         ia32_attr_t *attr   = get_ia32_attr(node);
497         attr->data.am_arity = arity;
498 }
499
500 /**
501  * Gets the address mode offset as int.
502  */
503 int get_ia32_am_offs_int(const ir_node *node) {
504         const ia32_attr_t *attr = get_ia32_attr_const(node);
505         return attr->am_offs;
506 }
507
508 /**
509  * Sets the address mode offset from an int.
510  */
511 void set_ia32_am_offs_int(ir_node *node, int offset) {
512         ia32_attr_t *attr = get_ia32_attr(node);
513         attr->am_offs = offset;
514 }
515
516 void add_ia32_am_offs_int(ir_node *node, int offset) {
517         ia32_attr_t *attr = get_ia32_attr(node);
518         attr->am_offs += offset;
519 }
520
521 /**
522  * Returns the symconst entity associated to address mode.
523  */
524 ir_entity *get_ia32_am_sc(const ir_node *node) {
525         const ia32_attr_t *attr = get_ia32_attr_const(node);
526         return attr->am_sc;
527 }
528
529 /**
530  * Sets the symconst entity associated to address mode.
531  */
532 void set_ia32_am_sc(ir_node *node, ir_entity *entity) {
533         ia32_attr_t *attr = get_ia32_attr(node);
534         attr->am_sc       = entity;
535 }
536
537 /**
538  * Sets the sign bit for address mode symconst.
539  */
540 void set_ia32_am_sc_sign(ir_node *node) {
541         ia32_attr_t *attr     = get_ia32_attr(node);
542         attr->data.am_sc_sign = 1;
543 }
544
545 /**
546  * Clears the sign bit for address mode symconst.
547  */
548 void clear_ia32_am_sc_sign(ir_node *node) {
549         ia32_attr_t *attr     = get_ia32_attr(node);
550         attr->data.am_sc_sign = 0;
551 }
552
553 /**
554  * Returns the sign bit for address mode symconst.
555  */
556 int is_ia32_am_sc_sign(const ir_node *node) {
557         const ia32_attr_t *attr = get_ia32_attr_const(node);
558         return attr->data.am_sc_sign;
559 }
560
561 /**
562  * Gets the addr mode const.
563  */
564 int get_ia32_am_scale(const ir_node *node) {
565         const ia32_attr_t *attr = get_ia32_attr_const(node);
566         return attr->data.am_scale;
567 }
568
569 /**
570  * Sets the index register scale for address mode.
571  */
572 void set_ia32_am_scale(ir_node *node, int scale) {
573         ia32_attr_t *attr = get_ia32_attr(node);
574         assert(0 <= scale && scale < 4 && "AM scale out of range");
575         attr->data.am_scale = scale;
576 }
577
578 void ia32_copy_am_attrs(ir_node *to, const ir_node *from)
579 {
580         set_ia32_ls_mode(to, get_ia32_ls_mode(from));
581         set_ia32_am_scale(to, get_ia32_am_scale(from));
582         set_ia32_am_sc(to, get_ia32_am_sc(from));
583         if(is_ia32_am_sc_sign(from))
584                 set_ia32_am_sc_sign(to);
585         add_ia32_am_offs_int(to, get_ia32_am_offs_int(from));
586         set_ia32_frame_ent(to, get_ia32_frame_ent(from));
587         if (is_ia32_use_frame(from))
588                 set_ia32_use_frame(to);
589 }
590
591 /**
592  * Sets the uses_frame flag.
593  */
594 void set_ia32_use_frame(ir_node *node) {
595         ia32_attr_t *attr    = get_ia32_attr(node);
596         attr->data.use_frame = 1;
597 }
598
599 /**
600  * Clears the uses_frame flag.
601  */
602 void clear_ia32_use_frame(ir_node *node) {
603         ia32_attr_t *attr    = get_ia32_attr(node);
604         attr->data.use_frame = 0;
605 }
606
607 /**
608  * Gets the uses_frame flag.
609  */
610 int is_ia32_use_frame(const ir_node *node) {
611         const ia32_attr_t *attr = get_ia32_attr_const(node);
612         return attr->data.use_frame;
613 }
614
615 /**
616  * Sets node to commutative.
617  */
618 void set_ia32_commutative(ir_node *node) {
619         ia32_attr_t *attr         = get_ia32_attr(node);
620         attr->data.is_commutative = 1;
621 }
622
623 /**
624  * Sets node to non-commutative.
625  */
626 void clear_ia32_commutative(ir_node *node) {
627         ia32_attr_t *attr         = get_ia32_attr(node);
628         attr->data.is_commutative = 0;
629 }
630
631 /**
632  * Checks if node is commutative.
633  */
634 int is_ia32_commutative(const ir_node *node) {
635         const ia32_attr_t *attr = get_ia32_attr_const(node);
636         return attr->data.is_commutative;
637 }
638
639 void set_ia32_need_stackent(ir_node *node) {
640         ia32_attr_t *attr     = get_ia32_attr(node);
641         attr->data.need_stackent = 1;
642 }
643
644 void clear_ia32_need_stackent(ir_node *node) {
645         ia32_attr_t *attr     = get_ia32_attr(node);
646         attr->data.need_stackent = 0;
647 }
648
649 int is_ia32_need_stackent(const ir_node *node) {
650         const ia32_attr_t *attr = get_ia32_attr_const(node);
651         return attr->data.need_stackent;
652 }
653
654 void set_ia32_is_reload(ir_node *node) {
655         ia32_attr_t *attr = get_ia32_attr(node);
656         attr->data.is_reload = 1;
657 }
658
659 int is_ia32_is_reload(const ir_node *node) {
660         const ia32_attr_t *attr = get_ia32_attr_const(node);
661         return attr->data.is_reload;
662 }
663
664 void set_ia32_is_spill(ir_node *node) {
665         ia32_attr_t *attr = get_ia32_attr(node);
666         attr->data.is_spill = 1;
667 }
668
669 int is_ia32_is_spill(const ir_node *node) {
670         const ia32_attr_t *attr = get_ia32_attr_const(node);
671         return attr->data.is_spill;
672 }
673
674 void set_ia32_is_remat(ir_node *node) {
675         ia32_attr_t *attr = get_ia32_attr(node);
676         attr->data.is_remat = 1;
677 }
678
679 int is_ia32_is_remat(const ir_node *node) {
680         const ia32_attr_t *attr = get_ia32_attr_const(node);
681         return attr->data.is_remat;
682 }
683
684 /**
685  * Gets the mode of the stored/loaded value (only set for Store/Load)
686  */
687 ir_mode *get_ia32_ls_mode(const ir_node *node) {
688         const ia32_attr_t *attr = get_ia32_attr_const(node);
689         return attr->ls_mode;
690 }
691
692 /**
693  * Sets the mode of the stored/loaded value (only set for Store/Load)
694  */
695 void set_ia32_ls_mode(ir_node *node, ir_mode *mode) {
696         ia32_attr_t *attr = get_ia32_attr(node);
697         attr->ls_mode     = mode;
698 }
699
700 /**
701  * Gets the frame entity assigned to this node.
702  */
703 ir_entity *get_ia32_frame_ent(const ir_node *node) {
704         const ia32_attr_t *attr = get_ia32_attr_const(node);
705         return attr->frame_ent;
706 }
707
708 /**
709  * Sets the frame entity for this node.
710  */
711 void set_ia32_frame_ent(ir_node *node, ir_entity *ent) {
712         ia32_attr_t *attr = get_ia32_attr(node);
713         attr->frame_ent   = ent;
714         if(ent != NULL)
715                 set_ia32_use_frame(node);
716         else
717                 clear_ia32_use_frame(node);
718 }
719
720
721 /**
722  * Gets the instruction latency.
723  */
724 unsigned get_ia32_latency(const ir_node *node) {
725         const ir_op *op               = get_irn_op(node);
726         const ia32_op_attr_t *op_attr = (ia32_op_attr_t*) get_op_attr(op);
727         return op_attr->latency;
728 }
729
730 /**
731  * Returns the argument register requirements of an ia32 node.
732  */
733 const arch_register_req_t **get_ia32_in_req_all(const ir_node *node) {
734         const ia32_attr_t *attr = get_ia32_attr_const(node);
735         return attr->in_req;
736 }
737
738 /**
739  * Sets the argument register requirements of an ia32 node.
740  */
741 void set_ia32_in_req_all(ir_node *node, const arch_register_req_t **reqs) {
742         ia32_attr_t *attr = get_ia32_attr(node);
743         attr->in_req      = reqs;
744 }
745
746 /**
747  * Returns the result register requirements of an ia32 node.
748  */
749 const arch_register_req_t **get_ia32_out_req_all(const ir_node *node) {
750         const ia32_attr_t *attr = get_ia32_attr_const(node);
751         return attr->out_req;
752 }
753
754 /**
755  * Sets the result register requirements of an ia32 node.
756  */
757 void set_ia32_out_req_all(ir_node *node, const arch_register_req_t **reqs) {
758         ia32_attr_t *attr = get_ia32_attr(node);
759         attr->out_req     = reqs;
760 }
761
762 /**
763  * Returns the argument register requirement at position pos of an ia32 node.
764  */
765 const arch_register_req_t *get_ia32_in_req(const ir_node *node, int pos) {
766         const ia32_attr_t *attr = get_ia32_attr_const(node);
767         if(attr->in_req == NULL)
768                 return arch_no_register_req;
769
770         return attr->in_req[pos];
771 }
772
773 /**
774  * Returns the result register requirement at position pos of an ia32 node.
775  */
776 const arch_register_req_t *get_ia32_out_req(const ir_node *node, int pos) {
777         const ia32_attr_t *attr = get_ia32_attr_const(node);
778         if(attr->out_req == NULL)
779                 return arch_no_register_req;
780
781         return attr->out_req[pos];
782 }
783
784 /**
785  * Sets the OUT register requirements at position pos.
786  */
787 void set_ia32_req_out(ir_node *node, const arch_register_req_t *req, int pos) {
788         ia32_attr_t *attr  = get_ia32_attr(node);
789         attr->out_req[pos] = req;
790 }
791
792 /**
793  * Sets the IN register requirements at position pos.
794  */
795 void set_ia32_req_in(ir_node *node, const arch_register_req_t *req, int pos) {
796         ia32_attr_t *attr = get_ia32_attr(node);
797         attr->in_req[pos] = req;
798 }
799
800 /**
801  * Returns the register flag of an ia32 node.
802  */
803 arch_irn_flags_t get_ia32_flags(const ir_node *node) {
804         const ia32_attr_t *attr = get_ia32_attr_const(node);
805         return attr->data.flags;
806 }
807
808 /**
809  * Sets the register flag of an ia32 node.
810  */
811 void set_ia32_flags(ir_node *node, arch_irn_flags_t flags) {
812         ia32_attr_t *attr = get_ia32_attr(node);
813         attr->data.flags  = flags;
814 }
815
816 void add_ia32_flags(ir_node *node, arch_irn_flags_t flags) {
817         ia32_attr_t *attr  = get_ia32_attr(node);
818         attr->data.flags  |= flags;
819 }
820
821 /**
822  * Returns the result register slots of an ia32 node.
823  */
824 const arch_register_t **get_ia32_slots(const ir_node *node) {
825         const ia32_attr_t *attr = get_ia32_attr_const(node);
826         return attr->slots;
827 }
828
829 /**
830  * Returns the number of results.
831  */
832 int get_ia32_n_res(const ir_node *node) {
833         const ia32_attr_t *attr = get_ia32_attr_const(node);
834         return ARR_LEN(attr->slots);
835 }
836
837 /**
838  * Returns the condition code of a node.
839  */
840 long get_ia32_condcode(const ir_node *node)
841 {
842         const ia32_condcode_attr_t *attr = get_ia32_condcode_attr_const(node);
843         return attr->pn_code;
844 }
845
846 /**
847  * Sets the condition code of a node
848  */
849 void set_ia32_condcode(ir_node *node, long code)
850 {
851         ia32_condcode_attr_t *attr = get_ia32_condcode_attr(node);
852         attr->pn_code = code;
853 }
854
855 /**
856  * Returns the condition code of a node.
857  */
858 unsigned get_ia32_copyb_size(const ir_node *node)
859 {
860         const ia32_copyb_attr_t *attr = get_ia32_copyb_attr_const(node);
861         return attr->size;
862 }
863
864 /**
865  * Sets the flags for the n'th out.
866  */
867 void set_ia32_out_flags(ir_node *node, arch_irn_flags_t flags, int pos) {
868         ia32_attr_t *attr = get_ia32_attr(node);
869         assert(pos < ARR_LEN(attr->out_flags) && "Invalid OUT position.");
870         attr->out_flags[pos] = flags;
871 }
872
873 /**
874  * Gets the flags for the n'th out.
875  */
876 arch_irn_flags_t get_ia32_out_flags(const ir_node *node, int pos) {
877         const ia32_attr_t *attr = get_ia32_attr_const(node);
878         assert(pos < ARR_LEN(attr->out_flags) && "Invalid OUT position.");
879         return attr->out_flags[pos];
880 }
881
882 /**
883  * Get the list of available execution units.
884  */
885 const be_execution_unit_t ***get_ia32_exec_units(const ir_node *node) {
886         const ia32_attr_t *attr = get_ia32_attr_const(node);
887         return attr->exec_units;
888 }
889
890 /**
891  * Get the exception label attribute.
892  */
893 unsigned get_ia32_exc_label(const ir_node *node) {
894         const ia32_attr_t *attr = get_ia32_attr_const(node);
895         return attr->data.has_except_label;
896 }
897
898 /**
899  * Set the exception label attribute.
900  */
901 void set_ia32_exc_label(ir_node *node, unsigned flag) {
902         ia32_attr_t *attr = get_ia32_attr(node);
903         attr->data.has_except_label = flag;
904 }
905
906 /**
907  * Return the exception label id.
908  */
909 ir_label_t get_ia32_exc_label_id(const ir_node *node) {
910         const ia32_attr_t *attr = get_ia32_attr_const(node);
911
912         assert(attr->data.has_except_label);
913         return attr->exc_label;
914 }
915
916 /**
917  * Assign the exception label id.
918  */
919 void set_ia32_exc_label_id(ir_node *node, ir_label_t id) {
920         ia32_attr_t *attr = get_ia32_attr(node);
921
922         assert(attr->data.has_except_label);
923         attr->exc_label = id;
924 }
925
926 #ifndef NDEBUG
927
928 /**
929  * Returns the name of the original ir node.
930  */
931 const char *get_ia32_orig_node(const ir_node *node) {
932         const ia32_attr_t *attr = get_ia32_attr_const(node);
933         return attr->orig_node;
934 }
935
936 /**
937  * Sets the name of the original ir node.
938  */
939 void set_ia32_orig_node(ir_node *node, const char *name) {
940         ia32_attr_t *attr = get_ia32_attr(node);
941         attr->orig_node   = name;
942 }
943
944 #endif /* NDEBUG */
945
946 /******************************************************************************************************
947  *                      _       _         _   _           __                  _   _
948  *                     (_)     | |       | | | |         / _|                | | (_)
949  *  ___ _ __   ___  ___ _  __ _| |   __ _| |_| |_ _ __  | |_ _   _ _ __   ___| |_ _  ___  _ __    ___
950  * / __| '_ \ / _ \/ __| |/ _` | |  / _` | __| __| '__| |  _| | | | '_ \ / __| __| |/ _ \| '_ \  / __|
951  * \__ \ |_) |  __/ (__| | (_| | | | (_| | |_| |_| |    | | | |_| | | | | (__| |_| | (_) | | | | \__ \
952  * |___/ .__/ \___|\___|_|\__,_|_|  \__,_|\__|\__|_|    |_|  \__,_|_| |_|\___|\__|_|\___/|_| |_| |___/
953  *     | |
954  *     |_|
955  ******************************************************************************************************/
956
957 /**
958  * Returns whether or not the node is an AddrModeS node.
959  */
960 int is_ia32_AddrModeS(const ir_node *node) {
961         const ia32_attr_t *attr = get_ia32_attr_const(node);
962         return (attr->data.tp == ia32_AddrModeS);
963 }
964
965 /**
966  * Returns whether or not the node is an AddrModeD node.
967  */
968 int is_ia32_AddrModeD(const ir_node *node) {
969         const ia32_attr_t *attr = get_ia32_attr_const(node);
970         return (attr->data.tp == ia32_AddrModeD);
971 }
972
973 /**
974  * Checks if node is a Load or xLoad/vfLoad.
975  */
976 int is_ia32_Ld(const ir_node *node) {
977         int op = get_ia32_irn_opcode(node);
978         return op == iro_ia32_Load ||
979                op == iro_ia32_xLoad ||
980                op == iro_ia32_vfld ||
981                op == iro_ia32_fld;
982 }
983
984 /**
985  * Checks if node is a Store or xStore/vfStore.
986  */
987 int is_ia32_St(const ir_node *node) {
988         int op = get_ia32_irn_opcode(node);
989         return op == iro_ia32_Store ||
990                op == iro_ia32_Store8Bit ||
991                op == iro_ia32_xStore ||
992                op == iro_ia32_vfst ||
993                op == iro_ia32_fst ||
994                op == iro_ia32_fstp;
995 }
996
997 /**
998  * Returns the name of the OUT register at position pos.
999  */
1000 const char *get_ia32_out_reg_name(const ir_node *node, int pos) {
1001         const ia32_attr_t *attr = get_ia32_attr_const(node);
1002
1003         assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
1004         assert(attr->slots[pos]  && "No register assigned");
1005
1006         return arch_register_get_name(attr->slots[pos]);
1007 }
1008
1009 /**
1010  * Returns the index of the OUT register at position pos within its register class.
1011  */
1012 int get_ia32_out_regnr(const ir_node *node, int pos) {
1013         const ia32_attr_t *attr = get_ia32_attr_const(node);
1014
1015         assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
1016         assert(attr->slots[pos]  && "No register assigned");
1017
1018         return arch_register_get_index(attr->slots[pos]);
1019 }
1020
1021 void ia32_swap_left_right(ir_node *node)
1022 {
1023         ia32_attr_t *attr  = get_ia32_attr(node);
1024         ir_node     *left  = get_irn_n(node, n_ia32_binary_left);
1025         ir_node     *right = get_irn_n(node, n_ia32_binary_right);
1026
1027         assert(is_ia32_commutative(node));
1028         attr->data.ins_permuted = !attr->data.ins_permuted;
1029         set_irn_n(node, n_ia32_binary_left,  right);
1030         set_irn_n(node, n_ia32_binary_right, left);
1031 }
1032
1033 /**
1034  * Returns the OUT register at position pos.
1035  */
1036 const arch_register_t *get_ia32_out_reg(const ir_node *node, int pos) {
1037         const ia32_attr_t *attr = get_ia32_attr_const(node);
1038
1039         assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
1040         assert(attr->slots[pos]  && "No register assigned");
1041
1042         return attr->slots[pos];
1043 }
1044
1045 /**
1046  * Initializes the nodes attributes.
1047  */
1048 void init_ia32_attributes(ir_node *node, arch_irn_flags_t flags,
1049                           const arch_register_req_t **in_reqs,
1050                           const arch_register_req_t **out_reqs,
1051                           const be_execution_unit_t ***execution_units,
1052                           int n_res)
1053 {
1054         ir_graph        *irg  = get_irn_irg(node);
1055         struct obstack  *obst = get_irg_obstack(irg);
1056         ia32_attr_t     *attr = get_ia32_attr(node);
1057
1058         set_ia32_flags(node, flags);
1059         set_ia32_in_req_all(node, in_reqs);
1060         set_ia32_out_req_all(node, out_reqs);
1061
1062         attr->exec_units  = execution_units;
1063 #ifndef NDEBUG
1064         attr->attr_type  |= IA32_ATTR_ia32_attr_t;
1065 #endif
1066
1067         attr->out_flags = NEW_ARR_D(int, obst, n_res);
1068         memset(attr->out_flags, 0, n_res * sizeof(attr->out_flags[0]));
1069
1070         attr->slots = NEW_ARR_D(const arch_register_t*, obst, n_res);
1071         /* void* cast to suppress an incorrect warning on MSVC */
1072         memset((void*)attr->slots, 0, n_res * sizeof(attr->slots[0]));
1073 }
1074
1075 void
1076 init_ia32_x87_attributes(ir_node *res)
1077 {
1078 #ifndef NDEBUG
1079         ia32_attr_t *attr  = get_ia32_attr(res);
1080         attr->attr_type   |= IA32_ATTR_ia32_x87_attr_t;
1081 #else
1082         (void) res;
1083 #endif
1084         ia32_current_cg->do_x87_sim = 1;
1085 }
1086
1087 void
1088 init_ia32_asm_attributes(ir_node *res)
1089 {
1090 #ifndef NDEBUG
1091         ia32_attr_t *attr  = get_ia32_attr(res);
1092         attr->attr_type   |= IA32_ATTR_ia32_asm_attr_t;
1093 #else
1094         (void) res;
1095 #endif
1096 }
1097
1098 void
1099 init_ia32_immediate_attributes(ir_node *res, ir_entity *symconst,
1100                                int symconst_sign, long offset)
1101 {
1102         ia32_immediate_attr_t *attr = get_irn_generic_attr(res);
1103
1104 #ifndef NDEBUG
1105         attr->attr.attr_type  |= IA32_ATTR_ia32_immediate_attr_t;
1106 #endif
1107         attr->symconst = symconst;
1108         attr->sc_sign  = symconst_sign;
1109         attr->offset   = offset;
1110 }
1111
1112 void init_ia32_call_attributes(ir_node *const res, unsigned const pop, ir_type *const call_tp)
1113 {
1114         ia32_call_attr_t *attr = get_irn_generic_attr(res);
1115
1116 #ifndef NDEBUG
1117         attr->attr.attr_type  |= IA32_ATTR_ia32_call_attr_t;
1118 #endif
1119         attr->pop     = pop;
1120         attr->call_tp = call_tp;
1121 }
1122
1123 void
1124 init_ia32_copyb_attributes(ir_node *res, unsigned size) {
1125         ia32_copyb_attr_t *attr = get_irn_generic_attr(res);
1126
1127 #ifndef NDEBUG
1128         attr->attr.attr_type  |= IA32_ATTR_ia32_copyb_attr_t;
1129 #endif
1130         attr->size = size;
1131 }
1132
1133 void
1134 init_ia32_condcode_attributes(ir_node *res, long pnc) {
1135         ia32_condcode_attr_t *attr = get_irn_generic_attr(res);
1136
1137 #ifndef NDEBUG
1138         attr->attr.attr_type  |= IA32_ATTR_ia32_condcode_attr_t;
1139 #endif
1140         attr->pn_code = pnc;
1141 }
1142
1143 ir_node *get_ia32_result_proj(const ir_node *node)
1144 {
1145         const ir_edge_t *edge;
1146
1147         foreach_out_edge(node, edge) {
1148                 ir_node *proj = get_edge_src_irn(edge);
1149                 if(get_Proj_proj(proj) == 0) {
1150                         return proj;
1151                 }
1152         }
1153         return NULL;
1154 }
1155
1156 /***************************************************************************************
1157  *                  _                            _                   _
1158  *                 | |                          | |                 | |
1159  *  _ __   ___   __| | ___    ___ ___  _ __  ___| |_ _ __ _   _  ___| |_ ___  _ __ ___
1160  * | '_ \ / _ \ / _` |/ _ \  / __/ _ \| '_ \/ __| __| '__| | | |/ __| __/ _ \| '__/ __|
1161  * | | | | (_) | (_| |  __/ | (_| (_) | | | \__ \ |_| |  | |_| | (__| || (_) | |  \__ \
1162  * |_| |_|\___/ \__,_|\___|  \___\___/|_| |_|___/\__|_|   \__,_|\___|\__\___/|_|  |___/
1163  *
1164  ***************************************************************************************/
1165
1166 /* default compare operation to compare attributes */
1167 int ia32_compare_attr(const ia32_attr_t *a, const ia32_attr_t *b) {
1168         if (a->data.tp != b->data.tp)
1169                 return 1;
1170
1171         if (a->data.am_scale != b->data.am_scale
1172             || a->data.am_sc_sign != b->data.am_sc_sign
1173             || a->am_offs != b->am_offs
1174             || a->am_sc != b->am_sc
1175             || a->ls_mode != b->ls_mode)
1176                 return 1;
1177
1178         /* nodes with not yet assigned entities shouldn't be CSEd (important for
1179          * unsigned int -> double conversions */
1180         if(a->data.use_frame && a->frame_ent == NULL)
1181                 return 1;
1182         if(b->data.use_frame && b->frame_ent == NULL)
1183                 return 1;
1184
1185         if (a->data.use_frame != b->data.use_frame
1186             || a->frame_ent != b->frame_ent)
1187                 return 1;
1188
1189         if (a->data.tp != b->data.tp)
1190                 return 1;
1191
1192         if (a->data.has_except_label != b->data.has_except_label)
1193                 return 1;
1194
1195         if (a->data.ins_permuted != b->data.ins_permuted
1196                         || a->data.cmp_unsigned != b->data.cmp_unsigned)
1197                 return 1;
1198
1199         return 0;
1200 }
1201
1202 /** Compare nodes attributes for all "normal" nodes. */
1203 static
1204 int ia32_compare_nodes_attr(ir_node *a, ir_node *b)
1205 {
1206         const ia32_attr_t* attr_a = get_ia32_attr_const(a);
1207         const ia32_attr_t* attr_b = get_ia32_attr_const(b);
1208
1209         return ia32_compare_attr(attr_a, attr_b);
1210 }
1211
1212 /** Compare node attributes for nodes with condition code. */
1213 static
1214 int ia32_compare_condcode_attr(ir_node *a, ir_node *b)
1215 {
1216         const ia32_condcode_attr_t *attr_a;
1217         const ia32_condcode_attr_t *attr_b;
1218
1219         if (ia32_compare_nodes_attr(a, b))
1220                 return 1;
1221
1222         attr_a = get_ia32_condcode_attr_const(a);
1223         attr_b = get_ia32_condcode_attr_const(b);
1224
1225         if(attr_a->pn_code != attr_b->pn_code)
1226                 return 1;
1227
1228         return 0;
1229 }
1230
1231 static int ia32_compare_call_attr(ir_node *a, ir_node *b)
1232 {
1233         const ia32_call_attr_t *attr_a;
1234         const ia32_call_attr_t *attr_b;
1235
1236         if (ia32_compare_nodes_attr(a, b))
1237                 return 1;
1238
1239         attr_a = get_ia32_call_attr_const(a);
1240         attr_b = get_ia32_call_attr_const(b);
1241
1242         if (attr_a->pop != attr_b->pop)
1243                 return 1;
1244
1245         if (attr_a->call_tp != attr_b->call_tp)
1246                 return 1;
1247
1248         return 0;
1249 }
1250
1251 /** Compare node attributes for CopyB nodes. */
1252 static
1253 int ia32_compare_copyb_attr(ir_node *a, ir_node *b)
1254 {
1255         const ia32_copyb_attr_t *attr_a;
1256         const ia32_copyb_attr_t *attr_b;
1257
1258         if (ia32_compare_nodes_attr(a, b))
1259                 return 1;
1260
1261         attr_a = get_ia32_copyb_attr_const(a);
1262         attr_b = get_ia32_copyb_attr_const(b);
1263
1264         if(attr_a->size != attr_b->size)
1265                 return 1;
1266
1267         return 0;
1268 }
1269
1270
1271 /** Compare ASM node attributes. */
1272 static
1273 int ia32_compare_asm_attr(ir_node *a, ir_node *b)
1274 {
1275         const ia32_asm_attr_t *attr_a;
1276         const ia32_asm_attr_t *attr_b;
1277
1278         if(ia32_compare_nodes_attr(a, b))
1279                 return 1;
1280
1281         attr_a = get_ia32_asm_attr_const(a);
1282         attr_b = get_ia32_asm_attr_const(b);
1283
1284         if(attr_a->asm_text != attr_b->asm_text)
1285                 return 1;
1286
1287         return 0;
1288 }
1289
1290 /**
1291  * Hash function for Immediates
1292  */
1293 static unsigned ia32_hash_Immediate(const ir_node *irn) {
1294         const ia32_immediate_attr_t *a = get_ia32_immediate_attr_const(irn);
1295
1296         return HASH_PTR(a->symconst) + (a->sc_sign << 16) + a->offset;
1297 }
1298
1299 /** Compare node attributes for Immediates. */
1300 static
1301 int ia32_compare_immediate_attr(ir_node *a, ir_node *b)
1302 {
1303         const ia32_immediate_attr_t *attr_a = get_ia32_immediate_attr_const(a);
1304         const ia32_immediate_attr_t *attr_b = get_ia32_immediate_attr_const(b);
1305
1306         if(attr_a->symconst != attr_b->symconst ||
1307            attr_a->sc_sign != attr_b->sc_sign ||
1308            attr_a->offset != attr_b->offset)
1309                 return 1;
1310
1311         return 0;
1312 }
1313
1314 /** Compare node attributes for x87 nodes. */
1315 static
1316 int ia32_compare_x87_attr(ir_node *a, ir_node *b)
1317 {
1318         return ia32_compare_nodes_attr(a, b);
1319 }
1320
1321
1322 /* copies the ia32 attributes */
1323 static void ia32_copy_attr(const ir_node *old_node, ir_node *new_node)
1324 {
1325         ir_graph          *irg      = get_irn_irg(new_node);
1326         struct obstack    *obst     = get_irg_obstack(irg);
1327         const ia32_attr_t *attr_old = get_ia32_attr_const(old_node);
1328         ia32_attr_t       *attr_new = get_ia32_attr(new_node);
1329
1330         /* copy the attributes */
1331         memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
1332
1333         /* copy out flags */
1334         attr_new->out_flags =
1335                 DUP_ARR_D(int, obst, attr_old->out_flags);
1336         /* copy register assignments */
1337         attr_new->slots =
1338                 DUP_ARR_D(arch_register_t*, obst, attr_old->slots);
1339 }
1340
1341 /* Include the generated constructor functions */
1342 #include "gen_ia32_new_nodes.c.inl"