2021-06-12 20:42:10 +00:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
|
|
|
#if PPSSPP_ARCH(AMD64) || PPSSPP_ARCH(X86)
|
|
|
|
|
2023-03-12 20:01:08 +00:00
|
|
|
#include "Common/CPUDetect.h"
|
2015-05-28 06:02:59 +00:00
|
|
|
#include "Common/x64Emitter.h"
|
2014-12-06 01:00:57 +00:00
|
|
|
#include "Core/MIPS/x86/RegCacheFPU.h"
|
|
|
|
#include "Core/MIPS/x86/Jit.h"
|
|
|
|
#include "Core/MIPS/JitCommon/JitState.h"
|
|
|
|
#include "Core/MIPS/JitCommon/JitCommon.h"
|
|
|
|
#include "Core/MIPS/MIPSVFPUUtils.h"
|
|
|
|
#include "ext/disarm.h"
|
|
|
|
|
|
|
|
#include "UnitTest.h"
|
|
|
|
|
|
|
|
static const u8 *prevStart = NULL;
|
|
|
|
|
2022-12-11 05:02:44 +00:00
|
|
|
static bool CheckLast(const Gen::XEmitter &emit, const char *comp) {
|
2022-01-30 23:15:38 +00:00
|
|
|
auto vec = DisassembleX86(prevStart, (int)(emit.GetCodePointer() - prevStart));
|
2014-12-06 01:00:57 +00:00
|
|
|
EXPECT_EQ_STR(vec[0], std::string(comp));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-12-11 05:02:44 +00:00
|
|
|
static void PrintLast(const Gen::XEmitter &emit) {
|
2016-05-01 09:13:51 +00:00
|
|
|
for (const u8 *p = prevStart; p < emit.GetCodePointer(); p++) {
|
2014-12-06 01:00:57 +00:00
|
|
|
printf("%02x ", *p);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TestX64Emitter() {
|
|
|
|
using namespace Gen;
|
|
|
|
|
|
|
|
u32 code[512];
|
|
|
|
XEmitter emitter((u8 *)code);
|
|
|
|
|
2023-03-12 20:01:08 +00:00
|
|
|
bool prevAVX = cpu_info.bAVX;
|
|
|
|
cpu_info.bAVX = true;
|
|
|
|
|
2016-05-01 09:13:51 +00:00
|
|
|
prevStart = emitter.GetCodePointer();
|
2014-12-06 01:00:57 +00:00
|
|
|
emitter.VADDSD(XMM0, XMM1, R(XMM7));
|
|
|
|
RET(CheckLast(emitter, "vaddsd xmm0, xmm1, xmm7"));
|
|
|
|
|
2016-05-01 09:13:51 +00:00
|
|
|
prevStart = emitter.GetCodePointer();
|
2014-12-06 01:00:57 +00:00
|
|
|
emitter.VMULSD(XMM0, XMM1, R(XMM7));
|
|
|
|
RET(CheckLast(emitter, "vmulsd xmm0, xmm1, xmm7"));
|
|
|
|
|
2023-03-12 20:01:08 +00:00
|
|
|
cpu_info.bAVX = prevAVX;
|
|
|
|
|
2014-12-06 01:00:57 +00:00
|
|
|
// Just for checking.
|
|
|
|
PrintLast(emitter);
|
|
|
|
return true;
|
|
|
|
}
|
2021-06-12 20:42:10 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
bool TestX64Emitter() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|