diff --git a/src/dynarmic/CMakeLists.txt b/src/dynarmic/CMakeLists.txt index 5c85b08e..4cdaa34f 100644 --- a/src/dynarmic/CMakeLists.txt +++ b/src/dynarmic/CMakeLists.txt @@ -273,6 +273,7 @@ if (ARCHITECTURE STREQUAL "x86_64") backend/x64/callback.h backend/x64/constant_pool.cpp backend/x64/constant_pool.h + backend/x64/constants.h backend/x64/devirtualize.h backend/x64/emit_x64.cpp backend/x64/emit_x64.h diff --git a/src/dynarmic/backend/x64/constants.h b/src/dynarmic/backend/x64/constants.h new file mode 100644 index 00000000..a458d102 --- /dev/null +++ b/src/dynarmic/backend/x64/constants.h @@ -0,0 +1,45 @@ +/* This file is part of the dynarmic project. + * Copyright (c) 2016 MerryMage + * SPDX-License-Identifier: 0BSD + */ + +#pragma once + +#include "dynarmic/common/common_types.h" + +namespace Dynarmic::Backend::X64 { + +// Redefinition of _MM_CMPINT_* constants for use with the 'vpcmp' instruction +namespace CmpInt { +constexpr u8 Equal = 0x0; +constexpr u8 LessThan = 0x1; +constexpr u8 LessEqual = 0x2; +constexpr u8 False = 0x3; +constexpr u8 NotEqual = 0x4; +constexpr u8 NotLessThan = 0x5; +constexpr u8 GreaterEqual = 0x5; +constexpr u8 NotLessEqual = 0x6; +constexpr u8 GreaterThan = 0x6; +constexpr u8 True = 0x7; +} // namespace CmpInt + +// Used to generate ternary logic truth-tables for vpternlog +// Use these to directly refer to terms and perform binary operations upon them +// and the resulting value will be the ternary lookup table +// ex: +// (Tern::a | ~Tern::b) & Tern::c +// = 0b10100010 +// = 0xa2 +// vpternlog a, b, c, 0xa2 +// +// ~(Tern::a ^ Tern::b) & Tern::c +// = 0b10000010 +// = 0x82 +// vpternlog a, b, c, 0x82 +namespace Tern { +constexpr u8 a = 0b11110000; +constexpr u8 b = 0b11001100; +constexpr u8 c = 0b10101010; +} // namespace Tern + +} // namespace Dynarmic::Backend::X64 diff --git a/src/dynarmic/backend/x64/emit_x64_vector.cpp b/src/dynarmic/backend/x64/emit_x64_vector.cpp index f07b52a0..4615320d 100644 --- a/src/dynarmic/backend/x64/emit_x64_vector.cpp +++ b/src/dynarmic/backend/x64/emit_x64_vector.cpp @@ -12,6 +12,7 @@ #include "dynarmic/backend/x64/abi.h" #include "dynarmic/backend/x64/block_of_code.h" +#include "dynarmic/backend/x64/constants.h" #include "dynarmic/backend/x64/emit_x64.h" #include "dynarmic/common/assert.h" #include "dynarmic/common/bit_util.h" @@ -4358,7 +4359,7 @@ void EmitX64::EmitVectorTableLookup128(EmitContext& ctx, IR::Inst* inst) { // Handle vector-table 2,3 // vpcmpuble - code.vpcmpub(upper_mask, indicies, code.MConst(xword, 0x3F3F3F3F3F3F3F3F, 0x3F3F3F3F3F3F3F3F), 2); + code.vpcmpub(upper_mask, indicies, code.MConst(xword, 0x3F3F3F3F3F3F3F3F, 0x3F3F3F3F3F3F3F3F), CmpInt::LessEqual); code.kandnw(write_mask, write_mask, upper_mask); const Xbyak::Xmm xmm_table2 = ctx.reg_alloc.UseScratchXmm(table[2]); diff --git a/src/dynarmic/backend/x64/emit_x64_vector_saturation.cpp b/src/dynarmic/backend/x64/emit_x64_vector_saturation.cpp index 62b2a294..2c7b8ff5 100644 --- a/src/dynarmic/backend/x64/emit_x64_vector_saturation.cpp +++ b/src/dynarmic/backend/x64/emit_x64_vector_saturation.cpp @@ -4,6 +4,7 @@ */ #include "dynarmic/backend/x64/block_of_code.h" +#include "dynarmic/backend/x64/constants.h" #include "dynarmic/backend/x64/emit_x64.h" #include "dynarmic/common/common_types.h" #include "dynarmic/ir/microinstruction.h"