); # %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);",
);
# |_| #
#--------------------------------------------------#
+$default_cmp_attr = "return mips_compare_attr(attr_a, attr_b);";
+
%nodes = (
#-----------------------------------------------------------------#
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",
},
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"
},
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",
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",
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",
},
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",
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"
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",
},
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"
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'
},
-
# _ _ ______ _
# | | ___ __ _ __| | / / ___|| |_ ___ _ __ ___
# | | / _ \ / _` |/ _` | / /\___ \| __/ _ \| '__/ _ \
# |_____\___/ \__,_|\__,_/_/ |____/ \__\___/|_| \___|
#
-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"
},