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