From: David Given Date: Mon, 10 Oct 2016 22:29:18 +0000 (+0200) Subject: A few more opcodes. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=668cccdff1d5292893f13e9c88a4312aa43a9d6e;p=ack.git A few more opcodes. --- diff --git a/mach/proto/mcg/table b/mach/proto/mcg/table index 20ef46b2b..f50f02c11 100644 --- a/mach/proto/mcg/table +++ b/mach/proto/mcg/table @@ -301,7 +301,11 @@ PATTERNS cost 4; out:(int)reg = SUB4(left:(int)reg, right:(int)reg) - emit "sub %out, %right, %left" + emit "subf %out, %left, %right" + cost 4; + + out:(int)reg = SUB4(left:(int)reg, right:CONST4) + emit "addi %out, %left, -($right)" cost 4; out:(int)reg = MUL4(left:(int)reg, right:(int)reg) diff --git a/mach/proto/mcg/treebuilder.c b/mach/proto/mcg/treebuilder.c index 8039b3449..828a99747 100644 --- a/mach/proto/mcg/treebuilder.c +++ b/mach/proto/mcg/treebuilder.c @@ -217,6 +217,30 @@ static void insn_simple(int opcode) break; } + case op_inc: + { + push( + new_ir2( + IR_ADD, EM_wordsize, + pop(EM_wordsize), + new_wordir(1) + ) + ); + break; + } + + case op_dec: + { + push( + new_ir2( + IR_SUB, EM_wordsize, + pop(EM_wordsize), + new_wordir(1) + ) + ); + break; + } + default: fatal("treebuilder: unknown simple instruction '%s'", em_mnem[opcode - sp_fmnem]);