X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fmips%2Fmips_spec.pl;h=872687cb1db147af94f6e1239db7a53c10433f2a;hb=98acf603b8f6198f7279e4f4f10031f9edee7ea4;hp=31b6333312acd1b981cb0dad586fa2d0feb1ecb5;hpb=aebc3c0c980bcc0536ffdc4cb2a545961b5a8b81;p=libfirm diff --git a/ir/be/mips/mips_spec.pl b/ir/be/mips/mips_spec.pl index 31b633331..872687cb1 100644 --- a/ir/be/mips/mips_spec.pl +++ b/ir/be/mips/mips_spec.pl @@ -126,15 +126,16 @@ $new_emit_syntax = 1; ); # %reg_classes %emit_templates = ( - S1 => "${arch}_emit_source_register(env, node, 0);", - S2 => "${arch}_emit_source_register(env, node, 1);", - S3 => "${arch}_emit_source_register(env, node, 2);", - D1 => "${arch}_emit_dest_register(env, node, 0);", - D2 => "${arch}_emit_dest_register(env, node, 1);", - D3 => "${arch}_emit_dest_register(env, node, 2);", + S0 => "${arch}_emit_source_register(env, node, 0);", + S1 => "${arch}_emit_source_register(env, node, 1);", + S2 => "${arch}_emit_source_register(env, node, 2);", + D0 => "${arch}_emit_dest_register(env, node, 0);", + D1 => "${arch}_emit_dest_register(env, node, 1);", + D2 => "${arch}_emit_dest_register(env, node, 2);", C => "${arch}_emit_immediate(env, node);", JumpTarget => "${arch}_emit_jump_target(env, node);", JumpTarget1 => "${arch}_emit_jump_target_proj(env, node, 1);", + JumpOrFallthrough => "${arch}_emit_jump_or_fallthrough(env, node, 0);", ); @@ -149,6 +150,8 @@ $new_emit_syntax = 1; # |_| # #--------------------------------------------------# +$default_cmp_attr = "return mips_compare_attr(attr_a, attr_b);"; + %nodes = ( #-----------------------------------------------------------------# @@ -167,13 +170,13 @@ $new_emit_syntax = 1; addu => { op_flags => "C", reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. addu %D1, %S1, %S2', + emit => '. addu %D0, %S0, %S1', mode => "mode_Iu", }, addiu => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. addiu %D1, %S1, %C', + emit => '. addiu %D0, %S0, %C', cmp_attr => 'return attr_a->tv != attr_b->tv;', mode => "mode_Iu", }, @@ -181,66 +184,66 @@ addiu => { and => { op_flags => "C", reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. and %D1, %S1, %S2', + emit => '. and %D0, %S0, %S1', mode => "mode_Iu", }, andi => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. andi %D1, %S1, %C', + emit => '. andi %D0, %S0, %C', cmp_attr => 'return attr_a->tv != attr_b->tv;', mode => "mode_Iu", }, div => { reg_req => { in => [ "gp", "gp" ], out => [ "none" ] }, - emit => '. div %S1, %S2', + emit => '. div %S0, %S1', mode => "mode_M", }, divu => { reg_req => { in => [ "gp", "gp" ], out => [ "none" ] }, - emit => '. divu %S1, %S2', + emit => '. divu %S0, %S1', mode => "mode_M", }, mult => { op_flags => "C", reg_req => { in => [ "gp", "gp" ], out => [ "none" ] }, - emit => '. mult %S1, %S2', + emit => '. mult %S0, %S1', mode => "mode_M" }, multu => { op_flags => "C", reg_req => { in => [ "gp", "gp" ], out => [ "none" ] }, - emit => '. multu %S1, %S2', + emit => '. multu %S0, %S1', mode => "mode_M", }, nor => { op_flags => "C", reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. nor %D1, %S1, %S2', + emit => '. nor %D0, %S0, %S1', mode => "mode_Iu" }, not => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. nor %D1, %S1, $zero', + emit => '. nor %D0, %S0, $zero', mode => "mode_Iu" }, or => { op_flags => "C", reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. or %D1, %S1, %S2', + emit => '. or %D0, %S0, %S1', mode => "mode_Iu" }, ori => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. ori %D1, %S1, %C', + emit => '. ori %D0, %S0, %C', cmp_attr => 'return attr_a->tv != attr_b->tv;', mode => "mode_Iu" }, @@ -249,9 +252,9 @@ sl => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, emit => ' if (mode_is_signed(get_irn_mode(node))) { - . sal %D1, %S1, %S2 + . sal %D0, %S0, %S1 } else { - . sll %D1, %S1, %S2 + . sll %D0, %S0, %S1 } ', mode => "mode_Iu", @@ -261,9 +264,9 @@ sli => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, emit => ' if (mode_is_signed(get_irn_mode(node))) { - . sal %D1, %S1, %C + . sal %D0, %S0, %C } else { - . sll %D1, %S1, %C + . sll %D0, %S0, %C } ', mode => "mode_Iu", @@ -271,13 +274,13 @@ sli => { sra => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. sra %D1, %S1, %S2', + emit => '. sra %D0, %S0, %S1', mode => "mode_Iu" }, srai => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. sra %D1, %S1, %C', + emit => '. sra %D0, %S0, %C', cmp_attr => 'return attr_a->tv != attr_b->tv;', mode => "mode_Iu", }, @@ -286,9 +289,9 @@ sr => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, emit => ' if (mode_is_signed(get_irn_mode(node))) { - . sra %D1, %S1, %S2 + . sra %D0, %S0, %S1 } else { - . srl %D1, %S1, %S2 + . srl %D0, %S0, %S1 } ', mode => "mode_Iu", @@ -298,9 +301,9 @@ sri => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, emit => ' if (mode_is_signed(get_irn_mode(node))) { - . sra %D1, %S1, %C + . sra %D0, %S0, %C } else { - . srl %D1, %S1, %C + . srl %D0, %S0, %C } ', mode => "mode_Iu" @@ -308,37 +311,37 @@ sri => { srlv => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. srlv %D1, %S1, %S2', + emit => '. srlv %D0, %S0, %S1', mode => "mode_Iu" }, sllv => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. sllv %D1, %S1, %S2', + emit => '. sllv %D0, %S0, %S1', mode => "mode_Iu" }, sub => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. subu %D1, %S1, %S2', + emit => '. subu %D0, %S0, %S1', mode => "mode_Iu" }, subuzero => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. subu %D1, $zero, %S1', + emit => '. subu %D0, $zero, %S0', mode => "mode_Iu", }, xor => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => '. xor %D1, %S1, %S2', + emit => '. xor %D0, %S0, %S1', mode => "mode_Iu", }, xori => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. xori %D1, %S1, %C', + emit => '. xori %D0, %S0, %C', cmp_attr => 'return attr_a->tv != attr_b->tv;', mode => "mode_Iu", }, @@ -354,41 +357,27 @@ xori => { lui => { op_flags => "c", reg_req => { out => [ "gp" ] }, - emit => '. lui %D1, %C', - cmp_attr => 'return attr_a->tv != attr_b->tv;', - mode => "mode_Iu", -}, - -# load lower immediate -lli => { - op_flags => "c", - reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. ori %D1, %S1, %C', + emit => '. lui %D0, %C', cmp_attr => 'return attr_a->tv != attr_b->tv;', mode => "mode_Iu", }, -la => { - op_flags => "c", - reg_req => { out => [ "gp" ] }, - emit => '. la %D1, %C', - cmp_attr => 'return attr_a->symconst_id != attr_b->symconst_id;', - mode => "mode_Iu", -}, - mflo => { reg_req => { in => [ "none" ], out => [ "gp" ] }, - emit => '. mflo %D1', + emit => '. mflo %D0', mode => "mode_Iu" }, mfhi => { reg_req => { in => [ "none" ], out => [ "gp" ] }, - emit => '. mfhi %D1', + emit => '. mfhi %D0', mode => "mode_Iu" }, zero => { + state => "pinned", + op_flags => "c", + irn_flags => "I", reg_req => { out => [ "zero" ] }, emit => '', mode => "mode_Iu" @@ -405,128 +394,80 @@ zero => { slt => { reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, - emit => ' - if (mode_is_signed(get_irn_mode(node))) { - . slt %D1, %S1, %S2 - } - else { - . sltu %D1, %S1, %S2 - } -', + emit => '. slt %D0, %S0, %S1', + mode => "mode_Iu", +}, + +sltu => { + reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] }, + emit => '. sltu %D0, %S0, %S1', mode => "mode_Iu", }, slti => { reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => ' - if (mode_is_signed(get_irn_mode(node))) { - . slti %D1, %S1, %C - } - else { - . sltiu %D1, %S1, %C - } -', - cmp_attr => 'return attr_a->tv != attr_b->tv;', + emit => '. slti %D0, %S0, %C', + mode => "mode_Iu", +}, + +sltiu => { + reg_req => { in => [ "gp" ], out => [ "gp" ] }, + emit => '. slti %D0, %S0, %C', mode => "mode_Iu", }, beq => { - op_flags => "X|Y", - # TxT -> TxX - reg_req => { in => [ "gp", "gp" ], out => [ "in_r0", "none" ] }, - emit => '. beq %S1, %S2, %JumpTarget1' + op_flags => "X|Y", + reg_req => { in => [ "gp", "gp" ], out => [ "none", "none" ] }, + outs => [ "false", "true" ], + emit => '. beq %S0, %S1, %JumpTarget1 + . %JumpOrFallthrough' }, bne => { - op_flags => "X|Y", - # TxT -> TxX - reg_req => { in => [ "gp", "gp" ], out => [ "in_r0", "none" ] }, - emit => '. bne %S1, %S2, %JumpTarget1' + op_flags => "X|Y", + reg_req => { in => [ "gp", "gp" ], out => [ "none", "none" ] }, + outs => [ "false", "true" ], + emit => '. bne %S0, %S1, %JumpTarget1 + . %JumpOrFallthrough' }, bgtz => { - op_flags => "X|Y", - # TxT -> TxX - reg_req => { in => [ "gp" ], out => [ "in_r0", "none" ] }, - emit => '. bgtz %S1, %JumpTarget1' + op_flags => "X|Y", + reg_req => { in => [ "gp" ], out => [ "none", "none" ] }, + outs => [ "false", "true" ], + emit => '. bgtz %S0, %JumpTarget1 + . %JumpOrFallthrough' }, blez => { - op_flags => "X|Y", - # TxT -> TxX - reg_req => { in => [ "gp" ], out => [ "in_r0", "none" ] }, - emit => '. blez %S1, %JumpTarget1' -}, - -j => { - op_flags => "X", - reg_req => { in => [ "gp" ] }, - emit => '. j %S1', + op_flags => "X|Y", + reg_req => { in => [ "gp" ], out => [ "none", "none" ] }, + outs => [ "false", "true" ], + emit => '. blez %S0, %JumpTarget1 + . %JumpOrFallthrough' }, b => { op_flags => "X", - # -> X - reg_req => { in => [ ], out => [ "none" ] }, - emit => '. b %JumpTarget' + reg_req => { in => [ ], out => [ "none" ] }, + emit => '. b %JumpTarget', + mode => 'mode_X' }, -fallthrough => { +jr => { op_flags => "X", - # -> X - reg_req => { in => [ ], out => [ "none" ] }, - emit => '. /* fallthrough to %JumpTarget */' + reg_req => { in => [ "gp" ], out => [ "none" ] }, + emit => '. jr %S0', + mode => 'mode_X' }, SwitchJump => { op_flags => "X", - # -> X,X,... - reg_req => { in => [ "gp" ], out => [ "none" ] }, - emit => '. j %S1' -}, - -# _ _ -# | | ___ __ _ __| | -# | | / _ \ / _` |/ _` | -# | |__| (_) | (_| | (_| | -# |_____\___/ \__,_|\__,_| -# - -load_r => { - reg_req => { in => [ "none", "gp" ], out => [ "none", "none", "gp" ] }, - emit => ' - mips_attr_t* attr = get_mips_attr(node); - ir_mode *mode; - - mode = attr->modes.load_store_mode; - - switch (get_mode_size_bits(mode)) { - case 8: - if (mode_is_signed(mode)) { - . lb %D3, %C(%S2) - } else { - . lbu %D3, %C(%S2) - } - break; - case 16: - if (mode_is_signed(mode)) { - . lh %D3, %C(%S2) - } else { - . lhu %D3, %C(%S2) - } - break; - case 32: - . lw %D3, %C(%S2) - break; - default: - assert(! "Only 8, 16 and 32 bit loads supported"); - break; - } -', - cmp_attr => 'return attr_a->tv != attr_b->tv || attr_a->stack_entity != attr_b->stack_entity;', + reg_req => { in => [ "gp" ], out => [ "none" ] }, + emit => '. jr %S0' }, - # _ _ ______ _ # | | ___ __ _ __| | / / ___|| |_ ___ _ __ ___ # | | / _ \ / _` |/ _` | / /\___ \| __/ _ \| '__/ _ \ @@ -534,73 +475,73 @@ load_r => { # |_____\___/ \__,_|\__,_/_/ |____/ \__\___/|_| \___| # -store_r => { - reg_req => { in => [ "none", "gp", "gp" ], out => [ "none", "none" ] }, - emit => ' - mips_attr_t* attr = get_mips_attr(node); - ir_mode* mode; - - mode = attr->modes.load_store_mode; - - switch (get_mode_size_bits(mode)) { - case 8: - if (mode_is_signed(mode)) - . sb %S3, %C(%S2) - break; - case 16: - if (mode_is_signed(mode)) - . sh %S3, %C(%S2) - break; - case 32: - . sw %S3, %C(%S2) - break; - default: - assert(! "Only 8, 16 and 32 bit stores supported"); - break; - } -', - cmp_attr => 'return attr_a->tv != attr_b->tv;', -}, - -store_i => { - reg_req => { in => [ "none", "none", "gp" ], out => [ "none", "none" ] }, - emit => ' - mips_attr_t* attr = get_mips_attr(node); - ir_mode *mode; - - mode = attr->modes.load_store_mode; - - switch (get_mode_size_bits(mode)) { - case 8: - . sb %S3, %C - break; - case 16: - . sh %S3, %C - break; - case 32: - . sw %S3, %C - break; - default: - assert(! "Only 8, 16 and 32 bit stores supported"); - break; - } -', - cmp_attr => 'return attr_a->stack_entity != attr_b->stack_entity;', +lw => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp" ], out => [ "gp", "none" ] }, + outs => [ "res", "M" ], + emit => '. lw %D0, %C(%S1)', }, -move => { - reg_req => { in => [ "gp" ], out => [ "gp" ] }, - emit => '. move %D1, %S1', - mode => "mode_Iu" +lh => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp" ], out => [ "gp", "none" ] }, + outs => [ "res", "M" ], + emit => '. lh %D0, %C(%S1)', }, -# -# Conversion -# +lhu => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp" ], out => [ "gp", "none" ] }, + outs => [ "res", "M" ], + emit => '. lhu %D0, %C(%S1)', +}, + +lb => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp" ], out => [ "gp", "none" ] }, + outs => [ "res", "M" ], + emit => '. lb %D0, %C(%S1)', +}, + +lbu => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp" ], out => [ "gp", "none" ] }, + outs => [ "res", "M" ], + emit => '. lbu %D0, %C(%S1)', +}, -reinterpret_conv => { - reg_req => { in => [ "gp" ], out => [ "in_r1" ] }, - emit => '. # reinterpret %S1 -> %D1', +sw => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp", "gp" ], out => [ "none" ] }, + emit => '. sw %S2, %C(%S1)', + mode => 'mode_M', +}, + +sh => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp", "gp" ], out => [ "none" ] }, + emit => '. sh %S2, %C(%S1)', + mode => 'mode_M', +}, + +sb => { + op_flags => "L|F", + state => "exc_pinned", + reg_req => { in => [ "none", "gp", "gp" ], out => [ "none" ] }, + emit => '. sb %S2, %C(%S1)', + mode => 'mode_M', +}, + +move => { + reg_req => { in => [ "gp" ], out => [ "gp" ] }, + emit => '. move %D0, %S0', mode => "mode_Iu" },