glasm: Fix INeg32 on negative immediates

This commit is contained in:
ReinUsesLisp 2021-05-25 02:48:03 -03:00 committed by ameerj
parent 75fd0079db
commit 70c9281fbf

View File

@ -67,7 +67,11 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
}
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
ctx.Add("MOV.S {},-{};", inst, value);
if (value.type != Type::Register && static_cast<s32>(value.imm_u32) < 0) {
ctx.Add("MOV.S {},{};", inst, -static_cast<s32>(value.imm_u32));
} else {
ctx.Add("MOV.S {},-{};", inst, value);
}
}
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, Register value) {