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