CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/android/jni/Arm64EmitterTest.cpp
Views: 1401
#include "Common/Arm64Emitter.h"1#include "Common/BitSet.h"2#include "Common/CPUDetect.h"3#include "Common/Log.h"45static bool functionWasCalled;67using namespace Arm64Gen;89class TestCode : public Arm64Gen::ARM64CodeBlock {10public:11TestCode();12void Generate();13const u8 *testCodePtr;14const u8 *testCodePtr2;15ARM64FloatEmitter fp;16};1718TestCode::TestCode() : fp(this)19{20AllocCodeSpace(0x10000);21}2223static float abc[256] = {1.0f, 2.0f, 0.0f};2425static float a[4] = {1.0f, 2.0f, 3.0f, 4.5f};26static float b[4] = {1.0f, 1.0f, 1.0f, 0.5f};27static float c[4] = {0.0f, 0.0f, 0.0f, 0.0f};2829static u32 x[4] = {0x04030201, 0x08070605, 0x0, 0x0};30static u32 y[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};31static u32 z[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF};3233void TestCode::Generate()34{35testCodePtr = this->GetCodePtr();3637const u8 *start = AlignCode16();3839uint32_t regs_to_save = Arm64Gen::ALL_CALLEE_SAVED;40uint32_t regs_to_save_fp = Arm64Gen::ALL_CALLEE_SAVED_FP;41fp.ABI_PushRegisters(regs_to_save, regs_to_save_fp);4243PUSH(X3);44POP(X3);4546PUSH2(X3, X4);47POP2(X3, X4);4849fp.SCVTF(S0, W3, 12);50fp.SCVTF(S3, W12);51MOVI2R(X0, 1337);5253fp.ABI_PopRegisters(regs_to_save, regs_to_save_fp);5455RET();5657FlushIcache();58}5960static u32 CallPtr(const void *ptr) {61return ((u32(*)())ptr)();62}6364void Arm64EmitterTest() {65return;6667for (int i = 0; i < 6; i++) {68INFO_LOG(Log::System, "---------------------------");69}70INFO_LOG(Log::System, "---------------------------");71INFO_LOG(Log::System, "Running ARM64 emitter test!");72INFO_LOG(Log::System, "---------------------------");7374TestCode gen;75gen.ReserveCodeSpace(0x1000);76const u8 *codeStart = gen.GetCodePtr();77gen.Generate();7879u32 retval = CallPtr(gen.testCodePtr);80INFO_LOG(Log::System, "Returned %d", retval);81// INFO_LOG(Log::System, "ARM emitter test 1 passed if %f == 3.0! retval = %08x", abc[32 + 31], retval);82/*83INFO_LOG(Log::System, "x: %08x %08x %08x %08x", x[0], x[1], x[2], x[3]);84INFO_LOG(Log::System, "y: %08x %08x %08x %08x", y[0], y[1], y[2], y[3]);85INFO_LOG(Log::System, "z: %08x %08x %08x %08x", z[0], z[1], z[2], z[3]);86INFO_LOG(Log::System, "c: %f %f %f %f", c[0], c[1], c[2], c[3]);*/87for (int i = 0; i < 6; i++) {88INFO_LOG(Log::System, "--------------------------");89}90// DisassembleArm(codeStart, gen.GetCodePtr()-codeStart);91}929394