translate: Deduplicate GetDataSize() functions
Avoids defining the same function multiple times in different files.
This commit is contained in:
parent
f83cd2da9a
commit
5ebf496d4e
9 changed files with 54 additions and 140 deletions
|
@ -10,22 +10,9 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
namespace {
|
||||
boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
// FP16Ext, unimplemented.
|
||||
return boost::none;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool FPCompare(TranslatorVisitor& v, Imm<2> type, Vec Vm, Vec Vn, bool exc_on_qnan, bool cmp_with_zero) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return v.UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,20 +10,8 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
namespace {
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
return 16;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool FPCompare(TranslatorVisitor& v, Imm<2> type, Vec Vm, Cond cond, Vec Vn, Imm<4> nzcv, bool exc_on_qnan) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return v.UnallocatedEncoding();
|
||||
}
|
||||
|
|
|
@ -10,20 +10,8 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
return 16;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FCSEL_float(Imm<2> type, Vec Vm, Cond cond, Vec Vn, Vec Vd) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
|
|
@ -10,21 +10,9 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
return 16;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FCVTZS_float_fix(bool sf, Imm<2> type, Imm<6> scale, Vec Vn, Reg Rd) {
|
||||
const size_t intsize = sf ? 64 : 32;
|
||||
const auto fltsize = GetDataSize(type);
|
||||
const auto fltsize = FPGetDataSize(type);
|
||||
if (!fltsize || *fltsize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -55,7 +43,7 @@ bool TranslatorVisitor::FCVTZS_float_fix(bool sf, Imm<2> type, Imm<6> scale, Vec
|
|||
|
||||
bool TranslatorVisitor::FCVTZU_float_fix(bool sf, Imm<2> type, Imm<6> scale, Vec Vn, Reg Rd) {
|
||||
const size_t intsize = sf ? 64 : 32;
|
||||
const auto fltsize = GetDataSize(type);
|
||||
const auto fltsize = FPGetDataSize(type);
|
||||
if (!fltsize || *fltsize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
|
|
@ -11,21 +11,9 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
return 16;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::SCVTF_float_int(bool sf, Imm<2> type, Reg Rn, Vec Vd) {
|
||||
const size_t intsize = sf ? 64 : 32;
|
||||
const auto fltsize = GetDataSize(type);
|
||||
const auto fltsize = FPGetDataSize(type);
|
||||
if (!fltsize || *fltsize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -52,7 +40,7 @@ bool TranslatorVisitor::SCVTF_float_int(bool sf, Imm<2> type, Reg Rn, Vec Vd) {
|
|||
|
||||
bool TranslatorVisitor::UCVTF_float_int(bool sf, Imm<2> type, Reg Rn, Vec Vd) {
|
||||
const size_t intsize = sf ? 64 : 32;
|
||||
const auto fltsize = GetDataSize(type);
|
||||
const auto fltsize = FPGetDataSize(type);
|
||||
if (!fltsize || *fltsize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -138,7 +126,7 @@ bool TranslatorVisitor::FMOV_float_gen(bool sf, Imm<2> type, Imm<1> rmode_0, Imm
|
|||
|
||||
static bool FloaingPointConvertSignedInteger(TranslatorVisitor& v, bool sf, Imm<2> type, Vec Vn, Reg Rd, FP::RoundingMode rounding_mode) {
|
||||
const size_t intsize = sf ? 64 : 32;
|
||||
const auto fltsize = GetDataSize(type);
|
||||
const auto fltsize = FPGetDataSize(type);
|
||||
if (!fltsize || *fltsize == 16) {
|
||||
return v.UnallocatedEncoding();
|
||||
}
|
||||
|
@ -165,7 +153,7 @@ static bool FloaingPointConvertSignedInteger(TranslatorVisitor& v, bool sf, Imm<
|
|||
|
||||
static bool FloaingPointConvertUnsignedInteger(TranslatorVisitor& v, bool sf, Imm<2> type, Vec Vn, Reg Rd, FP::RoundingMode rounding_mode) {
|
||||
const size_t intsize = sf ? 64 : 32;
|
||||
const auto fltsize = GetDataSize(type);
|
||||
const auto fltsize = FPGetDataSize(type);
|
||||
if (!fltsize || *fltsize == 16) {
|
||||
return v.UnallocatedEncoding();
|
||||
}
|
||||
|
|
|
@ -10,20 +10,8 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
return 16;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FMOV_float(Imm<2> type, Vec Vn, Vec Vd) {
|
||||
const boost::optional<size_t> datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -35,7 +23,7 @@ bool TranslatorVisitor::FMOV_float(Imm<2> type, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FABS_float(Imm<2> type, Vec Vn, Vec Vd) {
|
||||
boost::optional<size_t> datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -47,7 +35,7 @@ bool TranslatorVisitor::FABS_float(Imm<2> type, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FNEG_float(Imm<2> type, Vec Vn, Vec Vd) {
|
||||
boost::optional<size_t> datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -59,7 +47,7 @@ bool TranslatorVisitor::FNEG_float(Imm<2> type, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FSQRT_float(Imm<2> type, Vec Vn, Vec Vd) {
|
||||
boost::optional<size_t> datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -71,7 +59,7 @@ bool TranslatorVisitor::FSQRT_float(Imm<2> type, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FMOV_float_imm(Imm<2> type, Imm<8> imm8, Vec Vd) {
|
||||
boost::optional<size_t> datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -109,8 +97,8 @@ bool TranslatorVisitor::FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) {
|
|||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
boost::optional<size_t> srcsize = GetDataSize(type);
|
||||
boost::optional<size_t> dstsize = GetDataSize(opc);
|
||||
const auto srcsize = FPGetDataSize(type);
|
||||
const auto dstsize = FPGetDataSize(opc);
|
||||
|
||||
if (!srcsize || !dstsize) {
|
||||
return UnallocatedEncoding();
|
||||
|
@ -152,8 +140,9 @@ bool TranslatorVisitor::FCVT_float(Imm<2> type, Imm<2> opc, Vec Vn, Vec Vd) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FloatingPointRoundToIntegral(TranslatorVisitor& v, Imm<2> type, Vec Vn, Vec Vd, FP::RoundingMode rounding_mode, bool exact) {
|
||||
const boost::optional<size_t> datasize = GetDataSize(type);
|
||||
static bool FloatingPointRoundToIntegral(TranslatorVisitor& v, Imm<2> type, Vec Vn, Vec Vd,
|
||||
FP::RoundingMode rounding_mode, bool exact) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return v.UnallocatedEncoding();
|
||||
}
|
||||
|
|
|
@ -10,21 +10,8 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
// FP16Ext, unimplemented.
|
||||
return boost::none;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FMADD_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -38,7 +25,7 @@ bool TranslatorVisitor::FMADD_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd)
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FMSUB_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -52,7 +39,7 @@ bool TranslatorVisitor::FMSUB_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd)
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FNMADD_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
@ -66,7 +53,7 @@ bool TranslatorVisitor::FNMADD_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FNMSUB_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd) {
|
||||
const auto datasize = GetDataSize(type);
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
|
|
@ -10,22 +10,9 @@
|
|||
|
||||
namespace Dynarmic::A64 {
|
||||
|
||||
static boost::optional<size_t> GetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
// FP16Ext, unimplemented.
|
||||
return boost::none;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool TranslatorVisitor::FMUL_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -39,8 +26,8 @@ bool TranslatorVisitor::FMUL_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FDIV_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -54,8 +41,8 @@ bool TranslatorVisitor::FDIV_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FADD_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -69,8 +56,8 @@ bool TranslatorVisitor::FADD_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FSUB_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -84,8 +71,8 @@ bool TranslatorVisitor::FSUB_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FMAX_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -99,8 +86,8 @@ bool TranslatorVisitor::FMAX_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FMIN_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -114,8 +101,8 @@ bool TranslatorVisitor::FMIN_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FMAXNM_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -129,8 +116,8 @@ bool TranslatorVisitor::FMAXNM_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FMINNM_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
@ -144,8 +131,8 @@ bool TranslatorVisitor::FMINNM_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
|||
}
|
||||
|
||||
bool TranslatorVisitor::FNMUL_float(Imm<2> type, Vec Vm, Vec Vn, Vec Vd) {
|
||||
auto datasize = GetDataSize(type);
|
||||
if (!datasize) {
|
||||
const auto datasize = FPGetDataSize(type);
|
||||
if (!datasize || *datasize == 16) {
|
||||
return UnallocatedEncoding();
|
||||
}
|
||||
|
||||
|
|
|
@ -1014,4 +1014,16 @@ struct TranslatorVisitor final {
|
|||
bool FNMSUB_float(Imm<2> type, Vec Vm, Vec Va, Vec Vn, Vec Vd);
|
||||
};
|
||||
|
||||
inline boost::optional<size_t> FPGetDataSize(Imm<2> type) {
|
||||
switch (type.ZeroExtend()) {
|
||||
case 0b00:
|
||||
return 32;
|
||||
case 0b01:
|
||||
return 64;
|
||||
case 0b11:
|
||||
return 16;
|
||||
}
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
} // namespace Dynarmic::A64
|
||||
|
|
Loading…
Reference in a new issue