mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-02-19 06:49:38 +00:00
A64: Implement CRC32C
This commit is contained in:
@@ -275,7 +275,7 @@ INST(LSRV, "LSRV", "z0011
|
||||
INST(ASRV, "ASRV", "z0011010110mmmmm001010nnnnnddddd")
|
||||
INST(RORV, "RORV", "z0011010110mmmmm001011nnnnnddddd")
|
||||
//INST(CRC32, "CRC32B, CRC32H, CRC32W, CRC32X", "z0011010110mmmmm0100zznnnnnddddd")
|
||||
//INST(CRC32C, "CRC32CB, CRC32CH, CRC32CW, CRC32CX", "z0011010110mmmmm0101zznnnnnddddd")
|
||||
INST(CRC32C, "CRC32CB, CRC32CH, CRC32CW, CRC32CX", "z0011010110mmmmm0101zznnnnnddddd")
|
||||
//INST(PACGA, "PACGA", "10011010110mmmmm001100nnnnnddddd")
|
||||
|
||||
// Data Processing - Register - 1 source
|
||||
|
||||
44
src/frontend/A64/translate/impl/data_processing_crc32.cpp
Normal file
44
src/frontend/A64/translate/impl/data_processing_crc32.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/* This file is part of the dynarmic project.
|
||||
* Copyright (c) 2018 MerryMage
|
||||
* This software may be used and distributed according to the terms of the GNU
|
||||
* General Public License version 2 or any later version.
|
||||
*/
|
||||
|
||||
#include "frontend/A64/translate/impl/impl.h"
|
||||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
bool TranslatorVisitor::CRC32C(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.CRC32Castagnoli8(accumulator, data);
|
||||
case 0b01:
|
||||
return ir.CRC32Castagnoli16(accumulator, data);
|
||||
case 0b10:
|
||||
return ir.CRC32Castagnoli32(accumulator, data);
|
||||
case 0b11:
|
||||
default:
|
||||
return ir.CRC32Castagnoli64(accumulator, data);
|
||||
}
|
||||
}();
|
||||
|
||||
X(32, Rd, result);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::A64
|
||||
@@ -683,6 +683,22 @@ U32 IREmitter::PackedSelect(const U32& ge, const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::PackedSelect, ge, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32Castagnoli8(const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::CRC32Castagnoli8, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32Castagnoli16(const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::CRC32Castagnoli16, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32Castagnoli32(const U32& a, const U32& b) {
|
||||
return Inst<U32>(Opcode::CRC32Castagnoli32, a, b);
|
||||
}
|
||||
|
||||
U32 IREmitter::CRC32Castagnoli64(const U32& a, const U64& b) {
|
||||
return Inst<U32>(Opcode::CRC32Castagnoli64, a, b);
|
||||
}
|
||||
|
||||
UAny IREmitter::VectorGetElement(size_t esize, const U128& a, size_t index) {
|
||||
ASSERT_MSG(esize * index < 128, "Invalid index");
|
||||
switch (esize) {
|
||||
|
||||
@@ -186,6 +186,11 @@ public:
|
||||
U32 PackedAbsDiffSumS8(const U32& a, const U32& b);
|
||||
U32 PackedSelect(const U32& ge, const U32& a, const U32& b);
|
||||
|
||||
U32 CRC32Castagnoli8(const U32& a, const U32& b);
|
||||
U32 CRC32Castagnoli16(const U32& a, const U32& b);
|
||||
U32 CRC32Castagnoli32(const U32& a, const U32& b);
|
||||
U32 CRC32Castagnoli64(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);
|
||||
U128 VectorAdd16(const U128& a, const U128& b);
|
||||
|
||||
@@ -167,6 +167,12 @@ OPCODE(PackedSaturatedSubS16, T::U32, T::U32, T::U32
|
||||
OPCODE(PackedAbsDiffSumS8, T::U32, T::U32, T::U32 )
|
||||
OPCODE(PackedSelect, T::U32, T::U32, T::U32, T::U32 )
|
||||
|
||||
// CRC instructions
|
||||
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 )
|
||||
|
||||
// Vector instructions
|
||||
OPCODE(VectorGetElement8, T::U8, T::U128, T::U8 )
|
||||
OPCODE(VectorGetElement16, T::U16, T::U128, T::U8 )
|
||||
|
||||
Reference in New Issue
Block a user