fixed indents, typos
[libfirm] / ir / be / ia32 / bearch_ia32.c
1 /**
2  * This is the main ia32 firm backend driver.
3  *
4  * $Id$
5  */
6
7 #ifdef HAVE_CONFIG_H
8 #include "config.h"
9 #endif
10
11 #ifdef HAVE_MALLOC_H
12 #include <malloc.h>
13 #endif
14
15 #ifdef HAVE_ALLOCA_H
16 #include <alloca.h>
17 #endif
18
19 #ifdef WITH_LIBCORE
20 #include <libcore/lc_opts.h>
21 #include <libcore/lc_opts_enum.h>
22 #endif /* WITH_LIBCORE */
23
24 #include "pseudo_irg.h"
25 #include "irgwalk.h"
26 #include "irprog.h"
27 #include "irprintf.h"
28 #include "iredges_t.h"
29 #include "ircons.h"
30 #include "irgmod.h"
31 #include "irgopt.h"
32
33 #include "bitset.h"
34 #include "debug.h"
35
36 #include "../beabi.h"                 /* the general register allocator interface */
37 #include "../benode_t.h"
38 #include "../belower.h"
39 #include "../besched_t.h"
40 #include "../be.h"
41 #include "bearch_ia32_t.h"
42
43 #include "ia32_new_nodes.h"           /* ia32 nodes interface */
44 #include "gen_ia32_regalloc_if.h"     /* the generated interface (register type and class defenitions) */
45 #include "ia32_gen_decls.h"           /* interface declaration emitter */
46 #include "ia32_transform.h"
47 #include "ia32_emitter.h"
48 #include "ia32_map_regs.h"
49 #include "ia32_optimize.h"
50 #include "ia32_x87.h"
51
52 #define DEBUG_MODULE "firm.be.ia32.isa"
53
54 /* TODO: ugly */
55 static set *cur_reg_set = NULL;
56
57 #undef is_Start
58 #define is_Start(irn) (get_irn_opcode(irn) == iro_Start)
59
60 /* Creates the unique per irg GP NoReg node. */
61 ir_node *ia32_new_NoReg_gp(ia32_code_gen_t *cg) {
62         return be_abi_get_callee_save_irn(cg->birg->abi, &ia32_gp_regs[REG_GP_NOREG]);
63 }
64
65 /* Creates the unique per irg FP NoReg node. */
66 ir_node *ia32_new_NoReg_fp(ia32_code_gen_t *cg) {
67         return be_abi_get_callee_save_irn(cg->birg->abi,
68                 USE_SSE2(cg) ? &ia32_xmm_regs[REG_XMM_NOREG] : &ia32_vfp_regs[REG_VFP_NOREG]);
69 }
70
71 /**************************************************
72  *                         _ _              _  __
73  *                        | | |            (_)/ _|
74  *  _ __ ___  __ _    __ _| | | ___   ___   _| |_
75  * | '__/ _ \/ _` |  / _` | | |/ _ \ / __| | |  _|
76  * | | |  __/ (_| | | (_| | | | (_) | (__  | | |
77  * |_|  \___|\__, |  \__,_|_|_|\___/ \___| |_|_|
78  *            __/ |
79  *           |___/
80  **************************************************/
81
82 static ir_node *my_skip_proj(const ir_node *n) {
83         while (is_Proj(n))
84                 n = get_Proj_pred(n);
85         return (ir_node *)n;
86 }
87
88
89 /**
90  * Return register requirements for an ia32 node.
91  * If the node returns a tuple (mode_T) then the proj's
92  * will be asked for this information.
93  */
94 static const arch_register_req_t *ia32_get_irn_reg_req(const void *self, arch_register_req_t *req, const ir_node *irn, int pos) {
95         const ia32_irn_ops_t      *ops = self;
96         const ia32_register_req_t *irn_req;
97         long                       node_pos = pos == -1 ? 0 : pos;
98         ir_mode                   *mode     = is_Block(irn) ? NULL : get_irn_mode(irn);
99         FIRM_DBG_REGISTER(firm_dbg_module_t *mod, DEBUG_MODULE);
100
101         if (is_Block(irn) || mode == mode_M || mode == mode_X) {
102                 DBG((mod, LEVEL_1, "ignoring Block, mode_M, mode_X node %+F\n", irn));
103                 return NULL;
104         }
105
106         if (mode == mode_T && pos < 0) {
107                 DBG((mod, LEVEL_1, "ignoring request OUT requirements for node %+F\n", irn));
108                 return NULL;
109         }
110
111         DBG((mod, LEVEL_1, "get requirements at pos %d for %+F ... ", pos, irn));
112
113         if (is_Proj(irn)) {
114                 if (pos == -1) {
115                         node_pos = ia32_translate_proj_pos(irn);
116                 }
117                 else {
118                         node_pos = pos;
119                 }
120
121                 irn = my_skip_proj(irn);
122
123                 DB((mod, LEVEL_1, "skipping Proj, going to %+F at pos %d ... ", irn, node_pos));
124         }
125
126         if (is_ia32_irn(irn)) {
127                 if (pos >= 0) {
128                         irn_req = get_ia32_in_req(irn, pos);
129                 }
130                 else {
131                         irn_req = get_ia32_out_req(irn, node_pos);
132                 }
133
134                 DB((mod, LEVEL_1, "returning reqs for %+F at pos %d\n", irn, pos));
135
136                 memcpy(req, &(irn_req->req), sizeof(*req));
137
138                 if (arch_register_req_is(&(irn_req->req), should_be_same)) {
139                         assert(irn_req->same_pos >= 0 && "should be same constraint for in -> out NYI");
140                         req->other_same = get_irn_n(irn, irn_req->same_pos);
141                 }
142
143                 if (arch_register_req_is(&(irn_req->req), should_be_different)) {
144                         assert(irn_req->different_pos >= 0 && "should be different constraint for in -> out NYI");
145                         req->other_different = get_irn_n(irn, irn_req->different_pos);
146                 }
147         }
148         else {
149                 /* treat Phi like Const with default requirements */
150                 if (is_Phi(irn)) {
151                         DB((mod, LEVEL_1, "returning standard reqs for %+F\n", irn));
152                         if (mode_is_float(mode)) {
153                                 if (USE_SSE2(ops->cg))
154                                         memcpy(req, &(ia32_default_req_ia32_xmm.req), sizeof(*req));
155                                 else
156                                         memcpy(req, &(ia32_default_req_ia32_vfp.req), sizeof(*req));
157                         }
158                         else if (mode_is_int(mode) || mode_is_reference(mode))
159                                 memcpy(req, &(ia32_default_req_ia32_gp.req), sizeof(*req));
160                         else if (mode == mode_T || mode == mode_M) {
161                                 DBG((mod, LEVEL_1, "ignoring Phi node %+F\n", irn));
162                                 return NULL;
163                         }
164                         else
165                                 assert(0 && "unsupported Phi-Mode");
166                 }
167                 else {
168                         DB((mod, LEVEL_1, "returning NULL for %+F (not ia32)\n", irn));
169                         req = NULL;
170                 }
171         }
172
173         return req;
174 }
175
176 static void ia32_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg) {
177         int                   pos = 0;
178         const ia32_irn_ops_t *ops = self;
179
180         if (get_irn_mode(irn) == mode_X) {
181                 return;
182         }
183
184         DBG((ops->cg->mod, LEVEL_1, "ia32 assigned register %s to node %+F\n", reg->name, irn));
185
186         if (is_Proj(irn)) {
187                 pos = ia32_translate_proj_pos(irn);
188                 irn = my_skip_proj(irn);
189         }
190
191         if (is_ia32_irn(irn)) {
192                 const arch_register_t **slots;
193
194                 slots      = get_ia32_slots(irn);
195                 slots[pos] = reg;
196         }
197         else {
198                 ia32_set_firm_reg(irn, reg, cur_reg_set);
199         }
200 }
201
202 static const arch_register_t *ia32_get_irn_reg(const void *self, const ir_node *irn) {
203         int pos = 0;
204         const arch_register_t *reg = NULL;
205
206         if (is_Proj(irn)) {
207
208                 if (get_irn_mode(irn) == mode_X) {
209                         return NULL;
210                 }
211
212                 pos = ia32_translate_proj_pos(irn);
213                 irn = my_skip_proj(irn);
214         }
215
216         if (is_ia32_irn(irn)) {
217                 const arch_register_t **slots;
218                 slots = get_ia32_slots(irn);
219                 reg   = slots[pos];
220         }
221         else {
222                 reg = ia32_get_firm_reg(irn, cur_reg_set);
223         }
224
225         return reg;
226 }
227
228 static arch_irn_class_t ia32_classify(const void *self, const ir_node *irn) {
229         irn = my_skip_proj(irn);
230         if (is_cfop(irn))
231                 return arch_irn_class_branch;
232         else if (is_ia32_irn(irn))
233                 return arch_irn_class_normal;
234         else
235                 return 0;
236 }
237
238 static arch_irn_flags_t ia32_get_flags(const void *self, const ir_node *irn) {
239         irn = my_skip_proj(irn);
240         if (is_ia32_irn(irn))
241                 return get_ia32_flags(irn);
242         else {
243                 return 0;
244         }
245 }
246
247 static entity *ia32_get_frame_entity(const void *self, const ir_node *irn) {
248         return is_ia32_irn(irn) ? get_ia32_frame_ent(irn) : NULL;
249 }
250
251 static void ia32_set_stack_bias(const void *self, ir_node *irn, int bias) {
252         char buf[64];
253         const ia32_irn_ops_t *ops = self;
254
255         if (get_ia32_frame_ent(irn)) {
256                 ia32_am_flavour_t am_flav = get_ia32_am_flavour(irn);
257
258                 DBG((ops->cg->mod, LEVEL_1, "stack biased %+F with %d\n", irn, bias));
259                 snprintf(buf, sizeof(buf), "%d", bias);
260
261                 if (get_ia32_op_type(irn) == ia32_Normal) {
262                         set_ia32_cnst(irn, buf);
263                 }
264                 else {
265                         add_ia32_am_offs(irn, buf);
266                         am_flav |= ia32_O;
267                         set_ia32_am_flavour(irn, am_flav);
268                 }
269         }
270 }
271
272 typedef struct {
273         be_abi_call_flags_bits_t flags;
274         const arch_isa_t *isa;
275         const arch_env_t *aenv;
276         ir_graph *irg;
277 } ia32_abi_env_t;
278
279 static void *ia32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
280 {
281         ia32_abi_env_t *env    = xmalloc(sizeof(env[0]));
282         be_abi_call_flags_t fl = be_abi_call_get_flags(call);
283         env->flags = fl.bits;
284         env->irg   = irg;
285         env->aenv  = aenv;
286         env->isa   = aenv->isa;
287         return env;
288 }
289
290 static void ia32_abi_dont_save_regs(void *self, pset *s)
291 {
292         ia32_abi_env_t *env = self;
293         if(env->flags.try_omit_fp)
294                 pset_insert_ptr(s, env->isa->bp);
295 }
296
297 /**
298  * Generate the prologue.
299  * @param self    The callback object.
300  * @param mem     A pointer to the mem node. Update this if you define new memory.
301  * @param reg_map A mapping mapping all callee_save/ignore/parameter registers to their defining nodes.
302  * @return        The register which shall be used as a stack frame base.
303  *
304  * All nodes which define registers in @p reg_map must keep @p reg_map current.
305  */
306 static const arch_register_t *ia32_abi_prologue(void *self, ir_node **mem, pmap *reg_map)
307 {
308         ia32_abi_env_t *env              = self;
309
310         if (!env->flags.try_omit_fp) {
311                 int reg_size         = get_mode_size_bytes(env->isa->bp->reg_class->mode);
312                 ir_node *bl          = get_irg_start_block(env->irg);
313                 ir_node *curr_sp     = be_abi_reg_map_get(reg_map, env->isa->sp);
314                 ir_node *curr_bp     = be_abi_reg_map_get(reg_map, env->isa->bp);
315                 ir_node *curr_no_reg = be_abi_reg_map_get(reg_map, &ia32_gp_regs[REG_GP_NOREG]);
316                 ir_node *store_bp;
317
318                 /* push ebp */
319                 curr_sp  = be_new_IncSP(env->isa->sp, env->irg, bl, curr_sp, *mem, reg_size, be_stack_dir_expand);
320                 store_bp = new_rd_ia32_Store(NULL, env->irg, bl, curr_sp, curr_no_reg, curr_bp, *mem, mode_T);
321                 set_ia32_am_support(store_bp, ia32_am_Dest);
322                 set_ia32_am_flavour(store_bp, ia32_B);
323                 set_ia32_op_type(store_bp, ia32_AddrModeD);
324                 set_ia32_ls_mode(store_bp, env->isa->bp->reg_class->mode);
325                 *mem     = new_r_Proj(env->irg, bl, store_bp, mode_M, 0);
326
327                 /* move esp to ebp */
328                 curr_bp  = be_new_Copy(env->isa->bp->reg_class, env->irg, bl, curr_sp);
329                 be_set_constr_single_reg(curr_bp, BE_OUT_POS(0), env->isa->bp);
330                 arch_set_irn_register(env->aenv, curr_bp, env->isa->bp);
331                 be_node_set_flags(curr_bp, BE_OUT_POS(0), arch_irn_flags_dont_spill);
332
333                 be_abi_reg_map_set(reg_map, env->isa->sp, curr_sp);
334                 be_abi_reg_map_set(reg_map, env->isa->bp, curr_bp);
335
336                 return env->isa->bp;
337         }
338
339         return env->isa->sp;
340 }
341
342 static void ia32_abi_epilogue(void *self, ir_node *bl, ir_node **mem, pmap *reg_map)
343 {
344         ia32_abi_env_t *env  = self;
345         ir_node *curr_sp     = be_abi_reg_map_get(reg_map, env->isa->sp);
346         ir_node *curr_bp     = be_abi_reg_map_get(reg_map, env->isa->bp);
347         ir_node *curr_no_reg = be_abi_reg_map_get(reg_map, &ia32_gp_regs[REG_GP_NOREG]);
348
349         if (env->flags.try_omit_fp) {
350                 /* simply remove the stack frame here */
351                 curr_sp = be_new_IncSP(env->isa->sp, env->irg, bl, curr_sp, *mem, BE_STACK_FRAME_SIZE, be_stack_dir_shrink);
352         }
353
354         else {
355                 ir_node *load_bp;
356                 ir_mode *mode_bp = env->isa->bp->reg_class->mode;
357                 int reg_size     = get_mode_size_bytes(env->isa->bp->reg_class->mode);
358
359                 /* copy ebp to esp */
360                 curr_sp = be_new_SetSP(env->isa->sp, env->irg, bl, curr_sp, curr_bp, *mem);
361
362                 /* pop ebp */
363                 load_bp = new_rd_ia32_Load(NULL, env->irg, bl, curr_sp, curr_no_reg, *mem, mode_T);
364                 set_ia32_am_support(load_bp, ia32_am_Source);
365                 set_ia32_am_flavour(load_bp, ia32_B);
366                 set_ia32_op_type(load_bp, ia32_AddrModeS);
367                 set_ia32_ls_mode(load_bp, mode_bp);
368                 curr_bp = new_r_Proj(env->irg, bl, load_bp, mode_bp, 0);
369                 *mem    = new_r_Proj(env->irg, bl, load_bp, mode_M, 1);
370                 arch_set_irn_register(env->aenv, curr_bp, env->isa->bp);
371
372                 curr_sp  = be_new_IncSP(env->isa->sp, env->irg, bl, curr_sp, *mem, reg_size, be_stack_dir_shrink);
373         }
374
375         be_abi_reg_map_set(reg_map, env->isa->sp, curr_sp);
376         be_abi_reg_map_set(reg_map, env->isa->bp, curr_bp);
377 }
378
379 /**
380  * Produces the type which sits between the stack args and the locals on the stack.
381  * it will contain the return address and space to store the old base pointer.
382  * @return The Firm type modeling the ABI between type.
383  */
384 static ir_type *ia32_abi_get_between_type(void *self)
385 {
386         static ir_type *omit_fp_between_type = NULL;
387         static ir_type *between_type         = NULL;
388
389         ia32_abi_env_t *env = self;
390
391         if(!between_type) {
392                 entity *old_bp_ent;
393                 entity *ret_addr_ent;
394                 entity *omit_fp_ret_addr_ent;
395
396                 ir_type *old_bp_type   = new_type_primitive(new_id_from_str("bp"), mode_P);
397                 ir_type *ret_addr_type = new_type_primitive(new_id_from_str("return_addr"), mode_P);
398
399                 between_type           = new_type_class(new_id_from_str("ia32_between_type"));
400                 old_bp_ent             = new_entity(between_type, new_id_from_str("old_bp"), old_bp_type);
401                 ret_addr_ent           = new_entity(between_type, new_id_from_str("ret_addr"), ret_addr_type);
402
403                 set_entity_offset_bytes(old_bp_ent, 0);
404                 set_entity_offset_bytes(ret_addr_ent, get_type_size_bytes(old_bp_type));
405                 set_type_size_bytes(between_type, get_type_size_bytes(old_bp_type) + get_type_size_bytes(ret_addr_type));
406
407                 omit_fp_between_type   = new_type_class(new_id_from_str("ia32_between_type_omit_fp"));
408                 omit_fp_ret_addr_ent   = new_entity(omit_fp_between_type, new_id_from_str("ret_addr"), ret_addr_type);
409
410                 set_entity_offset_bytes(omit_fp_ret_addr_ent, 0);
411                 set_type_size_bytes(omit_fp_between_type, get_type_size_bytes(ret_addr_type));
412         }
413
414         return env->flags.try_omit_fp ? omit_fp_between_type : between_type;
415 }
416
417 static const be_abi_callbacks_t ia32_abi_callbacks = {
418         ia32_abi_init,
419         free,
420         ia32_abi_get_between_type,
421         ia32_abi_dont_save_regs,
422         ia32_abi_prologue,
423         ia32_abi_epilogue,
424 };
425
426 /* fill register allocator interface */
427
428 static const arch_irn_ops_if_t ia32_irn_ops_if = {
429         ia32_get_irn_reg_req,
430         ia32_set_irn_reg,
431         ia32_get_irn_reg,
432         ia32_classify,
433         ia32_get_flags,
434         ia32_get_frame_entity,
435         ia32_set_stack_bias
436 };
437
438 ia32_irn_ops_t ia32_irn_ops = {
439         &ia32_irn_ops_if,
440         NULL
441 };
442
443
444
445 /**************************************************
446  *                _                         _  __
447  *               | |                       (_)/ _|
448  *   ___ ___   __| | ___  __ _  ___ _ __    _| |_
449  *  / __/ _ \ / _` |/ _ \/ _` |/ _ \ '_ \  | |  _|
450  * | (_| (_) | (_| |  __/ (_| |  __/ | | | | | |
451  *  \___\___/ \__,_|\___|\__, |\___|_| |_| |_|_|
452  *                        __/ |
453  *                       |___/
454  **************************************************/
455
456 /**
457  * Transforms the standard firm graph into
458  * an ia32 firm graph
459  */
460 static void ia32_prepare_graph(void *self) {
461         ia32_code_gen_t *cg = self;
462         DEBUG_ONLY(firm_dbg_module_t *old_mod = cg->mod;)
463
464         FIRM_DBG_REGISTER(cg->mod, "firm.be.ia32.transform");
465         irg_walk_blkwise_graph(cg->irg, ia32_place_consts_set_modes, ia32_transform_node, cg);
466         be_dump(cg->irg, "-transformed", dump_ir_block_graph_sched);
467
468         if (cg->opt.doam) {
469                 edges_deactivate(cg->irg);
470                 //dead_node_elimination(cg->irg);
471                 edges_activate(cg->irg);
472
473                 FIRM_DBG_REGISTER(cg->mod, "firm.be.ia32.am");
474
475                 irg_walk_blkwise_graph(cg->irg, NULL, ia32_optimize_am, cg);
476                 be_dump(cg->irg, "-am", dump_ir_block_graph_sched);
477         }
478
479         DEBUG_ONLY(cg->mod = old_mod;)
480 }
481
482
483 /**
484  * Insert copies for all ia32 nodes where the should_be_same requirement
485  * is not fulfilled.
486  * Transform Sub into Neg -- Add if IN2 == OUT
487  */
488 static void ia32_finish_node(ir_node *irn, void *env) {
489         ia32_code_gen_t            *cg = env;
490         const ia32_register_req_t **reqs;
491         const arch_register_t      *out_reg, *in_reg, *in2_reg;
492         int                         n_res, i;
493         ir_node                    *copy, *in_node, *block, *in2_node;
494         ia32_op_type_t              op_tp;
495
496         if (is_ia32_irn(irn)) {
497                 /* AM Dest nodes don't produce any values  */
498                 op_tp = get_ia32_op_type(irn);
499                 if (op_tp == ia32_AddrModeD)
500                         goto end;
501
502                 reqs  = get_ia32_out_req_all(irn);
503                 n_res = get_ia32_n_res(irn);
504                 block = get_nodes_block(irn);
505
506                 /* check all OUT requirements, if there is a should_be_same */
507                 if (op_tp == ia32_Normal) {
508                         for (i = 0; i < n_res; i++) {
509                                 if (arch_register_req_is(&(reqs[i]->req), should_be_same)) {
510                                         /* get in and out register */
511                                         out_reg  = get_ia32_out_reg(irn, i);
512                                         in_node  = get_irn_n(irn, reqs[i]->same_pos);
513                                         in_reg   = arch_get_irn_register(cg->arch_env, in_node);
514                                         in2_node = get_irn_n(irn, reqs[i]->same_pos ^ 1);
515                                         in2_reg  = arch_get_irn_register(cg->arch_env, in2_node);
516
517                                         /* don't copy ignore nodes */
518                                         if (arch_irn_is(cg->arch_env, in_node, ignore) && is_Proj(in_node))
519                                                 continue;
520
521                                         /* check if in and out register are equal */
522                                         if (! REGS_ARE_EQUAL(out_reg, in_reg)) {
523                                                 /* in case of a commutative op: just exchange the in's */
524                                                 if (is_ia32_commutative(irn) && REGS_ARE_EQUAL(out_reg, in2_reg)) {
525                                                         set_irn_n(irn, reqs[i]->same_pos, in2_node);
526                                                         set_irn_n(irn, reqs[i]->same_pos ^ 1, in_node);
527                                                 }
528                                                 else {
529                                                         DBG((cg->mod, LEVEL_1, "inserting copy for %+F in_pos %d\n", irn, reqs[i]->same_pos));
530                                                         /* create copy from in register */
531                                                         copy = be_new_Copy(arch_register_get_class(in_reg), cg->irg, block, in_node);
532
533                                                         /* destination is the out register */
534                                                         arch_set_irn_register(cg->arch_env, copy, out_reg);
535
536                                                         /* insert copy before the node into the schedule */
537                                                         sched_add_before(irn, copy);
538
539                                                         /* set copy as in */
540                                                         set_irn_n(irn, reqs[i]->same_pos, copy);
541                                                 }
542                                         }
543                                 }
544                         }
545                 }
546
547                 /* If we have a CondJmp with immediate, we need to    */
548                 /* check if it's the right operand, otherwise we have */
549                 /* to change it, as CMP doesn't support immediate as  */
550                 /* left operands.                                     */
551                 if (is_ia32_CondJmp(irn) && (is_ia32_ImmConst(irn) || is_ia32_ImmSymConst(irn)) && op_tp == ia32_AddrModeS) {
552                         long pnc = get_negated_pnc(get_ia32_pncode(irn), get_ia32_res_mode(irn));
553                         set_ia32_op_type(irn, ia32_AddrModeD);
554                         set_ia32_pncode(irn, pnc);
555                 }
556
557                 /* check if there is a sub which need to be transformed */
558                 ia32_transform_sub_to_neg_add(irn, cg);
559
560                 /* transform a LEA into an Add if possible */
561                 ia32_transform_lea_to_add(irn, cg);
562         }
563 end:
564
565         /* check for peephole optimization */
566         ia32_peephole_optimization(irn, cg);
567 }
568
569 static void ia32_finish_irg_walker(ir_node *block, void *env) {
570         ir_node *irn, *next;
571
572         for (irn = sched_first(block); !sched_is_end(irn); irn = next) {
573                 next = sched_next(irn);
574                 ia32_finish_node(irn, env);
575         }
576 }
577
578 /**
579  * Add Copy nodes for not fulfilled should_be_equal constraints
580  */
581 static void ia32_finish_irg(ir_graph *irg, ia32_code_gen_t *cg) {
582         irg_block_walk_graph(irg, NULL, ia32_finish_irg_walker, cg);
583 }
584
585
586
587 /**
588  * Dummy functions for hooks we don't need but which must be filled.
589  */
590 static void ia32_before_sched(void *self) {
591 }
592
593 /**
594  * Called before the register allocator.
595  * Calculate a block schedule here. We need it for the x87
596  * simulator and the emitter.
597  */
598 static void ia32_before_ra(void *self) {
599         ia32_code_gen_t *cg = self;
600
601         cg->blk_sched = sched_create_block_schedule(cg->irg);
602 }
603
604
605 /**
606  * Transforms a be node into a Load.
607  */
608 static void transform_to_Load(ia32_transform_env_t *env) {
609         ir_node *irn         = env->irn;
610         entity  *ent         = be_get_frame_entity(irn);
611         ir_mode *mode        = env->mode;
612         ir_node *noreg       = ia32_new_NoReg_gp(env->cg);
613         ir_node *nomem       = new_rd_NoMem(env->irg);
614         ir_node *sched_point = NULL;
615         ir_node *ptr         = get_irn_n(irn, 0);
616         ir_node *mem         = be_is_Reload(irn) ? get_irn_n(irn, 1) : nomem;
617         ir_node *new_op, *proj;
618         const arch_register_t *reg;
619
620         if (sched_is_scheduled(irn)) {
621                 sched_point = sched_prev(irn);
622         }
623
624         if (mode_is_float(mode)) {
625                 if (USE_SSE2(env->cg))
626                         new_op = new_rd_ia32_fLoad(env->dbg, env->irg, env->block, ptr, noreg, mem, mode_T);
627                 else
628                         new_op = new_rd_ia32_vfld(env->dbg, env->irg, env->block, ptr, noreg, mem, mode_T);
629         }
630         else {
631                 new_op = new_rd_ia32_Load(env->dbg, env->irg, env->block, ptr, noreg, mem, mode_T);
632         }
633
634         set_ia32_am_support(new_op, ia32_am_Source);
635         set_ia32_op_type(new_op, ia32_AddrModeS);
636         set_ia32_am_flavour(new_op, ia32_B);
637         set_ia32_ls_mode(new_op, mode);
638         set_ia32_frame_ent(new_op, ent);
639         set_ia32_use_frame(new_op);
640
641         proj = new_rd_Proj(env->dbg, env->irg, env->block, new_op, mode, pn_Load_res);
642
643         if (sched_point) {
644                 sched_add_after(sched_point, new_op);
645                 sched_add_after(new_op, proj);
646
647                 sched_remove(irn);
648         }
649
650         /* copy the register from the old node to the new Load */
651         reg = arch_get_irn_register(env->cg->arch_env, irn);
652         arch_set_irn_register(env->cg->arch_env, new_op, reg);
653
654         SET_IA32_ORIG_NODE(new_op, ia32_get_old_node_name(env->cg, new_op));
655
656         exchange(irn, proj);
657 }
658
659 /**
660  * Transforms a be node into a Store.
661  */
662 static void transform_to_Store(ia32_transform_env_t *env) {
663         ir_node *irn   = env->irn;
664         entity  *ent   = be_get_frame_entity(irn);
665         ir_mode *mode  = env->mode;
666         ir_node *noreg = ia32_new_NoReg_gp(env->cg);
667         ir_node *nomem = new_rd_NoMem(env->irg);
668         ir_node *ptr   = get_irn_n(irn, 0);
669         ir_node *val   = get_irn_n(irn, 1);
670         ir_node *new_op, *proj;
671         ir_node *sched_point = NULL;
672
673         if (sched_is_scheduled(irn)) {
674                 sched_point = sched_prev(irn);
675         }
676
677         if (mode_is_float(mode)) {
678                 if (USE_SSE2(env->cg))
679                         new_op = new_rd_ia32_fStore(env->dbg, env->irg, env->block, ptr, noreg, val, nomem, mode_T);
680                 else
681                         new_op = new_rd_ia32_vfst(env->dbg, env->irg, env->block, ptr, noreg, val, nomem, mode_T);
682         }
683         else if (get_mode_size_bits(mode) == 8) {
684                 new_op = new_rd_ia32_Store8Bit(env->dbg, env->irg, env->block, ptr, noreg, val, nomem, mode_T);
685         }
686         else {
687                 new_op = new_rd_ia32_Store(env->dbg, env->irg, env->block, ptr, noreg, val, nomem, mode_T);
688         }
689
690         set_ia32_am_support(new_op, ia32_am_Dest);
691         set_ia32_op_type(new_op, ia32_AddrModeD);
692         set_ia32_am_flavour(new_op, ia32_B);
693         set_ia32_ls_mode(new_op, mode);
694         set_ia32_frame_ent(new_op, ent);
695         set_ia32_use_frame(new_op);
696
697         proj = new_rd_Proj(env->dbg, env->irg, env->block, new_op, mode_M, 0);
698
699         if (sched_point) {
700                 sched_add_after(sched_point, new_op);
701                 sched_add_after(new_op, proj);
702
703                 sched_remove(irn);
704         }
705
706         SET_IA32_ORIG_NODE(new_op, ia32_get_old_node_name(env->cg, new_op));
707
708         exchange(irn, proj);
709 }
710
711 /**
712  * Fix the mode of Spill/Reload
713  */
714 static ir_mode *fix_spill_mode(ia32_code_gen_t *cg, ir_mode *mode)
715 {
716         if (mode_is_float(mode)) {
717                 if (USE_SSE2(cg))
718                         mode = mode_D;
719                 else
720                         mode = mode_E;
721         }
722         else
723                 mode = mode_Is;
724         return mode;
725 }
726
727 /**
728  * Block-Walker: Calls the transform functions Spill and Reload.
729  */
730 static void ia32_after_ra_walker(ir_node *block, void *env) {
731         ir_node *node, *prev;
732         ia32_code_gen_t *cg = env;
733         ia32_transform_env_t tenv;
734
735         tenv.block = block;
736         tenv.irg   = current_ir_graph;
737         tenv.cg    = cg;
738         DEBUG_ONLY(tenv.mod = cg->mod;)
739
740         /* beware: the schedule is changed here */
741         for (node = sched_last(block); !sched_is_begin(node); node = prev) {
742                 prev = sched_prev(node);
743                 if (be_is_Reload(node)) {
744                         /* we always reload the whole register  */
745                         tenv.dbg  = get_irn_dbg_info(node);
746                         tenv.irn  = node;
747                         tenv.mode = fix_spill_mode(cg, get_irn_mode(node));
748                         transform_to_Load(&tenv);
749                 }
750                 else if (be_is_Spill(node)) {
751                         /* we always spill the whole register  */
752                         tenv.dbg  = get_irn_dbg_info(node);
753                         tenv.irn  = node;
754                         tenv.mode = fix_spill_mode(cg, get_irn_mode(be_get_Spill_context(node)));
755                         transform_to_Store(&tenv);
756                 }
757         }
758 }
759
760 /**
761  * We transform Spill and Reload here. This needs to be done before
762  * stack biasing otherwise we would miss the corrected offset for these nodes.
763  *
764  * If x87 instruction should be emitted, run the x87 simulator and patch
765  * the virtual instructions. This must obviously be done after register allocation.
766  */
767 static void ia32_after_ra(void *self) {
768         ia32_code_gen_t *cg = self;
769         irg_block_walk_graph(cg->irg, NULL, ia32_after_ra_walker, self);
770
771         /* if we do x87 code generation, rewrite all the virtual instructions and registers */
772         if (cg->used_fp == fp_x87) {
773                 x87_simulate_graph(cg->arch_env, cg->irg, cg->blk_sched);
774         }
775 }
776
777
778 /**
779  * Emits the code, closes the output file and frees
780  * the code generator interface.
781  */
782 static void ia32_codegen(void *self) {
783         ia32_code_gen_t *cg = self;
784         ir_graph        *irg = cg->irg;
785
786         ia32_finish_irg(irg, cg);
787         be_dump(irg, "-finished", dump_ir_block_graph_sched);
788         ia32_gen_routine(cg->isa->out, irg, cg);
789
790         cur_reg_set = NULL;
791
792         /* remove it from the isa */
793         cg->isa->cg = NULL;
794
795         /* de-allocate code generator */
796         del_set(cg->reg_set);
797         free(self);
798
799 }
800
801 static void *ia32_cg_init(const be_irg_t *birg);
802
803 static const arch_code_generator_if_t ia32_code_gen_if = {
804         ia32_cg_init,
805         NULL,                /* before abi introduce hook */
806         ia32_prepare_graph,
807         ia32_before_sched,   /* before scheduling hook */
808         ia32_before_ra,      /* before register allocation hook */
809         ia32_after_ra,       /* after register allocation hook */
810         ia32_codegen         /* emit && done */
811 };
812
813 /**
814  * Initializes a IA32 code generator.
815  */
816 static void *ia32_cg_init(const be_irg_t *birg) {
817         ia32_isa_t      *isa = (ia32_isa_t *)birg->main_env->arch_env->isa;
818         ia32_code_gen_t *cg  = xcalloc(1, sizeof(*cg));
819
820         cg->impl      = &ia32_code_gen_if;
821         cg->irg       = birg->irg;
822         cg->reg_set   = new_set(ia32_cmp_irn_reg_assoc, 1024);
823         cg->arch_env  = birg->main_env->arch_env;
824         cg->isa       = isa;
825         cg->birg      = birg;
826         cg->blk_sched = NULL;
827         cg->fp_kind   = isa->fp_kind;
828         cg->used_fp   = fp_none;
829
830         FIRM_DBG_REGISTER(cg->mod, "firm.be.ia32.cg");
831
832         /* set optimizations */
833         cg->opt.incdec    = 0;
834         cg->opt.doam      = 1;
835         cg->opt.placecnst = 1;
836         cg->opt.immops    = 1;
837         cg->opt.extbb     = 1;
838
839         /* enter it */
840         isa->cg = cg;
841
842 #ifndef NDEBUG
843         if (isa->name_obst_size) {
844                 //printf("freed %d bytes from name obst\n", isa->name_obst_size);
845                 isa->name_obst_size = 0;
846                 obstack_free(isa->name_obst, NULL);
847                 obstack_init(isa->name_obst);
848         }
849 #endif /* NDEBUG */
850
851         isa->num_codegens++;
852
853         if (isa->num_codegens > 1)
854                 cg->emit_decls = 0;
855         else
856                 cg->emit_decls = 1;
857
858         cur_reg_set = cg->reg_set;
859
860         ia32_irn_ops.cg = cg;
861
862         return (arch_code_generator_t *)cg;
863 }
864
865
866
867 /*****************************************************************
868  *  ____             _                  _   _____  _____
869  * |  _ \           | |                | | |_   _|/ ____|  /\
870  * | |_) | __ _  ___| | _____ _ __   __| |   | | | (___   /  \
871  * |  _ < / _` |/ __| |/ / _ \ '_ \ / _` |   | |  \___ \ / /\ \
872  * | |_) | (_| | (__|   <  __/ | | | (_| |  _| |_ ____) / ____ \
873  * |____/ \__,_|\___|_|\_\___|_| |_|\__,_| |_____|_____/_/    \_\
874  *
875  *****************************************************************/
876
877 /**
878  * The template that generates a new ISA object.
879  * Note that this template can be changed by command line
880  * arguments.
881  */
882 static ia32_isa_t ia32_isa_template = {
883         &ia32_isa_if,            /* isa interface implementation */
884         &ia32_gp_regs[REG_ESP],  /* stack pointer register */
885         &ia32_gp_regs[REG_EBP],  /* base pointer register */
886         -1,                      /* stack direction */
887         0,                       /* number of code generator objects so far */
888         NULL,                    /* 16bit register names */
889         NULL,                    /* 8bit register names */
890         NULL,                    /* types */
891         NULL,                    /* tv_ents */
892         arch_pentium_4,          /* instruction architecture */
893         arch_pentium_4,          /* optimize for architecture */
894         fp_sse2,                 /* use sse2 unit */
895         NULL,                    /* current code generator */
896 #ifndef NDEBUG
897         NULL,                    /* name obstack */
898         0                        /* name obst size */
899 #endif
900 };
901
902 /**
903  * Initializes the backend ISA.
904  */
905 static void *ia32_init(FILE *file_handle) {
906         static int inited = 0;
907         ia32_isa_t *isa;
908
909         if (inited)
910                 return NULL;
911
912         isa = xmalloc(sizeof(*isa));
913         memcpy(isa, &ia32_isa_template, sizeof(*isa));
914
915         ia32_register_init(isa);
916         ia32_create_opcodes();
917         ia32_register_copy_attr_func();
918
919         isa->regs_16bit = pmap_create();
920         isa->regs_8bit  = pmap_create();
921         isa->types      = pmap_create();
922         isa->tv_ent     = pmap_create();
923         isa->out        = file_handle;
924
925         ia32_build_16bit_reg_map(isa->regs_16bit);
926         ia32_build_8bit_reg_map(isa->regs_8bit);
927
928         /* patch register names of x87 registers */
929         if (USE_x87(isa)) {
930           ia32_st_regs[0].name = "st";
931           ia32_st_regs[1].name = "st(1)";
932           ia32_st_regs[2].name = "st(2)";
933           ia32_st_regs[3].name = "st(3)";
934           ia32_st_regs[4].name = "st(4)";
935           ia32_st_regs[5].name = "st(5)";
936           ia32_st_regs[6].name = "st(6)";
937           ia32_st_regs[7].name = "st(7)";
938         }
939
940 #ifndef NDEBUG
941         isa->name_obst = xmalloc(sizeof(*isa->name_obst));
942         obstack_init(isa->name_obst);
943         isa->name_obst_size = 0;
944 #endif /* NDEBUG */
945
946         fprintf(isa->out, "\t.intel_syntax\n");
947
948         inited = 1;
949
950         return isa;
951 }
952
953
954
955 /**
956  * Closes the output file and frees the ISA structure.
957  */
958 static void ia32_done(void *self) {
959         ia32_isa_t *isa = self;
960
961         /* emit now all global declarations */
962         ia32_gen_decls(isa->out);
963
964         pmap_destroy(isa->regs_16bit);
965         pmap_destroy(isa->regs_8bit);
966         pmap_destroy(isa->tv_ent);
967         pmap_destroy(isa->types);
968
969 #ifndef NDEBUG
970         //printf("name obst size = %d bytes\n", isa->name_obst_size);
971         obstack_free(isa->name_obst, NULL);
972 #endif /* NDEBUG */
973
974         free(self);
975 }
976
977
978 /**
979  * Return the number of register classes for this architecture.
980  * We report always these:
981  *  - the general purpose registers
982  *  - the floating point register set (depending on the unit used for FP)
983  *  - MMX/SSE registers (currently not supported)
984  */
985 static int ia32_get_n_reg_class(const void *self) {
986         return 2;
987 }
988
989 /**
990  * Return the register class for index i.
991  */
992 static const arch_register_class_t *ia32_get_reg_class(const void *self, int i) {
993         const ia32_isa_t *isa = self;
994         assert(i >= 0 && i < 2 && "Invalid ia32 register class requested.");
995         if (i == 0)
996                 return &ia32_reg_classes[CLASS_ia32_gp];
997         return USE_SSE2(isa) ? &ia32_reg_classes[CLASS_ia32_xmm] : &ia32_reg_classes[CLASS_ia32_vfp];
998 }
999
1000 /**
1001  * Get the register class which shall be used to store a value of a given mode.
1002  * @param self The this pointer.
1003  * @param mode The mode in question.
1004  * @return A register class which can hold values of the given mode.
1005  */
1006 const arch_register_class_t *ia32_get_reg_class_for_mode(const void *self, const ir_mode *mode) {
1007         const ia32_isa_t *isa = self;
1008         if (mode_is_float(mode)) {
1009                 return USE_SSE2(isa) ? &ia32_reg_classes[CLASS_ia32_xmm] : &ia32_reg_classes[CLASS_ia32_vfp];
1010         }
1011         else
1012                 return &ia32_reg_classes[CLASS_ia32_gp];
1013 }
1014
1015 /**
1016  * Get the ABI restrictions for procedure calls.
1017  * @param self        The this pointer.
1018  * @param method_type The type of the method (procedure) in question.
1019  * @param abi         The abi object to be modified
1020  */
1021 static void ia32_get_call_abi(const void *self, ir_type *method_type, be_abi_call_t *abi) {
1022         const ia32_isa_t *isa = self;
1023         ir_type  *tp;
1024         ir_mode  *mode;
1025         unsigned  cc        = get_method_calling_convention(method_type);
1026         int       n         = get_method_n_params(method_type);
1027         int       biggest_n = -1;
1028         int       stack_idx = 0;
1029         int       i, ignore_1, ignore_2;
1030         ir_mode **modes;
1031         const arch_register_t *reg;
1032         be_abi_call_flags_t call_flags = be_abi_call_get_flags(abi);
1033
1034         /* set abi flags for calls */
1035         call_flags.bits.left_to_right         = 0;  /* always last arg first on stack */
1036         call_flags.bits.store_args_sequential = 0;  /* use stores instead of push */
1037         /* call_flags.bits.try_omit_fp                 not changed: can handle both settings */
1038         call_flags.bits.fp_free               = 0;  /* the frame pointer is fixed in IA32 */
1039         call_flags.bits.call_has_imm          = 1;  /* IA32 calls can have immediate address */
1040
1041         /* set stack parameter passing style */
1042         be_abi_call_set_flags(abi, call_flags, &ia32_abi_callbacks);
1043
1044         /* collect the mode for each type */
1045         modes = alloca(n * sizeof(modes[0]));
1046
1047         for (i = 0; i < n; i++) {
1048                 tp       = get_method_param_type(method_type, i);
1049                 modes[i] = get_type_mode(tp);
1050         }
1051
1052         /* set register parameters  */
1053         if (cc & cc_reg_param) {
1054                 /* determine the number of parameters passed via registers */
1055                 biggest_n = ia32_get_n_regparam_class(n, modes, &ignore_1, &ignore_2);
1056
1057                 /* loop over all parameters and set the register requirements */
1058                 for (i = 0; i <= biggest_n; i++) {
1059                         reg = ia32_get_RegParam_reg(n, modes, i, cc);
1060                         assert(reg && "kaputt");
1061                         be_abi_call_param_reg(abi, i, reg);
1062                 }
1063
1064                 stack_idx = i;
1065         }
1066
1067
1068         /* set stack parameters */
1069         for (i = stack_idx; i < n; i++) {
1070                 be_abi_call_param_stack(abi, i, 1, 0, 0);
1071         }
1072
1073
1074         /* set return registers */
1075         n = get_method_n_ress(method_type);
1076
1077         assert(n <= 2 && "more than two results not supported");
1078
1079         /* In case of 64bit returns, we will have two 32bit values */
1080         if (n == 2) {
1081                 tp   = get_method_res_type(method_type, 0);
1082                 mode = get_type_mode(tp);
1083
1084                 assert(!mode_is_float(mode) && "two FP results not supported");
1085
1086                 tp   = get_method_res_type(method_type, 1);
1087                 mode = get_type_mode(tp);
1088
1089                 assert(!mode_is_float(mode) && "two FP results not supported");
1090
1091                 be_abi_call_res_reg(abi, 0, &ia32_gp_regs[REG_EAX]);
1092                 be_abi_call_res_reg(abi, 1, &ia32_gp_regs[REG_EDX]);
1093         }
1094         else if (n == 1) {
1095                 const arch_register_t *reg;
1096
1097                 tp   = get_method_res_type(method_type, 0);
1098                 assert(is_atomic_type(tp));
1099                 mode = get_type_mode(tp);
1100
1101                 reg = mode_is_float(mode) ?
1102                         (USE_SSE2(isa) ? &ia32_xmm_regs[REG_XMM0] : &ia32_vfp_regs[REG_VF0]) :
1103                         &ia32_gp_regs[REG_EAX];
1104
1105                 be_abi_call_res_reg(abi, 0, reg);
1106         }
1107 }
1108
1109
1110 static const void *ia32_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn) {
1111         return &ia32_irn_ops;
1112 }
1113
1114 const arch_irn_handler_t ia32_irn_handler = {
1115         ia32_get_irn_ops
1116 };
1117
1118 const arch_irn_handler_t *ia32_get_irn_handler(const void *self) {
1119         return &ia32_irn_handler;
1120 }
1121
1122 int ia32_to_appear_in_schedule(void *block_env, const ir_node *irn) {
1123         return is_ia32_irn(irn);
1124 }
1125
1126 /**
1127  * Initializes the code generator interface.
1128  */
1129 static const arch_code_generator_if_t *ia32_get_code_generator_if(void *self) {
1130         return &ia32_code_gen_if;
1131 }
1132
1133 list_sched_selector_t ia32_sched_selector;
1134
1135 /**
1136  * Returns the reg_pressure scheduler with to_appear_in_schedule() overloaded
1137  */
1138 static const list_sched_selector_t *ia32_get_list_sched_selector(const void *self) {
1139 //      memcpy(&ia32_sched_selector, reg_pressure_selector, sizeof(list_sched_selector_t));
1140         memcpy(&ia32_sched_selector, trivial_selector, sizeof(list_sched_selector_t));
1141         ia32_sched_selector.to_appear_in_schedule = ia32_to_appear_in_schedule;
1142         return &ia32_sched_selector;
1143 }
1144
1145 /**
1146  * Returns the necessary byte alignment for storing a register of given class.
1147  */
1148 static int ia32_get_reg_class_alignment(const void *self, const arch_register_class_t *cls) {
1149         ir_mode *mode = arch_register_class_mode(cls);
1150         int bytes     = get_mode_size_bytes(mode);
1151
1152         if (mode_is_float(mode) && bytes > 8)
1153                 return 16;
1154         return bytes;
1155 }
1156
1157 #ifdef WITH_LIBCORE
1158
1159 /* instruction set architectures. */
1160 static const lc_opt_enum_int_items_t arch_items[] = {
1161         { "386",        arch_i386, },
1162         { "486",        arch_i486, },
1163         { "pentium",    arch_pentium, },
1164         { "586",        arch_pentium, },
1165         { "pentiumpro", arch_pentium_pro, },
1166         { "686",        arch_pentium_pro, },
1167         { "pentiummmx", arch_pentium_mmx, },
1168         { "pentium2",   arch_pentium_2, },
1169         { "p2",         arch_pentium_2, },
1170         { "pentium3",   arch_pentium_3, },
1171         { "p3",         arch_pentium_3, },
1172         { "pentium4",   arch_pentium_4, },
1173         { "p4",         arch_pentium_4, },
1174         { "pentiumm",   arch_pentium_m, },
1175         { "pm",         arch_pentium_m, },
1176         { "core",       arch_core, },
1177         { "k6",         arch_k6, },
1178         { "athlon",     arch_athlon, },
1179         { "athlon64",   arch_athlon_64, },
1180         { "opteron",    arch_opteron, },
1181         { NULL,         0 }
1182 };
1183
1184 static lc_opt_enum_int_var_t arch_var = {
1185         &ia32_isa_template.arch, arch_items
1186 };
1187
1188 static lc_opt_enum_int_var_t opt_arch_var = {
1189         &ia32_isa_template.opt_arch, arch_items
1190 };
1191
1192 static const lc_opt_enum_int_items_t fp_unit_items[] = {
1193         { "x87" ,    fp_x87 },
1194         { "sse2",    fp_sse2 },
1195         { NULL,      0 }
1196 };
1197
1198 static lc_opt_enum_int_var_t fp_unit_var = {
1199         &ia32_isa_template.fp_kind, fp_unit_items
1200 };
1201
1202 static const lc_opt_table_entry_t ia32_options[] = {
1203         LC_OPT_ENT_ENUM_INT("arch",   "select the instruction architecture", &arch_var),
1204         LC_OPT_ENT_ENUM_INT("opt",    "optimize for instruction architecture", &opt_arch_var),
1205         LC_OPT_ENT_ENUM_INT("fpunit", "select the floating point unit", &fp_unit_var),
1206         { NULL }
1207 };
1208
1209 /**
1210  * Register command line options for the ia32 backend.
1211  *
1212  * Options so far:
1213  *
1214  * ia32-arch=arch    create instruction for arch
1215  * ia32-opt=arch     optimize for run on arch
1216  * ia32-fpunit=unit  select floating point unit (x87 or SSE2)
1217  */
1218 static void ia32_register_options(lc_opt_entry_t *ent)
1219 {
1220         lc_opt_entry_t *be_grp_ia32 = lc_opt_get_grp(ent, "ia32");
1221         lc_opt_add_table(be_grp_ia32, ia32_options);
1222 }
1223 #endif /* WITH_LIBCORE */
1224
1225 const arch_isa_if_t ia32_isa_if = {
1226         ia32_init,
1227         ia32_done,
1228         ia32_get_n_reg_class,
1229         ia32_get_reg_class,
1230         ia32_get_reg_class_for_mode,
1231         ia32_get_call_abi,
1232         ia32_get_irn_handler,
1233         ia32_get_code_generator_if,
1234         ia32_get_list_sched_selector,
1235         ia32_get_reg_class_alignment,
1236 #ifdef WITH_LIBCORE
1237         ia32_register_options
1238 #endif
1239 };