Add "Arm64EmitterTest" which can run on startup to play around with instructions.

This commit is contained in:
Henrik Rydgard committed 2015-04-06 18:13:26 +02:00
1 parent 6cb107d6fc
commit db0fd1042f
8 files changed
+127 -10

No files matched your search

+2 -1
View File
@@ -92,7 +92,8 @@ ARCH_FILES := \
$(SRC)/Core/MIPS/ARM64/Arm64RegCache.cpp \
$(SRC)/Core/MIPS/ARM64/Arm64RegCacheFPU.cpp \
$(SRC)/Core/Util/DisArm64.cpp \
$(SRC)/GPU/Common/VertexDecoderArm64.cpp
$(SRC)/GPU/Common/VertexDecoderArm64.cpp \
Arm64EmitterTest.cpp
endif
ifeq ($(TARGET_ARCH_ABI),armeabi)
+1 -1
View File
@@ -2,6 +2,6 @@ APP_STL := gnustl_static
APP_PLATFORM := android-9
#APP_ABI := armeabi-v7a x86
#APP_ABI := armeabi-v7a
APP_ABI := arm64-v8a
APP_ABI := arm64-v8a armeabi-v7a
APP_GNUSTL_CPP_FEATURES :=
# NDK_TOOLCHAIN_VERSION := 4.9
+88
View File
@@ -0,0 +1,88 @@
#include "base/logging.h"
#include "Arm64EmitterTest.h"
#include "Common/Arm64Emitter.h"
#include "Common/BitSet.h"
#include "Common/CPUDetect.h"
static bool functionWasCalled;
using namespace Arm64Gen;
class TestCode : public Arm64Gen::ARM64CodeBlock {
public:
TestCode();
void Generate();
const u8 *testCodePtr;
const u8 *testCodePtr2;
ARM64FloatEmitter fp;
};
TestCode::TestCode() : fp(this)
{
AllocCodeSpace(0x10000);
}
static float abc[256] = {1.0f, 2.0f, 0.0f};
static float a[4] = {1.0f, 2.0f, 3.0f, 4.5f};
static float b[4] = {1.0f, 1.0f, 1.0f, 0.5f};
static float c[4] = {0.0f, 0.0f, 0.0f, 0.0f};
static u32 x[4] = {0x04030201, 0x08070605, 0x0, 0x0};
static u32 y[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
static u32 z[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};
void TestCode::Generate()
{
testCodePtr = this->GetCodePtr();
const u32 ALL_CALLEE_SAVED = 0x7FF80000;
BitSet32 regs_to_save(ALL_CALLEE_SAVED);
const u8 *start = AlignCode16();
ABI_PushRegisters(regs_to_save);
fp.SCVTF(S0, W3, 12);
fp.SCVTF(S3, W12);
MOVI2R(X0, 1337);
ABI_PopRegisters(regs_to_save);
RET();
FlushIcache();
}
static u32 CallPtr(const void *ptr) {
return ((u32(*)())ptr)();
}
void Arm64EmitterTest() {
for (int i = 0; i < 6; i++) {
ILOG("---------------------------");
}
ILOG("---------------------------");
ILOG("Running ARM64 emitter test!");
ILOG("---------------------------");
TestCode gen;
gen.ReserveCodeSpace(0x1000);
const u8 *codeStart = gen.GetCodePtr();
gen.Generate();
u32 retval = CallPtr(gen.testCodePtr);
ILOG("Returned %d", retval);
// ILOG("ARM emitter test 1 passed if %f == 3.0! retval = %08x", abc[32 + 31], retval);
/*
ILOG("x: %08x %08x %08x %08x", x[0], x[1], x[2], x[3]);
ILOG("y: %08x %08x %08x %08x", y[0], y[1], y[2], y[3]);
ILOG("z: %08x %08x %08x %08x", z[0], z[1], z[2], z[3]);
ILOG("c: %f %f %f %f", c[0], c[1], c[2], c[3]);*/
for (int i = 0; i < 6; i++) {
ILOG("--------------------------");
}
// DisassembleArm(codeStart, gen.GetCodePtr()-codeStart);
}
+5
View File
@@ -0,0 +1,5 @@
#pragma once
// Just a test of the ARM64 emitter, playing around with running some code without having the whole emu around.
void Arm64EmitterTest();