sparc: model restore as explicit node, refactor Save node
[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, 1);",
118         S0  => "${arch}_emit_source_register(node, 0);",
119         S1  => "${arch}_emit_source_register(node, 1);",
120         D0  => "${arch}_emit_dest_register(node, 0);",
121         HIM => "${arch}_emit_high_immediate(node);",
122         LM  => "${arch}_emit_load_mode(node);",
123         SM  => "${arch}_emit_store_mode(node);",
124         FLSM => "${arch}_emit_float_load_store_mode(node);",
125         FPM  => "${arch}_emit_fp_mode_suffix(node);",
126         FCONVS => "${arch}_emit_fp_conv_source(node);",
127         FCONVD => "${arch}_emit_fp_conv_destination(node);",
128         O1     => "${arch}_emit_offset(node, 1);",
129         O2     => "${arch}_emit_offset(node, 2);",
130 );
131
132 $default_attr_type = "sparc_attr_t";
133 $default_copy_attr = "sparc_copy_attr";
134
135
136 %init_attr = (
137         sparc_attr_t             => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
138         sparc_load_store_attr_t  => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
139         sparc_jmp_cond_attr_t    => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
140         sparc_switch_jmp_attr_t  => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
141                                     "\tinit_sparc_switch_jmp_attributes(res, default_pn, jump_table);\n",
142         sparc_fp_attr_t          => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
143                                     "\tinit_sparc_fp_attributes(res, fp_mode);\n",
144         sparc_fp_conv_attr_t     => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);".
145                                     "\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
146 );
147
148 %compare_attr = (
149         sparc_attr_t            => "cmp_attr_sparc",
150         sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
151         sparc_jmp_cond_attr_t   => "cmp_attr_sparc_jmp_cond",
152         sparc_switch_jmp_attr_t => "cmp_attr_sparc_switch_jmp",
153         sparc_fp_attr_t         => "cmp_attr_sparc_fp",
154         sparc_fp_conv_attr_t    => "cmp_attr_sparc_fp_conv",
155 );
156
157 %custom_irn_flags = (
158         modifies_flags    => "sparc_arch_irn_flag_modifies_flags",
159         modifies_fp_flags => "sparc_arch_irn_flag_modifies_fp_flags",
160 );
161
162 my %cmp_operand_constructors = (
163         imm => {
164                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
165                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
166                 reg_req    => { in => [ "gp" ], out => [ "flags" ] },
167                 ins        => [ "left" ],
168         },
169         reg => {
170                 reg_req    => { in => [ "gp", "gp" ], out => [ "flags" ] },
171                 ins        => [ "left", "right" ],
172         },
173 );
174
175 my %binop_operand_constructors = (
176         imm => {
177                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
178                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
179                 reg_req    => { in => [ "gp" ], out => [ "gp" ] },
180                 ins        => [ "left" ],
181         },
182         reg => {
183                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp" ] },
184                 ins        => [ "left", "right" ],
185         },
186 );
187
188 my %binopcczero_operand_constructors = (
189         imm => {
190                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
191                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
192                 reg_req    => { in => [ "gp" ], out => [ "flags" ] },
193                 ins        => [ "left" ],
194         },
195         reg => {
196                 reg_req    => { in => [ "gp", "gp" ], out => [ "flags" ] },
197                 ins        => [ "left", "right" ],
198         },
199 );
200
201 my %div_operand_constructors = (
202         imm => {
203                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
204                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
205                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp" ] },
206         },
207         reg => {
208                 reg_req    => { in => [ "gp", "gp", "gp" ], out => [ "gp" ] },
209         },
210 );
211
212 my %float_binop_constructors = (
213         s => {
214                 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
215                 mode    => $mode_fp,
216         },
217         d => {
218                 reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2" ] },
219                 mode    => $mode_fp2,
220         },
221         q => {
222                 reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4" ] },
223                 mode    => $mode_fp4,
224         }
225 );
226
227 my %float_unop_constructors = (
228         s => {
229                 reg_req => { in => [ "fp" ], out => [ "fp" ] },
230                 mode    => $mode_fp,
231         },
232         d => {
233                 reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|2" ] },
234                 mode    => $mode_fp2,
235         },
236         q => {
237                 reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|4" ] },
238                 mode    => $mode_fp4,
239         }
240 );
241
242 %nodes = (
243
244 Add => {
245         irn_flags    => [ "rematerializable" ],
246         mode         => $mode_gp,
247         emit         => '. add %S0, %R1I, %D0',
248         constructors => \%binop_operand_constructors,
249 },
250
251 Sub => {
252         irn_flags    => [ "rematerializable" ],
253         mode         => $mode_gp,
254         emit         => '. sub %S0, %R1I, %D0',
255         constructors => \%binop_operand_constructors,
256 },
257
258 # Load / Store
259 Ld => {
260         op_flags  => [ "labeled", "fragile" ],
261         state     => "exc_pinned",
262         constructors => {
263                 imm => {
264                         reg_req    => { in => [ "gp", "none" ], out => [ "gp", "none" ] },
265                         ins        => [ "ptr", "mem" ],
266                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
267                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
268                 },
269                 reg => {
270                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
271                         ins        => [ "ptr", "ptr2", "mem" ],
272                         attr       => "ir_mode *ls_mode",
273                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
274                 },
275         },
276         ins       => [ "ptr", "mem" ],
277         outs      => [ "res", "M" ],
278         attr_type => "sparc_load_store_attr_t",
279         emit      => '. ld%LM [%S0%O1], %D0'
280 },
281
282 SetHi => {
283         irn_flags  => [ "rematerializable" ],
284         outs       => [ "res" ],
285         mode       => $mode_gp,
286         reg_req    => { in => [], out => [ "gp" ] },
287         attr       => "ir_entity *entity, int32_t immediate_value",
288         custominit => "sparc_set_attr_imm(res, entity, immediate_value);",
289         emit       => '. sethi %HIM, %D0'
290 },
291
292 St => {
293         op_flags  => [ "labeled", "fragile" ],
294         mode      => "mode_M",
295         state     => "exc_pinned",
296         constructors => {
297                 imm => {
298                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
299                         ins        => [ "val", "ptr", "mem" ],
300                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
301                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
302                 },
303                 reg => {
304                         reg_req    => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
305                         ins        => [ "val", "ptr", "ptr2", "mem" ],
306                         attr       => "ir_mode *ls_mode",
307                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
308                 },
309         },
310         ins       => [ "val", "ptr", "mem" ],
311         outs      => [ "M" ],
312         attr_type => "sparc_load_store_attr_t",
313         emit      => '. st%SM %S0, [%S1%O2]'
314 },
315
316 Save => {
317         emit      => '. save %S0, %R1I, %D0',
318         outs      => [ "stack" ],
319         constructors => {
320                 imm => {
321                         attr       => "ir_entity *immediate_entity, int32_t immediate_value",
322                         custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
323                         reg_req    => { in => [ "sp" ], out => [ "sp:I|S" ] },
324                         ins        => [ "stack" ],
325                 },
326                 reg => {
327                         reg_req    => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
328                         ins        => [ "stack", "increment" ],
329                 }
330         },
331 },
332
333 Restore => {
334         emit => '. restore %S0, %R1I, %D0',
335         outs => [ "stack" ],
336         constructors => {
337                 imm => {
338                         attr       => "ir_entity *immediate_entity, int32_t immediate_value",
339                         custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
340                         reg_req    => { in => [ "sp" ], out => [ "sp:I|S" ] },
341                         ins        => [ "stack" ],
342                 },
343                 reg => {
344                         reg_req    => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
345                         ins        => [ "stack", "increment" ],
346                 }
347         },
348 },
349
350 RestoreZero => {
351         emit => '. restore',
352         outs => [ ],
353         ins  => [ ],
354         mode => "mode_T",
355 },
356
357 SubSP => {
358         reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "gp", "none" ] },
359         ins       => [ "stack", "size", "mem" ],
360         outs      => [ "stack", "addr", "M" ],
361         emit      => ". sub %S0, %S1, %D0\n",
362 },
363
364 AddSP => {
365         reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "none" ] },
366         ins       => [ "stack", "size", "mem" ],
367         outs      => [ "stack", "M" ],
368         emit      => ". add %S0, %S1, %D0\n",
369 },
370
371 FrameAddr => {
372         op_flags   => [ "constlike" ],
373         irn_flags  => [ "rematerializable" ],
374         attr       => "ir_entity *entity, int32_t offset",
375         reg_req    => { in => [ "gp" ], out => [ "gp" ] },
376         ins        => [ "base" ],
377         attr_type  => "sparc_attr_t",
378         custominit => "sparc_set_attr_imm(res, entity, offset);",
379         mode       => $mode_gp,
380 },
381
382 Bicc => {
383         op_flags  => [ "labeled", "cfopcode", "forking" ],
384         state     => "pinned",
385         mode      => "mode_T",
386         attr_type => "sparc_jmp_cond_attr_t",
387         attr      => "pn_Cmp pnc, bool is_unsigned",
388         init_attr => "\tinit_sparc_jmp_cond_attr(res, pnc, is_unsigned);",
389         reg_req   => { in => [ "flags" ], out => [ "none", "none" ] },
390 },
391
392 fbfcc => {
393         op_flags  => [ "labeled", "cfopcode", "forking" ],
394         state     => "pinned",
395         mode      => "mode_T",
396         attr_type => "sparc_jmp_cond_attr_t",
397         attr      => "pn_Cmp pnc",
398         init_attr => "\tinit_sparc_jmp_cond_attr(res, pnc, false);",
399         reg_req   => { in => [ "fpflags" ], out => [ "none", "none" ] },
400 },
401
402 Ba => {
403         state     => "pinned",
404         op_flags  => [ "cfopcode" ],
405         irn_flags => [ "simple_jump" ],
406         reg_req   => { out => [ "none" ] },
407         mode      => "mode_X",
408 },
409
410 # This is a JumpLink instruction, but with the addition that you can add custom
411 # register constraints to model your calling conventions
412 Return => {
413         arity     => "variable",
414         out_arity => "variable",
415         constructors => {
416                 imm => {
417                         attr       => "ir_entity *entity, int32_t offset",
418                         custominit => "\tsparc_set_attr_imm(res, entity, offset);",
419                         arity     => "variable",
420                         out_arity => "variable",
421                 },
422                 reg => {
423                         arity     => "variable",
424                         out_arity => "variable",
425                 }
426         },
427 },
428
429 Call => {
430         irn_flags => [ "modifies_flags", "modifies_fp_flags" ],
431         state     => "exc_pinned",
432         arity     => "variable",
433         out_arity => "variable",
434         constructors => {
435                 imm => {
436                         attr       => "ir_entity *entity, int32_t offset",
437                         custominit => "\tsparc_set_attr_imm(res, entity, offset);",
438                         arity     => "variable",
439                         out_arity => "variable",
440                 },
441                 reg => {
442                         arity     => "variable",
443                         out_arity => "variable",
444                 }
445         },
446 },
447
448 Cmp => {  # aka SubccZero
449         irn_flags    => [ "rematerializable", "modifies_flags" ],
450         emit         => '. cmp %S0, %R1I',
451         mode         => $mode_flags,
452         constructors => \%binopcczero_operand_constructors,
453 },
454
455 SwitchJmp => {
456         op_flags     => [ "labeled", "cfopcode", "forking" ],
457         state        => "pinned",
458         mode         => "mode_T",
459         reg_req      => { in => [ "gp" ], out => [ ] },
460         attr_type    => "sparc_switch_jmp_attr_t",
461         attr         => "long default_pn, ir_entity *jump_table",
462         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
463 },
464
465 Sll => {
466         irn_flags    => [ "rematerializable" ],
467         mode         => $mode_gp,
468         emit         => '. sll %S0, %R1I, %D0',
469         constructors => \%binop_operand_constructors,
470 },
471
472 Srl => {
473         irn_flags    => [ "rematerializable" ],
474         mode         => $mode_gp,
475         emit         => '. srl %S0, %R1I, %D0',
476         constructors => \%binop_operand_constructors,
477 },
478
479 Sra => {
480         irn_flags    => [ "rematerializable" ],
481         mode         => $mode_gp,
482         emit         => '. sra %S0, %R1I, %D0',
483         constructors => \%binop_operand_constructors,
484 },
485
486 And => {
487         irn_flags    => [ "rematerializable" ],
488         mode         => $mode_gp,
489         emit         => '. and %S0, %R1I, %D0',
490         constructors => \%binop_operand_constructors,
491 },
492
493 AndCCZero => {
494         irn_flags    => [ "rematerializable", "modifies_flags" ],
495         emit         => '. andcc %S0, %R1I, %%g0',
496         mode         => $mode_flags,
497         constructors => \%binopcczero_operand_constructors,
498 },
499
500 AndN => {
501         irn_flags => [ "rematerializable" ],
502         mode      => $mode_gp,
503         emit      => '. andn %S0, %R1I, %D0',
504         constructors => \%binop_operand_constructors,
505 },
506
507 AndNCCZero => {
508         irn_flags    => [ "rematerializable", "modifies_flags" ],
509         emit         => '. andncc %S0, %R1I, %%g0',
510         mode         => $mode_flags,
511         constructors => \%binopcczero_operand_constructors,
512 },
513
514 Or => {
515         irn_flags    => [ "rematerializable" ],
516         mode         => $mode_gp,
517         emit         => '. or %S0, %R1I, %D0',
518         constructors => \%binop_operand_constructors,
519 },
520
521 OrCCZero => {
522         irn_flags    => [ "rematerializable", "modifies_flags" ],
523         emit         => '. orcc %S0, %R1I, %%g0',
524         mode         => $mode_flags,
525         constructors => \%binopcczero_operand_constructors,
526 },
527
528 OrN => {
529         irn_flags => [ "rematerializable" ],
530         mode      => $mode_gp,
531         emit      => '. orn %S0, %R1I, %D0',
532         constructors => \%binop_operand_constructors,
533 },
534
535 OrNCCZero => {
536         irn_flags    => [ "rematerializable", "modifies_flags" ],
537         emit         => '. orncc %S0, %R1I, %%g0',
538         mode         => $mode_flags,
539         constructors => \%binopcczero_operand_constructors,
540 },
541
542 Xor => {
543         irn_flags    => [ "rematerializable" ],
544         mode         => $mode_gp,
545         emit         => '. xor %S0, %R1I, %D0',
546         constructors => \%binop_operand_constructors,
547 },
548
549 XorCCZero => {
550         irn_flags    => [ "rematerializable", "modifies_flags" ],
551         emit         => '. xorcc %S0, %R1I, %%g0',
552         mode         => $mode_flags,
553         constructors => \%binopcczero_operand_constructors,
554 },
555
556 XNor => {
557         irn_flags => [ "rematerializable" ],
558         mode      => $mode_gp,
559         emit      => '. xnor %S0, %R1I, %D0',
560         constructors => \%binop_operand_constructors,
561 },
562
563 XNorCCZero => {
564         irn_flags    => [ "rematerializable", "modifies_flags" ],
565         emit         => '. xnorcc %S0, %R1I, %%g0',
566         mode         => $mode_flags,
567         constructors => \%binopcczero_operand_constructors,
568 },
569
570 Mul => {
571         irn_flags    => [ "rematerializable" ],
572         mode         => $mode_gp,
573         emit         => '. smul %S0, %R1I, %D0',
574         constructors => \%binop_operand_constructors,
575 },
576
577 Mulh => {
578         irn_flags    => [ "rematerializable" ],
579         outs         => [ "low", "high" ],
580         constructors => \%binop_operand_constructors,
581 },
582
583 SDiv => {
584         irn_flags    => [ "rematerializable" ],
585         state        => "exc_pinned",
586         ins          => [ "dividend_high", "dividend_low", "divisor" ],
587         outs         => [ "res", "M" ],
588         constructors => \%div_operand_constructors,
589 },
590
591 UDiv => {
592         irn_flags    => [ "rematerializable" ],
593         state        => "exc_pinned",
594         ins          => [ "dividend_high", "dividend_low", "divisor" ],
595         outs         => [ "res", "M" ],
596         constructors => \%div_operand_constructors,
597 },
598
599 fcmp => {
600         irn_flags => [ "rematerializable", "modifies_fp_flags" ],
601         emit      => '. fcmp%FPM %S0, %S1',
602         attr_type => "sparc_fp_attr_t",
603         attr      => "ir_mode *fp_mode",
604         mode      => $mode_fpflags,
605         constructors => {
606                 s => {
607                         reg_req => { in => [ "fp", "fp" ], out => [ "fpflags" ] },
608                 },
609                 d => {
610                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fpflags" ] },
611                 },
612                 q => {
613                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fpflags" ] },
614                 },
615         },
616 },
617
618 fadd => {
619         op_flags     => [ "commutative" ],
620         irn_flags    => [ "rematerializable" ],
621         emit         => '. fadd%FPM %S0, %S1, %D0',
622         attr_type    => "sparc_fp_attr_t",
623         attr         => "ir_mode *fp_mode",
624         ins          => [ "left", "right" ],
625         constructors => \%float_binop_constructors,
626 },
627
628 fsub => {
629         irn_flags    => [ "rematerializable" ],
630         emit         => '. fsub%FPM %S0, %S1, %D0',
631         attr_type    => "sparc_fp_attr_t",
632         attr         => "ir_mode *fp_mode",
633         ins          => [ "left", "right" ],
634         constructors => \%float_binop_constructors,
635 },
636
637 fmul => {
638         irn_flags    => [ "rematerializable" ],
639         op_flags     => [ "commutative" ],
640         emit         =>'. fmul%FPM %S0, %S1, %D0',
641         attr_type    => "sparc_fp_attr_t",
642         attr         => "ir_mode *fp_mode",
643         ins          => [ "left", "right" ],
644         constructors => \%float_binop_constructors,
645 },
646
647 fdiv => {
648         irn_flags    => [ "rematerializable" ],
649         emit         => '. fdiv%FPM %S0, %S1, %D0',
650         attr_type    => "sparc_fp_attr_t",
651         attr         => "ir_mode *fp_mode",
652         ins          => [ "left", "right" ],
653         outs         => [ "res", "M" ],
654         constructors => {
655                 s => {
656                         reg_req => { in => [ "fp", "fp" ], out => [ "fp", "none" ] },
657                 },
658                 d => {
659                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2", "none" ] },
660                 },
661                 q => {
662                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4", "none" ] },
663                 }
664         },
665 },
666
667 fneg => {
668         irn_flags => [ "rematerializable" ],
669         reg_req   => { in => [ "fp" ], out => [ "fp" ] },
670         # note that we only need the first register even for wide-values
671         emit      => '. fneg %S0, %D0',
672         attr_type => "sparc_fp_attr_t",
673         attr      => "ir_mode *fp_mode",
674         ins          => [ "val" ],
675         constructors => \%float_unop_constructors,
676 },
677
678 "fabs" => {
679         irn_flags    => [ "rematerializable" ],
680         # note that we only need the first register even for wide-values
681         emit         => '. fabs %S0, %D0',
682         attr_type    => "sparc_fp_attr_t",
683         attr         => "ir_mode *fp_mode",
684         ins          => [ "val" ],
685         constructors => \%float_unop_constructors,
686 },
687
688 fftof => {
689         irn_flags => [ "rematerializable" ],
690         emit      => '. f%FCONVS%.to%FCONVD %S0, %D0',
691         attr_type => "sparc_fp_conv_attr_t",
692         attr      => "ir_mode *src_mode, ir_mode *dest_mode",
693         constructors => {
694                 s_d => {
695                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
696                         mode    => $mode_fp2,
697                 },
698                 s_q => {
699                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
700                         mode    => $mode_fp4,
701                 },
702                 d_s => {
703                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
704                         mode    => $mode_fp,
705                 },
706                 d_q => {
707                         reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|4" ] },
708                         mode    => $mode_fp4,
709                 },
710                 q_s => {
711                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
712                         mode    => $mode_fp,
713                 },
714                 q_d => {
715                         reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|2" ] },
716                         mode    => $mode_fp2,
717                 },
718         },
719 },
720
721 fitof => {
722         irn_flags => [ "rematerializable" ],
723         emit      => '. fito%FPM %S0, %D0',
724         attr_type => "sparc_fp_attr_t",
725         attr      => "ir_mode *fp_mode",
726         constructors => {
727                 s => {
728                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
729                         mode    => $mode_fp,
730                 },
731                 d => {
732                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
733                         mode    => $mode_fp2,
734                 },
735                 q => {
736                         reg_req => { in => [ "fp" ], out => [ "fp:a|4" ] },
737                         mode    => $mode_fp4,
738                 },
739         },
740 },
741
742 fftoi => {
743         irn_flags => [ "rematerializable" ],
744         emit      => '. f%FPM%.toi %S0, %D0',
745         attr_type => "sparc_fp_attr_t",
746         attr      => "ir_mode *fp_mode",
747         mode      => $mode_gp,
748         constructors => {
749                 s => {
750                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
751                 },
752                 d => {
753                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
754                 },
755                 q => {
756                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
757                 },
758         },
759 },
760
761 Ldf => {
762         op_flags  => [ "labeled", "fragile" ],
763         state     => "exc_pinned",
764         constructors => {
765                 s => {
766                         reg_req => { in => [ "gp", "none" ], out => [ "fp", "none" ] },
767                 },
768                 d => {
769                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|2", "none" ] },
770                 },
771                 q => {
772                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|4", "none" ] },
773                 },
774         },
775         ins       => [ "ptr", "mem" ],
776         outs      => [ "res", "M" ],
777         attr_type => "sparc_load_store_attr_t",
778         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
779         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
780         emit      => '. ld%FLSM [%S0%O1], %D0'
781 },
782
783 Stf => {
784         op_flags  => [ "labeled", "fragile" ],
785         state     => "exc_pinned",
786         constructors => {
787                 s => {
788                         reg_req => { in => [ "fp",     "gp", "none" ], out => [ "none" ] },
789                 },
790                 d => {
791                         reg_req => { in => [ "fp:a|2", "gp", "none" ], out => [ "none" ] },
792                 },
793                 q => {
794                         reg_req => { in => [ "fp:a|4", "gp", "none" ], out => [ "none" ] },
795                 },
796         },
797         ins       => [ "val", "ptr", "mem" ],
798         outs      => [ "M" ],
799         attr_type => "sparc_load_store_attr_t",
800         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
801         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
802         emit      => '. st%FLSM %S0, [%S1%O2]',
803         mode      => 'mode_M',
804 },
805
806 ); # end of %nodes