aboutsummaryrefslogtreecommitdiff
path: root/src/ir.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-05-09 16:21:31 +0100
committerGinger Bill <bill@gingerbill.org>2017-05-09 16:21:31 +0100
commitc6d531df9597253ee95593c56e61039fe4e40ba2 (patch)
tree8469ee00657577f4909891e8773231351f54b3cd /src/ir.c
parent8677c81da7ca8af37c49a203a18fd7beab74f023 (diff)
Add %% operator (divisor modulo)
Diffstat (limited to 'src/ir.c')
-rw-r--r--src/ir.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ir.c b/src/ir.c
index 4f8e31bae..28b698b0d 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -2073,6 +2073,7 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue *
case Token_Mul:
case Token_Quo:
case Token_Mod:
+ case Token_ModMod:
case Token_And:
case Token_Or:
case Token_Xor:
@@ -2081,6 +2082,14 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue *
break;
}
+ if (op == Token_ModMod) {
+ irValue *n = left;
+ irValue *m = right;
+ irValue *a = ir_emit(proc, ir_instr_binary_op(proc, Token_Mod, n, m, type));
+ irValue *b = ir_emit(proc, ir_instr_binary_op(proc, Token_Add, a, m, type));
+ return ir_emit(proc, ir_instr_binary_op(proc, Token_Mod, b, m, type));
+ }
+
return ir_emit(proc, ir_instr_binary_op(proc, op, left, right, type));
}
@@ -3744,6 +3753,7 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) {
case Token_Mul:
case Token_Quo:
case Token_Mod:
+ case Token_ModMod:
case Token_And:
case Token_Or:
case Token_Xor: