sparc: fix abort when matching addressmode Adds
[libfirm] / ir / be / sparc / sparc_spec.pl
1 # Creation: 2006/02/13
2 # $Id$
3
4 $arch = "sparc";
5
6 $mode_gp      = "mode_Iu";
7 $mode_flags   = "mode_Bu";
8 $mode_fpflags = "mode_Bu";
9 $mode_fp      = "mode_F";
10 $mode_fp2     = "mode_D";
11 $mode_fp4     = "mode_E"; # not correct, we need to register a new mode
12
13 $normal      =  0; # no special type
14 $caller_save =  1; # caller save (register must be saved by the caller of a function)
15 $callee_save =  2; # callee save (register must be saved by the called function)
16 $ignore      =  4; # ignore (do not assign this register)
17 $arbitrary   =  8; # emitter can choose an arbitrary register of this class
18 $virtual     = 16; # the register is a virtual one
19 $state       = 32; # register represents a state
20
21 # available SPARC registers: 8 globals, 24 window regs (8 ins, 8 outs, 8 locals)
22 %reg_classes = (
23         gp => [
24                 { name => "g0", type => $ignore }, # hardwired 0, behaves like /dev/null
25                 { name => "g1", type => $caller_save }, # temp. value
26                 { name => "g2", type => $caller_save },
27                 { name => "g3", type => $caller_save },
28                 { name => "g4", type => $caller_save },
29                 { name => "g5", type => $ignore }, # reserved by SPARC ABI
30                 { name => "g6", type => $ignore }, # reserved by SPARC ABI
31                 { name => "g7", type => $ignore }, # reserved by SPARC ABI
32
33                 # window's out registers
34                 { name => "o0", type => $caller_save }, # param 1 / return value from callee
35                 { name => "o1", type => $caller_save }, # param 2
36                 { name => "o2", type => $caller_save }, # param 3
37                 { name => "o3", type => $caller_save }, # param 4
38                 { name => "o4", type => $caller_save }, # param 5
39                 { name => "o5", type => $caller_save }, # param 6
40                 { name => "sp", type => $ignore }, # our stackpointer
41                 { name => "o7", type => $ignore }, # temp. value / address of CALL instr.
42
43                 # window's local registers
44                 { name => "l0", type => 0 },
45                 { name => "l1", type => 0 },
46                 { name => "l2", type => 0 },
47                 { name => "l3", type => 0 },
48                 { name => "l4", type => 0 },
49                 { name => "l5", type => 0 },
50                 { name => "l6", type => 0 },
51                 { name => "l7", type => 0 },
52
53                 # window's in registers
54                 { name => "i0", type => 0 }, # incoming param1 / return value to caller
55                 { name => "i1", type => 0 }, # param 2
56                 { name => "i2", type => 0 }, # param 3
57                 { name => "i3", type => 0 }, # param 4
58                 { name => "i4", type => 0 }, # param 5
59                 { name => "i5", type => 0 }, # param 6
60                 { name => "frame_pointer", realname => "fp", type => $ignore }, # our framepointer
61                 { name => "i7", type => $ignore }, # return address - 8
62                 { mode => $mode_gp }
63         ],
64         fpflags_class => [
65                 { name => "fpflags", type => $ignore },
66                 { mode => $mode_fpflags, flags => "manual_ra" }
67         ],
68         flags_class => [
69                 { name => "flags", type => $ignore },
70                 { mode => $mode_flags, flags => "manual_ra" }
71         ],
72         mul_div_high_res => [
73                 { name => "y", type => $ignore },
74                 { mode => $mode_gp, flags => "manual_ra" }
75         ],
76         # fp registers can be accessed any time
77         fp => [
78                 { name => "f0",  type => $caller_save },
79                 { name => "f1",  type => $caller_save },
80                 { name => "f2",  type => $caller_save },
81                 { name => "f3",  type => $caller_save },
82                 { name => "f4",  type => $caller_save },
83                 { name => "f5",  type => $caller_save },
84                 { name => "f6",  type => $caller_save },
85                 { name => "f7",  type => $caller_save },
86                 { name => "f8",  type => $caller_save },
87                 { name => "f9",  type => $caller_save },
88                 { name => "f10", type => $caller_save },
89                 { name => "f11", type => $caller_save },
90                 { name => "f12", type => $caller_save },
91                 { name => "f13", type => $caller_save },
92                 { name => "f14", type => $caller_save },
93                 { name => "f15", type => $caller_save },
94                 { name => "f16", type => $caller_save },
95                 { name => "f17", type => $caller_save },
96                 { name => "f18", type => $caller_save },
97                 { name => "f19", type => $caller_save },
98                 { name => "f20", type => $caller_save },
99                 { name => "f21", type => $caller_save },
100                 { name => "f22", type => $caller_save },
101                 { name => "f23", type => $caller_save },
102                 { name => "f24", type => $caller_save },
103                 { name => "f25", type => $caller_save },
104                 { name => "f26", type => $caller_save },
105                 { name => "f27", type => $caller_save },
106                 { name => "f28", type => $caller_save },
107                 { name => "f29", type => $caller_save },
108                 { name => "f30", type => $caller_save },
109                 { name => "f31", type => $caller_save },
110                 { mode => $mode_fp }
111         ]
112 ); # %reg_classes
113
114 %emit_templates = (
115 # emit source reg or imm dep. on node's arity
116         RI  => "${arch}_emit_reg_or_imm(node, -1);",
117         R1I => "${arch}_emit_reg_or_imm(node, 0);",
118         R2I => "${arch}_emit_reg_or_imm(node, 1);",
119         R3I => "${arch}_emit_reg_or_imm(node, 2);",
120         S1  => "${arch}_emit_source_register(node, 0);",
121         S2  => "${arch}_emit_source_register(node, 1);",
122         S3  => "${arch}_emit_source_register(node, 2);",
123         S4  => "${arch}_emit_source_register(node, 3);",
124         S5  => "${arch}_emit_source_register(node, 4);",
125         S6  => "${arch}_emit_source_register(node, 5);",
126         D1  => "${arch}_emit_dest_register(node, 0);",
127         D2  => "${arch}_emit_dest_register(node, 1);",
128         D3  => "${arch}_emit_dest_register(node, 2);",
129         D4  => "${arch}_emit_dest_register(node, 3);",
130         D5  => "${arch}_emit_dest_register(node, 4);",
131         D6  => "${arch}_emit_dest_register(node, 5);",
132         IM  => "${arch}_emit_immediate(node);",
133         HIM => "${arch}_emit_high_immediate(node);",
134         LM  => "${arch}_emit_load_mode(node);",
135         SM  => "${arch}_emit_store_mode(node);",
136         FLSM => "${arch}_emit_float_load_store_mode(node);",
137         FPM  => "${arch}_emit_fp_mode_suffix(node);",
138         FCONVS => "${arch}_emit_fp_conv_source(node);",
139         FCONVD => "${arch}_emit_fp_conv_destination(node);",
140         O2     => "${arch}_emit_offset(node, 1);",
141         O3     => "${arch}_emit_offset(node, 2);",
142 );
143
144 $default_attr_type = "sparc_attr_t";
145 $default_copy_attr = "sparc_copy_attr";
146
147
148 %init_attr = (
149         sparc_attr_t             => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
150         sparc_load_store_attr_t  => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
151         sparc_jmp_cond_attr_t    => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
152         sparc_switch_jmp_attr_t  => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
153                                     "\tinit_sparc_switch_jmp_attributes(res, default_pn, jump_table);\n",
154         sparc_save_attr_t        => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
155         sparc_fp_attr_t          => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
156                                     "\tinit_sparc_fp_attributes(res, fp_mode);\n",
157         sparc_fp_conv_attr_t     => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);".
158                                     "\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
159 );
160
161 %compare_attr = (
162         sparc_attr_t            => "cmp_attr_sparc",
163         sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
164         sparc_jmp_cond_attr_t   => "cmp_attr_sparc_jmp_cond",
165         sparc_switch_jmp_attr_t => "cmp_attr_sparc_switch_jmp",
166         sparc_save_attr_t       => "cmp_attr_sparc_save",
167         sparc_fp_attr_t         => "cmp_attr_sparc_fp",
168         sparc_fp_conv_attr_t    => "cmp_attr_sparc_fp_conv",
169 );
170
171 %custom_irn_flags = (
172         modifies_flags    => "sparc_arch_irn_flag_modifies_flags",
173         modifies_fp_flags => "sparc_arch_irn_flag_modifies_fp_flags",
174 );
175
176 # addressing modes: imm, reg, reg +/- imm, reg + reg
177 # max. imm = 13 bits signed (-4096 ... 4096)
178
179 my %cmp_operand_constructors = (
180         imm => {
181                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
182                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
183                 reg_req    => { in => [ "gp" ], out => [ "flags" ] },
184                 ins        => [ "left" ],
185         },
186         reg => {
187                 reg_req    => { in => [ "gp", "gp" ], out => [ "flags" ] },
188                 ins        => [ "left", "right" ],
189         },
190 );
191
192 my %binop_operand_constructors = (
193         imm => {
194                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
195                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
196                 reg_req    => { in => [ "gp" ], out => [ "gp" ] },
197                 ins        => [ "left" ],
198         },
199         reg => {
200                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp" ] },
201                 ins        => [ "left", "right" ],
202         },
203 );
204
205 my %binopcczero_operand_constructors = (
206         imm => {
207                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
208                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
209                 reg_req    => { in => [ "gp" ], out => [ "flags" ] },
210                 ins        => [ "left" ],
211         },
212         reg => {
213                 reg_req    => { in => [ "gp", "gp" ], out => [ "flags" ] },
214                 ins        => [ "left", "right" ],
215         },
216 );
217
218 my %div_operand_constructors = (
219         imm => {
220                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
221                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
222                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp" ] },
223         },
224         reg => {
225                 reg_req    => { in => [ "gp", "gp", "gp" ], out => [ "gp" ] },
226         },
227 );
228
229 my %float_binop_constructors = (
230         s => {
231                 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
232                 mode    => $mode_fp,
233         },
234         d => {
235                 reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2" ] },
236                 mode    => $mode_fp2,
237         },
238         q => {
239                 reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4" ] },
240                 mode    => $mode_fp4,
241         }
242 );
243
244 my %float_unop_constructors = (
245         s => {
246                 reg_req => { in => [ "fp" ], out => [ "fp" ] },
247                 mode    => $mode_fp,
248         },
249         d => {
250                 reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|2" ] },
251                 mode    => $mode_fp2,
252         },
253         q => {
254                 reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|4" ] },
255                 mode    => $mode_fp4,
256         }
257 );
258
259 %nodes = (
260
261 Add => {
262         irn_flags    => [ "rematerializable" ],
263         mode         => $mode_gp,
264         emit         => '. add %S1, %R2I, %D1',
265         constructors => \%binop_operand_constructors,
266 },
267
268 Sub => {
269         irn_flags    => [ "rematerializable" ],
270         mode         => $mode_gp,
271         emit         => '. sub %S1, %R2I, %D1',
272         constructors => \%binop_operand_constructors,
273 },
274
275
276 # Load / Store
277 Ld => {
278         op_flags  => [ "labeled", "fragile" ],
279         state     => "exc_pinned",
280         constructors => {
281                 imm => {
282                         reg_req    => { in => [ "gp", "none" ], out => [ "gp", "none" ] },
283                         ins        => [ "ptr", "mem" ],
284                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
285                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
286                 },
287                 reg => {
288                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
289                         ins        => [ "ptr", "ptr2", "mem" ],
290                         attr       => "ir_mode *ls_mode",
291                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
292                 },
293         },
294         ins       => [ "ptr", "mem" ],
295         outs      => [ "res", "M" ],
296         attr_type => "sparc_load_store_attr_t",
297         emit      => '. ld%LM [%S1%O2], %D1'
298 },
299
300 SetHi => {
301         irn_flags  => [ "rematerializable" ],
302         outs       => [ "res" ],
303         mode       => $mode_gp,
304         reg_req    => { in => [], out => [ "gp" ] },
305         attr       => "ir_entity *entity, int32_t immediate_value",
306         custominit => "sparc_set_attr_imm(res, entity, immediate_value);",
307         emit       => '. sethi %HIM, %D1'
308 },
309
310 St => {
311         op_flags  => [ "labeled", "fragile" ],
312         mode      => "mode_M",
313         state     => "exc_pinned",
314         constructors => {
315                 imm => {
316                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
317                         ins        => [ "val", "ptr", "mem" ],
318                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
319                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
320                 },
321                 reg => {
322                         reg_req    => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
323                         ins        => [ "val", "ptr", "ptr2", "mem" ],
324                         attr       => "ir_mode *ls_mode",
325                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
326                 },
327         },
328         ins       => [ "val", "ptr", "mem" ],
329         outs      => [ "M" ],
330         attr_type => "sparc_load_store_attr_t",
331         emit      => '. st%SM %S1, [%S2%O3]'
332 },
333
334 Save => {
335         reg_req   => {
336                 in => [ "sp", "none"],
337                 out => [ "sp:I|S", "frame_pointer:I", "none" ]
338         },
339         ins       => [ "stack", "mem" ],
340         outs      => [ "stack", "frame", "mem" ],
341         attr      => "int initial_stacksize",
342         attr_type => "sparc_save_attr_t",
343         init_attr => "\tinit_sparc_save_attributes(res, initial_stacksize);",
344 },
345
346 SubSP => {
347         reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "gp", "none" ] },
348         ins       => [ "stack", "size", "mem" ],
349         outs      => [ "stack", "addr", "M" ],
350         emit      => ". sub %S1, %S2, %D1\n",
351 },
352
353 AddSP => {
354         reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "none" ] },
355         ins       => [ "stack", "size", "mem" ],
356         outs      => [ "stack", "M" ],
357         emit      => ". add %S1, %S2, %D1\n",
358 },
359
360 FrameAddr => {
361         op_flags   => [ "constlike" ],
362         irn_flags  => [ "rematerializable" ],
363         attr       => "ir_entity *entity, int32_t offset",
364         reg_req    => { in => [ "gp" ], out => [ "gp" ] },
365         ins        => [ "base" ],
366         attr_type  => "sparc_attr_t",
367         custominit => "sparc_set_attr_imm(res, entity, offset);",
368         mode       => $mode_gp,
369 },
370
371 Bicc => {
372         op_flags  => [ "labeled", "cfopcode", "forking" ],
373         state     => "pinned",
374         mode      => "mode_T",
375         attr_type => "sparc_jmp_cond_attr_t",
376         attr      => "pn_Cmp pnc, bool is_unsigned",
377         init_attr => "\tinit_sparc_jmp_cond_attr(res, pnc, is_unsigned);",
378         reg_req   => { in => [ "flags" ], out => [ "none", "none" ] },
379 },
380
381 fbfcc => {
382         op_flags  => [ "labeled", "cfopcode", "forking" ],
383         state     => "pinned",
384         mode      => "mode_T",
385         attr_type => "sparc_jmp_cond_attr_t",
386         attr      => "pn_Cmp pnc",
387         init_attr => "\tinit_sparc_jmp_cond_attr(res, pnc, false);",
388         reg_req   => { in => [ "fpflags" ], out => [ "none", "none" ] },
389 },
390
391 Ba => {
392         state     => "pinned",
393         op_flags  => [ "cfopcode" ],
394         irn_flags => [ "simple_jump" ],
395         reg_req   => { out => [ "none" ] },
396         mode      => "mode_X",
397 },
398
399 Call => {
400         irn_flags => [ "modifies_flags", "modifies_fp_flags" ],
401         state     => "exc_pinned",
402         arity     => "variable",
403         out_arity => "variable",
404         constructors => {
405                 imm => {
406                         attr       => "ir_entity *entity, int32_t offset",
407                         custominit => "\tsparc_set_attr_imm(res, entity, offset);",
408                         arity     => "variable",
409                         out_arity => "variable",
410                 },
411                 reg => {
412                         arity     => "variable",
413                         out_arity => "variable",
414                 }
415         },
416 },
417
418 Cmp => {  # aka SubccZero
419         irn_flags    => [ "rematerializable", "modifies_flags" ],
420         emit         => '. cmp %S1, %R2I',
421         mode         => $mode_flags,
422         constructors => \%binopcczero_operand_constructors,
423 },
424
425 SwitchJmp => {
426         op_flags     => [ "labeled", "cfopcode", "forking" ],
427         state        => "pinned",
428         mode         => "mode_T",
429         reg_req      => { in => [ "gp" ], out => [ ] },
430         attr_type    => "sparc_switch_jmp_attr_t",
431         attr         => "long default_pn, ir_entity *jump_table",
432         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
433 },
434
435 Sll => {
436         irn_flags    => [ "rematerializable" ],
437         mode         => $mode_gp,
438         emit         => '. sll %S1, %R2I, %D1',
439         constructors => \%binop_operand_constructors,
440 },
441
442 Slr => {
443         irn_flags    => [ "rematerializable" ],
444         mode         => $mode_gp,
445         emit         => '. srl %S1, %R2I, %D1',
446         constructors => \%binop_operand_constructors,
447 },
448
449 Sra => {
450         irn_flags    => [ "rematerializable" ],
451         mode         => $mode_gp,
452         emit         => '. sra %S1, %R2I, %D1',
453         constructors => \%binop_operand_constructors,
454 },
455
456 And => {
457         irn_flags    => [ "rematerializable" ],
458         mode         => $mode_gp,
459         emit         => '. and %S1, %R2I, %D1',
460         constructors => \%binop_operand_constructors,
461 },
462
463 AndCCZero => {
464         irn_flags    => [ "rematerializable", "modifies_flags" ],
465         emit         => '. and %S1, %R2I, %%g0',
466         mode         => $mode_flags,
467         constructors => \%binopcczero_operand_constructors,
468 },
469
470 AndN => {
471         irn_flags => [ "rematerializable" ],
472         mode      => $mode_gp,
473         emit      => '. andn %S1, %R2I, %D1',
474         constructors => \%binop_operand_constructors,
475 },
476
477 AndNCCZero => {
478         irn_flags    => [ "rematerializable", "modifies_flags" ],
479         emit         => '. andn %S1, %R2I, %%g0',
480         mode         => $mode_flags,
481         constructors => \%binopcczero_operand_constructors,
482 },
483
484 Or => {
485         irn_flags    => [ "rematerializable" ],
486         mode         => $mode_gp,
487         emit         => '. or %S1, %R2I, %D1',
488         constructors => \%binop_operand_constructors,
489 },
490
491 OrCCZero => {
492         irn_flags    => [ "rematerializable", "modifies_flags" ],
493         emit         => '. or %S1, %R2I, %%g0',
494         mode         => $mode_flags,
495         constructors => \%binopcczero_operand_constructors,
496 },
497
498 OrN => {
499         irn_flags => [ "rematerializable" ],
500         mode      => $mode_gp,
501         emit      => '. orn %S1, %R2I, %D1',
502         constructors => \%binop_operand_constructors,
503 },
504
505 OrNCCZero => {
506         irn_flags    => [ "rematerializable", "modifies_flags" ],
507         emit         => '. orn %S1, %R2I, %%g0',
508         mode         => $mode_flags,
509         constructors => \%binopcczero_operand_constructors,
510 },
511
512 Xor => {
513         irn_flags    => [ "rematerializable" ],
514         mode         => $mode_gp,
515         emit         => '. xor %S1, %R2I, %D1',
516         constructors => \%binop_operand_constructors,
517 },
518
519 XorCCZero => {
520         irn_flags    => [ "rematerializable", "modifies_flags" ],
521         emit         => '. xor %S1, %R2I, %%g0',
522         mode         => $mode_flags,
523         constructors => \%binopcczero_operand_constructors,
524 },
525
526 XNor => {
527         irn_flags => [ "rematerializable" ],
528         mode      => $mode_gp,
529         emit      => '. xnor %S1, %R2I, %D1',
530         constructors => \%binop_operand_constructors,
531 },
532
533 XNorCCZero => {
534         irn_flags    => [ "rematerializable", "modifies_flags" ],
535         emit         => '. xnor %S1, %R2I, %%g0',
536         mode         => $mode_flags,
537         constructors => \%binopcczero_operand_constructors,
538 },
539
540 Mul => {
541         irn_flags    => [ "rematerializable" ],
542         mode         => $mode_gp,
543         emit         => '. smul %S1, %R2I, %D1',
544         constructors => \%binop_operand_constructors,
545 },
546
547 Mulh => {
548         irn_flags    => [ "rematerializable" ],
549         outs         => [ "low", "high" ],
550         constructors => \%binop_operand_constructors,
551 },
552
553 SDiv => {
554         irn_flags    => [ "rematerializable" ],
555         state        => "exc_pinned",
556         ins          => [ "dividend_high", "dividend_low", "divisor" ],
557         outs         => [ "res", "M" ],
558         constructors => \%div_operand_constructors,
559 },
560
561 UDiv => {
562         irn_flags    => [ "rematerializable" ],
563         state        => "exc_pinned",
564         ins          => [ "dividend_high", "dividend_low", "divisor" ],
565         outs         => [ "res", "M" ],
566         constructors => \%div_operand_constructors,
567 },
568
569 fcmp => {
570         irn_flags => [ "rematerializable", "modifies_fp_flags" ],
571         emit      => '. fcmp%FPM %S1, %S2',
572         attr_type => "sparc_fp_attr_t",
573         attr      => "ir_mode *fp_mode",
574         mode      => $mode_fpflags,
575         constructors => {
576                 s => {
577                         reg_req => { in => [ "fp", "fp" ], out => [ "fpflags" ] },
578                 },
579                 d => {
580                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fpflags" ] },
581                 },
582                 q => {
583                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fpflags" ] },
584                 },
585         },
586 },
587
588 fadd => {
589         op_flags     => [ "commutative" ],
590         irn_flags    => [ "rematerializable" ],
591         emit         => '. fadd%FPM %S1, %S2, %D1',
592         attr_type    => "sparc_fp_attr_t",
593         attr         => "ir_mode *fp_mode",
594         ins          => [ "left", "right" ],
595         constructors => \%float_binop_constructors,
596 },
597
598 fsub => {
599         irn_flags    => [ "rematerializable" ],
600         emit         => '. fsub%FPM %S1, %S2, %D1',
601         attr_type    => "sparc_fp_attr_t",
602         attr         => "ir_mode *fp_mode",
603         ins          => [ "left", "right" ],
604         constructors => \%float_binop_constructors,
605 },
606
607 fmul => {
608         irn_flags    => [ "rematerializable" ],
609         op_flags     => [ "commutative" ],
610         emit         =>'. fmul%FPM %S1, %S2, %D1',
611         attr_type    => "sparc_fp_attr_t",
612         attr         => "ir_mode *fp_mode",
613         ins          => [ "left", "right" ],
614         constructors => \%float_binop_constructors,
615 },
616
617 fdiv => {
618         irn_flags    => [ "rematerializable" ],
619         emit         => '. fdiv%FPM %S1, %S2, %D1',
620         attr_type    => "sparc_fp_attr_t",
621         attr         => "ir_mode *fp_mode",
622         ins          => [ "left", "right" ],
623         outs         => [ "res", "M" ],
624         constructors => \%float_binop_constructors,
625 },
626
627 fneg => {
628         irn_flags => [ "rematerializable" ],
629         reg_req   => { in => [ "fp" ], out => [ "fp" ] },
630         # note that we only need the first register even for wide-values
631         emit      => '. fneg %S1, %D1',
632         attr_type => "sparc_fp_attr_t",
633         attr      => "ir_mode *fp_mode",
634         ins          => [ "val" ],
635         constructors => \%float_unop_constructors,
636 },
637
638 "fabs" => {
639         irn_flags    => [ "rematerializable" ],
640         # note that we only need the first register even for wide-values
641         emit         => '. fabs %S1, %D1',
642         attr_type    => "sparc_fp_attr_t",
643         attr         => "ir_mode *fp_mode",
644         ins          => [ "val" ],
645         constructors => \%float_unop_constructors,
646 },
647
648 fftof => {
649         irn_flags => [ "rematerializable" ],
650         emit      => '. f%FCONVS%.to%FCONVD %S1, %D1',
651         attr_type => "sparc_fp_conv_attr_t",
652         attr      => "ir_mode *src_mode, ir_mode *dest_mode",
653         constructors => {
654                 s_d => {
655                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
656                         mode    => $mode_fp2,
657                 },
658                 s_q => {
659                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
660                         mode    => $mode_fp4,
661                 },
662                 d_s => {
663                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
664                         mode    => $mode_fp,
665                 },
666                 d_q => {
667                         reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|4" ] },
668                         mode    => $mode_fp4,
669                 },
670                 q_s => {
671                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
672                         mode    => $mode_fp,
673                 },
674                 q_d => {
675                         reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|2" ] },
676                         mode    => $mode_fp2,
677                 },
678         },
679 },
680
681 fitof => {
682         irn_flags => [ "rematerializable" ],
683         reg_req   => { in => [ "gp" ], out => [ "fp" ] },
684         emit      => '. fito%FPM %S1, %D1',
685         attr_type => "sparc_fp_attr_t",
686         attr      => "ir_mode *fp_mode",
687         constructors => {
688                 s => {
689                         reg_req => { in => [ "gp" ], out => [ "fp" ] },
690                         mode    => $mode_fp,
691                 },
692                 d => {
693                         reg_req => { in => [ "gp" ], out => [ "fp:a|2" ] },
694                         mode    => $mode_fp2,
695                 },
696                 q => {
697                         reg_req => { in => [ "gp" ], out => [ "fp:a|4" ] },
698                         mode    => $mode_fp4,
699                 },
700         },
701 },
702
703 fftoi => {
704         irn_flags => [ "rematerializable" ],
705         reg_req   => { in => [ "fp" ], out => [ "gp" ] },
706         emit      => '. f%FPM.toi %S1, %D1',
707         attr_type => "sparc_fp_attr_t",
708         attr      => "ir_mode *fp_mode",
709         mode      => $mode_gp,
710         constructors => {
711                 s => {
712                         reg_req => { in => [ "gp" ], out => [ "gp" ] },
713                 },
714                 d => {
715                         reg_req => { in => [ "fp:a|2" ], out => [ "gp" ] },
716                 },
717                 q => {
718                         reg_req => { in => [ "fp:a|4" ], out => [ "gp" ] },
719                 },
720         },
721 },
722
723 Ldf => {
724         op_flags  => [ "labeled", "fragile" ],
725         state     => "exc_pinned",
726         constructors => {
727                 s => {
728                         reg_req => { in => [ "gp", "none" ], out => [ "fp", "none" ] },
729                 },
730                 d => {
731                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|2", "none" ] },
732                 },
733                 q => {
734                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|4", "none" ] },
735                 },
736         },
737         ins       => [ "ptr", "mem" ],
738         outs      => [ "res", "M" ],
739         attr_type => "sparc_load_store_attr_t",
740         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
741         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
742         emit      => '. ld%FLSM [%S1%O2], %D1'
743 },
744
745 Stf => {
746         op_flags  => [ "labeled", "fragile" ],
747         state     => "exc_pinned",
748         constructors => {
749                 s => {
750                         reg_req => { in => [ "fp",     "gp", "none" ], out => [ "none" ] },
751                 },
752                 d => {
753                         reg_req => { in => [ "fp:a|2", "gp", "none" ], out => [ "none" ] },
754                 },
755                 q => {
756                         reg_req => { in => [ "fp:a|4", "gp", "none" ], out => [ "none" ] },
757                 },
758         },
759         ins       => [ "val", "ptr", "mem" ],
760         outs      => [ "M" ],
761         attr_type => "sparc_load_store_attr_t",
762         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
763         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
764         emit      => '. st%FLSM %S2, [%S1%O2]',
765         mode      => 'mode_M',
766 },
767
768 ); # end of %nodes