remove now unnecessary beabi stuff from bearch_arm
[libfirm] / ir / be / arm / bearch_arm.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   The main arm backend driver file.
23  * @author  Matthias Braun, Oliver Richter, Tobias Gneist
24  * @version $Id$
25  */
26 #include "config.h"
27
28 #include "lc_opts.h"
29 #include "lc_opts_enum.h"
30
31 #include "pseudo_irg.h"
32 #include "irgwalk.h"
33 #include "irprog.h"
34 #include "irprintf.h"
35 #include "ircons.h"
36 #include "irgmod.h"
37 #include "irgopt.h"
38 #include "iroptimize.h"
39 #include "irdump.h"
40 #include "lowering.h"
41 #include "error.h"
42
43 #include "bitset.h"
44 #include "debug.h"
45 #include "array_t.h"
46 #include "irtools.h"
47
48 #include "../bearch.h"
49 #include "../benode.h"
50 #include "../belower.h"
51 #include "../besched.h"
52 #include "be.h"
53 #include "../bemachine.h"
54 #include "../beilpsched.h"
55 #include "../bemodule.h"
56 #include "../beirg.h"
57 #include "../bespillslots.h"
58 #include "../begnuas.h"
59 #include "../belistsched.h"
60 #include "../beflags.h"
61
62 #include "bearch_arm_t.h"
63
64 #include "arm_new_nodes.h"
65 #include "gen_arm_regalloc_if.h"
66 #include "arm_transform.h"
67 #include "arm_optimize.h"
68 #include "arm_emitter.h"
69 #include "arm_map_regs.h"
70
71 static arch_irn_class_t arm_classify(const ir_node *irn)
72 {
73         (void) irn;
74         /* TODO: we should mark reload/spill instructions and classify them here */
75         return 0;
76 }
77
78 static ir_entity *arm_get_frame_entity(const ir_node *irn)
79 {
80         const arm_attr_t *attr = get_arm_attr_const(irn);
81
82         if (is_arm_FrameAddr(irn)) {
83                 const arm_SymConst_attr_t *attr = get_irn_generic_attr_const(irn);
84                 return attr->entity;
85         }
86         if (attr->is_load_store) {
87                 const arm_load_store_attr_t *load_store_attr
88                         = get_arm_load_store_attr_const(irn);
89                 if (load_store_attr->is_frame_entity) {
90                         return load_store_attr->entity;
91                 }
92         }
93         return NULL;
94 }
95
96 static void arm_set_frame_entity(ir_node *irn, ir_entity *ent)
97 {
98         (void) irn;
99         (void) ent;
100         panic("arm_set_frame_entity() called. This should not happen.");
101 }
102
103 /**
104  * This function is called by the generic backend to correct offsets for
105  * nodes accessing the stack.
106  */
107 static void arm_set_stack_bias(ir_node *irn, int bias)
108 {
109         if (is_arm_FrameAddr(irn)) {
110                 arm_SymConst_attr_t *attr = get_irn_generic_attr(irn);
111                 attr->fp_offset += bias;
112         } else {
113                 arm_load_store_attr_t *attr = get_arm_load_store_attr(irn);
114                 assert(attr->base.is_load_store);
115                 attr->offset += bias;
116         }
117 }
118
119 static int arm_get_sp_bias(const ir_node *irn)
120 {
121         /* We don't have any nodes changing the stack pointer.
122            We probably want to support post-/pre increment/decrement later */
123         (void) irn;
124         return 0;
125 }
126
127 /* fill register allocator interface */
128
129 static const arch_irn_ops_t arm_irn_ops = {
130         get_arm_in_req,
131         arm_classify,
132         arm_get_frame_entity,
133         arm_set_frame_entity,
134         arm_set_stack_bias,
135         arm_get_sp_bias,
136         NULL,    /* get_inverse             */
137         NULL,    /* get_op_estimated_cost   */
138         NULL,    /* possible_memory_operand */
139         NULL,    /* perform_memory_operand  */
140 };
141
142 /**
143  * Transforms the standard Firm graph into
144  * a ARM firm graph.
145  */
146 static void arm_prepare_graph(void *self)
147 {
148         arm_code_gen_t *cg = self;
149
150         /* transform nodes into assembler instructions */
151         arm_transform_graph(cg);
152
153         /* do local optimizations (mainly CSE) */
154         local_optimize_graph(cg->irg);
155
156         if (cg->dump)
157                 dump_ir_graph(cg->irg, "transformed");
158
159         /* do code placement, to optimize the position of constants */
160         place_code(cg->irg);
161
162         if (cg->dump)
163                 dump_ir_graph(cg->irg, "place");
164 }
165
166 /**
167  * Called immediately before emit phase.
168  */
169 static void arm_finish_irg(void *self)
170 {
171         arm_code_gen_t *cg = self;
172
173         /* do peephole optimizations and fix stack offsets */
174         arm_peephole_optimization(cg);
175 }
176
177 static ir_node *arm_flags_remat(ir_node *node, ir_node *after)
178 {
179         ir_node *block;
180         ir_node *copy;
181
182         if (is_Block(after)) {
183                 block = after;
184         } else {
185                 block = get_nodes_block(after);
186         }
187         copy = exact_copy(node);
188         set_nodes_block(copy, block);
189         sched_add_after(after, copy);
190         return copy;
191 }
192
193 static void arm_before_ra(void *self)
194 {
195         arm_code_gen_t *cg = self;
196
197         be_sched_fix_flags(cg->irg, &arm_reg_classes[CLASS_arm_flags],
198                            &arm_flags_remat);
199 }
200
201 static void transform_Reload(ir_node *node)
202 {
203         ir_node   *block  = get_nodes_block(node);
204         dbg_info  *dbgi   = get_irn_dbg_info(node);
205         ir_node   *ptr    = get_irn_n(node, be_pos_Reload_frame);
206         ir_node   *mem    = get_irn_n(node, be_pos_Reload_mem);
207         ir_mode   *mode   = get_irn_mode(node);
208         ir_entity *entity = be_get_frame_entity(node);
209         const arch_register_t *reg;
210         ir_node   *proj;
211         ir_node   *load;
212
213         ir_node  *sched_point = sched_prev(node);
214
215         load = new_bd_arm_Ldr(dbgi, block, ptr, mem, mode, entity, false, 0, true);
216         sched_add_after(sched_point, load);
217         sched_remove(node);
218
219         proj = new_rd_Proj(dbgi, load, mode, pn_arm_Ldr_res);
220
221         reg = arch_get_irn_register(node);
222         arch_set_irn_register(proj, reg);
223
224         exchange(node, proj);
225 }
226
227 static void transform_Spill(ir_node *node)
228 {
229         ir_node   *block  = get_nodes_block(node);
230         dbg_info  *dbgi   = get_irn_dbg_info(node);
231         ir_node   *ptr    = get_irn_n(node, be_pos_Spill_frame);
232         ir_node   *mem    = new_NoMem();
233         ir_node   *val    = get_irn_n(node, be_pos_Spill_val);
234         ir_mode   *mode   = get_irn_mode(val);
235         ir_entity *entity = be_get_frame_entity(node);
236         ir_node   *sched_point;
237         ir_node   *store;
238
239         sched_point = sched_prev(node);
240         store = new_bd_arm_Str(dbgi, block, ptr, val, mem, mode, entity, false, 0,
241                                true);
242
243         sched_remove(node);
244         sched_add_after(sched_point, store);
245
246         exchange(node, store);
247 }
248
249 static void arm_after_ra_walker(ir_node *block, void *data)
250 {
251         ir_node *node, *prev;
252         (void) data;
253
254         for (node = sched_last(block); !sched_is_begin(node); node = prev) {
255                 prev = sched_prev(node);
256
257                 if (be_is_Reload(node)) {
258                         transform_Reload(node);
259                 } else if (be_is_Spill(node)) {
260                         transform_Spill(node);
261                 }
262         }
263 }
264
265 static void arm_after_ra(void *self)
266 {
267         arm_code_gen_t *cg = self;
268         be_coalesce_spillslots(cg->irg);
269
270         irg_block_walk_graph(cg->irg, NULL, arm_after_ra_walker, NULL);
271 }
272
273 /**
274  * Emits the code, closes the output file and frees
275  * the code generator interface.
276  */
277 static void arm_emit_and_done(void *self)
278 {
279         arm_code_gen_t *cg = self;
280         ir_graph       *irg = cg->irg;
281
282         arm_gen_routine(cg, irg);
283
284         /* de-allocate code generator */
285         del_set(cg->reg_set);
286         free(self);
287 }
288
289 /* forward */
290 static void *arm_cg_init(ir_graph *irg);
291
292 static const arch_code_generator_if_t arm_code_gen_if = {
293         arm_cg_init,
294         NULL,               /* get_pic_base */
295         NULL,               /* before abi introduce */
296         arm_prepare_graph,
297         NULL,               /* spill */
298         arm_before_ra,      /* before register allocation hook */
299         arm_after_ra,
300         arm_finish_irg,
301         arm_emit_and_done,
302 };
303
304 /**
305  * Initializes the code generator.
306  */
307 static void *arm_cg_init(ir_graph *irg)
308 {
309         static ir_type *int_tp = NULL;
310         arm_isa_t      *isa = (arm_isa_t *) be_get_irg_arch_env(irg);
311         arm_code_gen_t *cg;
312
313         if (! int_tp) {
314                 /* create an integer type with machine size */
315                 int_tp = new_type_primitive(mode_Is);
316         }
317
318         cg = XMALLOC(arm_code_gen_t);
319         cg->impl         = &arm_code_gen_if;
320         cg->irg          = irg;
321         cg->reg_set      = new_set(arm_cmp_irn_reg_assoc, 1024);
322         cg->isa          = isa;
323         cg->int_tp       = int_tp;
324         cg->have_fp_insn = 0;
325         cg->dump         = (be_get_irg_options(irg)->dump_flags & DUMP_BE) ? 1 : 0;
326
327         FIRM_DBG_REGISTER(cg->mod, "firm.be.arm.cg");
328
329         /* enter the current code generator */
330         isa->cg = cg;
331
332         return (arch_code_generator_t *)cg;
333 }
334
335
336 /**
337  * Maps all intrinsic calls that the backend support
338  * and map all instructions the backend did not support
339  * to runtime calls.
340  */
341 static void arm_handle_intrinsics(void)
342 {
343         ir_type *tp, *int_tp, *uint_tp;
344         i_record records[8];
345         int n_records = 0;
346
347         runtime_rt rt_iDiv, rt_uDiv, rt_iMod, rt_uMod;
348
349 #define ID(x) new_id_from_chars(x, sizeof(x)-1)
350
351         int_tp  = new_type_primitive(mode_Is);
352         uint_tp = new_type_primitive(mode_Iu);
353
354         /* ARM has neither a signed div instruction ... */
355         {
356                 i_instr_record *map_Div = &records[n_records++].i_instr;
357
358                 tp = new_type_method(2, 1);
359                 set_method_param_type(tp, 0, int_tp);
360                 set_method_param_type(tp, 1, int_tp);
361                 set_method_res_type(tp, 0, int_tp);
362
363                 rt_iDiv.ent             = new_entity(get_glob_type(), ID("__divsi3"), tp);
364                 set_entity_ld_ident(rt_iDiv.ent, ID("__divsi3"));
365                 rt_iDiv.mode            = mode_T;
366                 rt_iDiv.res_mode        = mode_Is;
367                 rt_iDiv.mem_proj_nr     = pn_Div_M;
368                 rt_iDiv.regular_proj_nr = pn_Div_X_regular;
369                 rt_iDiv.exc_proj_nr     = pn_Div_X_except;
370                 rt_iDiv.exc_mem_proj_nr = pn_Div_M;
371                 rt_iDiv.res_proj_nr     = pn_Div_res;
372
373                 add_entity_linkage(rt_iDiv.ent, IR_LINKAGE_CONSTANT);
374                 set_entity_visibility(rt_iDiv.ent, ir_visibility_external);
375
376                 map_Div->kind     = INTRINSIC_INSTR;
377                 map_Div->op       = op_Div;
378                 map_Div->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
379                 map_Div->ctx      = &rt_iDiv;
380         }
381         /* ... nor an unsigned div instruction ... */
382         {
383                 i_instr_record *map_Div = &records[n_records++].i_instr;
384
385                 tp = new_type_method(2, 1);
386                 set_method_param_type(tp, 0, uint_tp);
387                 set_method_param_type(tp, 1, uint_tp);
388                 set_method_res_type(tp, 0, uint_tp);
389
390                 rt_uDiv.ent             = new_entity(get_glob_type(), ID("__udivsi3"), tp);
391                 set_entity_ld_ident(rt_uDiv.ent, ID("__udivsi3"));
392                 rt_uDiv.mode            = mode_T;
393                 rt_uDiv.res_mode        = mode_Iu;
394                 rt_uDiv.mem_proj_nr     = pn_Div_M;
395                 rt_uDiv.regular_proj_nr = pn_Div_X_regular;
396                 rt_uDiv.exc_proj_nr     = pn_Div_X_except;
397                 rt_uDiv.exc_mem_proj_nr = pn_Div_M;
398                 rt_uDiv.res_proj_nr     = pn_Div_res;
399
400                 set_entity_visibility(rt_uDiv.ent, ir_visibility_external);
401
402                 map_Div->kind     = INTRINSIC_INSTR;
403                 map_Div->op       = op_Div;
404                 map_Div->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
405                 map_Div->ctx      = &rt_uDiv;
406         }
407         /* ... nor a signed mod instruction ... */
408         {
409                 i_instr_record *map_Mod = &records[n_records++].i_instr;
410
411                 tp = new_type_method(2, 1);
412                 set_method_param_type(tp, 0, int_tp);
413                 set_method_param_type(tp, 1, int_tp);
414                 set_method_res_type(tp, 0, int_tp);
415
416                 rt_iMod.ent             = new_entity(get_glob_type(), ID("__modsi3"), tp);
417                 set_entity_ld_ident(rt_iMod.ent, ID("__modsi3"));
418                 rt_iMod.mode            = mode_T;
419                 rt_iMod.res_mode        = mode_Is;
420                 rt_iMod.mem_proj_nr     = pn_Mod_M;
421                 rt_iMod.regular_proj_nr = pn_Mod_X_regular;
422                 rt_iMod.exc_proj_nr     = pn_Mod_X_except;
423                 rt_iMod.exc_mem_proj_nr = pn_Mod_M;
424                 rt_iMod.res_proj_nr     = pn_Mod_res;
425
426                 set_entity_visibility(rt_iMod.ent, ir_visibility_external);
427
428                 map_Mod->kind     = INTRINSIC_INSTR;
429                 map_Mod->op       = op_Mod;
430                 map_Mod->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
431                 map_Mod->ctx      = &rt_iMod;
432         }
433         /* ... nor an unsigned mod. */
434         {
435                 i_instr_record *map_Mod = &records[n_records++].i_instr;
436
437                 tp = new_type_method(2, 1);
438                 set_method_param_type(tp, 0, uint_tp);
439                 set_method_param_type(tp, 1, uint_tp);
440                 set_method_res_type(tp, 0, uint_tp);
441
442                 rt_uMod.ent             = new_entity(get_glob_type(), ID("__umodsi3"), tp);
443                 set_entity_ld_ident(rt_uMod.ent, ID("__umodsi3"));
444                 rt_uMod.mode            = mode_T;
445                 rt_uMod.res_mode        = mode_Iu;
446                 rt_uMod.mem_proj_nr     = pn_Mod_M;
447                 rt_uMod.regular_proj_nr = pn_Mod_X_regular;
448                 rt_uMod.exc_proj_nr     = pn_Mod_X_except;
449                 rt_uMod.exc_mem_proj_nr = pn_Mod_M;
450                 rt_uMod.res_proj_nr     = pn_Mod_res;
451
452                 set_entity_visibility(rt_uMod.ent, ir_visibility_external);
453
454                 map_Mod->kind     = INTRINSIC_INSTR;
455                 map_Mod->op       = op_Mod;
456                 map_Mod->i_mapper = (i_mapper_func)i_mapper_RuntimeCall;
457                 map_Mod->ctx      = &rt_uMod;
458         }
459
460         if (n_records > 0)
461                 lower_intrinsics(records, n_records, /*part_block_used=*/0);
462 }
463
464
465 static arm_isa_t arm_isa_template = {
466         {
467                 &arm_isa_if,           /* isa interface */
468                 &arm_gp_regs[REG_SP],  /* stack pointer */
469                 &arm_gp_regs[REG_R11], /* base pointer */
470                 &arm_reg_classes[CLASS_arm_gp],  /* static link pointer class */
471                 -1,                    /* stack direction */
472                 2,                     /* power of two stack alignment for calls, 2^2 == 4 */
473                 NULL,                  /* main environment */
474                 7,                     /* spill costs */
475                 5,                     /* reload costs */
476                 true,                  /* we do have custom abi handling */
477         },
478         0,                     /* use generic register names instead of SP, LR, PC */
479         ARM_FPU_ARCH_FPE,      /* FPU architecture */
480         NULL,                  /* current code generator */
481 };
482
483 /**
484  * Initializes the backend ISA and opens the output file.
485  */
486 static arch_env_t *arm_init(FILE *file_handle)
487 {
488         static int inited = 0;
489         arm_isa_t *isa;
490
491         if (inited)
492                 return NULL;
493
494         isa = XMALLOC(arm_isa_t);
495         memcpy(isa, &arm_isa_template, sizeof(*isa));
496
497         arm_register_init();
498
499         isa->cg  = NULL;
500         be_emit_init(file_handle);
501
502         arm_create_opcodes(&arm_irn_ops);
503         arm_handle_intrinsics();
504
505         be_gas_emit_types = false;
506
507         /* needed for the debug support */
508         be_gas_emit_switch_section(GAS_SECTION_TEXT);
509         be_emit_irprintf("%stext0:\n", be_gas_get_private_prefix());
510         be_emit_write_line();
511
512         inited = 1;
513         return &isa->arch_env;
514 }
515
516
517
518 /**
519  * Closes the output file and frees the ISA structure.
520  */
521 static void arm_done(void *self)
522 {
523         arm_isa_t *isa = self;
524
525         be_gas_emit_decls(isa->arch_env.main_env);
526
527         be_emit_exit();
528         free(self);
529 }
530
531
532 /**
533  * Report the number of register classes.
534  * If we don't have fp instructions, report only GP
535  * here to speed up register allocation (and makes dumps
536  * smaller and more readable).
537  */
538 static unsigned arm_get_n_reg_class(void)
539 {
540         return N_CLASSES;
541 }
542
543 /**
544  * Return the register class with requested index.
545  */
546 static const arch_register_class_t *arm_get_reg_class(unsigned i)
547 {
548         assert(i < N_CLASSES);
549         return &arm_reg_classes[i];
550 }
551
552 /**
553  * Get the register class which shall be used to store a value of a given mode.
554  * @param self The this pointer.
555  * @param mode The mode in question.
556  * @return A register class which can hold values of the given mode.
557  */
558 static const arch_register_class_t *arm_get_reg_class_for_mode(const ir_mode *mode)
559 {
560         if (mode_is_float(mode))
561                 return &arm_reg_classes[CLASS_arm_fpa];
562         else
563                 return &arm_reg_classes[CLASS_arm_gp];
564 }
565
566 static int arm_to_appear_in_schedule(void *block_env, const ir_node *irn)
567 {
568         (void) block_env;
569         if (!is_arm_irn(irn))
570                 return -1;
571
572         return 1;
573 }
574
575 /**
576  * Initializes the code generator interface.
577  */
578 static const arch_code_generator_if_t *arm_get_code_generator_if(void *self)
579 {
580         (void) self;
581         return &arm_code_gen_if;
582 }
583
584 list_sched_selector_t arm_sched_selector;
585
586 /**
587  * Returns the reg_pressure scheduler with to_appear_in_schedule() over\loaded
588  */
589 static const list_sched_selector_t *arm_get_list_sched_selector(const void *self, list_sched_selector_t *selector)
590 {
591         (void) self;
592         memcpy(&arm_sched_selector, selector, sizeof(arm_sched_selector));
593         /* arm_sched_selector.exectime              = arm_sched_exectime; */
594         arm_sched_selector.to_appear_in_schedule = arm_to_appear_in_schedule;
595         return &arm_sched_selector;
596
597 }
598
599 static const ilp_sched_selector_t *arm_get_ilp_sched_selector(const void *self)
600 {
601         (void) self;
602         return NULL;
603 }
604
605 /**
606  * Returns the necessary byte alignment for storing a register of given class.
607  */
608 static int arm_get_reg_class_alignment(const arch_register_class_t *cls)
609 {
610         (void) cls;
611         /* ARM is a 32 bit CPU, no need for other alignment */
612         return 4;
613 }
614
615 static const be_execution_unit_t ***arm_get_allowed_execution_units(const ir_node *irn)
616 {
617         (void) irn;
618         /* TODO */
619         panic("Unimplemented arm_get_allowed_execution_units()");
620 }
621
622 static const be_machine_t *arm_get_machine(const void *self)
623 {
624         (void) self;
625         /* TODO */
626         panic("Unimplemented arm_get_machine()");
627 }
628
629 /**
630  * Return irp irgs in the desired order.
631  */
632 static ir_graph **arm_get_irg_list(const void *self, ir_graph ***irg_list)
633 {
634         (void) self;
635         (void) irg_list;
636         return NULL;
637 }
638
639 /**
640  * Allows or disallows the creation of Psi nodes for the given Phi nodes.
641  * @return 1 if allowed, 0 otherwise
642  */
643 static int arm_is_mux_allowed(ir_node *sel, ir_node *mux_false,
644                               ir_node *mux_true)
645 {
646         (void) sel;
647         (void) mux_false;
648         (void) mux_true;
649
650         return 0;
651 }
652
653 static asm_constraint_flags_t arm_parse_asm_constraint(const char **c)
654 {
655         /* asm not supported */
656         (void) c;
657         return ASM_CONSTRAINT_FLAG_INVALID;
658 }
659
660 static int arm_is_valid_clobber(const char *clobber)
661 {
662         (void) clobber;
663         return 0;
664 }
665
666 /**
667  * Returns the libFirm configuration parameter for this backend.
668  */
669 static const backend_params *arm_get_libfirm_params(void)
670 {
671         static const ir_settings_if_conv_t ifconv = {
672                 4,                    /* maxdepth, doesn't matter for Psi-conversion */
673                 arm_is_mux_allowed   /* allows or disallows Mux creation for given selector */
674         };
675         static ir_settings_arch_dep_t ad = {
676                 1,    /* allow subs */
677                 1,        /* Muls are fast enough on ARM but ... */
678                 31,   /* ... one shift would be possible better */
679                 NULL, /* no evaluator function */
680                 0,    /* SMUL is needed, only in Arch M */
681                 0,    /* UMUL is needed, only in Arch M */
682                 32,   /* SMUL & UMUL available for 32 bit */
683         };
684         static backend_params p = {
685                 1,     /* need dword lowering */
686                 0,     /* don't support inline assembler yet */
687                 NULL,  /* will be set later */
688                 NULL,  /* but yet no creator function */
689                 NULL,  /* context for create_intrinsic_fkt */
690                 NULL,  /* ifconv_info will be set below */
691                 NULL,  /* float arithmetic mode (TODO) */
692                 0,     /* no trampoline support: size 0 */
693                 0,     /* no trampoline support: align 0 */
694                 NULL,  /* no trampoline support: no trampoline builder */
695                 4      /* alignment of stack parameter */
696         };
697
698         p.dep_param    = &ad;
699         p.if_conv_info = &ifconv;
700         return &p;
701 }
702
703 /* fpu set architectures. */
704 static const lc_opt_enum_int_items_t arm_fpu_items[] = {
705         { "softfloat", ARM_FPU_ARCH_SOFTFLOAT },
706         { "fpe",       ARM_FPU_ARCH_FPE },
707         { "fpa",       ARM_FPU_ARCH_FPA },
708         { "vfp1xd",    ARM_FPU_ARCH_VFP_V1xD },
709         { "vfp1",      ARM_FPU_ARCH_VFP_V1 },
710         { "vfp2",      ARM_FPU_ARCH_VFP_V2 },
711         { NULL,        0 }
712 };
713
714 static lc_opt_enum_int_var_t arch_fpu_var = {
715         &arm_isa_template.fpu_arch, arm_fpu_items
716 };
717
718 static const lc_opt_table_entry_t arm_options[] = {
719         LC_OPT_ENT_ENUM_INT("fpunit",    "select the floating point unit", &arch_fpu_var),
720         LC_OPT_ENT_BOOL("gen_reg_names", "use generic register names", &arm_isa_template.gen_reg_names),
721         LC_OPT_LAST
722 };
723
724 const arch_isa_if_t arm_isa_if = {
725         arm_init,
726         arm_done,
727         NULL,  /* handle_intrinsics */
728         arm_get_n_reg_class,
729         arm_get_reg_class,
730         arm_get_reg_class_for_mode,
731         NULL,
732         arm_get_code_generator_if,
733         arm_get_list_sched_selector,
734         arm_get_ilp_sched_selector,
735         arm_get_reg_class_alignment,
736         arm_get_libfirm_params,
737         arm_get_allowed_execution_units,
738         arm_get_machine,
739         arm_get_irg_list,
740         NULL,               /* mark remat */
741         arm_parse_asm_constraint,
742         arm_is_valid_clobber
743 };
744
745 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_arm);
746 void be_init_arch_arm(void)
747 {
748         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
749         lc_opt_entry_t *arm_grp = lc_opt_get_grp(be_grp, "arm");
750
751         lc_opt_add_table(arm_grp, arm_options);
752
753         be_register_isa_if("arm", &arm_isa_if);
754
755         arm_init_transform();
756         arm_init_emitter();
757 }