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