sparc: mark has_delay_slot as node flag
[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 # available SPARC registers: 8 globals, 24 window regs (8 ins, 8 outs, 8 locals)
14 %reg_classes = (
15         gp => [
16                 { name => "g0" },
17                 { name => "g1" },
18                 { name => "g2" },
19                 { name => "g3" },
20                 { name => "g4" },
21                 { name => "g5" },
22                 { name => "g6" },
23                 { name => "g7" },
24
25                 { name => "o0" },
26                 { name => "o1" },
27                 { name => "o2" },
28                 { name => "o3" },
29                 { name => "o4" },
30                 { name => "o5" },
31                 { name => "sp" },
32                 { name => "o7" },
33
34                 { name => "l0" },
35                 { name => "l1" },
36                 { name => "l2" },
37                 { name => "l3" },
38                 { name => "l4" },
39                 { name => "l5" },
40                 { name => "l6" },
41                 { name => "l7" },
42
43                 { name => "i0" },
44                 { name => "i1" },
45                 { name => "i2" },
46                 { name => "i3" },
47                 { name => "i4" },
48                 { name => "i5" },
49                 { name => "frame_pointer", realname => "fp" },
50                 { name => "i7" },
51                 { mode => $mode_gp }
52         ],
53         fpflags_class => [
54                 { name => "fpflags" },
55                 { mode => $mode_fpflags, flags => "manual_ra" }
56         ],
57         flags_class => [
58                 { name => "flags" },
59                 { mode => $mode_flags, flags => "manual_ra" }
60         ],
61         mul_div_high_res => [
62                 { name => "y" },
63                 { mode => $mode_gp, flags => "manual_ra" }
64         ],
65         # fp registers can be accessed any time
66         fp => [
67                 { name => "f0" },
68                 { name => "f1" },
69                 { name => "f2" },
70                 { name => "f3" },
71                 { name => "f4" },
72                 { name => "f5" },
73                 { name => "f6" },
74                 { name => "f7" },
75                 { name => "f8" },
76                 { name => "f9" },
77                 { name => "f10" },
78                 { name => "f11" },
79                 { name => "f12" },
80                 { name => "f13" },
81                 { name => "f14" },
82                 { name => "f15" },
83                 { name => "f16" },
84                 { name => "f17" },
85                 { name => "f18" },
86                 { name => "f19" },
87                 { name => "f20" },
88                 { name => "f21" },
89                 { name => "f22" },
90                 { name => "f23" },
91                 { name => "f24" },
92                 { name => "f25" },
93                 { name => "f26" },
94                 { name => "f27" },
95                 { name => "f28" },
96                 { name => "f29" },
97                 { name => "f30" },
98                 { name => "f31" },
99                 { mode => $mode_fp }
100         ]
101 ); # %reg_classes
102
103 %emit_templates = (
104 # emit source reg or imm dep. on node's arity
105         RI  => "${arch}_emit_reg_or_imm(node, -1);",
106         R1I => "${arch}_emit_reg_or_imm(node, 1);",
107         S0  => "${arch}_emit_source_register(node, 0);",
108         S1  => "${arch}_emit_source_register(node, 1);",
109         D0  => "${arch}_emit_dest_register(node, 0);",
110         HIM => "${arch}_emit_high_immediate(node);",
111         LM  => "${arch}_emit_load_mode(node);",
112         SM  => "${arch}_emit_store_mode(node);",
113         FLSM => "${arch}_emit_float_load_store_mode(node);",
114         FPM  => "${arch}_emit_fp_mode_suffix(node);",
115         FCONVS => "${arch}_emit_fp_conv_source(node);",
116         FCONVD => "${arch}_emit_fp_conv_destination(node);",
117         O1     => "${arch}_emit_offset(node, 1);",
118         O2     => "${arch}_emit_offset(node, 2);",
119 );
120
121 $default_attr_type = "sparc_attr_t";
122 $default_copy_attr = "sparc_copy_attr";
123
124 %init_attr = (
125         sparc_attr_t             => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
126         sparc_load_store_attr_t  => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
127         sparc_jmp_cond_attr_t    => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
128         sparc_switch_jmp_attr_t  => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
129                                     "\tinit_sparc_switch_jmp_attributes(res, default_pn, jump_table);\n",
130         sparc_fp_attr_t          => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
131                                     "\tinit_sparc_fp_attributes(res, fp_mode);\n",
132         sparc_fp_conv_attr_t     => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);".
133                                     "\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
134 );
135
136 %compare_attr = (
137         sparc_attr_t            => "cmp_attr_sparc",
138         sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
139         sparc_jmp_cond_attr_t   => "cmp_attr_sparc_jmp_cond",
140         sparc_switch_jmp_attr_t => "cmp_attr_sparc_switch_jmp",
141         sparc_fp_attr_t         => "cmp_attr_sparc_fp",
142         sparc_fp_conv_attr_t    => "cmp_attr_sparc_fp_conv",
143 );
144
145 %custom_irn_flags = (
146         modifies_flags    => "(arch_irn_flags_t)sparc_arch_irn_flag_modifies_flags",
147         modifies_fp_flags => "(arch_irn_flags_t)sparc_arch_irn_flag_modifies_fp_flags",
148         has_delay_slot    => "(arch_irn_flags_t)sparc_arch_irn_flag_has_delay_slot",
149 );
150
151 my %cmp_operand_constructors = (
152         imm => {
153                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
154                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
155                 reg_req    => { in => [ "gp" ], out => [ "flags" ] },
156                 ins        => [ "left" ],
157         },
158         reg => {
159                 reg_req    => { in => [ "gp", "gp" ], out => [ "flags" ] },
160                 ins        => [ "left", "right" ],
161         },
162 );
163
164 my %binop_operand_constructors = (
165         imm => {
166                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
167                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
168                 reg_req    => { in => [ "gp" ], out => [ "gp" ] },
169                 ins        => [ "left" ],
170         },
171         reg => {
172                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp" ] },
173                 ins        => [ "left", "right" ],
174         },
175 );
176
177 my %binopcc_operand_constructors = (
178         imm => {
179                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
180                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
181                 reg_req    => { in => [ "gp" ], out => [ "gp", "flags" ] },
182                 ins        => [ "left" ],
183         },
184         reg => {
185                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp", "flags" ] },
186                 ins        => [ "left", "right" ],
187         },
188 );
189
190 my %binopx_operand_constructors = (
191         imm => {
192                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
193                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
194                 reg_req    => { in => [ "gp", "flags" ], out => [ "gp" ] },
195                 ins        => [ "left", "carry" ],
196         },
197         reg => {
198                 reg_req    => { in => [ "gp", "gp", "flags" ], out => [ "gp" ] },
199                 ins        => [ "left", "right", "carry" ],
200         },
201 );
202
203
204 my %binopcczero_operand_constructors = (
205         imm => {
206                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
207                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
208                 reg_req    => { in => [ "gp" ], out => [ "flags" ] },
209                 ins        => [ "left" ],
210         },
211         reg => {
212                 reg_req    => { in => [ "gp", "gp" ], out => [ "flags" ] },
213                 ins        => [ "left", "right" ],
214         },
215 );
216
217 my %div_operand_constructors = (
218         imm => {
219                 attr       => "ir_entity *immediate_entity, int32_t immediate_value",
220                 custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
221                 reg_req    => { in => [ "gp", "gp" ], out => [ "gp" ] },
222         },
223         reg => {
224                 reg_req    => { in => [ "gp", "gp", "gp" ], out => [ "gp" ] },
225         },
226 );
227
228 my %float_binop_constructors = (
229         s => {
230                 reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] },
231                 mode    => $mode_fp,
232         },
233         d => {
234                 reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2" ] },
235                 mode    => $mode_fp2,
236         },
237         q => {
238                 reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4" ] },
239                 mode    => $mode_fp4,
240         }
241 );
242
243 my %float_unop_constructors = (
244         s => {
245                 reg_req => { in => [ "fp" ], out => [ "fp" ] },
246                 mode    => $mode_fp,
247         },
248         d => {
249                 reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|2" ] },
250                 mode    => $mode_fp2,
251         },
252         q => {
253                 reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|4" ] },
254                 mode    => $mode_fp4,
255         }
256 );
257
258 %nodes = (
259
260 Add => {
261         irn_flags    => [ "rematerializable" ],
262         mode         => $mode_gp,
263         emit         => '. add %S0, %R1I, %D0',
264         constructors => \%binop_operand_constructors,
265 },
266
267 AddCC => {
268         irn_flags    => [ "rematerializable" ],
269         emit         => '. addcc %S0, %R1I, %D0',
270         outs         => [ "res", "flags" ],
271         constructors => \%binopcc_operand_constructors,
272 },
273
274 AddX => {
275         # At the moment not rematerializable because of assert in beflags.c/
276         # (it claims that spiller can't rematerialize flag stuff correctly)
277         #irn_flags    => [ "rematerializable" ],
278         emit         => '. addx %S0, %R1I, %D0',
279         constructors => \%binopx_operand_constructors,
280         mode         => $mode_gp,
281 },
282
283 AddCC_t => {
284         ins       => [ "left", "right" ],
285         outs      => [ "res", "flags" ],
286         attr_type => "",
287         dump_func => "NULL",
288 },
289
290 AddX_t => {
291         ins       => [ "left", "right", "flags_input" ],
292         attr_type => "",
293         dump_func => "NULL",
294 },
295
296 Sub => {
297         irn_flags    => [ "rematerializable" ],
298         mode         => $mode_gp,
299         emit         => '. sub %S0, %R1I, %D0',
300         constructors => \%binop_operand_constructors,
301 },
302
303 SubCC => {
304         irn_flags    => [ "rematerializable" ],
305         emit         => '. subcc %S0, %R1I, %D0',
306         outs         => [ "res", "flags" ],
307         constructors => \%binopcc_operand_constructors,
308 },
309
310 SubX => {
311         # Not rematerializable (see AddX)
312         emit         => '. subx %S0, %R1I, %D0',
313         constructors => \%binopx_operand_constructors,
314         mode         => $mode_gp,
315 },
316
317 SubCC_t => {
318         ins       => [ "left", "right" ],
319         outs      => [ "res", "flags" ],
320         attr_type => "",
321         dump_func => "NULL",
322 },
323
324 SubX_t => {
325         ins       => [ "left", "right", "flags_input" ],
326         attr_type => "",
327         dump_func => "NULL",
328 },
329
330 # Load / Store
331 Ld => {
332         op_flags  => [ "labeled" ],
333         state     => "exc_pinned",
334         constructors => {
335                 imm => {
336                         reg_req    => { in => [ "gp", "none" ], out => [ "gp", "none" ] },
337                         ins        => [ "ptr", "mem" ],
338                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
339                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
340                 },
341                 reg => {
342                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
343                         ins        => [ "ptr", "ptr2", "mem" ],
344                         attr       => "ir_mode *ls_mode",
345                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
346                 },
347         },
348         ins       => [ "ptr", "mem" ],
349         outs      => [ "res", "M" ],
350         attr_type => "sparc_load_store_attr_t",
351         emit      => '. ld%LM [%S0%O1], %D0'
352 },
353
354 SetHi => {
355         irn_flags  => [ "rematerializable" ],
356         outs       => [ "res" ],
357         mode       => $mode_gp,
358         reg_req    => { in => [], out => [ "gp" ] },
359         attr       => "ir_entity *entity, int32_t immediate_value",
360         custominit => "sparc_set_attr_imm(res, entity, immediate_value);",
361         emit       => '. sethi %HIM, %D0'
362 },
363
364 St => {
365         op_flags  => [ "labeled" ],
366         mode      => "mode_M",
367         state     => "exc_pinned",
368         constructors => {
369                 imm => {
370                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
371                         ins        => [ "val", "ptr", "mem" ],
372                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
373                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
374                 },
375                 reg => {
376                         reg_req    => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
377                         ins        => [ "val", "ptr", "ptr2", "mem" ],
378                         attr       => "ir_mode *ls_mode",
379                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
380                 },
381         },
382         ins       => [ "val", "ptr", "mem" ],
383         outs      => [ "M" ],
384         attr_type => "sparc_load_store_attr_t",
385         emit      => '. st%SM %S0, [%S1%O2]'
386 },
387
388 Save => {
389         emit      => '. save %S0, %R1I, %D0',
390         outs      => [ "stack" ],
391         ins       => [ "stack" ],
392         constructors => {
393                 imm => {
394                         attr       => "ir_entity *immediate_entity, int32_t immediate_value",
395                         custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
396                         reg_req    => { in => [ "sp" ], out => [ "sp:I|S" ] },
397                         ins        => [ "stack" ],
398                 },
399                 reg => {
400                         reg_req    => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
401                         ins        => [ "stack", "increment" ],
402                 }
403         },
404         mode => $mode_gp,
405 },
406
407 Restore => {
408         emit => '. restore %S0, %R1I, %D0',
409         outs => [ "stack" ],
410         ins  => [ "stack" ],
411         constructors => {
412                 imm => {
413                         attr       => "ir_entity *immediate_entity, int32_t immediate_value",
414                         custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
415                         reg_req    => { in => [ "sp" ], out => [ "sp:I|S" ] },
416                         ins        => [ "stack" ],
417                 },
418                 reg => {
419                         reg_req    => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
420                         ins        => [ "stack", "increment" ],
421                 }
422         },
423         mode => $mode_gp,
424 },
425
426 RestoreZero => {
427         reg_req => { in => [ "frame_pointer" ], out => [ "sp:I|S" ] },
428         ins     => [ "frame_pointer" ],
429         outs    => [ "stack" ],
430         emit    => '. restore',
431         mode    => $mode_gp,
432 },
433
434 SubSP => {
435         reg_req => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
436         ins     => [ "stack", "size" ],
437         outs    => [ "stack" ],
438         emit    => ". sub %S0, %S1, %D0\n",
439         mode    => $mode_gp,
440 },
441
442 AddSP => {
443         reg_req => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
444         ins     => [ "stack", "size" ],
445         outs    => [ "stack" ],
446         emit    => ". add %S0, %S1, %D0\n",
447         mode    => $mode_gp,
448 },
449
450 FrameAddr => {
451         op_flags   => [ "constlike" ],
452         irn_flags  => [ "rematerializable" ],
453         attr       => "ir_entity *entity, int32_t offset",
454         reg_req    => { in => [ "gp" ], out => [ "gp" ] },
455         ins        => [ "base" ],
456         attr_type  => "sparc_attr_t",
457         custominit => "sparc_set_attr_imm(res, entity, offset);",
458         mode       => $mode_gp,
459 },
460
461 Bicc => {
462         op_flags  => [ "labeled", "cfopcode", "forking" ],
463         irn_flags => [ "has_delay_slot" ],
464         state     => "pinned",
465         mode      => "mode_T",
466         attr_type => "sparc_jmp_cond_attr_t",
467         attr      => "ir_relation relation, bool is_unsigned",
468         init_attr => "\tinit_sparc_jmp_cond_attr(res, relation, is_unsigned);",
469         reg_req   => { in => [ "flags" ], out => [ "none", "none" ] },
470         ins       => [ "flags" ],
471         outs      => [ "false", "true" ],
472 },
473
474 fbfcc => {
475         op_flags  => [ "labeled", "cfopcode", "forking" ],
476         irn_flags => [ "has_delay_slot" ],
477         state     => "pinned",
478         mode      => "mode_T",
479         attr_type => "sparc_jmp_cond_attr_t",
480         attr      => "ir_relation relation",
481         init_attr => "\tinit_sparc_jmp_cond_attr(res, relation, false);",
482         reg_req   => { in => [ "fpflags" ], out => [ "none", "none" ] },
483         ins       => [ "flags" ],
484         outs      => [ "false", "true" ],
485 },
486
487 Ba => {
488         # Note: has_delay_slot depends on wether it is a fallthrough or not, so we
489         # have special code for this in sparc_emitter
490         state     => "pinned",
491         op_flags  => [ "cfopcode" ],
492         irn_flags => [ "simple_jump" ],
493         reg_req   => { out => [ "none" ] },
494         mode      => "mode_X",
495 },
496
497 Start => {
498         state     => "pinned",
499         out_arity => "variable",
500         ins       => [],
501 },
502
503 # This is a JumpLink instruction, but with the addition that you can add custom
504 # register constraints to model your calling conventions
505 Return => {
506         state     => "pinned",
507         op_flags  => [ "cfopcode" ],
508         irn_flags => [ "has_delay_slot" ],
509         arity     => "variable",
510         mode      => "mode_X",
511         constructors => {
512                 imm => {
513                         attr       => "ir_entity *entity, int32_t offset",
514                         custominit => "\tsparc_set_attr_imm(res, entity, offset);",
515                         arity     => "variable",
516                         reg_req   => { out => [ "none" ] },
517                 },
518                 reg => {
519                         arity     => "variable",
520                         reg_req   => { out => [ "none" ] },
521                 }
522         },
523 },
524
525 Call => {
526         irn_flags => [ "modifies_flags", "modifies_fp_flags", "has_delay_slot" ],
527         state     => "exc_pinned",
528         arity     => "variable",
529         out_arity => "variable",
530         constructors => {
531                 imm => {
532                         attr       => "ir_entity *entity, int32_t offset, bool aggregate_return",
533                         custominit => "\tsparc_set_attr_imm(res, entity, offset);".
534                                       "\tif (aggregate_return) arch_add_irn_flags(res, sparc_arch_irn_flag_aggregate_return);",
535                         arity     => "variable",
536                         out_arity => "variable",
537                 },
538                 reg => {
539                         attr       => "bool aggregate_return",
540                         arity      => "variable",
541                         out_arity  => "variable",
542                         custominit => "\tif (aggregate_return) arch_add_irn_flags(res, sparc_arch_irn_flag_aggregate_return);",
543                 }
544         },
545 },
546
547 Cmp => {  # aka SubccZero
548         irn_flags    => [ "rematerializable", "modifies_flags" ],
549         emit         => '. cmp %S0, %R1I',
550         mode         => $mode_flags,
551         constructors => \%binopcczero_operand_constructors,
552 },
553
554 SwitchJmp => {
555         op_flags     => [ "labeled", "cfopcode", "forking" ],
556         irn_flags    => [ "has_delay_slot" ],
557         state        => "pinned",
558         mode         => "mode_T",
559         reg_req      => { in => [ "gp" ], out => [ ] },
560         attr_type    => "sparc_switch_jmp_attr_t",
561         attr         => "long default_pn, ir_entity *jump_table",
562         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
563 },
564
565 Sll => {
566         irn_flags    => [ "rematerializable" ],
567         mode         => $mode_gp,
568         emit         => '. sll %S0, %R1I, %D0',
569         constructors => \%binop_operand_constructors,
570 },
571
572 Srl => {
573         irn_flags    => [ "rematerializable" ],
574         mode         => $mode_gp,
575         emit         => '. srl %S0, %R1I, %D0',
576         constructors => \%binop_operand_constructors,
577 },
578
579 Sra => {
580         irn_flags    => [ "rematerializable" ],
581         mode         => $mode_gp,
582         emit         => '. sra %S0, %R1I, %D0',
583         constructors => \%binop_operand_constructors,
584 },
585
586 And => {
587         irn_flags    => [ "rematerializable" ],
588         mode         => $mode_gp,
589         emit         => '. and %S0, %R1I, %D0',
590         constructors => \%binop_operand_constructors,
591 },
592
593 AndCCZero => {
594         irn_flags    => [ "rematerializable", "modifies_flags" ],
595         emit         => '. andcc %S0, %R1I, %%g0',
596         mode         => $mode_flags,
597         constructors => \%binopcczero_operand_constructors,
598 },
599
600 AndN => {
601         irn_flags => [ "rematerializable" ],
602         mode      => $mode_gp,
603         emit      => '. andn %S0, %R1I, %D0',
604         constructors => \%binop_operand_constructors,
605 },
606
607 AndNCCZero => {
608         irn_flags    => [ "rematerializable", "modifies_flags" ],
609         emit         => '. andncc %S0, %R1I, %%g0',
610         mode         => $mode_flags,
611         constructors => \%binopcczero_operand_constructors,
612 },
613
614 Or => {
615         irn_flags    => [ "rematerializable" ],
616         mode         => $mode_gp,
617         emit         => '. or %S0, %R1I, %D0',
618         constructors => \%binop_operand_constructors,
619 },
620
621 OrCCZero => {
622         irn_flags    => [ "rematerializable", "modifies_flags" ],
623         emit         => '. orcc %S0, %R1I, %%g0',
624         mode         => $mode_flags,
625         constructors => \%binopcczero_operand_constructors,
626 },
627
628 OrN => {
629         irn_flags => [ "rematerializable" ],
630         mode      => $mode_gp,
631         emit      => '. orn %S0, %R1I, %D0',
632         constructors => \%binop_operand_constructors,
633 },
634
635 OrNCCZero => {
636         irn_flags    => [ "rematerializable", "modifies_flags" ],
637         emit         => '. orncc %S0, %R1I, %%g0',
638         mode         => $mode_flags,
639         constructors => \%binopcczero_operand_constructors,
640 },
641
642 Xor => {
643         irn_flags    => [ "rematerializable" ],
644         mode         => $mode_gp,
645         emit         => '. xor %S0, %R1I, %D0',
646         constructors => \%binop_operand_constructors,
647 },
648
649 XorCCZero => {
650         irn_flags    => [ "rematerializable", "modifies_flags" ],
651         emit         => '. xorcc %S0, %R1I, %%g0',
652         mode         => $mode_flags,
653         constructors => \%binopcczero_operand_constructors,
654 },
655
656 XNor => {
657         irn_flags => [ "rematerializable" ],
658         mode      => $mode_gp,
659         emit      => '. xnor %S0, %R1I, %D0',
660         constructors => \%binop_operand_constructors,
661 },
662
663 XNorCCZero => {
664         irn_flags    => [ "rematerializable", "modifies_flags" ],
665         emit         => '. xnorcc %S0, %R1I, %%g0',
666         mode         => $mode_flags,
667         constructors => \%binopcczero_operand_constructors,
668 },
669
670 Mul => {
671         irn_flags    => [ "rematerializable" ],
672         mode         => $mode_gp,
673         emit         => '. smul %S0, %R1I, %D0',
674         constructors => \%binop_operand_constructors,
675 },
676
677 SMulh => {
678         irn_flags    => [ "rematerializable" ],
679         outs         => [ "low", "high" ],
680         constructors => \%binop_operand_constructors,
681 },
682
683 UMulh => {
684         irn_flags    => [ "rematerializable" ],
685         outs         => [ "low", "high" ],
686         constructors => \%binop_operand_constructors,
687 },
688
689 SDiv => {
690         irn_flags    => [ "rematerializable", "has_delay_slot" ],
691         state        => "exc_pinned",
692         ins          => [ "dividend_high", "dividend_low", "divisor" ],
693         outs         => [ "res", "M" ],
694         constructors => \%div_operand_constructors,
695 },
696
697 UDiv => {
698         irn_flags    => [ "rematerializable", "has_delay_slot" ],
699         state        => "exc_pinned",
700         ins          => [ "dividend_high", "dividend_low", "divisor" ],
701         outs         => [ "res", "M" ],
702         constructors => \%div_operand_constructors,
703 },
704
705 fcmp => {
706         irn_flags => [ "rematerializable", "modifies_fp_flags" ],
707         emit      => '. fcmp%FPM %S0, %S1',
708         attr_type => "sparc_fp_attr_t",
709         attr      => "ir_mode *fp_mode",
710         mode      => $mode_fpflags,
711         constructors => {
712                 s => {
713                         reg_req => { in => [ "fp", "fp" ], out => [ "fpflags" ] },
714                 },
715                 d => {
716                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fpflags" ] },
717                 },
718                 q => {
719                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fpflags" ] },
720                 },
721         },
722 },
723
724 fadd => {
725         op_flags     => [ "commutative" ],
726         irn_flags    => [ "rematerializable" ],
727         emit         => '. fadd%FPM %S0, %S1, %D0',
728         attr_type    => "sparc_fp_attr_t",
729         attr         => "ir_mode *fp_mode",
730         ins          => [ "left", "right" ],
731         constructors => \%float_binop_constructors,
732 },
733
734 fsub => {
735         irn_flags    => [ "rematerializable" ],
736         emit         => '. fsub%FPM %S0, %S1, %D0',
737         attr_type    => "sparc_fp_attr_t",
738         attr         => "ir_mode *fp_mode",
739         ins          => [ "left", "right" ],
740         constructors => \%float_binop_constructors,
741 },
742
743 fmul => {
744         irn_flags    => [ "rematerializable" ],
745         op_flags     => [ "commutative" ],
746         emit         =>'. fmul%FPM %S0, %S1, %D0',
747         attr_type    => "sparc_fp_attr_t",
748         attr         => "ir_mode *fp_mode",
749         ins          => [ "left", "right" ],
750         constructors => \%float_binop_constructors,
751 },
752
753 fdiv => {
754         irn_flags    => [ "rematerializable" ],
755         emit         => '. fdiv%FPM %S0, %S1, %D0',
756         attr_type    => "sparc_fp_attr_t",
757         attr         => "ir_mode *fp_mode",
758         ins          => [ "left", "right" ],
759         outs         => [ "res", "M" ],
760         constructors => {
761                 s => {
762                         reg_req => { in => [ "fp", "fp" ], out => [ "fp", "none" ] },
763                 },
764                 d => {
765                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2", "none" ] },
766                 },
767                 q => {
768                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4", "none" ] },
769                 }
770         },
771 },
772
773 fneg => {
774         irn_flags => [ "rematerializable" ],
775         reg_req   => { in => [ "fp" ], out => [ "fp" ] },
776         # note that we only need the first register even for wide-values
777         emit      => '. fnegs %S0, %D0',
778         attr_type => "sparc_fp_attr_t",
779         attr      => "ir_mode *fp_mode",
780         ins          => [ "val" ],
781         constructors => \%float_unop_constructors,
782 },
783
784 "fabs" => {
785         irn_flags    => [ "rematerializable" ],
786         # note that we only need the first register even for wide-values
787         emit         => '. fabs %S0, %D0',
788         attr_type    => "sparc_fp_attr_t",
789         attr         => "ir_mode *fp_mode",
790         ins          => [ "val" ],
791         constructors => \%float_unop_constructors,
792 },
793
794 fftof => {
795         irn_flags => [ "rematerializable" ],
796         emit      => '. f%FCONVS%.to%FCONVD %S0, %D0',
797         attr_type => "sparc_fp_conv_attr_t",
798         attr      => "ir_mode *src_mode, ir_mode *dest_mode",
799         constructors => {
800                 s_d => {
801                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
802                         mode    => $mode_fp2,
803                 },
804                 s_q => {
805                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
806                         mode    => $mode_fp4,
807                 },
808                 d_s => {
809                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
810                         mode    => $mode_fp,
811                 },
812                 d_q => {
813                         reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|4" ] },
814                         mode    => $mode_fp4,
815                 },
816                 q_s => {
817                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
818                         mode    => $mode_fp,
819                 },
820                 q_d => {
821                         reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|2" ] },
822                         mode    => $mode_fp2,
823                 },
824         },
825 },
826
827 fitof => {
828         irn_flags => [ "rematerializable" ],
829         emit      => '. fito%FPM %S0, %D0',
830         attr_type => "sparc_fp_attr_t",
831         attr      => "ir_mode *fp_mode",
832         constructors => {
833                 s => {
834                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
835                         mode    => $mode_fp,
836                 },
837                 d => {
838                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
839                         mode    => $mode_fp2,
840                 },
841                 q => {
842                         reg_req => { in => [ "fp" ], out => [ "fp:a|4" ] },
843                         mode    => $mode_fp4,
844                 },
845         },
846 },
847
848 fftoi => {
849         irn_flags => [ "rematerializable" ],
850         emit      => '. f%FPM%.toi %S0, %D0',
851         attr_type => "sparc_fp_attr_t",
852         attr      => "ir_mode *fp_mode",
853         mode      => $mode_gp,
854         constructors => {
855                 s => {
856                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
857                 },
858                 d => {
859                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
860                 },
861                 q => {
862                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
863                 },
864         },
865 },
866
867 Ldf => {
868         op_flags  => [ "labeled" ],
869         state     => "exc_pinned",
870         constructors => {
871                 s => {
872                         reg_req => { in => [ "gp", "none" ], out => [ "fp", "none" ] },
873                 },
874                 d => {
875                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|2", "none" ] },
876                 },
877                 q => {
878                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|4", "none" ] },
879                 },
880         },
881         ins       => [ "ptr", "mem" ],
882         outs      => [ "res", "M" ],
883         attr_type => "sparc_load_store_attr_t",
884         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
885         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
886         emit      => '. ld%FLSM [%S0%O1], %D0'
887 },
888
889 Stf => {
890         op_flags  => [ "labeled" ],
891         state     => "exc_pinned",
892         constructors => {
893                 s => {
894                         reg_req => { in => [ "fp",     "gp", "none" ], out => [ "none" ] },
895                 },
896                 d => {
897                         reg_req => { in => [ "fp:a|2", "gp", "none" ], out => [ "none" ] },
898                 },
899                 q => {
900                         reg_req => { in => [ "fp:a|4", "gp", "none" ], out => [ "none" ] },
901                 },
902         },
903         ins       => [ "val", "ptr", "mem" ],
904         outs      => [ "M" ],
905         attr_type => "sparc_load_store_attr_t",
906         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
907         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
908         emit      => '. st%FLSM %S0, [%S1%O2]',
909         mode      => 'mode_M',
910 },
911
912 ); # end of %nodes