From 614ecb70203bcb5b39539f684fdb29c23807ae1c Mon Sep 17 00:00:00 2001 From: merry Date: Sat, 26 Mar 2022 14:30:20 +0000 Subject: [PATCH] A64: Propagate AccType information to IR-level --- src/dynarmic/frontend/A64/a64_ir_emitter.cpp | 80 +++++++++---------- src/dynarmic/frontend/A64/a64_ir_emitter.h | 40 +++++----- .../frontend/A64/translate/impl/impl.cpp | 48 +++++------ src/dynarmic/ir/opcodes.inc | 40 +++++----- .../ir/opt/a64_callback_config_pass.cpp | 6 +- 5 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/dynarmic/frontend/A64/a64_ir_emitter.cpp b/src/dynarmic/frontend/A64/a64_ir_emitter.cpp index 8e9df1d6..e4ea1f5e 100644 --- a/src/dynarmic/frontend/A64/a64_ir_emitter.cpp +++ b/src/dynarmic/frontend/A64/a64_ir_emitter.cpp @@ -105,84 +105,84 @@ void IREmitter::ClearExclusive() { Inst(Opcode::A64ClearExclusive); } -IR::U8 IREmitter::ReadMemory8(const IR::U64& vaddr) { - return Inst(Opcode::A64ReadMemory8, vaddr); +IR::U8 IREmitter::ReadMemory8(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ReadMemory8, vaddr, IR::Value{acc_type}); } -IR::U16 IREmitter::ReadMemory16(const IR::U64& vaddr) { - return Inst(Opcode::A64ReadMemory16, vaddr); +IR::U16 IREmitter::ReadMemory16(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ReadMemory16, vaddr, IR::Value{acc_type}); } -IR::U32 IREmitter::ReadMemory32(const IR::U64& vaddr) { - return Inst(Opcode::A64ReadMemory32, vaddr); +IR::U32 IREmitter::ReadMemory32(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ReadMemory32, vaddr, IR::Value{acc_type}); } -IR::U64 IREmitter::ReadMemory64(const IR::U64& vaddr) { - return Inst(Opcode::A64ReadMemory64, vaddr); +IR::U64 IREmitter::ReadMemory64(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ReadMemory64, vaddr, IR::Value{acc_type}); } -IR::U128 IREmitter::ReadMemory128(const IR::U64& vaddr) { - return Inst(Opcode::A64ReadMemory128, vaddr); +IR::U128 IREmitter::ReadMemory128(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ReadMemory128, vaddr, IR::Value{acc_type}); } -IR::U8 IREmitter::ExclusiveReadMemory8(const IR::U64& vaddr) { - return Inst(Opcode::A64ExclusiveReadMemory8, vaddr); +IR::U8 IREmitter::ExclusiveReadMemory8(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveReadMemory8, vaddr, IR::Value{acc_type}); } -IR::U16 IREmitter::ExclusiveReadMemory16(const IR::U64& vaddr) { - return Inst(Opcode::A64ExclusiveReadMemory16, vaddr); +IR::U16 IREmitter::ExclusiveReadMemory16(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveReadMemory16, vaddr, IR::Value{acc_type}); } -IR::U32 IREmitter::ExclusiveReadMemory32(const IR::U64& vaddr) { - return Inst(Opcode::A64ExclusiveReadMemory32, vaddr); +IR::U32 IREmitter::ExclusiveReadMemory32(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveReadMemory32, vaddr, IR::Value{acc_type}); } -IR::U64 IREmitter::ExclusiveReadMemory64(const IR::U64& vaddr) { - return Inst(Opcode::A64ExclusiveReadMemory64, vaddr); +IR::U64 IREmitter::ExclusiveReadMemory64(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveReadMemory64, vaddr, IR::Value{acc_type}); } -IR::U128 IREmitter::ExclusiveReadMemory128(const IR::U64& vaddr) { - return Inst(Opcode::A64ExclusiveReadMemory128, vaddr); +IR::U128 IREmitter::ExclusiveReadMemory128(const IR::U64& vaddr, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveReadMemory128, vaddr, IR::Value{acc_type}); } -void IREmitter::WriteMemory8(const IR::U64& vaddr, const IR::U8& value) { - Inst(Opcode::A64WriteMemory8, vaddr, value); +void IREmitter::WriteMemory8(const IR::U64& vaddr, const IR::U8& value, IR::AccType acc_type) { + Inst(Opcode::A64WriteMemory8, vaddr, value, IR::Value{acc_type}); } -void IREmitter::WriteMemory16(const IR::U64& vaddr, const IR::U16& value) { - Inst(Opcode::A64WriteMemory16, vaddr, value); +void IREmitter::WriteMemory16(const IR::U64& vaddr, const IR::U16& value, IR::AccType acc_type) { + Inst(Opcode::A64WriteMemory16, vaddr, value, IR::Value{acc_type}); } -void IREmitter::WriteMemory32(const IR::U64& vaddr, const IR::U32& value) { - Inst(Opcode::A64WriteMemory32, vaddr, value); +void IREmitter::WriteMemory32(const IR::U64& vaddr, const IR::U32& value, IR::AccType acc_type) { + Inst(Opcode::A64WriteMemory32, vaddr, value, IR::Value{acc_type}); } -void IREmitter::WriteMemory64(const IR::U64& vaddr, const IR::U64& value) { - Inst(Opcode::A64WriteMemory64, vaddr, value); +void IREmitter::WriteMemory64(const IR::U64& vaddr, const IR::U64& value, IR::AccType acc_type) { + Inst(Opcode::A64WriteMemory64, vaddr, value, IR::Value{acc_type}); } -void IREmitter::WriteMemory128(const IR::U64& vaddr, const IR::U128& value) { - Inst(Opcode::A64WriteMemory128, vaddr, value); +void IREmitter::WriteMemory128(const IR::U64& vaddr, const IR::U128& value, IR::AccType acc_type) { + Inst(Opcode::A64WriteMemory128, vaddr, value, IR::Value{acc_type}); } -IR::U32 IREmitter::ExclusiveWriteMemory8(const IR::U64& vaddr, const IR::U8& value) { - return Inst(Opcode::A64ExclusiveWriteMemory8, vaddr, value); +IR::U32 IREmitter::ExclusiveWriteMemory8(const IR::U64& vaddr, const IR::U8& value, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveWriteMemory8, vaddr, value, IR::Value{acc_type}); } -IR::U32 IREmitter::ExclusiveWriteMemory16(const IR::U64& vaddr, const IR::U16& value) { - return Inst(Opcode::A64ExclusiveWriteMemory16, vaddr, value); +IR::U32 IREmitter::ExclusiveWriteMemory16(const IR::U64& vaddr, const IR::U16& value, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveWriteMemory16, vaddr, value, IR::Value{acc_type}); } -IR::U32 IREmitter::ExclusiveWriteMemory32(const IR::U64& vaddr, const IR::U32& value) { - return Inst(Opcode::A64ExclusiveWriteMemory32, vaddr, value); +IR::U32 IREmitter::ExclusiveWriteMemory32(const IR::U64& vaddr, const IR::U32& value, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveWriteMemory32, vaddr, value, IR::Value{acc_type}); } -IR::U32 IREmitter::ExclusiveWriteMemory64(const IR::U64& vaddr, const IR::U64& value) { - return Inst(Opcode::A64ExclusiveWriteMemory64, vaddr, value); +IR::U32 IREmitter::ExclusiveWriteMemory64(const IR::U64& vaddr, const IR::U64& value, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveWriteMemory64, vaddr, value, IR::Value{acc_type}); } -IR::U32 IREmitter::ExclusiveWriteMemory128(const IR::U64& vaddr, const IR::U128& value) { - return Inst(Opcode::A64ExclusiveWriteMemory128, vaddr, value); +IR::U32 IREmitter::ExclusiveWriteMemory128(const IR::U64& vaddr, const IR::U128& value, IR::AccType acc_type) { + return Inst(Opcode::A64ExclusiveWriteMemory128, vaddr, value, IR::Value{acc_type}); } IR::U32 IREmitter::GetW(Reg reg) { diff --git a/src/dynarmic/frontend/A64/a64_ir_emitter.h b/src/dynarmic/frontend/A64/a64_ir_emitter.h index 9928e03b..56ad7673 100644 --- a/src/dynarmic/frontend/A64/a64_ir_emitter.h +++ b/src/dynarmic/frontend/A64/a64_ir_emitter.h @@ -56,26 +56,26 @@ public: void SetTPIDR(const IR::U64& value); void ClearExclusive(); - IR::U8 ReadMemory8(const IR::U64& vaddr); - IR::U16 ReadMemory16(const IR::U64& vaddr); - IR::U32 ReadMemory32(const IR::U64& vaddr); - IR::U64 ReadMemory64(const IR::U64& vaddr); - IR::U128 ReadMemory128(const IR::U64& vaddr); - IR::U8 ExclusiveReadMemory8(const IR::U64& vaddr); - IR::U16 ExclusiveReadMemory16(const IR::U64& vaddr); - IR::U32 ExclusiveReadMemory32(const IR::U64& vaddr); - IR::U64 ExclusiveReadMemory64(const IR::U64& vaddr); - IR::U128 ExclusiveReadMemory128(const IR::U64& vaddr); - void WriteMemory8(const IR::U64& vaddr, const IR::U8& value); - void WriteMemory16(const IR::U64& vaddr, const IR::U16& value); - void WriteMemory32(const IR::U64& vaddr, const IR::U32& value); - void WriteMemory64(const IR::U64& vaddr, const IR::U64& value); - void WriteMemory128(const IR::U64& vaddr, const IR::U128& value); - IR::U32 ExclusiveWriteMemory8(const IR::U64& vaddr, const IR::U8& value); - IR::U32 ExclusiveWriteMemory16(const IR::U64& vaddr, const IR::U16& value); - IR::U32 ExclusiveWriteMemory32(const IR::U64& vaddr, const IR::U32& value); - IR::U32 ExclusiveWriteMemory64(const IR::U64& vaddr, const IR::U64& value); - IR::U32 ExclusiveWriteMemory128(const IR::U64& vaddr, const IR::U128& value); + IR::U8 ReadMemory8(const IR::U64& vaddr, IR::AccType acc_type); + IR::U16 ReadMemory16(const IR::U64& vaddr, IR::AccType acc_type); + IR::U32 ReadMemory32(const IR::U64& vaddr, IR::AccType acc_type); + IR::U64 ReadMemory64(const IR::U64& vaddr, IR::AccType acc_type); + IR::U128 ReadMemory128(const IR::U64& vaddr, IR::AccType acc_type); + IR::U8 ExclusiveReadMemory8(const IR::U64& vaddr, IR::AccType acc_type); + IR::U16 ExclusiveReadMemory16(const IR::U64& vaddr, IR::AccType acc_type); + IR::U32 ExclusiveReadMemory32(const IR::U64& vaddr, IR::AccType acc_type); + IR::U64 ExclusiveReadMemory64(const IR::U64& vaddr, IR::AccType acc_type); + IR::U128 ExclusiveReadMemory128(const IR::U64& vaddr, IR::AccType acc_type); + void WriteMemory8(const IR::U64& vaddr, const IR::U8& value, IR::AccType acc_type); + void WriteMemory16(const IR::U64& vaddr, const IR::U16& value, IR::AccType acc_type); + void WriteMemory32(const IR::U64& vaddr, const IR::U32& value, IR::AccType acc_type); + void WriteMemory64(const IR::U64& vaddr, const IR::U64& value, IR::AccType acc_type); + void WriteMemory128(const IR::U64& vaddr, const IR::U128& value, IR::AccType acc_type); + IR::U32 ExclusiveWriteMemory8(const IR::U64& vaddr, const IR::U8& value, IR::AccType acc_type); + IR::U32 ExclusiveWriteMemory16(const IR::U64& vaddr, const IR::U16& value, IR::AccType acc_type); + IR::U32 ExclusiveWriteMemory32(const IR::U64& vaddr, const IR::U32& value, IR::AccType acc_type); + IR::U32 ExclusiveWriteMemory64(const IR::U64& vaddr, const IR::U64& value, IR::AccType acc_type); + IR::U32 ExclusiveWriteMemory128(const IR::U64& vaddr, const IR::U128& value, IR::AccType acc_type); IR::U32 GetW(Reg source_reg); IR::U64 GetX(Reg source_reg); diff --git a/src/dynarmic/frontend/A64/translate/impl/impl.cpp b/src/dynarmic/frontend/A64/translate/impl/impl.cpp index 23773727..24607ef7 100644 --- a/src/dynarmic/frontend/A64/translate/impl/impl.cpp +++ b/src/dynarmic/frontend/A64/translate/impl/impl.cpp @@ -217,74 +217,74 @@ void TranslatorVisitor::Vpart_scalar(size_t bitsize, Vec vec, size_t part, IR::U } } -IR::UAnyU128 TranslatorVisitor::Mem(IR::U64 address, size_t bytesize, IR::AccType /*acc_type*/) { +IR::UAnyU128 TranslatorVisitor::Mem(IR::U64 address, size_t bytesize, IR::AccType acc_type) { switch (bytesize) { case 1: - return ir.ReadMemory8(address); + return ir.ReadMemory8(address, acc_type); case 2: - return ir.ReadMemory16(address); + return ir.ReadMemory16(address, acc_type); case 4: - return ir.ReadMemory32(address); + return ir.ReadMemory32(address, acc_type); case 8: - return ir.ReadMemory64(address); + return ir.ReadMemory64(address, acc_type); case 16: - return ir.ReadMemory128(address); + return ir.ReadMemory128(address, acc_type); default: ASSERT_FALSE("Invalid bytesize parameter {}", bytesize); } } -void TranslatorVisitor::Mem(IR::U64 address, size_t bytesize, IR::AccType /*acc_type*/, IR::UAnyU128 value) { +void TranslatorVisitor::Mem(IR::U64 address, size_t bytesize, IR::AccType acc_type, IR::UAnyU128 value) { switch (bytesize) { case 1: - ir.WriteMemory8(address, value); + ir.WriteMemory8(address, value, acc_type); return; case 2: - ir.WriteMemory16(address, value); + ir.WriteMemory16(address, value, acc_type); return; case 4: - ir.WriteMemory32(address, value); + ir.WriteMemory32(address, value, acc_type); return; case 8: - ir.WriteMemory64(address, value); + ir.WriteMemory64(address, value, acc_type); return; case 16: - ir.WriteMemory128(address, value); + ir.WriteMemory128(address, value, acc_type); return; default: ASSERT_FALSE("Invalid bytesize parameter {}", bytesize); } } -IR::UAnyU128 TranslatorVisitor::ExclusiveMem(IR::U64 address, size_t bytesize, IR::AccType /*acctype*/) { +IR::UAnyU128 TranslatorVisitor::ExclusiveMem(IR::U64 address, size_t bytesize, IR::AccType acc_type) { switch (bytesize) { case 1: - return ir.ExclusiveReadMemory8(address); + return ir.ExclusiveReadMemory8(address, acc_type); case 2: - return ir.ExclusiveReadMemory16(address); + return ir.ExclusiveReadMemory16(address, acc_type); case 4: - return ir.ExclusiveReadMemory32(address); + return ir.ExclusiveReadMemory32(address, acc_type); case 8: - return ir.ExclusiveReadMemory64(address); + return ir.ExclusiveReadMemory64(address, acc_type); case 16: - return ir.ExclusiveReadMemory128(address); + return ir.ExclusiveReadMemory128(address, acc_type); default: ASSERT_FALSE("Invalid bytesize parameter {}", bytesize); } } -IR::U32 TranslatorVisitor::ExclusiveMem(IR::U64 address, size_t bytesize, IR::AccType /*acctype*/, IR::UAnyU128 value) { +IR::U32 TranslatorVisitor::ExclusiveMem(IR::U64 address, size_t bytesize, IR::AccType acc_type, IR::UAnyU128 value) { switch (bytesize) { case 1: - return ir.ExclusiveWriteMemory8(address, value); + return ir.ExclusiveWriteMemory8(address, value, acc_type); case 2: - return ir.ExclusiveWriteMemory16(address, value); + return ir.ExclusiveWriteMemory16(address, value, acc_type); case 4: - return ir.ExclusiveWriteMemory32(address, value); + return ir.ExclusiveWriteMemory32(address, value, acc_type); case 8: - return ir.ExclusiveWriteMemory64(address, value); + return ir.ExclusiveWriteMemory64(address, value, acc_type); case 16: - return ir.ExclusiveWriteMemory128(address, value); + return ir.ExclusiveWriteMemory128(address, value, acc_type); default: ASSERT_FALSE("Invalid bytesize parameter {}", bytesize); } diff --git a/src/dynarmic/ir/opcodes.inc b/src/dynarmic/ir/opcodes.inc index d4ca86f2..cf44893b 100644 --- a/src/dynarmic/ir/opcodes.inc +++ b/src/dynarmic/ir/opcodes.inc @@ -707,26 +707,26 @@ A32OPC(ExclusiveWriteMemory64, U32, U32, // A64 Memory access A64OPC(ClearExclusive, Void, ) -A64OPC(ReadMemory8, U8, U64 ) -A64OPC(ReadMemory16, U16, U64 ) -A64OPC(ReadMemory32, U32, U64 ) -A64OPC(ReadMemory64, U64, U64 ) -A64OPC(ReadMemory128, U128, U64 ) -A64OPC(ExclusiveReadMemory8, U8, U64 ) -A64OPC(ExclusiveReadMemory16, U16, U64 ) -A64OPC(ExclusiveReadMemory32, U32, U64 ) -A64OPC(ExclusiveReadMemory64, U64, U64 ) -A64OPC(ExclusiveReadMemory128, U128, U64 ) -A64OPC(WriteMemory8, Void, U64, U8 ) -A64OPC(WriteMemory16, Void, U64, U16 ) -A64OPC(WriteMemory32, Void, U64, U32 ) -A64OPC(WriteMemory64, Void, U64, U64 ) -A64OPC(WriteMemory128, Void, U64, U128 ) -A64OPC(ExclusiveWriteMemory8, U32, U64, U8 ) -A64OPC(ExclusiveWriteMemory16, U32, U64, U16 ) -A64OPC(ExclusiveWriteMemory32, U32, U64, U32 ) -A64OPC(ExclusiveWriteMemory64, U32, U64, U64 ) -A64OPC(ExclusiveWriteMemory128, U32, U64, U128 ) +A64OPC(ReadMemory8, U8, U64, AccType ) +A64OPC(ReadMemory16, U16, U64, AccType ) +A64OPC(ReadMemory32, U32, U64, AccType ) +A64OPC(ReadMemory64, U64, U64, AccType ) +A64OPC(ReadMemory128, U128, U64, AccType ) +A64OPC(ExclusiveReadMemory8, U8, U64, AccType ) +A64OPC(ExclusiveReadMemory16, U16, U64, AccType ) +A64OPC(ExclusiveReadMemory32, U32, U64, AccType ) +A64OPC(ExclusiveReadMemory64, U64, U64, AccType ) +A64OPC(ExclusiveReadMemory128, U128, U64, AccType ) +A64OPC(WriteMemory8, Void, U64, U8, AccType ) +A64OPC(WriteMemory16, Void, U64, U16, AccType ) +A64OPC(WriteMemory32, Void, U64, U32, AccType ) +A64OPC(WriteMemory64, Void, U64, U64, AccType ) +A64OPC(WriteMemory128, Void, U64, U128, AccType ) +A64OPC(ExclusiveWriteMemory8, U32, U64, U8, AccType ) +A64OPC(ExclusiveWriteMemory16, U32, U64, U16, AccType ) +A64OPC(ExclusiveWriteMemory32, U32, U64, U32, AccType ) +A64OPC(ExclusiveWriteMemory64, U32, U64, U64, AccType ) +A64OPC(ExclusiveWriteMemory128, U32, U64, U128, AccType ) // Coprocessor A32OPC(CoprocInternalOperation, Void, CoprocInfo ) diff --git a/src/dynarmic/ir/opt/a64_callback_config_pass.cpp b/src/dynarmic/ir/opt/a64_callback_config_pass.cpp index 5535c502..f9037071 100644 --- a/src/dynarmic/ir/opt/a64_callback_config_pass.cpp +++ b/src/dynarmic/ir/opt/a64_callback_config_pass.cpp @@ -32,19 +32,19 @@ void A64CallbackConfigPass(IR::Block& block, const A64::UserConfig& conf) { const IR::U128 zero_u128 = ir.ZeroExtendToQuad(ir.Imm64(0)); while (bytes >= 16) { - ir.WriteMemory128(addr, zero_u128); + ir.WriteMemory128(addr, zero_u128, IR::AccType::DCZVA); addr = ir.Add(addr, ir.Imm64(16)); bytes -= 16; } while (bytes >= 8) { - ir.WriteMemory64(addr, ir.Imm64(0)); + ir.WriteMemory64(addr, ir.Imm64(0), IR::AccType::DCZVA); addr = ir.Add(addr, ir.Imm64(8)); bytes -= 8; } while (bytes >= 4) { - ir.WriteMemory32(addr, ir.Imm32(0)); + ir.WriteMemory32(addr, ir.Imm32(0), IR::AccType::DCZVA); addr = ir.Add(addr, ir.Imm64(4)); bytes -= 4; }