use default error handler if none is specified
[libfirm] / ir / be / arm / arm_new_nodes.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief  This file implements the creation of the architecture specific firm
23  *         opcodes and the corresponding node constructors for the arm
24  *         assembler irg.
25  * @author Oliver Richter, Tobias Gneist
26  * @version $Id$
27  */
28 #include "config.h"
29
30 #include <stdlib.h>
31
32 #include "irprog_t.h"
33 #include "irgraph_t.h"
34 #include "irnode_t.h"
35 #include "irmode_t.h"
36 #include "ircons_t.h"
37 #include "iropt_t.h"
38 #include "irop.h"
39 #include "firm_common_t.h"
40 #include "irvrfy_t.h"
41 #include "irprintf.h"
42 #include "xmalloc.h"
43
44 #include "../bearch_t.h"
45
46 #include "arm_nodes_attr.h"
47 #include "arm_new_nodes.h"
48 #include "arm_optimize.h"
49
50 #include "../beabi.h"
51 #include "bearch_arm_t.h"
52
53 /**
54  * Returns the shift modifier string.
55  */
56 const char *arm_shf_mod_name(arm_shift_modifier mod) {
57         static const char *names[] = { NULL, NULL, "asr", "lsl", "lsr", "ror", "rrx" };
58         return names[mod];
59 }
60
61 /**
62  * Return the fpa immediate from the encoding.
63  */
64 const char *arm_get_fpa_imm_name(long imm_value) {
65         static const char *fpa_imm[] = {
66                 "0",
67                 "1",
68                 "2",
69                 "3",
70                 "4",
71                 "5",
72                 "10",
73                 "0.5"
74         };
75         return fpa_imm[imm_value];
76 }
77
78 /***********************************************************************************
79  *      _                                   _       _             __
80  *     | |                                 (_)     | |           / _|
81  *   __| |_   _ _ __ ___  _ __   ___ _ __   _ _ __ | |_ ___ _ __| |_ __ _  ___ ___
82  *  / _` | | | | '_ ` _ \| '_ \ / _ \ '__| | | '_ \| __/ _ \ '__|  _/ _` |/ __/ _ \
83  * | (_| | |_| | | | | | | |_) |  __/ |    | | | | | ||  __/ |  | || (_| | (_|  __/
84  *  \__,_|\__,_|_| |_| |_| .__/ \___|_|    |_|_| |_|\__\___|_|  |_| \__,_|\___\___|
85  *                       | |
86  *                       |_|
87  ***********************************************************************************/
88
89 /**
90  * Dumps the register requirements for either in or out.
91  */
92 static void dump_reg_req(FILE *F, const ir_node *node,
93                          const arch_register_req_t **reqs, int inout) {
94         char *dir = inout ? "out" : "in";
95         int   max = inout ? get_arm_n_res(node) : get_irn_arity(node);
96         char  buf[1024];
97         int   i;
98
99         memset(buf, 0, sizeof(buf));
100
101         if (reqs) {
102                 for (i = 0; i < max; i++) {
103                         fprintf(F, "%sreq #%d =", dir, i);
104
105                         if (reqs[i]->type == arch_register_req_type_none) {
106                                 fprintf(F, " n/a");
107                         }
108
109                         if (reqs[i]->type & arch_register_req_type_normal) {
110                                 fprintf(F, " %s", reqs[i]->cls->name);
111                         }
112
113                         if (reqs[i]->type & arch_register_req_type_limited) {
114                                 fprintf(F, " %s",
115                                         arch_register_req_format(buf, sizeof(buf), reqs[i], node));
116                         }
117
118                         if (reqs[i]->type & arch_register_req_type_should_be_same) {
119                                 const unsigned other = reqs[i]->other_same;
120                                 int i;
121
122                                 ir_fprintf(F, " same as");
123                                 for (i = 0; 1U << i <= other; ++i) {
124                                         if (other & (1U << i)) {
125                                                 ir_fprintf(F, " %+F", get_irn_n(node, i));
126                                         }
127                                 }
128                         }
129
130                         if (reqs[i]->type & arch_register_req_type_must_be_different) {
131                                 const unsigned other = reqs[i]->other_different;
132                                 int i;
133
134                                 ir_fprintf(F, " different from");
135                                 for (i = 0; 1U << i <= other; ++i) {
136                                         if (other & (1U << i)) {
137                                                 ir_fprintf(F, " %+F", get_irn_n(node, i));
138                                         }
139                                 }
140                         }
141
142                         fprintf(F, "\n");
143                 }
144
145                 fprintf(F, "\n");
146         } else {
147                 fprintf(F, "%sreq = N/A\n", dir);
148         }
149 }
150
151 /**
152  * Dumper interface for dumping arm nodes in vcg.
153  * @param n        the node to dump
154  * @param F        the output file
155  * @param reason   indicates which kind of information should be dumped
156  * @return 0 on success or != 0 on failure
157  */
158 static int arm_dump_node(ir_node *n, FILE *F, dump_reason_t reason) {
159         ir_mode     *mode = NULL;
160         int          bad  = 0;
161         int          i;
162         arm_attr_t  *attr = get_arm_attr(n);
163         const arch_register_req_t **reqs;
164         const arch_register_t     **slots;
165         arm_shift_modifier        mod;
166
167         switch (reason) {
168                 case dump_node_opcode_txt:
169                         fprintf(F, "%s", get_irn_opname(n));
170                         break;
171
172                 case dump_node_mode_txt:
173                         mode = get_irn_mode(n);
174
175                         if (mode) {
176                                 fprintf(F, "[%s]", get_mode_name(mode));
177                         }
178                         else {
179                                 fprintf(F, "[?NOMODE?]");
180                         }
181                         break;
182
183                 case dump_node_nodeattr_txt:
184                         mod = ARM_GET_SHF_MOD(attr);
185                         if (ARM_HAS_SHIFT(mod)) {
186                                 fprintf(F, "[%s #%ld]", arm_shf_mod_name(mod), attr->imm_value);
187                         }
188                         else if (mod == ARM_SHF_IMM) {
189                                 /* immediate */
190                                 fprintf(F, "[#0x%X]", arm_decode_imm_w_shift(attr->imm_value));
191                         }
192                         break;
193
194                 case dump_node_info_txt:
195                         fprintf(F, "=== arm attr begin ===\n");
196
197                         /* dump IN requirements */
198                         if (get_irn_arity(n) > 0) {
199                                 reqs = get_arm_in_req_all(n);
200                                 dump_reg_req(F, n, reqs, 0);
201                         }
202
203                         /* dump OUT requirements */
204                         if (ARR_LEN(attr->slots) > 0) {
205                                 reqs = get_arm_out_req_all(n);
206                                 dump_reg_req(F, n, reqs, 1);
207                         }
208
209                         /* dump assigned registers */
210                         slots = get_arm_slots(n);
211                         if (slots && ARR_LEN(attr->slots) > 0) {
212                                 for (i = 0; i < ARR_LEN(attr->slots); i++) {
213                                         if (slots[i]) {
214                                                 fprintf(F, "reg #%d = %s\n", i, slots[i]->name);
215                                         }
216                                         else {
217                                                 fprintf(F, "reg #%d = n/a\n", i);
218                                         }
219                                 }
220                         }
221                         fprintf(F, "\n");
222
223                         /* dump n_res */
224                         fprintf(F, "n_res = %d\n", get_arm_n_res(n));
225
226                         /* dump flags */
227                         fprintf(F, "flags =");
228                         if (attr->flags == arch_irn_flags_none) {
229                                 fprintf(F, " none");
230                         }
231                         else {
232                                 if (attr->flags & arch_irn_flags_dont_spill) {
233                                         fprintf(F, " unspillable");
234                                 }
235                                 if (attr->flags & arch_irn_flags_rematerializable) {
236                                         fprintf(F, " remat");
237                                 }
238                                 if (attr->flags & arch_irn_flags_ignore) {
239                                         fprintf(F, " ignore");
240                                 }
241                         }
242                         fprintf(F, " (%d)\n", attr->flags);
243
244                         if (is_arm_CopyB(n)) {
245                                 fprintf(F, "size = %lu\n", get_arm_imm_value(n));
246                         } else {
247                                 long v =  get_arm_imm_value(n);
248                                 if (ARM_GET_FPA_IMM(attr)) {
249                                         fprintf(F, "immediate float value = %s\n", arm_get_fpa_imm_name(v));
250                                 } else {
251                                         fprintf(F, "immediate value = %ld (0x%08lx)\n", v, v);
252                                 }
253                         }
254
255                         if (is_arm_CmpBra(n) && get_arm_CondJmp_proj_num(n) >= 0) {
256                                 fprintf(F, "proj_num = (%d)\n", get_arm_CondJmp_proj_num(n));
257                         }
258                         /* TODO: dump all additional attributes */
259
260                         fprintf(F, "=== arm attr end ===\n");
261                         /* end of: case dump_node_info_txt */
262                         break;
263         }
264         return bad;
265 }
266
267
268
269 /***************************************************************************************************
270  *        _   _                   _       __        _                    _   _               _
271  *       | | | |                 | |     / /       | |                  | | | |             | |
272  *   __ _| |_| |_ _ __   ___  ___| |_   / /_ _  ___| |_   _ __ ___   ___| |_| |__   ___   __| |___
273  *  / _` | __| __| '__| / __|/ _ \ __| / / _` |/ _ \ __| | '_ ` _ \ / _ \ __| '_ \ / _ \ / _` / __|
274  * | (_| | |_| |_| |    \__ \  __/ |_ / / (_| |  __/ |_  | | | | | |  __/ |_| | | | (_) | (_| \__ \
275  *  \__,_|\__|\__|_|    |___/\___|\__/_/ \__, |\___|\__| |_| |_| |_|\___|\__|_| |_|\___/ \__,_|___/
276  *                                        __/ |
277  *                                       |___/
278  ***************************************************************************************************/
279
280 /* Returns the attributes of a generic Arm node. */
281 arm_attr_t *get_arm_attr(ir_node *node) {
282         assert(is_arm_irn(node) && "need arm node to get attributes");
283         return get_irn_generic_attr(node);
284 }
285
286 const arm_attr_t *get_arm_attr_const(const ir_node *node) {
287         assert(is_arm_irn(node) && "need arm node to get attributes");
288         return get_irn_generic_attr_const(node);
289 }
290
291 /**
292  * Returns the attributes of an ARM SymConst node.
293  */
294 arm_SymConst_attr_t *get_arm_SymConst_attr(ir_node *node) {
295         assert(is_arm_SymConst(node));
296         return get_irn_generic_attr(node);
297 }
298
299 const arm_SymConst_attr_t *get_arm_SymConst_attr_const(const ir_node *node) {
300         assert(is_arm_SymConst(node));
301         return get_irn_generic_attr_const(node);
302 }
303
304 static const arm_fpaConst_attr_t *get_arm_fpaConst_attr_const(const ir_node *node) {
305         const arm_attr_t          *attr     = get_arm_attr_const(node);
306         const arm_fpaConst_attr_t *fpa_attr = CONST_CAST_ARM_ATTR(arm_fpaConst_attr_t, attr);
307
308         return fpa_attr;
309 }
310
311 static arm_fpaConst_attr_t *get_arm_fpaConst_attr(ir_node *node) {
312         arm_attr_t          *attr     = get_arm_attr(node);
313         arm_fpaConst_attr_t *fpa_attr = CAST_ARM_ATTR(arm_fpaConst_attr_t, attr);
314
315         return fpa_attr;
316 }
317
318 static int is_arm_CondJmp(const ir_node *node) {
319         int code = get_arm_irn_opcode(node);
320
321         return (code == iro_arm_CmpBra || code == iro_arm_fpaCmfBra ||
322                 code == iro_arm_fpaCnfBra || iro_arm_fpaCmfeBra ||
323                 code == iro_arm_fpaCnfeBra);
324 }
325
326 /* Returns the attributes of a CondJmp node. */
327 arm_CondJmp_attr_t *get_arm_CondJmp_attr(ir_node *node) {
328         assert(is_arm_CondJmp(node));
329         return get_irn_generic_attr(node);
330 }
331
332 const arm_CondJmp_attr_t *get_arm_CondJmp_attr_const(const ir_node *node) {
333         assert(is_arm_CondJmp(node));
334         return get_irn_generic_attr_const(node);
335 }
336
337 /* Returns the attributes of a SwitchJmp node. */
338 arm_SwitchJmp_attr_t *get_arm_SwitchJmp_attr(ir_node *node) {
339         assert(is_arm_SwitchJmp(node));
340         return get_irn_generic_attr(node);
341 }
342
343 const arm_SwitchJmp_attr_t *get_arm_SwitchJmp_attr_const(const ir_node *node) {
344         assert(is_arm_SwitchJmp(node));
345         return get_irn_generic_attr_const(node);
346 }
347
348 /**
349  * Returns the argument register requirements of a arm node.
350  */
351 const arch_register_req_t **get_arm_in_req_all(const ir_node *node) {
352         const arm_attr_t *attr = get_arm_attr_const(node);
353         return attr->in_req;
354 }
355
356 /**
357  * Returns the result register requirements of an arm node.
358  */
359 const arch_register_req_t **get_arm_out_req_all(const ir_node *node) {
360         const arm_attr_t *attr = get_arm_attr_const(node);
361         return attr->out_req;
362 }
363
364 /**
365  * Returns the argument register requirement at position pos of an arm node.
366  */
367 const arch_register_req_t *get_arm_in_req(const ir_node *node, int pos) {
368         const arm_attr_t *attr = get_arm_attr_const(node);
369         return attr->in_req[pos];
370 }
371
372 /**
373  * Returns the result register requirement at position pos of an arm node.
374  */
375 const arch_register_req_t *get_arm_out_req(const ir_node *node, int pos) {
376         const arm_attr_t *attr = get_arm_attr_const(node);
377         return attr->out_req[pos];
378 }
379
380 /**
381  * Sets the OUT register requirements at position pos.
382  */
383 void set_arm_req_out(ir_node *node, const arch_register_req_t *req, int pos) {
384         arm_attr_t *attr   = get_arm_attr(node);
385         attr->out_req[pos] = req;
386 }
387
388 /**
389  * Sets the complete OUT requirements of node.
390  */
391 void set_arm_req_out_all(ir_node *node, const arch_register_req_t **reqs) {
392         arm_attr_t *attr = get_arm_attr(node);
393         attr->out_req    = reqs;
394 }
395
396 /**
397  * Sets the IN register requirements at position pos.
398  */
399 void set_arm_req_in(ir_node *node, const arch_register_req_t *req, int pos) {
400         arm_attr_t *attr  = get_arm_attr(node);
401         attr->in_req[pos] = req;
402 }
403
404 /**
405  * Returns the register flag of an arm node.
406  */
407 arch_irn_flags_t get_arm_flags(const ir_node *node) {
408         const arm_attr_t *attr = get_arm_attr_const(node);
409         return attr->flags;
410 }
411
412 /**
413  * Sets the register flag of an arm node.
414  */
415 void set_arm_flags(ir_node *node, arch_irn_flags_t flags) {
416         arm_attr_t *attr = get_arm_attr(node);
417         attr->flags      = flags;
418 }
419
420 /**
421  * Returns the result register slots of an arm node.
422  */
423 const arch_register_t **get_arm_slots(const ir_node *node) {
424         const arm_attr_t *attr = get_arm_attr_const(node);
425         return attr->slots;
426 }
427
428 /**
429  * Returns the name of the OUT register at position pos.
430  */
431 const char *get_arm_out_reg_name(const ir_node *node, int pos) {
432         const arm_attr_t *attr = get_arm_attr_const(node);
433
434         assert(is_arm_irn(node) && "Not an arm node.");
435         assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
436         assert(attr->slots[pos]  && "No register assigned");
437
438         return arch_register_get_name(attr->slots[pos]);
439 }
440
441 /**
442  * Returns the index of the OUT register at position pos within its register class.
443  */
444 int get_arm_out_regnr(const ir_node *node, int pos) {
445         const arm_attr_t *attr = get_arm_attr_const(node);
446
447         assert(is_arm_irn(node) && "Not an arm node.");
448         assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
449         assert(attr->slots[pos]  && "No register assigned");
450
451         return arch_register_get_index(attr->slots[pos]);
452 }
453
454 /**
455  * Returns the OUT register at position pos.
456  */
457 const arch_register_t *get_arm_out_reg(const ir_node *node, int pos) {
458         const arm_attr_t *attr = get_arm_attr_const(node);
459
460         assert(is_arm_irn(node) && "Not an arm node.");
461         assert(pos < ARR_LEN(attr->slots) && "Invalid OUT position.");
462         assert(attr->slots[pos]  && "No register assigned");
463
464         return attr->slots[pos];
465 }
466
467 /**
468  * Sets the flags for the n'th out.
469  */
470 void set_arm_out_flags(ir_node *node, arch_irn_flags_t flags, int pos) {
471         arm_attr_t *attr = get_arm_attr(node);
472         assert(pos < ARR_LEN(attr->out_flags) && "Invalid OUT position.");
473         attr->out_flags[pos] = flags;
474 }
475
476 /**
477  * Gets the flags for the n'th out.
478  */
479 arch_irn_flags_t get_arm_out_flags(const ir_node *node, int pos) {
480         const arm_attr_t *attr = get_arm_attr_const(node);
481         assert(pos < ARR_LEN(attr->out_flags) && "Invalid OUT position.");
482         return attr->out_flags[pos];
483 }
484
485 /**
486  * Returns the number of results.
487  */
488 int get_arm_n_res(const ir_node *node) {
489         const arm_attr_t *attr = get_arm_attr_const(node);
490         return ARR_LEN(attr->slots);
491 }
492
493 /**
494  * Returns the immediate value
495  */
496 long get_arm_imm_value(const ir_node *node) {
497         const arm_attr_t *attr = get_arm_attr_const(node);
498         return attr->imm_value;
499 }
500
501 /**
502  * Sets the tarval value
503  */
504 void set_arm_imm_value(ir_node *node, long imm_value) {
505         arm_attr_t *attr = get_arm_attr(node);
506         attr->imm_value = imm_value;
507 }
508
509 /**
510  * Returns the fpaConst value
511  */
512 tarval *get_fpaConst_value(const ir_node *node) {
513         const arm_fpaConst_attr_t *attr = get_arm_fpaConst_attr_const(node);
514         return attr->tv;
515 }
516
517 /**
518  * Sets the tarval value
519  */
520 void set_fpaConst_value(ir_node *node, tarval *tv) {
521         arm_fpaConst_attr_t *attr = get_arm_fpaConst_attr(node);
522         attr->tv = tv;
523 }
524
525 /**
526  * Returns the proj num
527  */
528 int get_arm_CondJmp_proj_num(const ir_node *node) {
529         const arm_CondJmp_attr_t *attr = get_arm_CondJmp_attr_const(node);
530         return attr->proj_num;
531 }
532
533 /**
534  * Sets the proj num
535  */
536 void set_arm_CondJmp_proj_num(ir_node *node, int proj_num) {
537         arm_CondJmp_attr_t *attr = get_arm_CondJmp_attr(node);
538         attr->proj_num   = proj_num;
539 }
540
541 /**
542  * Returns the SymConst label
543  */
544 ident *get_arm_symconst_id(const ir_node *node) {
545         const arm_SymConst_attr_t *attr = get_arm_SymConst_attr_const(node);
546         return attr->symconst_id;
547 }
548
549 /**
550  * Sets the SymConst label
551  */
552 void set_arm_symconst_id(ir_node *node, ident *symconst_id) {
553         arm_SymConst_attr_t *attr = get_arm_SymConst_attr(node);
554         attr->symconst_id = symconst_id;
555 }
556
557 /**
558  * Returns the number of projs of a SwitchJmp.
559  */
560 int get_arm_SwitchJmp_n_projs(const ir_node *node) {
561         const arm_SwitchJmp_attr_t *attr = get_arm_SwitchJmp_attr_const(node);
562         return attr->n_projs;
563 }
564
565 /**
566  * Sets the number of projs.
567  */
568 void set_arm_SwitchJmp_n_projs(ir_node *node, int n_projs) {
569         arm_SwitchJmp_attr_t *attr = get_arm_SwitchJmp_attr(node);
570         attr->n_projs = n_projs;
571 }
572
573 /**
574  * Returns the default_proj_num.
575  */
576 long get_arm_SwitchJmp_default_proj_num(const ir_node *node) {
577         const arm_SwitchJmp_attr_t *attr = get_arm_SwitchJmp_attr_const(node);
578         return attr->default_proj_num;
579 }
580
581 /**
582  * Sets the default_proj_num.
583  */
584 void set_arm_SwitchJmp_default_proj_num(ir_node *node, long default_proj_num) {
585         arm_SwitchJmp_attr_t *attr = get_arm_SwitchJmp_attr(node);
586         attr->default_proj_num = default_proj_num;
587 }
588
589 /**
590  * Gets the shift modifier attribute.
591  */
592 arm_shift_modifier get_arm_shift_modifier(const ir_node *node) {
593         const arm_attr_t *attr = get_arm_attr_const(node);
594         return ARM_GET_SHF_MOD(attr);
595 }
596
597 /* Set the ARM machine node attributes to default values. */
598 static void init_arm_attributes(ir_node *node, int flags,
599                          const arch_register_req_t ** in_reqs,
600                                                  const arch_register_req_t ** out_reqs,
601                          const be_execution_unit_t ***execution_units,
602                                                  int n_res) {
603         ir_graph       *irg  = get_irn_irg(node);
604         struct obstack *obst = get_irg_obstack(irg);
605         arm_attr_t     *attr = get_arm_attr(node);
606         (void) execution_units;
607
608         attr->in_req           = in_reqs;
609         attr->out_req          = out_reqs;
610         attr->flags            = flags;
611         attr->instr_fl         = (ARM_COND_AL << 3) | ARM_SHF_NONE;
612         attr->imm_value        = 0;
613
614         attr->out_flags = NEW_ARR_D(int, obst, n_res);
615         memset(attr->out_flags, 0, n_res * sizeof(attr->out_flags[0]));
616
617         attr->slots = NEW_ARR_D(const arch_register_t*, obst, n_res);
618         memset(attr->slots, 0, n_res * sizeof(attr->slots[0]));
619 }
620
621 /************************************************
622  *   ___        _   _           _               *
623  *  / _ \ _ __ | |_(_)_ __ ___ (_)_______ _ __  *
624  * | | | | '_ \| __| | '_ ` _ \| |_  / _ \ '__| *
625  * | |_| | |_) | |_| | | | | | | |/ /  __/ |    *
626  *  \___/| .__/ \__|_|_| |_| |_|_/___\___|_|    *
627  *       |_|                                    *
628  ************************************************/
629
630 typedef struct _opt_tuple {
631         ir_op *op_imm_left;             /**< immediate is left */
632         ir_op *op_imm_right;    /**< immediate is right */
633         ir_op *op_shf_left;             /**< shift operand on left */
634         ir_op *op_shf_right;    /**< shift operand on right */
635 } opt_tuple;
636
637 //static const opt_tuple *opt_ops[iro_arm_last];
638
639 void arm_set_optimizers(void) {
640         /*
641 #define STD(op)         p_##op = { op_arm_##op##_i, op_arm_##op##_i, op_arm_##op, op_arm_##op }
642 #define LEFT(op)        p_##op = { op_arm_##op##_i, NULL, op_arm_##op, NULL }
643 #define SET(op)   opt_ops[iro_arm_##op] = &p_##op;
644
645         static const opt_tuple
646                 STD(Add),
647                 STD(And),
648                 STD(Or),
649                 STD(Eor),
650                 LEFT(Bic),
651                 LEFT(Shl),
652                 LEFT(Shr),
653                 LEFT(Shrs),
654                 p_Sub = { op_arm_Sub_i, op_arm_Rsb_i, op_arm_Sub, op_arm_Rsb },
655
656         memset(opt_ops, 0, sizeof(opt_ops));
657         SET(Add);
658         SET(And);
659         SET(Or);
660         SET(Eor);
661         SET(Sub);
662         SET(Bic);
663         SET(Shl);
664         SET(Shr);
665         SET(Shrs);
666         */
667 }
668
669 static int cmp_attr_arm(ir_node *a, ir_node *b) {
670         arm_attr_t *attr_a = get_irn_generic_attr(a);
671         arm_attr_t *attr_b = get_irn_generic_attr(b);
672         return (attr_a->instr_fl != attr_b->instr_fl) || (attr_a->imm_value != attr_b->imm_value);
673 }
674
675 static int cmp_attr_arm_SymConst(ir_node *a, ir_node *b) {
676         const arm_SymConst_attr_t *attr_a;
677         const arm_SymConst_attr_t *attr_b;
678
679         if (cmp_attr_arm(a, b))
680                 return 1;
681
682         attr_a = get_irn_generic_attr_const(a);
683         attr_b = get_irn_generic_attr_const(b);
684         return attr_a->symconst_id != attr_b->symconst_id;
685 }
686
687 static int cmp_attr_arm_CondJmp(ir_node *a, ir_node *b) {
688         (void) a;
689         (void) b;
690         /* never identical */
691         return 1;
692 }
693
694 static int cmp_attr_arm_SwitchJmp(ir_node *a, ir_node *b) {
695         (void) a;
696         (void) b;
697         /* never identical */
698         return 1;
699 }
700
701 static int cmp_attr_arm_fpaConst(ir_node *a, ir_node *b) {
702         const arm_fpaConst_attr_t *attr_a;
703         const arm_fpaConst_attr_t *attr_b;
704
705         if (cmp_attr_arm(a, b))
706                 return 1;
707
708         attr_a = get_arm_fpaConst_attr_const(a);
709         attr_b = get_arm_fpaConst_attr_const(b);
710
711         return attr_a->tv != attr_b->tv;
712 }
713
714 /** copies the ARM attributes of a node. */
715 static void arm_copy_attr(const ir_node *old_node, ir_node *new_node) {
716         ir_graph          *irg     = get_irn_irg(new_node);
717         struct obstack    *obst    = get_irg_obstack(irg);
718         const arm_attr_t *attr_old = get_arm_attr_const(old_node);
719         arm_attr_t       *attr_new = get_arm_attr(new_node);
720
721         /* copy the attributes */
722         memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));
723
724         /* copy out flags */
725         attr_new->out_flags =
726                 DUP_ARR_D(int, obst, attr_old->out_flags);
727         /* copy register assignments */
728         attr_new->slots =
729                 DUP_ARR_D(arch_register_t*, obst, attr_old->slots);
730 }
731
732
733
734 /* Include the generated constructor functions */
735 #include "gen_arm_new_nodes.c.inl"