diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-10-02 01:00:59 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | b124548bcee1ab6d034d4499fe695073566ae37d (patch) | |
tree | e4014070ac69a2b821e12cc9264ba54aaa8089f4 /src/ssa | |
parent | 7eb8642c3ace697b03c4fc6edc90ea0ada715689 (diff) |
Add !=,<,<=,>,>=; both signed and not
Diffstat (limited to 'src/ssa')
-rw-r--r-- | src/ssa/ssa.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/ssa/ssa.c b/src/ssa/ssa.c index d875ea4..34ecada 100644 --- a/src/ssa/ssa.c +++ b/src/ssa/ssa.c @@ -244,15 +244,23 @@ static CHECK_RESULT int ssa_add_ins_form1(Ssa *self, SsaInstruction ins_type, Ss } static const char* binop_type_to_string(SsaInstruction binop_type) { - assert(binop_type >= SSA_ADD && binop_type <= SSA_EQUALS); + assert(binop_type >= SSA_ADD && binop_type <= SSA_GE); switch(binop_type) { - case SSA_ADD: return "+"; - case SSA_SUB: return "-"; - case SSA_MUL: return "*"; - case SSA_DIV: return "/"; - case SSA_EQUALS: return "=="; - case SSA_AND: return "&&"; - default: return ""; + case SSA_ADD: return "+"; + case SSA_SUB: return "-"; + case SSA_MUL: return "*"; + case SSA_DIV: return "/"; + case SSA_EQUALS: return "=="; + case SSA_AND: return "&&"; + case SSA_ILT: return "<"; + case SSA_LT: return "<"; + case SSA_ILE: return "<="; + case SSA_LE: return "<="; + case SSA_IGT: return ">"; + case SSA_GT: return ">"; + case SSA_IGE: return ">="; + case SSA_GE: return ">="; + default: return ""; } } @@ -287,7 +295,7 @@ static CHECK_RESULT int ssa_ins_assign_reg(Ssa *self, SsaRegister dest, SsaRegis } static CHECK_RESULT int ssa_ins_binop(Ssa *self, SsaInstruction binop_type, SsaRegister lhs, SsaRegister rhs, SsaRegister *result) { - assert(binop_type >= SSA_ADD && binop_type <= SSA_AND); + assert(binop_type >= SSA_ADD && binop_type <= SSA_GE); return ssa_add_ins_form2(self, binop_type, lhs, rhs, result); } @@ -759,8 +767,18 @@ static SsaInstruction binop_type_to_ssa_type(BinopType binop_type, amal_default_ return 0; case BINOP_EQUALS: return SSA_EQUALS; + case BINOP_NOT_EQUAL: + return SSA_NOT_EQUAL; case BINOP_AND: return SSA_AND; + case BINOP_LESS: + return type->is_signed ? SSA_ILT : SSA_LT; + case BINOP_LESS_EQUAL: + return type->is_signed ? SSA_ILE : SSA_LE; + case BINOP_GREATER: + return type->is_signed ? SSA_IGT : SSA_GT; + case BINOP_GREATER_EQUAL: + return type->is_signed ? SSA_IGE : SSA_GE; } return 0; } |