diff options
Diffstat (limited to 'src/ssa')
-rw-r--r-- | src/ssa/ssa.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/ssa/ssa.c b/src/ssa/ssa.c index 34ecada..44b5589 100644 --- a/src/ssa/ssa.c +++ b/src/ssa/ssa.c @@ -487,10 +487,15 @@ static bool lhs_expr_is_decl(LhsExpr *self) { static CHECK_RESULT SsaRegister number_generate_ssa(Number *self, SsaCompilerContext *context) { SsaRegister reg; SsaNumber number; - if(self->is_integer) - number = create_ssa_integer(self->value.integer); - else - number = create_ssa_float(self->value.floating); + switch(self->value.type) { + case AMAL_NUMBER_SIGNED_INTEGER: + case AMAL_NUMBER_UNSIGNED_INTEGER: + number = create_ssa_integer(self->value.value.integer); + break; + case AMAL_NUMBER_FLOAT: + number = create_ssa_float(self->value.value.floating); + break; + } throw_if_error(ssa_get_unique_reg(context->ssa, ®)); throw_if_error(ssa_ins_assign_inter(context->ssa, reg, number)); return reg; @@ -759,9 +764,9 @@ static SsaInstruction binop_type_to_ssa_type(BinopType binop_type, amal_default_ case BINOP_SUB: return SSA_SUB; case BINOP_MUL: - return type->is_signed ? SSA_IMUL : SSA_MUL; + return amal_default_type_is_signed(type) ? SSA_IMUL : SSA_MUL; case BINOP_DIV: - return type->is_signed ? SSA_IDIV : SSA_DIV; + return amal_default_type_is_signed(type) ? SSA_IDIV : SSA_DIV; case BINOP_DOT: assert(bool_false && "Binop dot not valid for arithmetic operation and requires special functionality"); return 0; @@ -772,13 +777,13 @@ static SsaInstruction binop_type_to_ssa_type(BinopType binop_type, amal_default_ case BINOP_AND: return SSA_AND; case BINOP_LESS: - return type->is_signed ? SSA_ILT : SSA_LT; + return amal_default_type_is_signed(type) ? SSA_ILT : SSA_LT; case BINOP_LESS_EQUAL: - return type->is_signed ? SSA_ILE : SSA_LE; + return amal_default_type_is_signed(type) ? SSA_ILE : SSA_LE; case BINOP_GREATER: - return type->is_signed ? SSA_IGT : SSA_GT; + return amal_default_type_is_signed(type) ? SSA_IGT : SSA_GT; case BINOP_GREATER_EQUAL: - return type->is_signed ? SSA_IGE : SSA_GE; + return amal_default_type_is_signed(type) ? SSA_IGE : SSA_GE; } return 0; } |