A64: Implement MADD and MSUB

This commit is contained in:
Lioncash 2018-01-23 09:51:57 -05:00 committed by MerryMage
parent b7c5055d42
commit c1a25bfc2f
5 changed files with 51 additions and 2 deletions

View file

@ -64,6 +64,7 @@ add_library(dynarmic
frontend/A64/translate/impl/data_processing_bitfield.cpp frontend/A64/translate/impl/data_processing_bitfield.cpp
frontend/A64/translate/impl/data_processing_conditional_select.cpp frontend/A64/translate/impl/data_processing_conditional_select.cpp
frontend/A64/translate/impl/data_processing_logical.cpp frontend/A64/translate/impl/data_processing_logical.cpp
frontend/A64/translate/impl/data_processing_multiply.cpp
frontend/A64/translate/impl/data_processing_pcrel.cpp frontend/A64/translate/impl/data_processing_pcrel.cpp
frontend/A64/translate/impl/data_processing_register.cpp frontend/A64/translate/impl/data_processing_register.cpp
frontend/A64/translate/impl/data_processing_shift.cpp frontend/A64/translate/impl/data_processing_shift.cpp

View file

@ -337,8 +337,8 @@ INST(CSINV, "CSINV", "z1011
INST(CSNEG, "CSNEG", "z1011010100mmmmmcccc01nnnnnddddd") INST(CSNEG, "CSNEG", "z1011010100mmmmmcccc01nnnnnddddd")
// Data Processing - Register - 3 source // Data Processing - Register - 3 source
//INST(MADD, "MADD", "z0011011000mmmmm0aaaaannnnnddddd") INST(MADD, "MADD", "z0011011000mmmmm0aaaaannnnnddddd")
//INST(MSUB, "MSUB", "z0011011000mmmmm1aaaaannnnnddddd") INST(MSUB, "MSUB", "z0011011000mmmmm1aaaaannnnnddddd")
//INST(SMADDL, "SMADDL", "10011011001mmmmm0aaaaannnnnddddd") //INST(SMADDL, "SMADDL", "10011011001mmmmm0aaaaannnnnddddd")
//INST(SMSUBL, "SMSUBL", "10011011001mmmmm1aaaaannnnnddddd") //INST(SMSUBL, "SMSUBL", "10011011001mmmmm1aaaaannnnnddddd")
//INST(SMULH, "SMULH", "10011011010mmmmm011111nnnnnddddd") //INST(SMULH, "SMULH", "10011011010mmmmm011111nnnnnddddd")

View file

@ -0,0 +1,39 @@
/* 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 {
namespace A64 {
bool TranslatorVisitor::MADD(bool sf, Reg Rm, Reg Ra, Reg Rn, Reg Rd) {
const size_t datasize = sf ? 64 : 32;
const IR::U32U64 a = X(datasize, Ra);
const IR::U32U64 m = X(datasize, Rm);
const IR::U32U64 n = X(datasize, Rn);
const IR::U32U64 result = ir.Add(a, ir.Mul(n, m));
X(datasize, Rd, result);
return true;
}
bool TranslatorVisitor::MSUB(bool sf, Reg Rm, Reg Ra, Reg Rn, Reg Rd) {
const size_t datasize = sf ? 64 : 32;
const IR::U32U64 a = X(datasize, Ra);
const IR::U32U64 m = X(datasize, Rm);
const IR::U32U64 n = X(datasize, Rn);
const IR::U32U64 result = ir.Sub(a, ir.Mul(n, m));
X(datasize, Rd, result);
return true;
}
} // namespace A64
} // namespace Dynarmic

View file

@ -265,6 +265,14 @@ U64 IREmitter::Mul(const U64& a, const U64& b) {
return Inst<U64>(Opcode::Mul64, a, b); return Inst<U64>(Opcode::Mul64, a, b);
} }
U32U64 IREmitter::Mul(const U32U64& a, const U32U64& b) {
if (a.GetType() == Type::U32) {
return Inst<U32>(Opcode::Mul32, a, b);
}
return Inst<U64>(Opcode::Mul64, a, b);
}
U32 IREmitter::And(const U32& a, const U32& b) { U32 IREmitter::And(const U32& a, const U32& b) {
return Inst<U32>(Opcode::And32, a, b); return Inst<U32>(Opcode::And32, a, b);
} }

View file

@ -115,6 +115,7 @@ public:
U32U64 Sub(const U32U64& a, const U32U64& b); U32U64 Sub(const U32U64& a, const U32U64& b);
U32 Mul(const U32& a, const U32& b); U32 Mul(const U32& a, const U32& b);
U64 Mul(const U64& a, const U64& b); U64 Mul(const U64& a, const U64& b);
U32U64 Mul(const U32U64& a, const U32U64& b);
U32 And(const U32& a, const U32& b); U32 And(const U32& a, const U32& b);
U32U64 And(const U32U64& a, const U32U64& b); U32U64 And(const U32U64& a, const U32U64& b);
U32 Eor(const U32& a, const U32& b); U32 Eor(const U32& a, const U32& b);