forked from ShuriZma/suyu
1
0
Fork 0

emit_glasm: Implement more integer alu ops

This commit is contained in:
ameerj 2021-05-09 18:49:27 -04:00
parent 3e10709091
commit 6705f56029
2 changed files with 41 additions and 47 deletions

View File

@ -302,15 +302,15 @@ void EmitIAdd64(EmitContext& ctx, Register a, Register b);
void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); void EmitISub32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitISub64(EmitContext& ctx, Register a, Register b); void EmitISub64(EmitContext& ctx, Register a, Register b);
void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitINeg32(EmitContext& ctx, ScalarS32 value); void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
void EmitINeg64(EmitContext& ctx, Register value); void EmitINeg64(EmitContext& ctx, Register value);
void EmitIAbs32(EmitContext& ctx, ScalarS32 value); void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
void EmitIAbs64(EmitContext& ctx, Register value); void EmitIAbs64(EmitContext& ctx, Register value);
void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift); void EmitShiftLeftLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift);
void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift); void EmitShiftLeftLogical64(EmitContext& ctx, Register base, Register shift);
void EmitShiftRightLogical32(EmitContext& ctx, ScalarU32 base, ScalarU32 shift); void EmitShiftRightLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift);
void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift); void EmitShiftRightLogical64(EmitContext& ctx, Register base, Register shift);
void EmitShiftRightArithmetic32(EmitContext& ctx, ScalarS32 base, ScalarS32 shift); void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, ScalarS32 shift);
void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift); void EmitShiftRightArithmetic64(EmitContext& ctx, Register base, Register shift);
void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); void EmitBitwiseAnd32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b); void EmitBitwiseOr32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
@ -322,14 +322,14 @@ void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, Scal
void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset, void EmitBitFieldUExtract(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 offset,
ScalarU32 count); ScalarU32 count);
void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
void EmitBitCount32(EmitContext& ctx, ScalarS32 value); void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value); void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
void EmitFindSMsb32(EmitContext& ctx, ScalarS32 value); void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value);
void EmitFindUMsb32(EmitContext& ctx, ScalarU32 value); void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value);
void EmitSMin32(EmitContext& ctx, ScalarS32 a, ScalarS32 b); void EmitSMin32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitUMin32(EmitContext& ctx, ScalarU32 a, ScalarU32 b); void EmitUMin32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b);
void EmitSMax32(EmitContext& ctx, ScalarS32 a, ScalarS32 b); void EmitSMax32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b);
void EmitUMax32(EmitContext& ctx, ScalarU32 a, ScalarU32 b); void EmitUMax32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b);
void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max); void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max);
void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max); void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max);
void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs); void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs);

View File

@ -30,16 +30,16 @@ void EmitIMul32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
ctx.Add("MUL.S {}.x,{},{};", inst, a, b); ctx.Add("MUL.S {}.x,{},{};", inst, a, b);
} }
void EmitINeg32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { void EmitINeg32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
throw NotImplementedException("GLASM instruction"); ctx.Add("MOV.S {},-{};", inst, value);
} }
void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { void EmitINeg64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitIAbs32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { void EmitIAbs32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
throw NotImplementedException("GLASM instruction"); ctx.Add("ABS.S {},{};", inst, value);
} }
void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) { void EmitIAbs64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register value) {
@ -55,9 +55,8 @@ void EmitShiftLeftLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]]
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightLogical32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 base, void EmitShiftRightLogical32(EmitContext& ctx, IR::Inst& inst, ScalarU32 base, ScalarU32 shift) {
[[maybe_unused]] ScalarU32 shift) { ctx.Add("SHR.U {}.x,{},{};", inst, base, shift);
throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
@ -65,9 +64,8 @@ void EmitShiftRightLogical64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]]
throw NotImplementedException("GLASM instruction"); throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightArithmetic32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 base, void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, ScalarS32 base, ScalarS32 shift) {
[[maybe_unused]] ScalarS32 shift) { ctx.Add("SHR.S {}.x,{},{};", inst, base, shift);
throw NotImplementedException("GLASM instruction");
} }
void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base, void EmitShiftRightArithmetic64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] Register base,
@ -109,52 +107,48 @@ void EmitBitReverse32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
ctx.Add("BFR {},{};", inst, value); ctx.Add("BFR {},{};", inst, value);
} }
void EmitBitCount32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { void EmitBitCount32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
throw NotImplementedException("GLASM instruction"); ctx.Add("BTC {},{};", inst, value);
} }
void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) { void EmitBitwiseNot32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
ctx.Add("NOT.S {},{};", inst, value); ctx.Add("NOT.S {},{};", inst, value);
} }
void EmitFindSMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 value) { void EmitFindSMsb32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value) {
throw NotImplementedException("GLASM instruction"); ctx.Add("BTFM.S {},{};", inst, value);
} }
void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 value) { void EmitFindUMsb32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value) {
throw NotImplementedException("GLASM instruction"); ctx.Add("BTFM.U {},{};", inst, value);
} }
void EmitSMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a, void EmitSMin32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
[[maybe_unused]] ScalarS32 b) { ctx.Add("MIN.S {},{},{};", inst, a, b);
throw NotImplementedException("GLASM instruction");
} }
void EmitUMin32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a, void EmitUMin32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b) {
[[maybe_unused]] ScalarU32 b) { ctx.Add("MIN.U {},{},{};", inst, a, b);
throw NotImplementedException("GLASM instruction");
} }
void EmitSMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarS32 a, void EmitSMax32(EmitContext& ctx, IR::Inst& inst, ScalarS32 a, ScalarS32 b) {
[[maybe_unused]] ScalarS32 b) { ctx.Add("MAX.S {},{},{};", inst, a, b);
throw NotImplementedException("GLASM instruction");
} }
void EmitUMax32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] ScalarU32 a, void EmitUMax32(EmitContext& ctx, IR::Inst& inst, ScalarU32 a, ScalarU32 b) {
[[maybe_unused]] ScalarU32 b) { ctx.Add("MAX.U {},{},{};", inst, a, b);
throw NotImplementedException("GLASM instruction");
} }
void EmitSClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, ScalarS32 value, ScalarS32 min, ScalarS32 max) {
[[maybe_unused]] ScalarS32 value, [[maybe_unused]] ScalarS32 min, const Register ret{ctx.reg_alloc.Define(inst)};
[[maybe_unused]] ScalarS32 max) { ctx.Add("MIN.S {}.x,{},{};", ret, max, value);
throw NotImplementedException("GLASM instruction"); ctx.Add("MAX.S {}.x,{},{};", ret, ret, min);
} }
void EmitUClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst, void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, ScalarU32 value, ScalarU32 min, ScalarU32 max) {
[[maybe_unused]] ScalarU32 value, [[maybe_unused]] ScalarU32 min, const Register ret{ctx.reg_alloc.Define(inst)};
[[maybe_unused]] ScalarU32 max) { ctx.Add("MIN.U {}.x,{},{};", ret, max, value);
throw NotImplementedException("GLASM instruction"); ctx.Add("MAX.U {}.x,{},{};", ret, ret, min);
} }
void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs) { void EmitSLessThan(EmitContext& ctx, IR::Inst& inst, ScalarS32 lhs, ScalarS32 rhs) {