mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-03-07 22:22:56 +00:00
A64: Implement CRC32
This commit is contained in:
@@ -274,7 +274,7 @@ INST(LSLV, "LSLV", "z0011
|
||||
INST(LSRV, "LSRV", "z0011010110mmmmm001001nnnnnddddd")
|
||||
INST(ASRV, "ASRV", "z0011010110mmmmm001010nnnnnddddd")
|
||||
INST(RORV, "RORV", "z0011010110mmmmm001011nnnnnddddd")
|
||||
//INST(CRC32, "CRC32B, CRC32H, CRC32W, CRC32X", "z0011010110mmmmm0100zznnnnnddddd")
|
||||
INST(CRC32, "CRC32B, CRC32H, CRC32W, CRC32X", "z0011010110mmmmm0100zznnnnnddddd")
|
||||
INST(CRC32C, "CRC32CB, CRC32CH, CRC32CW, CRC32CX", "z0011010110mmmmm0101zznnnnnddddd")
|
||||
//INST(PACGA, "PACGA", "10011010110mmmmm001100nnnnnddddd")
|
||||
|
||||
|
||||
@@ -8,6 +8,39 @@
|
||||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
bool TranslatorVisitor::CRC32(bool sf, Reg Rm, Imm<2> sz, Reg Rn, Reg Rd) {
|
||||
const u32 integral_size = sz.ZeroExtend();
|
||||
|
||||
if (sf && integral_size != 0b11) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
if (!sf && integral_size == 0b11) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
const IR::U32 result = [&] {
|
||||
const size_t datasize = sf ? 64 : 32;
|
||||
const IR::U32 accumulator = ir.GetW(Rn);
|
||||
const IR::U32U64 data = X(datasize, Rm);
|
||||
|
||||
switch (integral_size) {
|
||||
case 0b00:
|
||||
return ir.CRC32ISO8(accumulator, data);
|
||||
case 0b01:
|
||||
return ir.CRC32ISO16(accumulator, data);
|
||||
case 0b10:
|
||||
return ir.CRC32ISO32(accumulator, data);
|
||||
case 0b11:
|
||||
default:
|
||||
return ir.CRC32ISO64(accumulator, data);
|
||||
}
|
||||
}();
|
||||
|
||||
X(32, Rd, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::CRC32C(bool sf, Reg Rm, Imm<2> sz, Reg Rn, Reg Rd) {
|
||||
const u32 integral_size = sz.ZeroExtend();
|
||||
|
||||
|
||||
@@ -699,6 +699,22 @@ U32 IREmitter::CRC32Castagnoli64(const U32& a, const U64& b) {
|
||||
return Inst<U32>(Opcode::CRC32Castagnoli64, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32ISO8(const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::CRC32ISO8, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32ISO16(const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::CRC32ISO16, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32ISO32(const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::CRC32ISO32, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32ISO64(const U32& a, const U64& b) {
|
||||
return Inst<U32>(Opcode::CRC32ISO64, a, b);
|
||||
}
|
||||
|
||||
UAny IREmitter::VectorGetElement(size_t esize, const U128& a, size_t index) {
|
||||
ASSERT_MSG(esize * index < 128, "Invalid index");
|
||||
switch (esize) {
|
||||
|
||||
@@ -190,6 +190,10 @@ public:
|
||||
U32 CRC32Castagnoli16(const U32& a, const U32& b);
|
||||
U32 CRC32Castagnoli32(const U32& a, const U32& b);
|
||||
U32 CRC32Castagnoli64(const U32& a, const U64& b);
|
||||
U32 CRC32ISO8(const U32& a, const U32& b);
|
||||
U32 CRC32ISO16(const U32& a, const U32& b);
|
||||
U32 CRC32ISO32(const U32& a, const U32& b);
|
||||
U32 CRC32ISO64(const U32& a, const U64& b);
|
||||
|
||||
UAny VectorGetElement(size_t esize, const U128& a, size_t index);
|
||||
U128 VectorAdd8(const U128& a, const U128& b);
|
||||
|
||||
@@ -173,6 +173,10 @@ OPCODE(CRC32Castagnoli8, T::U32, T::U32, T::U32
|
||||
OPCODE(CRC32Castagnoli16, T::U32, T::U32, T::U32 )
|
||||
OPCODE(CRC32Castagnoli32, T::U32, T::U32, T::U32 )
|
||||
OPCODE(CRC32Castagnoli64, T::U32, T::U32, T::U64 )
|
||||
OPCODE(CRC32ISO8, T::U32, T::U32, T::U32 )
|
||||
OPCODE(CRC32ISO16, T::U32, T::U32, T::U32 )
|
||||
OPCODE(CRC32ISO32, T::U32, T::U32, T::U32 )
|
||||
OPCODE(CRC32ISO64, T::U32, T::U32, T::U64 )
|
||||
|
||||
// Vector instructions
|
||||
OPCODE(VectorGetElement8, T::U8, T::U128, T::U8 )
|
||||
|
||||
Reference in New Issue
Block a user