# the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
$arch = "mips";
-
-# this strings mark the beginning and the end of a comment in emit
-$comment_string = "#";
-$comment_string_end = "";
+$new_emit_syntax = 1;
# The node description is done as a perl hash initializer with the
# following structure:
],
); # %reg_classes
+%emit_templates = (
+ 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"
},
sl => {
reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
emit => '
- if (mode_is_signed(get_irn_mode(n))) {
-2. sal %D1, %S1, %S2
+ if (mode_is_signed(get_irn_mode(node))) {
+ . sal %D0, %S0, %S1
} else {
-2. sll %D1, %S1, %S2
+ . sll %D0, %S0, %S1
}
',
mode => "mode_Iu",
sli => {
reg_req => { in => [ "gp" ], out => [ "gp" ] },
emit => '
- if (mode_is_signed(get_irn_mode(n))) {
-2. sal %D1, %S1, %C
+ if (mode_is_signed(get_irn_mode(node))) {
+ . sal %D0, %S0, %C
} else {
-2. 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",
},
sr => {
reg_req => { in => [ "gp", "gp" ], out => [ "gp" ] },
emit => '
- if (mode_is_signed(get_irn_mode(n))) {
-2. sra %D1, %S1, %S2
+ if (mode_is_signed(get_irn_mode(node))) {
+ . sra %D0, %S0, %S1
} else {
-2. srl %D1, %S1, %S2
+ . srl %D0, %S0, %S1
}
',
mode => "mode_Iu",
sri => {
reg_req => { in => [ "gp" ], out => [ "gp" ] },
emit => '
- if (mode_is_signed(get_irn_mode(n))) {
-2. sra %D1, %S1, %C
+ if (mode_is_signed(get_irn_mode(node))) {
+ . sra %D0, %S0, %C
} else {
-2. 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',
+ emit => '. lui %D0, %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',
- 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(n))) {
-2. slt %D1, %S1, %S2
- }
- else {
-2. 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(n))) {
-2. slti %D1, %S1, %C
- }
- else {
-2. sltiu %D1, %S1, %C
- }
-',
- cmp_attr => 'return attr_a->tv != attr_b->tv;',
+ 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 => '
- ir_node *jumpblock = mips_get_jump_block(n, 1);
- assert(jumpblock != NULL);
+sltiu => {
+ reg_req => { in => [ "gp" ], out => [ "gp" ] },
+ emit => '. slti %D0, %S0, %C',
+ mode => "mode_Iu",
+},
- (void) cmd_buf;
- (void) cmnt_buf;
- lc_efprintf(arg_env, F, "\tbeq %1S, %2S, BLOCK_%d\n", n, n, get_irn_node_nr(jumpblock));
-'
+beq => {
+ 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 => '
- ir_node *jumpblock = mips_get_jump_block(n, 1);
- assert(jumpblock != NULL);
-
- (void) cmd_buf;
- (void) cmnt_buf;
- lc_efprintf(arg_env, F, "\tbne %1S, %2S, BLOCK_%d\n", n, n, get_irn_node_nr(jumpblock));
-'
+ 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 => '
- ir_node *jumpblock = mips_get_jump_block(n, 1);
- assert(jumpblock != NULL);
-
- (void) cmd_buf;
- (void) cmnt_buf;
- lc_efprintf(arg_env, F, "\tbgtz %1S, BLOCK_%d\n", n, get_irn_node_nr(jumpblock));
-'
+ 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 => '
- ir_node *jumpblock = mips_get_jump_block(n, 1);
- assert(jumpblock != NULL);
-
- (void) cmd_buf;
- (void) cmnt_buf;
- lc_efprintf(arg_env, F, "\tblez %1S, BLOCK_%d\n", n, get_irn_node_nr(jumpblock));
-'
-},
-
-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 => '
- ir_node *jumpblock = get_irn_link(n);
- assert(jumpblock != NULL);
-
- (void) cmd_buf;
- (void) cmnt_buf;
- lc_efprintf(arg_env, F, "\tb BLOCK_%d\t\t\t# mips_b\n", get_irn_node_nr(jumpblock));
-'
+ reg_req => { in => [ ], out => [ "none" ] },
+ emit => '. b %JumpTarget',
+ mode => 'mode_X'
},
-fallthrough => {
+jr => {
op_flags => "X",
- # -> X
- reg_req => { in => [ ], out => [ "none" ] },
- emit => '. # fallthrough'
+ 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'
+ reg_req => { in => [ "gp" ], out => [ "none" ] },
+ emit => '. jr %S0'
},
-# _ _
-# | | ___ __ _ __| |
-# | | / _ \ / _` |/ _` |
-# | |__| (_) | (_| | (_| |
-# |_____\___/ \__,_|\__,_|
-#
-
-load_r => {
- reg_req => { in => [ "none", "gp" ], out => [ "none", "none", "gp" ] },
- emit => '
- mips_attr_t* attr = get_mips_attr(n);
- ir_mode *mode;
-
- mode = attr->modes.load_store_mode;
-
- switch (get_mode_size_bits(mode)) {
- case 8:
- if (mode_is_signed(mode)) {
-3. lb %D3, %C(%S2)
- } else {
-3. lbu %D3, %C(%S2)
- }
- break;
- case 16:
- if (mode_is_signed(mode)) {
-3. lh %D3, %C(%S2)
- } else {
-3. lhu %D3, %C(%S2)
- }
- break;
- case 32:
-2. 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;',
-},
-
-
# _ _ ______ _
# | | ___ __ _ __| | / / ___|| |_ ___ _ __ ___
# | | / _ \ / _` |/ _` | / /\___ \| __/ _ \| '__/ _ \
# |_____\___/ \__,_|\__,_/_/ |____/ \__\___/|_| \___|
#
-store_r => {
- reg_req => { in => [ "none", "gp", "gp" ], out => [ "none", "none" ] },
- emit => '
- mips_attr_t* attr = get_mips_attr(n);
- ir_mode* mode;
-
- mode = attr->modes.load_store_mode;
-
- switch (get_mode_size_bits(mode)) {
- case 8:
- if (mode_is_signed(mode))
-2. sb %S3, %C(%S2)
- break;
- case 16:
- if (mode_is_signed(mode))
-2. sh %S3, %C(%S2)
- break;
- case 32:
-2. 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(n);
- ir_mode *mode;
-
- mode = attr->modes.load_store_mode;
-
- switch (get_mode_size_bits(mode)) {
- case 8:
-2. sb %S3, %C
- break;
- case 16:
-2. sh %S3, %C
- break;
- case 32:
-2. 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"
},