X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fsparc%2Fsparc_spec.pl;h=484cf0290e1c18e94b915e7b800fc9cf58599f4c;hb=b5092879c450022efcb43edac2a662cb84fa0ae4;hp=fe388433f9c4e9c1649e97fbb87aeda9fb1c2b36;hpb=efa9475a9a5cc691ca4052eaaf3eb727d47b98b9;p=libfirm diff --git a/ir/be/sparc/sparc_spec.pl b/ir/be/sparc/sparc_spec.pl index fe388433f..484cf0290 100644 --- a/ir/be/sparc/sparc_spec.pl +++ b/ir/be/sparc/sparc_spec.pl @@ -114,22 +114,10 @@ $state = 32; # register represents a state %emit_templates = ( # 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, 0);", - R2I => "${arch}_emit_reg_or_imm(node, 1);", - R3I => "${arch}_emit_reg_or_imm(node, 2);", - S1 => "${arch}_emit_source_register(node, 0);", - S2 => "${arch}_emit_source_register(node, 1);", - S3 => "${arch}_emit_source_register(node, 2);", - S4 => "${arch}_emit_source_register(node, 3);", - S5 => "${arch}_emit_source_register(node, 4);", - S6 => "${arch}_emit_source_register(node, 5);", - D1 => "${arch}_emit_dest_register(node, 0);", - D2 => "${arch}_emit_dest_register(node, 1);", - D3 => "${arch}_emit_dest_register(node, 2);", - D4 => "${arch}_emit_dest_register(node, 3);", - D5 => "${arch}_emit_dest_register(node, 4);", - D6 => "${arch}_emit_dest_register(node, 5);", - IM => "${arch}_emit_immediate(node);", + R1I => "${arch}_emit_reg_or_imm(node, 1);", + S0 => "${arch}_emit_source_register(node, 0);", + S1 => "${arch}_emit_source_register(node, 1);", + D0 => "${arch}_emit_dest_register(node, 0);", HIM => "${arch}_emit_high_immediate(node);", LM => "${arch}_emit_load_mode(node);", SM => "${arch}_emit_store_mode(node);", @@ -137,7 +125,8 @@ $state = 32; # register represents a state FPM => "${arch}_emit_fp_mode_suffix(node);", FCONVS => "${arch}_emit_fp_conv_source(node);", FCONVD => "${arch}_emit_fp_conv_destination(node);", - O => "${arch}_emit_offset(node);", + O1 => "${arch}_emit_offset(node, 1);", + O2 => "${arch}_emit_offset(node, 2);", ); $default_attr_type = "sparc_attr_t"; @@ -146,10 +135,10 @@ $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);\n". - "\tinit_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity);", + 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_jmp_switch_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_save_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);", sparc_fp_attr_t => "\tinit_sparc_attributes(res, flags, in_reqs, exec_units, n_res);\n". "\tinit_sparc_fp_attributes(res, fp_mode);\n", @@ -161,7 +150,7 @@ $default_copy_attr = "sparc_copy_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_jmp_switch_attr_t => "cmp_attr_sparc_jmp_switch", + sparc_switch_jmp_attr_t => "cmp_attr_sparc_switch_jmp", sparc_save_attr_t => "cmp_attr_sparc_save", sparc_fp_attr_t => "cmp_attr_sparc_fp", sparc_fp_conv_attr_t => "cmp_attr_sparc_fp_conv", @@ -188,44 +177,54 @@ my %cmp_operand_constructors = ( }, ); -my %unop_operand_constructors = ( +my %binop_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 => [], out => [ "gp" ] }, + reg_req => { in => [ "gp" ], out => [ "gp" ] }, + ins => [ "left" ], }, reg => { - reg_req => { in => [ "gp" ], out => [ "gp" ] }, + reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, + ins => [ "left", "right" ], }, ); -my %binop_operand_constructors = ( +my %binopcczero_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" ] }, + reg_req => { in => [ "gp" ], out => [ "flags" ] }, ins => [ "left" ], }, reg => { - reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, + reg_req => { in => [ "gp", "gp" ], out => [ "flags" ] }, ins => [ "left", "right" ], }, ); +my %div_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", "gp" ], out => [ "gp" ] }, + }, + reg => { + reg_req => { in => [ "gp", "gp", "gp" ], out => [ "gp" ] }, + }, +); + my %float_binop_constructors = ( s => { reg_req => { in => [ "fp", "fp" ], out => [ "fp" ] }, - ins => [ "left", "right" ], mode => $mode_fp, }, d => { reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2" ] }, - ins => [ "left", "right" ], mode => $mode_fp2, }, q => { reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4" ] }, - ins => [ "left", "right" ], mode => $mode_fp4, } ); @@ -233,17 +232,14 @@ my %float_binop_constructors = ( my %float_unop_constructors = ( s => { reg_req => { in => [ "fp" ], out => [ "fp" ] }, - ins => [ "left", "right" ], mode => $mode_fp, }, d => { reg_req => { in => [ "fp:a|2" ], out => [ "fp:a|2" ] }, - ins => [ "left", "right" ], mode => $mode_fp2, }, q => { reg_req => { in => [ "fp:a|4" ], out => [ "fp:a|4" ] }, - ins => [ "left", "right" ], mode => $mode_fp4, } ); @@ -253,14 +249,14 @@ my %float_unop_constructors = ( Add => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. add %S1, %R2I, %D1', + emit => '. add %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, Sub => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. sub %S1, %R2I, %D1', + emit => '. sub %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, @@ -270,18 +266,23 @@ Ld => { op_flags => [ "labeled", "fragile" ], state => "exc_pinned", constructors => { - "" => { - reg_req => { in => [ "gp", "none" ], out => [ "gp", "none" ] }, + imm => { + reg_req => { in => [ "gp", "none" ], out => [ "gp", "none" ] }, + ins => [ "ptr", "mem" ], + attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity", + custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);", }, - d => { - reg_req => { in => [ "gp", "none" ], out => [ "gp:a|2", "none" ] }, + reg => { + reg_req => { in => [ "gp", "gp", "none" ], out => [ "gp", "none" ] }, + ins => [ "ptr", "ptr2", "mem" ], + attr => "ir_mode *ls_mode", + custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);", }, }, - outs => [ "res", "M" ], ins => [ "ptr", "mem" ], + outs => [ "res", "M" ], attr_type => "sparc_load_store_attr_t", - attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity", - emit => '. ld%LM [%S1%O], %D1' + emit => '. ld%LM [%S0%O1], %D0' }, SetHi => { @@ -291,7 +292,7 @@ SetHi => { reg_req => { in => [], out => [ "gp" ] }, attr => "ir_entity *entity, int32_t immediate_value", custominit => "sparc_set_attr_imm(res, entity, immediate_value);", - emit => '. sethi %HIM, %D1' + emit => '. sethi %HIM, %D0' }, St => { @@ -299,18 +300,23 @@ St => { mode => "mode_M", state => "exc_pinned", constructors => { - "" => { - reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] }, + imm => { + reg_req => { in => [ "gp", "gp", "none" ], out => [ "none" ] }, + ins => [ "val", "ptr", "mem" ], + attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity", + custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);", }, - d => { - reg_req => { in => [ "gp", "gp:a|2", "none" ], out => [ "none" ] }, + reg => { + reg_req => { in => [ "gp", "gp", "gp", "none" ], out => [ "none" ] }, + ins => [ "val", "ptr", "ptr2", "mem" ], + attr => "ir_mode *ls_mode", + custominit => "init_sparc_load_store_attributes(res, ls_mode, NULL, 0, false, true);", }, }, - ins => [ "ptr", "val", "mem" ], + ins => [ "val", "ptr", "mem" ], outs => [ "M" ], attr_type => "sparc_load_store_attr_t", - attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity", - emit => '. st%SM %S2, [%S1%O]' + emit => '. st%SM %S0, [%S1%O2]' }, Save => { @@ -329,14 +335,14 @@ SubSP => { reg_req => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "gp", "none" ] }, ins => [ "stack", "size", "mem" ], outs => [ "stack", "addr", "M" ], - emit => ". sub %S1, %S2, %D1\n", + emit => ". sub %S0, %S1, %D0\n", }, AddSP => { reg_req => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "none" ] }, ins => [ "stack", "size", "mem" ], outs => [ "stack", "M" ], - emit => ". add %S1, %S2, %D1\n", + emit => ". add %S0, %S1, %D0\n", }, FrameAddr => { @@ -397,101 +403,132 @@ Call => { }, }, -Cmp => { +Cmp => { # aka SubccZero irn_flags => [ "rematerializable", "modifies_flags" ], - emit => '. cmp %S1, %R2I', - ins => [ "left", "right" ], + emit => '. cmp %S0, %R1I', mode => $mode_flags, - constructors => \%cmp_operand_constructors, -}, - -Tst => { - irn_flags => [ "rematerializable", "modifies_flags" ], - emit => '. tst %S1', - mode => $mode_flags, - reg_req => { in => [ "gp" ], out => [ "flags" ] }, - ins => [ "val" ], + constructors => \%binopcczero_operand_constructors, }, SwitchJmp => { - op_flags => [ "labeled", "cfopcode", "forking" ], - irn_flags => [ "modifies_flags" ], - state => "pinned", - mode => "mode_T", - attr => "int n_projs, long def_proj_num", - init_attr => "\tset_sparc_jmp_switch_n_projs(res, n_projs);\n". - "\tset_sparc_jmp_switch_default_proj_num(res, def_proj_num);", - reg_req => { in => [ "gp" ], out => [ "none" ] }, - attr_type => "sparc_jmp_switch_attr_t", + op_flags => [ "labeled", "cfopcode", "forking" ], + state => "pinned", + mode => "mode_T", + reg_req => { in => [ "gp" ], out => [ ] }, + 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 }, Sll => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. sll %S1, %R2I, %D1', + emit => '. sll %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, -Slr => { +Srl => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. srl %S1, %R2I, %D1', + emit => '. srl %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, Sra => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. sra %S1, %R2I, %D1', + emit => '. sra %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, And => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. and %S1, %R2I, %D1', + emit => '. and %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, +AndCCZero => { + irn_flags => [ "rematerializable", "modifies_flags" ], + emit => '. andcc %S0, %R1I, %%g0', + mode => $mode_flags, + constructors => \%binopcczero_operand_constructors, +}, + AndN => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. andn %S1, %R2I, %D1', + emit => '. andn %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, +AndNCCZero => { + irn_flags => [ "rematerializable", "modifies_flags" ], + emit => '. andncc %S0, %R1I, %%g0', + mode => $mode_flags, + constructors => \%binopcczero_operand_constructors, +}, + Or => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. or %S1, %R2I, %D1', + emit => '. or %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, +OrCCZero => { + irn_flags => [ "rematerializable", "modifies_flags" ], + emit => '. orcc %S0, %R1I, %%g0', + mode => $mode_flags, + constructors => \%binopcczero_operand_constructors, +}, + OrN => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. orn %S1, %R2I, %D1', + emit => '. orn %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, +OrNCCZero => { + irn_flags => [ "rematerializable", "modifies_flags" ], + emit => '. orncc %S0, %R1I, %%g0', + mode => $mode_flags, + constructors => \%binopcczero_operand_constructors, +}, + Xor => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. xor %S1, %R2I, %D1', + emit => '. xor %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, +XorCCZero => { + irn_flags => [ "rematerializable", "modifies_flags" ], + emit => '. xorcc %S0, %R1I, %%g0', + mode => $mode_flags, + constructors => \%binopcczero_operand_constructors, +}, + XNor => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. xnor %S1, %R2I, %D1', + emit => '. xnor %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, +XNorCCZero => { + irn_flags => [ "rematerializable", "modifies_flags" ], + emit => '. xnorcc %S0, %R1I, %%g0', + mode => $mode_flags, + constructors => \%binopcczero_operand_constructors, +}, + Mul => { irn_flags => [ "rematerializable" ], mode => $mode_gp, - emit => '. smul %S1, %R2I, %D1', + emit => '. smul %S0, %R1I, %D0', constructors => \%binop_operand_constructors, }, @@ -501,29 +538,25 @@ Mulh => { constructors => \%binop_operand_constructors, }, -# The div instructions are kinda hacky. Things to improve: -# * Make high-value input explicitely. Either as a gp at first or ideally -# as an explicit y-register - SDiv => { irn_flags => [ "rematerializable" ], state => "exc_pinned", - ins => [ "dividend_low", "divisor" ], + ins => [ "dividend_high", "dividend_low", "divisor" ], outs => [ "res", "M" ], - constructors => \%binop_operand_constructors, + constructors => \%div_operand_constructors, }, UDiv => { irn_flags => [ "rematerializable" ], state => "exc_pinned", - ins => [ "dividend_low", "divisor" ], + ins => [ "dividend_high", "dividend_low", "divisor" ], outs => [ "res", "M" ], - constructors => \%binop_operand_constructors, + constructors => \%div_operand_constructors, }, fcmp => { irn_flags => [ "rematerializable", "modifies_fp_flags" ], - emit => '. fcmp%FPM %S1, %S2', + emit => '. fcmp%FPM %S0, %S1', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", mode => $mode_fpflags, @@ -543,60 +576,76 @@ fcmp => { fadd => { op_flags => [ "commutative" ], irn_flags => [ "rematerializable" ], - emit => '. fadd%FPM %S1, %S2, %D1', + emit => '. fadd%FPM %S0, %S1, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", + ins => [ "left", "right" ], constructors => \%float_binop_constructors, }, fsub => { irn_flags => [ "rematerializable" ], - emit => '. fsub%FPM %S1, %S2, %D1', + emit => '. fsub%FPM %S0, %S1, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", + ins => [ "left", "right" ], constructors => \%float_binop_constructors, }, fmul => { irn_flags => [ "rematerializable" ], op_flags => [ "commutative" ], - emit =>'. fmul%FPM %S1, %S2, %D1', + emit =>'. fmul%FPM %S0, %S1, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", + ins => [ "left", "right" ], constructors => \%float_binop_constructors, }, fdiv => { irn_flags => [ "rematerializable" ], - emit => '. fdiv%FPM %S1, %S2, %D1', + emit => '. fdiv%FPM %S0, %S1, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", + ins => [ "left", "right" ], outs => [ "res", "M" ], - constructors => \%float_binop_constructors, + constructors => { + s => { + reg_req => { in => [ "fp", "fp" ], out => [ "fp", "none" ] }, + }, + d => { + reg_req => { in => [ "fp:a|2", "fp:a|2" ], out => [ "fp:a|2", "none" ] }, + }, + q => { + reg_req => { in => [ "fp:a|4", "fp:a|4" ], out => [ "fp:a|4", "none" ] }, + } + }, }, fneg => { irn_flags => [ "rematerializable" ], reg_req => { in => [ "fp" ], out => [ "fp" ] }, # note that we only need the first register even for wide-values - emit => '. fneg %S1, %D1', + emit => '. fneg %S0, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", + ins => [ "val" ], constructors => \%float_unop_constructors, }, "fabs" => { irn_flags => [ "rematerializable" ], # note that we only need the first register even for wide-values - emit => '. fabs %S1, %D1', + emit => '. fabs %S0, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", + ins => [ "val" ], constructors => \%float_unop_constructors, }, fftof => { irn_flags => [ "rematerializable" ], - emit => '. f%FCONVS%.to%FCONVD %S1, %D1', + emit => '. f%FCONVS%.to%FCONVD %S0, %D0', attr_type => "sparc_fp_conv_attr_t", attr => "ir_mode *src_mode, ir_mode *dest_mode", constructors => { @@ -629,21 +678,20 @@ fftof => { fitof => { irn_flags => [ "rematerializable" ], - reg_req => { in => [ "gp" ], out => [ "fp" ] }, - emit => '. fito%FPM %S1, %D1', + emit => '. fito%FPM %S0, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", constructors => { s => { - reg_req => { in => [ "gp" ], out => [ "fp" ] }, + reg_req => { in => [ "fp" ], out => [ "fp" ] }, mode => $mode_fp, }, d => { - reg_req => { in => [ "gp" ], out => [ "fp:a|2" ] }, + reg_req => { in => [ "fp" ], out => [ "fp:a|2" ] }, mode => $mode_fp2, }, q => { - reg_req => { in => [ "gp" ], out => [ "fp:a|4" ] }, + reg_req => { in => [ "fp" ], out => [ "fp:a|4" ] }, mode => $mode_fp4, }, }, @@ -651,20 +699,19 @@ fitof => { fftoi => { irn_flags => [ "rematerializable" ], - reg_req => { in => [ "fp" ], out => [ "gp" ] }, - emit => '. f%FPM.toi %S1, %D1', + emit => '. f%FPM%.toi %S0, %D0', attr_type => "sparc_fp_attr_t", attr => "ir_mode *fp_mode", mode => $mode_gp, constructors => { s => { - reg_req => { in => [ "gp" ], out => [ "gp" ] }, + reg_req => { in => [ "fp" ], out => [ "fp" ] }, }, d => { - reg_req => { in => [ "fp:a|2" ], out => [ "gp" ] }, + reg_req => { in => [ "fp:a|2" ], out => [ "fp" ] }, }, q => { - reg_req => { in => [ "fp:a|4" ], out => [ "gp" ] }, + reg_req => { in => [ "fp:a|4" ], out => [ "fp" ] }, }, }, }, @@ -687,7 +734,8 @@ Ldf => { outs => [ "res", "M" ], attr_type => "sparc_load_store_attr_t", attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity", - emit => '. ld%FLSM [%S1%O], %D1' + custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);", + emit => '. ld%FLSM [%S0%O1], %D0' }, Stf => { @@ -695,20 +743,21 @@ Stf => { state => "exc_pinned", constructors => { s => { - reg_req => { in => [ "gp", "fp", "none" ], out => [ "none" ] }, + reg_req => { in => [ "fp", "gp", "none" ], out => [ "none" ] }, }, d => { - reg_req => { in => [ "gp", "fp:a|2", "none" ], out => [ "none" ] }, + reg_req => { in => [ "fp:a|2", "gp", "none" ], out => [ "none" ] }, }, q => { - reg_req => { in => [ "gp", "fp:a|4", "none" ], out => [ "none" ] }, + reg_req => { in => [ "fp:a|4", "gp", "none" ], out => [ "none" ] }, }, }, - ins => [ "ptr", "val", "mem" ], + ins => [ "val", "ptr", "mem" ], outs => [ "M" ], attr_type => "sparc_load_store_attr_t", attr => "ir_mode *ls_mode, ir_entity *entity, int32_t offset, bool is_frame_entity", - emit => '. st%FLSM %S2, [%S1%O]', + custominit => "init_sparc_load_store_attributes(res, ls_mode, entity, offset, is_frame_entity, false);", + emit => '. st%FLSM %S0, [%S1%O2]', mode => 'mode_M', },