mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 04:46:27 -05:00
glasm: Fix INeg32 on negative immediates
This commit is contained in:
parent
75fd0079db
commit
70c9281fbf
1 changed files with 5 additions and 1 deletions
|
@ -67,8 +67,12 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
|
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 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);
|
ctx.Add("MOV.S {},-{};", inst, value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, Register value) {
|
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, Register value) {
|
||||||
ctx.LongAdd("MOV.S64 {},-{};", inst, value);
|
ctx.LongAdd("MOV.S64 {},-{};", inst, value);
|
||||||
|
|
Loading…
Reference in a new issue