sparc: improve delay slot picking
[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 Jump 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 # This is a JumpLink instruction, but with the addition that you can add custom
527 # register constraints to model your calling conventions
528 Call => {
529         irn_flags => [ "modifies_flags", "modifies_fp_flags", "has_delay_slot" ],
530         state     => "exc_pinned",
531         arity     => "variable",
532         out_arity => "variable",
533         constructors => {
534                 imm => {
535                         attr       => "ir_entity *entity, int32_t offset, bool aggregate_return",
536                         custominit => "\tsparc_set_attr_imm(res, entity, offset);".
537                                       "\tif (aggregate_return) arch_add_irn_flags(res, sparc_arch_irn_flag_aggregate_return);",
538                         arity     => "variable",
539                         out_arity => "variable",
540                 },
541                 reg => {
542                         attr       => "bool aggregate_return",
543                         arity      => "variable",
544                         out_arity  => "variable",
545                         custominit => "\tif (aggregate_return) arch_add_irn_flags(res, sparc_arch_irn_flag_aggregate_return);",
546                 }
547         },
548 },
549
550 Cmp => {  # aka SubccZero
551         irn_flags    => [ "rematerializable", "modifies_flags" ],
552         emit         => '. cmp %S0, %R1I',
553         mode         => $mode_flags,
554         constructors => \%binopcczero_operand_constructors,
555 },
556
557 SwitchJmp => {
558         op_flags     => [ "labeled", "cfopcode", "forking" ],
559         irn_flags    => [ "has_delay_slot" ],
560         state        => "pinned",
561         mode         => "mode_T",
562         reg_req      => { in => [ "gp" ], out => [ ] },
563         attr_type    => "sparc_switch_jmp_attr_t",
564         attr         => "long default_pn, ir_entity *jump_table",
565         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
566 },
567
568 Sll => {
569         irn_flags    => [ "rematerializable" ],
570         mode         => $mode_gp,
571         emit         => '. sll %S0, %R1I, %D0',
572         constructors => \%binop_operand_constructors,
573 },
574
575 Srl => {
576         irn_flags    => [ "rematerializable" ],
577         mode         => $mode_gp,
578         emit         => '. srl %S0, %R1I, %D0',
579         constructors => \%binop_operand_constructors,
580 },
581
582 Sra => {
583         irn_flags    => [ "rematerializable" ],
584         mode         => $mode_gp,
585         emit         => '. sra %S0, %R1I, %D0',
586         constructors => \%binop_operand_constructors,
587 },
588
589 And => {
590         irn_flags    => [ "rematerializable" ],
591         mode         => $mode_gp,
592         emit         => '. and %S0, %R1I, %D0',
593         constructors => \%binop_operand_constructors,
594 },
595
596 AndCCZero => {
597         irn_flags    => [ "rematerializable", "modifies_flags" ],
598         emit         => '. andcc %S0, %R1I, %%g0',
599         mode         => $mode_flags,
600         constructors => \%binopcczero_operand_constructors,
601 },
602
603 AndN => {
604         irn_flags => [ "rematerializable" ],
605         mode      => $mode_gp,
606         emit      => '. andn %S0, %R1I, %D0',
607         constructors => \%binop_operand_constructors,
608 },
609
610 AndNCCZero => {
611         irn_flags    => [ "rematerializable", "modifies_flags" ],
612         emit         => '. andncc %S0, %R1I, %%g0',
613         mode         => $mode_flags,
614         constructors => \%binopcczero_operand_constructors,
615 },
616
617 Or => {
618         irn_flags    => [ "rematerializable" ],
619         mode         => $mode_gp,
620         emit         => '. or %S0, %R1I, %D0',
621         constructors => \%binop_operand_constructors,
622 },
623
624 OrCCZero => {
625         irn_flags    => [ "rematerializable", "modifies_flags" ],
626         emit         => '. orcc %S0, %R1I, %%g0',
627         mode         => $mode_flags,
628         constructors => \%binopcczero_operand_constructors,
629 },
630
631 OrN => {
632         irn_flags => [ "rematerializable" ],
633         mode      => $mode_gp,
634         emit      => '. orn %S0, %R1I, %D0',
635         constructors => \%binop_operand_constructors,
636 },
637
638 OrNCCZero => {
639         irn_flags    => [ "rematerializable", "modifies_flags" ],
640         emit         => '. orncc %S0, %R1I, %%g0',
641         mode         => $mode_flags,
642         constructors => \%binopcczero_operand_constructors,
643 },
644
645 Xor => {
646         irn_flags    => [ "rematerializable" ],
647         mode         => $mode_gp,
648         emit         => '. xor %S0, %R1I, %D0',
649         constructors => \%binop_operand_constructors,
650 },
651
652 XorCCZero => {
653         irn_flags    => [ "rematerializable", "modifies_flags" ],
654         emit         => '. xorcc %S0, %R1I, %%g0',
655         mode         => $mode_flags,
656         constructors => \%binopcczero_operand_constructors,
657 },
658
659 XNor => {
660         irn_flags => [ "rematerializable" ],
661         mode      => $mode_gp,
662         emit      => '. xnor %S0, %R1I, %D0',
663         constructors => \%binop_operand_constructors,
664 },
665
666 XNorCCZero => {
667         irn_flags    => [ "rematerializable", "modifies_flags" ],
668         emit         => '. xnorcc %S0, %R1I, %%g0',
669         mode         => $mode_flags,
670         constructors => \%binopcczero_operand_constructors,
671 },
672
673 Mul => {
674         irn_flags    => [ "rematerializable" ],
675         mode         => $mode_gp,
676         emit         => '. smul %S0, %R1I, %D0',
677         constructors => \%binop_operand_constructors,
678 },
679
680 SMulh => {
681         irn_flags    => [ "rematerializable" ],
682         outs         => [ "low", "high" ],
683         constructors => \%binop_operand_constructors,
684 },
685
686 UMulh => {
687         irn_flags    => [ "rematerializable" ],
688         outs         => [ "low", "high" ],
689         constructors => \%binop_operand_constructors,
690 },
691
692 SDiv => {
693         irn_flags    => [ "rematerializable", "has_delay_slot" ],
694         state        => "exc_pinned",
695         ins          => [ "dividend_high", "dividend_low", "divisor" ],
696         outs         => [ "res", "M" ],
697         constructors => \%div_operand_constructors,
698 },
699
700 UDiv => {
701         irn_flags    => [ "rematerializable", "has_delay_slot" ],
702         state        => "exc_pinned",
703         ins          => [ "dividend_high", "dividend_low", "divisor" ],
704         outs         => [ "res", "M" ],
705         constructors => \%div_operand_constructors,
706 },
707
708 fcmp => {
709         irn_flags => [ "rematerializable", "modifies_fp_flags" ],
710         emit      => '. fcmp%FPM %S0, %S1',
711         attr_type => "sparc_fp_attr_t",
712         attr      => "ir_mode *fp_mode",
713         mode      => $mode_fpflags,
714         constructors => {
715                 s => {
716                         reg_req => { in => [ "fp", "fp" ], out => [ "fpflags" ] },
717                 },
718                 d => {
719                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fpflags" ] },
720                 },
721                 q => {
722                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fpflags" ] },
723                 },
724         },
725 },
726
727 fadd => {
728         op_flags     => [ "commutative" ],
729         irn_flags    => [ "rematerializable" ],
730         emit         => '. fadd%FPM %S0, %S1, %D0',
731         attr_type    => "sparc_fp_attr_t",
732         attr         => "ir_mode *fp_mode",
733         ins          => [ "left", "right" ],
734         constructors => \%float_binop_constructors,
735 },
736
737 fsub => {
738         irn_flags    => [ "rematerializable" ],
739         emit         => '. fsub%FPM %S0, %S1, %D0',
740         attr_type    => "sparc_fp_attr_t",
741         attr         => "ir_mode *fp_mode",
742         ins          => [ "left", "right" ],
743         constructors => \%float_binop_constructors,
744 },
745
746 fmul => {
747         irn_flags    => [ "rematerializable" ],
748         op_flags     => [ "commutative" ],
749         emit         =>'. fmul%FPM %S0, %S1, %D0',
750         attr_type    => "sparc_fp_attr_t",
751         attr         => "ir_mode *fp_mode",
752         ins          => [ "left", "right" ],
753         constructors => \%float_binop_constructors,
754 },
755
756 fdiv => {
757         irn_flags    => [ "rematerializable" ],
758         emit         => '. fdiv%FPM %S0, %S1, %D0',
759         attr_type    => "sparc_fp_attr_t",
760         attr         => "ir_mode *fp_mode",
761         ins          => [ "left", "right" ],
762         outs         => [ "res", "M" ],
763         constructors => {
764                 s => {
765                         reg_req => { in => [ "fp", "fp" ], out => [ "fp", "none" ] },
766                 },
767                 d => {
768                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2", "none" ] },
769                 },
770                 q => {
771                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4", "none" ] },
772                 }
773         },
774 },
775
776 fneg => {
777         irn_flags => [ "rematerializable" ],
778         reg_req   => { in => [ "fp" ], out => [ "fp" ] },
779         # note that we only need the first register even for wide-values
780         emit      => '. fnegs %S0, %D0',
781         attr_type => "sparc_fp_attr_t",
782         attr      => "ir_mode *fp_mode",
783         ins          => [ "val" ],
784         constructors => \%float_unop_constructors,
785 },
786
787 "fabs" => {
788         irn_flags    => [ "rematerializable" ],
789         # note that we only need the first register even for wide-values
790         emit         => '. fabs %S0, %D0',
791         attr_type    => "sparc_fp_attr_t",
792         attr         => "ir_mode *fp_mode",
793         ins          => [ "val" ],
794         constructors => \%float_unop_constructors,
795 },
796
797 fftof => {
798         irn_flags => [ "rematerializable" ],
799         emit      => '. f%FCONVS%.to%FCONVD %S0, %D0',
800         attr_type => "sparc_fp_conv_attr_t",
801         attr      => "ir_mode *src_mode, ir_mode *dest_mode",
802         constructors => {
803                 s_d => {
804                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
805                         mode    => $mode_fp2,
806                 },
807                 s_q => {
808                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
809                         mode    => $mode_fp4,
810                 },
811                 d_s => {
812                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
813                         mode    => $mode_fp,
814                 },
815                 d_q => {
816                         reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|4" ] },
817                         mode    => $mode_fp4,
818                 },
819                 q_s => {
820                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
821                         mode    => $mode_fp,
822                 },
823                 q_d => {
824                         reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|2" ] },
825                         mode    => $mode_fp2,
826                 },
827         },
828 },
829
830 fitof => {
831         irn_flags => [ "rematerializable" ],
832         emit      => '. fito%FPM %S0, %D0',
833         attr_type => "sparc_fp_attr_t",
834         attr      => "ir_mode *fp_mode",
835         constructors => {
836                 s => {
837                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
838                         mode    => $mode_fp,
839                 },
840                 d => {
841                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
842                         mode    => $mode_fp2,
843                 },
844                 q => {
845                         reg_req => { in => [ "fp" ], out => [ "fp:a|4" ] },
846                         mode    => $mode_fp4,
847                 },
848         },
849 },
850
851 fftoi => {
852         irn_flags => [ "rematerializable" ],
853         emit      => '. f%FPM%.toi %S0, %D0',
854         attr_type => "sparc_fp_attr_t",
855         attr      => "ir_mode *fp_mode",
856         mode      => $mode_gp,
857         constructors => {
858                 s => {
859                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
860                 },
861                 d => {
862                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
863                 },
864                 q => {
865                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
866                 },
867         },
868 },
869
870 Ldf => {
871         op_flags  => [ "labeled" ],
872         state     => "exc_pinned",
873         constructors => {
874                 s => {
875                         reg_req => { in => [ "gp", "none" ], out => [ "fp", "none" ] },
876                 },
877                 d => {
878                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|2", "none" ] },
879                 },
880                 q => {
881                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|4", "none" ] },
882                 },
883         },
884         ins       => [ "ptr", "mem" ],
885         outs      => [ "res", "M" ],
886         attr_type => "sparc_load_store_attr_t",
887         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
888         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
889         emit      => '. ld%FLSM [%S0%O1], %D0'
890 },
891
892 Stf => {
893         op_flags  => [ "labeled" ],
894         state     => "exc_pinned",
895         constructors => {
896                 s => {
897                         reg_req => { in => [ "fp",     "gp", "none" ], out => [ "none" ] },
898                 },
899                 d => {
900                         reg_req => { in => [ "fp:a|2", "gp", "none" ], out => [ "none" ] },
901                 },
902                 q => {
903                         reg_req => { in => [ "fp:a|4", "gp", "none" ], out => [ "none" ] },
904                 },
905         },
906         ins       => [ "val", "ptr", "mem" ],
907         outs      => [ "M" ],
908         attr_type => "sparc_load_store_attr_t",
909         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
910         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
911         emit      => '. st%FLSM %S0, [%S1%O2]',
912         mode      => 'mode_M',
913 },
914
915 ); # end of %nodes