# Creation: 2006/02/13
-# $Id$
$arch = "sparc";
$mode_fpflags = "mode_Bu";
$mode_fp = "mode_F";
$mode_fp2 = "mode_D";
-$mode_fp4 = "mode_E"; # not correct, we need to register a new mode
+$mode_fp4 = "mode_Q";
# available SPARC registers: 8 globals, 24 window regs (8 ins, 8 outs, 8 locals)
%reg_classes = (
# emit source reg or imm dep. on node's arity
RI => "${arch}_emit_reg_or_imm(node, -1);",
R1I => "${arch}_emit_reg_or_imm(node, 1);",
+ R2I => "${arch}_emit_reg_or_imm(node, 2);",
S0 => "${arch}_emit_source_register(node, 0);",
S1 => "${arch}_emit_source_register(node, 1);",
D0 => "${arch}_emit_dest_register(node, 0);",
+ D1 => "${arch}_emit_dest_register(node, 1);",
HIM => "${arch}_emit_high_immediate(node);",
LM => "${arch}_emit_load_mode(node);",
SM => "${arch}_emit_store_mode(node);",
FCONVD => "${arch}_emit_fp_conv_destination(node);",
O1 => "${arch}_emit_offset(node, 1);",
O2 => "${arch}_emit_offset(node, 2);",
+ S0O1 => "${arch}_emit_source_reg_and_offset(node, 0, 1);",
+ S1O2 => "${arch}_emit_source_reg_and_offset(node, 1, 2);",
);
+$indent_line_func = "sparc_emit_indent()";
$default_attr_type = "sparc_attr_t";
$default_copy_attr = "sparc_copy_attr";
-
%init_attr = (
- sparc_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
- sparc_load_store_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
- sparc_jmp_cond_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);",
- sparc_switch_jmp_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
- "\tinit_sparc_switch_jmp_attributes(res, default_pn, jump_table);\n",
- sparc_fp_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n".
+ sparc_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);",
+ sparc_load_store_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);",
+ sparc_jmp_cond_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);",
+ sparc_switch_jmp_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
+ "\tinit_sparc_switch_jmp_attributes(res, table, jump_table);\n",
+ sparc_fp_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);\n".
"\tinit_sparc_fp_attributes(res, fp_mode);\n",
- sparc_fp_conv_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);".
+ sparc_fp_conv_attr_t => "\tinit_sparc_attributes(res, irn_flags_, in_reqs, n_res);".
"\tinit_sparc_fp_conv_attributes(res, src_mode, dest_mode);\n",
);
%compare_attr = (
sparc_attr_t => "cmp_attr_sparc",
- sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
- sparc_jmp_cond_attr_t => "cmp_attr_sparc_jmp_cond",
- sparc_switch_jmp_attr_t => "cmp_attr_sparc_switch_jmp",
sparc_fp_attr_t => "cmp_attr_sparc_fp",
sparc_fp_conv_attr_t => "cmp_attr_sparc_fp_conv",
+ sparc_jmp_cond_attr_t => "cmp_attr_sparc_jmp_cond",
+ sparc_load_store_attr_t => "cmp_attr_sparc_load_store",
+ sparc_switch_jmp_attr_t => "cmp_attr_sparc",
);
%custom_irn_flags = (
modifies_flags => "(arch_irn_flags_t)sparc_arch_irn_flag_modifies_flags",
modifies_fp_flags => "(arch_irn_flags_t)sparc_arch_irn_flag_modifies_fp_flags",
+ has_delay_slot => "(arch_irn_flags_t)sparc_arch_irn_flag_has_delay_slot",
);
my %cmp_operand_constructors = (
},
);
+my %binopcc_operand_constructors = (
+ imm => {
+ attr => "ir_entity *immediate_entity, int32_t immediate_value",
+ custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
+ reg_req => { in => [ "gp" ], out => [ "gp", "flags" ] },
+ ins => [ "left" ],
+ },
+ reg => {
+ reg_req => { in => [ "gp", "gp" ], out => [ "gp", "flags" ] },
+ ins => [ "left", "right" ],
+ },
+);
+
+my %binopx_operand_constructors = (
+ imm => {
+ attr => "ir_entity *immediate_entity, int32_t immediate_value",
+ custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
+ reg_req => { in => [ "gp", "flags" ], out => [ "gp" ] },
+ ins => [ "left", "carry" ],
+ },
+ reg => {
+ reg_req => { in => [ "gp", "gp", "flags" ], out => [ "gp" ] },
+ ins => [ "left", "right", "carry" ],
+ },
+);
+
+
my %binopcczero_operand_constructors = (
imm => {
attr => "ir_entity *immediate_entity, int32_t immediate_value",
constructors => \%binop_operand_constructors,
},
+AddCC => {
+ irn_flags => [ "rematerializable", "modifies_flags" ],
+ emit => '. addcc %S0, %R1I, %D0',
+ outs => [ "res", "flags" ],
+ constructors => \%binopcc_operand_constructors,
+},
+
+AddCCZero => {
+ irn_flags => [ "rematerializable", "modifies_flags" ],
+ emit => '. addcc %S0, %R1I, %%g0',
+ mode => $mode_flags,
+ constructors => \%binopcczero_operand_constructors,
+},
+
+AddX => {
+ # At the moment not rematerializable because of assert in beflags.c/
+ # (it claims that spiller can't rematerialize flag stuff correctly)
+ #irn_flags => [ "rematerializable" ],
+ emit => '. addx %S0, %R1I, %D0',
+ constructors => \%binopx_operand_constructors,
+ mode => $mode_gp,
+},
+
+AddCC_t => {
+ ins => [ "left", "right" ],
+ outs => [ "res", "flags" ],
+ attr_type => "",
+ dump_func => "NULL",
+},
+
+AddX_t => {
+ ins => [ "left", "right", "flags_input" ],
+ attr_type => "",
+ dump_func => "NULL",
+},
+
Sub => {
irn_flags => [ "rematerializable" ],
mode => $mode_gp,
constructors => \%binop_operand_constructors,
},
+SubCC => {
+ irn_flags => [ "rematerializable", "modifies_flags" ],
+ emit => '. subcc %S0, %R1I, %D0',
+ outs => [ "res", "flags" ],
+ constructors => \%binopcc_operand_constructors,
+},
+
+SubCCZero => {
+ irn_flags => [ "rematerializable", "modifies_flags" ],
+ emit => '. subcc %S0, %R1I, %%g0',
+ mode => $mode_flags,
+ constructors => \%binopcczero_operand_constructors,
+},
+
+SubX => {
+ # Not rematerializable (see AddX)
+ emit => '. subx %S0, %R1I, %D0',
+ constructors => \%binopx_operand_constructors,
+ mode => $mode_gp,
+},
+
+SubCC_t => {
+ ins => [ "left", "right" ],
+ outs => [ "res", "flags" ],
+ attr_type => "",
+ dump_func => "NULL",
+},
+
+SubX_t => {
+ ins => [ "left", "right", "flags_input" ],
+ attr_type => "",
+ dump_func => "NULL",
+},
+
# Load / Store
Ld => {
- op_flags => [ "labeled", "fragile" ],
+ op_flags => [ "labeled" ],
state => "exc_pinned",
constructors => {
imm => {
ins => [ "ptr", "mem" ],
outs => [ "res", "M" ],
attr_type => "sparc_load_store_attr_t",
- emit => '. ld%LM [%S0%O1], %D0'
+ emit => '. ld%LM [%S0O1], %D0'
},
SetHi => {
},
St => {
- op_flags => [ "labeled", "fragile" ],
+ op_flags => [ "labeled" ],
mode => "mode_M",
state => "exc_pinned",
constructors => {
ins => [ "val", "ptr", "mem" ],
outs => [ "M" ],
attr_type => "sparc_load_store_attr_t",
- emit => '. st%SM %S0, [%S1%O2]'
+ emit => '. st%SM %S0, [%S1O2]'
},
Save => {
},
Restore => {
- emit => '. restore %S0, %R1I, %D0',
- outs => [ "stack" ],
- ins => [ "stack" ],
+ outs => [ "stack", "res" ],
constructors => {
imm => {
attr => "ir_entity *immediate_entity, int32_t immediate_value",
custominit => "sparc_set_attr_imm(res, immediate_entity, immediate_value);",
- reg_req => { in => [ "sp" ], out => [ "sp:I|S" ] },
- ins => [ "stack" ],
+ reg_req => { in => [ "frame_pointer", "gp" ], out => [ "sp:I|S", "gp" ] },
+ ins => [ "frame_pointer", "left" ],
},
reg => {
- reg_req => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
- ins => [ "stack", "increment" ],
+ reg_req => { in => [ "frame_pointer", "gp", "gp" ], out => [ "sp:I|S", "gp" ] },
+ ins => [ "frame_pointer", "left", "right" ],
}
},
- mode => $mode_gp,
},
RestoreZero => {
- emit => '. restore',
- reg_req => { out => [ "sp:I|S" ] },
+ reg_req => { in => [ "frame_pointer" ], out => [ "sp:I|S" ] },
+ ins => [ "frame_pointer" ],
outs => [ "stack" ],
- ins => [ ],
+ emit => '. restore',
mode => $mode_gp,
},
SubSP => {
- reg_req => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "gp", "none" ] },
- ins => [ "stack", "size", "mem" ],
- outs => [ "stack", "addr", "M" ],
- emit => ". sub %S0, %S1, %D0\n",
+ reg_req => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
+ ins => [ "stack", "size" ],
+ outs => [ "stack" ],
+ emit => ". sub %S0, %S1, %D0\n",
+ mode => $mode_gp,
},
AddSP => {
- reg_req => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "none" ] },
- ins => [ "stack", "size", "mem" ],
- outs => [ "stack", "M" ],
- emit => ". add %S0, %S1, %D0\n",
+ reg_req => { in => [ "sp", "gp" ], out => [ "sp:I|S" ] },
+ ins => [ "stack", "size" ],
+ outs => [ "stack" ],
+ emit => ". add %S0, %S1, %D0\n",
+ mode => $mode_gp,
},
FrameAddr => {
Bicc => {
op_flags => [ "labeled", "cfopcode", "forking" ],
+ irn_flags => [ "has_delay_slot" ],
state => "pinned",
mode => "mode_T",
attr_type => "sparc_jmp_cond_attr_t",
attr => "ir_relation relation, bool is_unsigned",
init_attr => "\tinit_sparc_jmp_cond_attr(res, relation, is_unsigned);",
reg_req => { in => [ "flags" ], out => [ "none", "none" ] },
+ ins => [ "flags" ],
+ outs => [ "false", "true" ],
},
fbfcc => {
op_flags => [ "labeled", "cfopcode", "forking" ],
+ irn_flags => [ "has_delay_slot" ],
state => "pinned",
mode => "mode_T",
attr_type => "sparc_jmp_cond_attr_t",
attr => "ir_relation relation",
init_attr => "\tinit_sparc_jmp_cond_attr(res, relation, false);",
reg_req => { in => [ "fpflags" ], out => [ "none", "none" ] },
+ ins => [ "flags" ],
+ outs => [ "false", "true" ],
},
Ba => {
+ # Note: has_delay_slot depends on wether it is a fallthrough or not, so we
+ # have special code for this in sparc_emitter
state => "pinned",
op_flags => [ "cfopcode" ],
irn_flags => [ "simple_jump" ],
mode => "mode_X",
},
-# This is a JumpLink instruction, but with the addition that you can add custom
+Start => {
+ state => "pinned",
+ out_arity => "variable",
+ ins => [],
+},
+
+# This is a Jump instruction, but with the addition that you can add custom
# register constraints to model your calling conventions
Return => {
+ state => "pinned",
+ op_flags => [ "cfopcode" ],
+ irn_flags => [ "has_delay_slot" ],
arity => "variable",
- out_arity => "variable",
+ mode => "mode_X",
constructors => {
imm => {
attr => "ir_entity *entity, int32_t offset",
custominit => "\tsparc_set_attr_imm(res, entity, offset);",
arity => "variable",
- out_arity => "variable",
+ reg_req => { out => [ "none" ] },
},
reg => {
arity => "variable",
- out_arity => "variable",
+ reg_req => { out => [ "none" ] },
}
},
},
+# This is a JumpLink instruction, but with the addition that you can add custom
+# register constraints to model your calling conventions
Call => {
- irn_flags => [ "modifies_flags", "modifies_fp_flags" ],
+ irn_flags => [ "modifies_flags", "modifies_fp_flags", "has_delay_slot" ],
state => "exc_pinned",
arity => "variable",
out_arity => "variable",
constructors => {
imm => {
- attr => "ir_entity *entity, int32_t offset",
- custominit => "\tsparc_set_attr_imm(res, entity, offset);",
+ attr => "ir_entity *entity, int32_t offset, bool aggregate_return",
+ custominit => "\tsparc_set_attr_imm(res, entity, offset);".
+ "\tif (aggregate_return) arch_add_irn_flags(res, (arch_irn_flags_t)sparc_arch_irn_flag_aggregate_return);",
arity => "variable",
out_arity => "variable",
},
reg => {
- arity => "variable",
- out_arity => "variable",
+ attr => "bool aggregate_return",
+ arity => "variable",
+ out_arity => "variable",
+ custominit => "\tif (aggregate_return) arch_add_irn_flags(res, (arch_irn_flags_t)sparc_arch_irn_flag_aggregate_return);",
}
},
},
SwitchJmp => {
op_flags => [ "labeled", "cfopcode", "forking" ],
+ irn_flags => [ "has_delay_slot" ],
state => "pinned",
mode => "mode_T",
reg_req => { in => [ "gp" ], out => [ ] },
+ out_arity => "variable",
attr_type => "sparc_switch_jmp_attr_t",
- attr => "long default_pn, ir_entity *jump_table",
- init_attr => "info->out_infos = NULL;", # XXX ugly hack for out requirements
+ attr => "const ir_switch_table *table, ir_entity *jump_table",
},
Sll => {
constructors => \%binop_operand_constructors,
},
-Mulh => {
+MulCCZero => {
+ irn_flags => [ "rematerializable", "modifies_flags" ],
+ emit => '. smulcc %S0, %R1I, %%g0',
+ mode => $mode_flags,
+ constructors => \%binopcczero_operand_constructors,
+},
+
+SMulh => {
irn_flags => [ "rematerializable" ],
outs => [ "low", "high" ],
constructors => \%binop_operand_constructors,
},
-SDiv => {
+UMulh => {
irn_flags => [ "rematerializable" ],
+ outs => [ "low", "high" ],
+ constructors => \%binop_operand_constructors,
+},
+
+SDiv => {
+ irn_flags => [ "rematerializable", "has_delay_slot" ],
state => "exc_pinned",
ins => [ "dividend_high", "dividend_low", "divisor" ],
outs => [ "res", "M" ],
},
UDiv => {
- irn_flags => [ "rematerializable" ],
+ irn_flags => [ "rematerializable", "has_delay_slot" ],
state => "exc_pinned",
ins => [ "dividend_high", "dividend_low", "divisor" ],
outs => [ "res", "M" ],
irn_flags => [ "rematerializable" ],
reg_req => { in => [ "fp" ], out => [ "fp" ] },
# note that we only need the first register even for wide-values
- emit => '. fneg %S0, %D0',
+ emit => '. fnegs %S0, %D0',
attr_type => "sparc_fp_attr_t",
attr => "ir_mode *fp_mode",
ins => [ "val" ],
},
Ldf => {
- op_flags => [ "labeled", "fragile" ],
+ op_flags => [ "labeled" ],
state => "exc_pinned",
constructors => {
s => {
},
Stf => {
- op_flags => [ "labeled", "fragile" ],
+ op_flags => [ "labeled" ],
state => "exc_pinned",
constructors => {
s => {