A few more opcodes.

This commit is contained in:
David Given 2016-10-11 00:29:18 +02:00
parent 2be1c51885
commit 668cccdff1
2 changed files with 29 additions and 1 deletions

View file

@ -301,7 +301,11 @@ PATTERNS
cost 4; cost 4;
out:(int)reg = SUB4(left:(int)reg, right:(int)reg) 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; cost 4;
out:(int)reg = MUL4(left:(int)reg, right:(int)reg) out:(int)reg = MUL4(left:(int)reg, right:(int)reg)

View file

@ -217,6 +217,30 @@ static void insn_simple(int opcode)
break; 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: default:
fatal("treebuilder: unknown simple instruction '%s'", fatal("treebuilder: unknown simple instruction '%s'",
em_mnem[opcode - sp_fmnem]); em_mnem[opcode - sp_fmnem]);