4de1ed0285f7e5ad0ab79b0fe562e68b8d8b1dcf
[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
125 %init_attr = (
126         sparc_attr_t             => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
127         sparc_load_store_attr_t  => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
128         sparc_jmp_cond_attr_t    => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);",
129         sparc_switch_jmp_attr_t  => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
130                                     "\tinit_sparc_switch_jmp_attributes(res, default_pn, jump_table);\n",
131         sparc_fp_attr_t          => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);\n".
132                                     "\tinit_sparc_fp_attributes(res, fp_mode);\n",
133         sparc_fp_conv_attr_t     => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, exec_units, n_res);".
134                                     "\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
135 );
136
137 %compare_attr = (
138         sparc_attr_t            => "cmp_attr_sparc",
139         sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
140         sparc_jmp_cond_attr_t   => "cmp_attr_sparc_jmp_cond",
141         sparc_switch_jmp_attr_t => "cmp_attr_sparc_switch_jmp",
142         sparc_fp_attr_t         => "cmp_attr_sparc_fp",
143         sparc_fp_conv_attr_t    => "cmp_attr_sparc_fp_conv",
144 );
145
146 %custom_irn_flags = (
147         modifies_flags    => "(arch_irn_flags_t)sparc_arch_irn_flag_modifies_flags",
148         modifies_fp_flags => "(arch_irn_flags_t)sparc_arch_irn_flag_modifies_fp_flags",
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 },
288
289 AddX_t => {
290         ins       => [ "left", "right", "flags_input" ],
291         attr_type => "",
292 },
293
294 Sub => {
295         irn_flags    => [ "rematerializable" ],
296         mode         => $mode_gp,
297         emit         => '. sub %S0, %R1I, %D0',
298         constructors => \%binop_operand_constructors,
299 },
300
301 SubCC => {
302         irn_flags    => [ "rematerializable" ],
303         emit         => '. subcc %S0, %R1I, %D0',
304         outs         => [ "res", "flags" ],
305         constructors => \%binopcc_operand_constructors,
306 },
307
308 SubX => {
309         # Not rematerializable (see AddX)
310         emit         => '. subx %S0, %R1I, %D0',
311         constructors => \%binopx_operand_constructors,
312         mode         => $mode_gp,
313 },
314
315 SubCC_t => {
316         ins       => [ "left", "right" ],
317         outs      => [ "res", "flags" ],
318         attr_type => "",
319 },
320
321 SubX_t => {
322         ins       => [ "left", "right", "flags_input" ],
323         attr_type => "",
324 },
325
326 # Load / Store
327 Ld => {
328         op_flags  => [ "labeled" ],
329         state     => "exc_pinned",
330         constructors => {
331                 imm => {
332                         reg_req    => { in => [ "gp", "none" ], out => [ "gp", "none" ] },
333                         ins        => [ "ptr", "mem" ],
334                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
335                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
336                 },
337                 reg => {
338                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] },
339                         ins        => [ "ptr", "ptr2", "mem" ],
340                         attr       => "ir_mode *ls_mode",
341                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
342                 },
343         },
344         ins       => [ "ptr", "mem" ],
345         outs      => [ "res", "M" ],
346         attr_type => "sparc_load_store_attr_t",
347         emit      => '. ld%LM [%S0%O1], %D0'
348 },
349
350 SetHi => {
351         irn_flags  => [ "rematerializable" ],
352         outs       => [ "res" ],
353         mode       => $mode_gp,
354         reg_req    => { in => [], out => [ "gp" ] },
355         attr       => "ir_entity *entity, int32_t immediate_value",
356         custominit => "sparc_set_attr_imm(res, entity, immediate_value);",
357         emit       => '. sethi %HIM, %D0'
358 },
359
360 St => {
361         op_flags  => [ "labeled" ],
362         mode      => "mode_M",
363         state     => "exc_pinned",
364         constructors => {
365                 imm => {
366                         reg_req    => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
367                         ins        => [ "val", "ptr", "mem" ],
368                         attr       => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
369                         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
370                 },
371                 reg => {
372                         reg_req    => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] },
373                         ins        => [ "val", "ptr", "ptr2", "mem" ],
374                         attr       => "ir_mode *ls_mode",
375                         custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);",
376                 },
377         },
378         ins       => [ "val", "ptr", "mem" ],
379         outs      => [ "M" ],
380         attr_type => "sparc_load_store_attr_t",
381         emit      => '. st%SM %S0, [%S1%O2]'
382 },
383
384 Save => {
385         emit      => '. save %S0, %R1I, %D0',
386         outs      => [ "stack" ],
387         ins       => [ "stack" ],
388         constructors => {
389                 imm => {
390                         attr       => "ir_entity *immediate_entity, int32_t immediate_value",
391                         custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
392                         reg_req    => { in => [ "sp" ], out => [ "sp:I|S" ] },
393                         ins        => [ "stack" ],
394                 },
395                 reg => {
396                         reg_req    => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
397                         ins        => [ "stack", "increment" ],
398                 }
399         },
400         mode => $mode_gp,
401 },
402
403 Restore => {
404         emit => '. restore %S0, %R1I, %D0',
405         outs => [ "stack" ],
406         ins  => [ "stack" ],
407         constructors => {
408                 imm => {
409                         attr       => "ir_entity *immediate_entity, int32_t immediate_value",
410                         custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
411                         reg_req    => { in => [ "sp" ], out => [ "sp:I|S" ] },
412                         ins        => [ "stack" ],
413                 },
414                 reg => {
415                         reg_req    => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
416                         ins        => [ "stack", "increment" ],
417                 }
418         },
419         mode => $mode_gp,
420 },
421
422 RestoreZero => {
423         emit => '. restore',
424         reg_req => { in => [ "frame_pointer" ], out => [ "sp:I|S" ] },
425         ins     => [ "frame_pointer" ],
426         outs    => [ "stack" ],
427         mode    => $mode_gp,
428 },
429
430 SubSP => {
431         reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "gp", "none" ] },
432         ins       => [ "stack", "size", "mem" ],
433         outs      => [ "stack", "addr", "M" ],
434         emit      => ". sub %S0, %S1, %D0\n",
435 },
436
437 AddSP => {
438         reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "none" ] },
439         ins       => [ "stack", "size", "mem" ],
440         outs      => [ "stack", "M" ],
441         emit      => ". add %S0, %S1, %D0\n",
442 },
443
444 FrameAddr => {
445         op_flags   => [ "constlike" ],
446         irn_flags  => [ "rematerializable" ],
447         attr       => "ir_entity *entity, int32_t offset",
448         reg_req    => { in => [ "gp" ], out => [ "gp" ] },
449         ins        => [ "base" ],
450         attr_type  => "sparc_attr_t",
451         custominit => "sparc_set_attr_imm(res, entity, offset);",
452         mode       => $mode_gp,
453 },
454
455 Bicc => {
456         op_flags  => [ "labeled", "cfopcode", "forking" ],
457         state     => "pinned",
458         mode      => "mode_T",
459         attr_type => "sparc_jmp_cond_attr_t",
460         attr      => "ir_relation relation, bool is_unsigned",
461         init_attr => "\tinit_sparc_jmp_cond_attr(res, relation, is_unsigned);",
462         reg_req   => { in => [ "flags" ], out => [ "none", "none" ] },
463         ins       => [ "flags" ],
464         outs      => [ "false", "true" ],
465 },
466
467 fbfcc => {
468         op_flags  => [ "labeled", "cfopcode", "forking" ],
469         state     => "pinned",
470         mode      => "mode_T",
471         attr_type => "sparc_jmp_cond_attr_t",
472         attr      => "ir_relation relation",
473         init_attr => "\tinit_sparc_jmp_cond_attr(res, relation, false);",
474         reg_req   => { in => [ "fpflags" ], out => [ "none", "none" ] },
475         ins       => [ "flags" ],
476         outs      => [ "false", "true" ],
477 },
478
479 Ba => {
480         state     => "pinned",
481         op_flags  => [ "cfopcode" ],
482         irn_flags => [ "simple_jump" ],
483         reg_req   => { out => [ "none" ] },
484         mode      => "mode_X",
485 },
486
487 Start => {
488         state     => "pinned",
489         out_arity => "variable",
490         ins       => [],
491 },
492
493 # This is a JumpLink instruction, but with the addition that you can add custom
494 # register constraints to model your calling conventions
495 Return => {
496         state     => "pinned",
497         op_flags  => [ "cfopcode" ],
498         arity     => "variable",
499         mode      => "mode_X",
500         constructors => {
501                 imm => {
502                         attr       => "ir_entity *entity, int32_t offset",
503                         custominit => "\tsparc_set_attr_imm(res, entity, offset);",
504                         arity     => "variable",
505                         reg_req   => { out => [ "none" ] },
506                 },
507                 reg => {
508                         arity     => "variable",
509                         reg_req   => { out => [ "none" ] },
510                 }
511         },
512 },
513
514 Call => {
515         irn_flags => [ "modifies_flags", "modifies_fp_flags" ],
516         state     => "exc_pinned",
517         arity     => "variable",
518         out_arity => "variable",
519         constructors => {
520                 imm => {
521                         attr       => "ir_entity *entity, int32_t offset, bool aggregate_return",
522                         custominit => "\tsparc_set_attr_imm(res, entity, offset);".
523                                       "\tif (aggregate_return) arch_irn_add_flags(res, sparc_arch_irn_flag_aggregate_return);",
524                         arity     => "variable",
525                         out_arity => "variable",
526                 },
527                 reg => {
528                         attr       => "bool aggregate_return",
529                         arity      => "variable",
530                         out_arity  => "variable",
531                         custominit => "\tif (aggregate_return) arch_irn_add_flags(res, sparc_arch_irn_flag_aggregate_return);",
532                 }
533         },
534 },
535
536 Cmp => {  # aka SubccZero
537         irn_flags    => [ "rematerializable", "modifies_flags" ],
538         emit         => '. cmp %S0, %R1I',
539         mode         => $mode_flags,
540         constructors => \%binopcczero_operand_constructors,
541 },
542
543 SwitchJmp => {
544         op_flags     => [ "labeled", "cfopcode", "forking" ],
545         state        => "pinned",
546         mode         => "mode_T",
547         reg_req      => { in => [ "gp" ], out => [ ] },
548         attr_type    => "sparc_switch_jmp_attr_t",
549         attr         => "long default_pn, ir_entity *jump_table",
550         init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
551 },
552
553 Sll => {
554         irn_flags    => [ "rematerializable" ],
555         mode         => $mode_gp,
556         emit         => '. sll %S0, %R1I, %D0',
557         constructors => \%binop_operand_constructors,
558 },
559
560 Srl => {
561         irn_flags    => [ "rematerializable" ],
562         mode         => $mode_gp,
563         emit         => '. srl %S0, %R1I, %D0',
564         constructors => \%binop_operand_constructors,
565 },
566
567 Sra => {
568         irn_flags    => [ "rematerializable" ],
569         mode         => $mode_gp,
570         emit         => '. sra %S0, %R1I, %D0',
571         constructors => \%binop_operand_constructors,
572 },
573
574 And => {
575         irn_flags    => [ "rematerializable" ],
576         mode         => $mode_gp,
577         emit         => '. and %S0, %R1I, %D0',
578         constructors => \%binop_operand_constructors,
579 },
580
581 AndCCZero => {
582         irn_flags    => [ "rematerializable", "modifies_flags" ],
583         emit         => '. andcc %S0, %R1I, %%g0',
584         mode         => $mode_flags,
585         constructors => \%binopcczero_operand_constructors,
586 },
587
588 AndN => {
589         irn_flags => [ "rematerializable" ],
590         mode      => $mode_gp,
591         emit      => '. andn %S0, %R1I, %D0',
592         constructors => \%binop_operand_constructors,
593 },
594
595 AndNCCZero => {
596         irn_flags    => [ "rematerializable", "modifies_flags" ],
597         emit         => '. andncc %S0, %R1I, %%g0',
598         mode         => $mode_flags,
599         constructors => \%binopcczero_operand_constructors,
600 },
601
602 Or => {
603         irn_flags    => [ "rematerializable" ],
604         mode         => $mode_gp,
605         emit         => '. or %S0, %R1I, %D0',
606         constructors => \%binop_operand_constructors,
607 },
608
609 OrCCZero => {
610         irn_flags    => [ "rematerializable", "modifies_flags" ],
611         emit         => '. orcc %S0, %R1I, %%g0',
612         mode         => $mode_flags,
613         constructors => \%binopcczero_operand_constructors,
614 },
615
616 OrN => {
617         irn_flags => [ "rematerializable" ],
618         mode      => $mode_gp,
619         emit      => '. orn %S0, %R1I, %D0',
620         constructors => \%binop_operand_constructors,
621 },
622
623 OrNCCZero => {
624         irn_flags    => [ "rematerializable", "modifies_flags" ],
625         emit         => '. orncc %S0, %R1I, %%g0',
626         mode         => $mode_flags,
627         constructors => \%binopcczero_operand_constructors,
628 },
629
630 Xor => {
631         irn_flags    => [ "rematerializable" ],
632         mode         => $mode_gp,
633         emit         => '. xor %S0, %R1I, %D0',
634         constructors => \%binop_operand_constructors,
635 },
636
637 XorCCZero => {
638         irn_flags    => [ "rematerializable", "modifies_flags" ],
639         emit         => '. xorcc %S0, %R1I, %%g0',
640         mode         => $mode_flags,
641         constructors => \%binopcczero_operand_constructors,
642 },
643
644 XNor => {
645         irn_flags => [ "rematerializable" ],
646         mode      => $mode_gp,
647         emit      => '. xnor %S0, %R1I, %D0',
648         constructors => \%binop_operand_constructors,
649 },
650
651 XNorCCZero => {
652         irn_flags    => [ "rematerializable", "modifies_flags" ],
653         emit         => '. xnorcc %S0, %R1I, %%g0',
654         mode         => $mode_flags,
655         constructors => \%binopcczero_operand_constructors,
656 },
657
658 Mul => {
659         irn_flags    => [ "rematerializable" ],
660         mode         => $mode_gp,
661         emit         => '. smul %S0, %R1I, %D0',
662         constructors => \%binop_operand_constructors,
663 },
664
665 Mulh => {
666         irn_flags    => [ "rematerializable" ],
667         outs         => [ "low", "high" ],
668         constructors => \%binop_operand_constructors,
669 },
670
671 SDiv => {
672         irn_flags    => [ "rematerializable" ],
673         state        => "exc_pinned",
674         ins          => [ "dividend_high", "dividend_low", "divisor" ],
675         outs         => [ "res", "M" ],
676         constructors => \%div_operand_constructors,
677 },
678
679 UDiv => {
680         irn_flags    => [ "rematerializable" ],
681         state        => "exc_pinned",
682         ins          => [ "dividend_high", "dividend_low", "divisor" ],
683         outs         => [ "res", "M" ],
684         constructors => \%div_operand_constructors,
685 },
686
687 fcmp => {
688         irn_flags => [ "rematerializable", "modifies_fp_flags" ],
689         emit      => '. fcmp%FPM %S0, %S1',
690         attr_type => "sparc_fp_attr_t",
691         attr      => "ir_mode *fp_mode",
692         mode      => $mode_fpflags,
693         constructors => {
694                 s => {
695                         reg_req => { in => [ "fp", "fp" ], out => [ "fpflags" ] },
696                 },
697                 d => {
698                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fpflags" ] },
699                 },
700                 q => {
701                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fpflags" ] },
702                 },
703         },
704 },
705
706 fadd => {
707         op_flags     => [ "commutative" ],
708         irn_flags    => [ "rematerializable" ],
709         emit         => '. fadd%FPM %S0, %S1, %D0',
710         attr_type    => "sparc_fp_attr_t",
711         attr         => "ir_mode *fp_mode",
712         ins          => [ "left", "right" ],
713         constructors => \%float_binop_constructors,
714 },
715
716 fsub => {
717         irn_flags    => [ "rematerializable" ],
718         emit         => '. fsub%FPM %S0, %S1, %D0',
719         attr_type    => "sparc_fp_attr_t",
720         attr         => "ir_mode *fp_mode",
721         ins          => [ "left", "right" ],
722         constructors => \%float_binop_constructors,
723 },
724
725 fmul => {
726         irn_flags    => [ "rematerializable" ],
727         op_flags     => [ "commutative" ],
728         emit         =>'. fmul%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 fdiv => {
736         irn_flags    => [ "rematerializable" ],
737         emit         => '. fdiv%FPM %S0, %S1, %D0',
738         attr_type    => "sparc_fp_attr_t",
739         attr         => "ir_mode *fp_mode",
740         ins          => [ "left", "right" ],
741         outs         => [ "res", "M" ],
742         constructors => {
743                 s => {
744                         reg_req => { in => [ "fp", "fp" ], out => [ "fp", "none" ] },
745                 },
746                 d => {
747                         reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2", "none" ] },
748                 },
749                 q => {
750                         reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4", "none" ] },
751                 }
752         },
753 },
754
755 fneg => {
756         irn_flags => [ "rematerializable" ],
757         reg_req   => { in => [ "fp" ], out => [ "fp" ] },
758         # note that we only need the first register even for wide-values
759         emit      => '. fnegs %S0, %D0',
760         attr_type => "sparc_fp_attr_t",
761         attr      => "ir_mode *fp_mode",
762         ins          => [ "val" ],
763         constructors => \%float_unop_constructors,
764 },
765
766 "fabs" => {
767         irn_flags    => [ "rematerializable" ],
768         # note that we only need the first register even for wide-values
769         emit         => '. fabs %S0, %D0',
770         attr_type    => "sparc_fp_attr_t",
771         attr         => "ir_mode *fp_mode",
772         ins          => [ "val" ],
773         constructors => \%float_unop_constructors,
774 },
775
776 fftof => {
777         irn_flags => [ "rematerializable" ],
778         emit      => '. f%FCONVS%.to%FCONVD %S0, %D0',
779         attr_type => "sparc_fp_conv_attr_t",
780         attr      => "ir_mode *src_mode, ir_mode *dest_mode",
781         constructors => {
782                 s_d => {
783                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
784                         mode    => $mode_fp2,
785                 },
786                 s_q => {
787                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
788                         mode    => $mode_fp4,
789                 },
790                 d_s => {
791                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
792                         mode    => $mode_fp,
793                 },
794                 d_q => {
795                         reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|4" ] },
796                         mode    => $mode_fp4,
797                 },
798                 q_s => {
799                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
800                         mode    => $mode_fp,
801                 },
802                 q_d => {
803                         reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|2" ] },
804                         mode    => $mode_fp2,
805                 },
806         },
807 },
808
809 fitof => {
810         irn_flags => [ "rematerializable" ],
811         emit      => '. fito%FPM %S0, %D0',
812         attr_type => "sparc_fp_attr_t",
813         attr      => "ir_mode *fp_mode",
814         constructors => {
815                 s => {
816                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
817                         mode    => $mode_fp,
818                 },
819                 d => {
820                         reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] },
821                         mode    => $mode_fp2,
822                 },
823                 q => {
824                         reg_req => { in => [ "fp" ], out => [ "fp:a|4" ] },
825                         mode    => $mode_fp4,
826                 },
827         },
828 },
829
830 fftoi => {
831         irn_flags => [ "rematerializable" ],
832         emit      => '. f%FPM%.toi %S0, %D0',
833         attr_type => "sparc_fp_attr_t",
834         attr      => "ir_mode *fp_mode",
835         mode      => $mode_gp,
836         constructors => {
837                 s => {
838                         reg_req => { in => [ "fp" ], out => [ "fp" ] },
839                 },
840                 d => {
841                         reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] },
842                 },
843                 q => {
844                         reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] },
845                 },
846         },
847 },
848
849 Ldf => {
850         op_flags  => [ "labeled" ],
851         state     => "exc_pinned",
852         constructors => {
853                 s => {
854                         reg_req => { in => [ "gp", "none" ], out => [ "fp", "none" ] },
855                 },
856                 d => {
857                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|2", "none" ] },
858                 },
859                 q => {
860                         reg_req => { in => [ "gp", "none" ], out => [ "fp:a|4", "none" ] },
861                 },
862         },
863         ins       => [ "ptr", "mem" ],
864         outs      => [ "res", "M" ],
865         attr_type => "sparc_load_store_attr_t",
866         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
867         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
868         emit      => '. ld%FLSM [%S0%O1], %D0'
869 },
870
871 Stf => {
872         op_flags  => [ "labeled" ],
873         state     => "exc_pinned",
874         constructors => {
875                 s => {
876                         reg_req => { in => [ "fp",     "gp", "none" ], out => [ "none" ] },
877                 },
878                 d => {
879                         reg_req => { in => [ "fp:a|2", "gp", "none" ], out => [ "none" ] },
880                 },
881                 q => {
882                         reg_req => { in => [ "fp:a|4", "gp", "none" ], out => [ "none" ] },
883                 },
884         },
885         ins       => [ "val", "ptr", "mem" ],
886         outs      => [ "M" ],
887         attr_type => "sparc_load_store_attr_t",
888         attr      => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity",
889         custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);",
890         emit      => '. st%FLSM %S0, [%S1%O2]',
891         mode      => 'mode_M',
892 },
893
894 ); # end of %nodes