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