asmjit 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +5 -3
- data/asmjit.gemspec +1 -3
- data/ext/asmjit/asmjit/.editorconfig +10 -0
- data/ext/asmjit/asmjit/.github/FUNDING.yml +1 -0
- data/ext/asmjit/asmjit/.github/workflows/build-config.json +47 -0
- data/ext/asmjit/asmjit/.github/workflows/build.yml +156 -0
- data/ext/asmjit/asmjit/.gitignore +6 -0
- data/ext/asmjit/asmjit/CMakeLists.txt +611 -0
- data/ext/asmjit/asmjit/LICENSE.md +17 -0
- data/ext/asmjit/asmjit/README.md +69 -0
- data/ext/asmjit/asmjit/src/asmjit/a64.h +62 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64archtraits_p.h +81 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.cpp +5115 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64assembler.h +72 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.cpp +51 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64builder.h +57 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.cpp +60 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64compiler.h +247 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper.cpp +464 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emithelper_p.h +50 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64emitter.h +1228 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter.cpp +298 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64formatter_p.h +59 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64func.cpp +189 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64func_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64globals.h +1894 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi.cpp +278 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instapi_p.h +41 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.cpp +1957 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb.h +74 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64instdb_p.h +876 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.cpp +85 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64operand.h +312 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass.cpp +852 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64rapass_p.h +105 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/a64utils.h +179 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armformatter.cpp +143 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armformatter_p.h +44 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armglobals.h +21 -0
- data/ext/asmjit/asmjit/src/asmjit/arm/armoperand.h +621 -0
- data/ext/asmjit/asmjit/src/asmjit/arm.h +62 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-begin.h +17 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit-scope-end.h +9 -0
- data/ext/asmjit/asmjit/src/asmjit/asmjit.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/core/api-build_p.h +55 -0
- data/ext/asmjit/asmjit/src/asmjit/core/api-config.h +613 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archcommons.h +229 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archtraits.cpp +160 -0
- data/ext/asmjit/asmjit/src/asmjit/core/archtraits.h +290 -0
- data/ext/asmjit/asmjit/src/asmjit/core/assembler.cpp +406 -0
- data/ext/asmjit/asmjit/src/asmjit/core/assembler.h +129 -0
- data/ext/asmjit/asmjit/src/asmjit/core/builder.cpp +889 -0
- data/ext/asmjit/asmjit/src/asmjit/core/builder.h +1391 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codebuffer.h +113 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codeholder.cpp +1149 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codeholder.h +1035 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codewriter.cpp +175 -0
- data/ext/asmjit/asmjit/src/asmjit/core/codewriter_p.h +179 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compiler.cpp +582 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compiler.h +737 -0
- data/ext/asmjit/asmjit/src/asmjit/core/compilerdefs.h +173 -0
- data/ext/asmjit/asmjit/src/asmjit/core/constpool.cpp +363 -0
- data/ext/asmjit/asmjit/src/asmjit/core/constpool.h +250 -0
- data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.cpp +1162 -0
- data/ext/asmjit/asmjit/src/asmjit/core/cpuinfo.h +813 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emithelper.cpp +323 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emithelper_p.h +58 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitter.cpp +333 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitter.h +741 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitterutils.cpp +129 -0
- data/ext/asmjit/asmjit/src/asmjit/core/emitterutils_p.h +89 -0
- data/ext/asmjit/asmjit/src/asmjit/core/environment.cpp +46 -0
- data/ext/asmjit/asmjit/src/asmjit/core/environment.h +508 -0
- data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.cpp +14 -0
- data/ext/asmjit/asmjit/src/asmjit/core/errorhandler.h +228 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter.cpp +584 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter.h +247 -0
- data/ext/asmjit/asmjit/src/asmjit/core/formatter_p.h +34 -0
- data/ext/asmjit/asmjit/src/asmjit/core/func.cpp +286 -0
- data/ext/asmjit/asmjit/src/asmjit/core/func.h +1445 -0
- data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext.cpp +293 -0
- data/ext/asmjit/asmjit/src/asmjit/core/funcargscontext_p.h +199 -0
- data/ext/asmjit/asmjit/src/asmjit/core/globals.cpp +133 -0
- data/ext/asmjit/asmjit/src/asmjit/core/globals.h +393 -0
- data/ext/asmjit/asmjit/src/asmjit/core/inst.cpp +113 -0
- data/ext/asmjit/asmjit/src/asmjit/core/inst.h +772 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.cpp +1242 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitallocator.h +261 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.cpp +80 -0
- data/ext/asmjit/asmjit/src/asmjit/core/jitruntime.h +89 -0
- data/ext/asmjit/asmjit/src/asmjit/core/logger.cpp +69 -0
- data/ext/asmjit/asmjit/src/asmjit/core/logger.h +198 -0
- data/ext/asmjit/asmjit/src/asmjit/core/misc_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/core/operand.cpp +132 -0
- data/ext/asmjit/asmjit/src/asmjit/core/operand.h +1611 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils.cpp +84 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils.h +61 -0
- data/ext/asmjit/asmjit/src/asmjit/core/osutils_p.h +68 -0
- data/ext/asmjit/asmjit/src/asmjit/core/raassignment_p.h +418 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rabuilders_p.h +612 -0
- data/ext/asmjit/asmjit/src/asmjit/core/radefs_p.h +1204 -0
- data/ext/asmjit/asmjit/src/asmjit/core/ralocal.cpp +1166 -0
- data/ext/asmjit/asmjit/src/asmjit/core/ralocal_p.h +254 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rapass.cpp +1969 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rapass_p.h +1183 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rastack.cpp +184 -0
- data/ext/asmjit/asmjit/src/asmjit/core/rastack_p.h +171 -0
- data/ext/asmjit/asmjit/src/asmjit/core/string.cpp +559 -0
- data/ext/asmjit/asmjit/src/asmjit/core/string.h +372 -0
- data/ext/asmjit/asmjit/src/asmjit/core/support.cpp +494 -0
- data/ext/asmjit/asmjit/src/asmjit/core/support.h +1773 -0
- data/ext/asmjit/asmjit/src/asmjit/core/target.cpp +14 -0
- data/ext/asmjit/asmjit/src/asmjit/core/target.h +53 -0
- data/ext/asmjit/asmjit/src/asmjit/core/type.cpp +74 -0
- data/ext/asmjit/asmjit/src/asmjit/core/type.h +419 -0
- data/ext/asmjit/asmjit/src/asmjit/core/virtmem.cpp +722 -0
- data/ext/asmjit/asmjit/src/asmjit/core/virtmem.h +242 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zone.cpp +353 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zone.h +615 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonehash.cpp +309 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonehash.h +186 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonelist.cpp +163 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonelist.h +209 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestack.cpp +176 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestack.h +239 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonestring.h +120 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonetree.cpp +99 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonetree.h +380 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonevector.cpp +356 -0
- data/ext/asmjit/asmjit/src/asmjit/core/zonevector.h +690 -0
- data/ext/asmjit/asmjit/src/asmjit/core.h +1861 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86archtraits_p.h +148 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.cpp +5110 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86assembler.h +685 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.cpp +52 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86builder.h +351 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.cpp +61 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86compiler.h +721 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper.cpp +619 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emithelper_p.h +60 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86emitter.h +4315 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter.cpp +944 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86formatter_p.h +58 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86func.cpp +503 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86func_p.h +33 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86globals.h +2169 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi.cpp +1732 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instapi_p.h +41 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.cpp +4427 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb.h +563 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86instdb_p.h +311 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86opcode_p.h +436 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.cpp +231 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86operand.h +1085 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass.cpp +1509 -0
- data/ext/asmjit/asmjit/src/asmjit/x86/x86rapass_p.h +94 -0
- data/ext/asmjit/asmjit/src/asmjit/x86.h +93 -0
- data/ext/asmjit/asmjit/src/asmjit.natvis +245 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler.cpp +84 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler.h +85 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_a64.cpp +4006 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_x64.cpp +17833 -0
- data/ext/asmjit/asmjit/test/asmjit_test_assembler_x86.cpp +8300 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler.cpp +253 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler.h +73 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler_a64.cpp +690 -0
- data/ext/asmjit/asmjit/test/asmjit_test_compiler_x86.cpp +4317 -0
- data/ext/asmjit/asmjit/test/asmjit_test_emitters.cpp +197 -0
- data/ext/asmjit/asmjit/test/asmjit_test_instinfo.cpp +181 -0
- data/ext/asmjit/asmjit/test/asmjit_test_misc.h +257 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf.cpp +62 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf.h +61 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf_a64.cpp +699 -0
- data/ext/asmjit/asmjit/test/asmjit_test_perf_x86.cpp +5032 -0
- data/ext/asmjit/asmjit/test/asmjit_test_unit.cpp +172 -0
- data/ext/asmjit/asmjit/test/asmjit_test_x86_sections.cpp +172 -0
- data/ext/asmjit/asmjit/test/asmjitutils.h +38 -0
- data/ext/asmjit/asmjit/test/broken.cpp +312 -0
- data/ext/asmjit/asmjit/test/broken.h +148 -0
- data/ext/asmjit/asmjit/test/cmdline.h +61 -0
- data/ext/asmjit/asmjit/test/performancetimer.h +41 -0
- data/ext/asmjit/asmjit/tools/configure-makefiles.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-ninja.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-sanitizers.sh +13 -0
- data/ext/asmjit/asmjit/tools/configure-vs2019-x64.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2019-x86.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2022-x64.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-vs2022-x86.bat +2 -0
- data/ext/asmjit/asmjit/tools/configure-xcode.sh +8 -0
- data/ext/asmjit/asmjit/tools/enumgen.js +417 -0
- data/ext/asmjit/asmjit/tools/enumgen.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen-arm.js +365 -0
- data/ext/asmjit/asmjit/tools/tablegen-arm.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen-x86.js +2638 -0
- data/ext/asmjit/asmjit/tools/tablegen-x86.sh +3 -0
- data/ext/asmjit/asmjit/tools/tablegen.js +947 -0
- data/ext/asmjit/asmjit/tools/tablegen.sh +4 -0
- data/ext/asmjit/asmjit.cc +167 -30
- data/ext/asmjit/extconf.rb +9 -9
- data/lib/asmjit/version.rb +1 -1
- data/lib/asmjit.rb +14 -4
- metadata +198 -17
@@ -0,0 +1,690 @@
|
|
1
|
+
// This file is part of AsmJit project <https://asmjit.com>
|
2
|
+
//
|
3
|
+
// See asmjit.h or LICENSE.md for license and copyright information
|
4
|
+
// SPDX-License-Identifier: Zlib
|
5
|
+
|
6
|
+
#include <asmjit/core.h>
|
7
|
+
#if !defined(ASMJIT_NO_AARCH64) && ASMJIT_ARCH_ARM == 64
|
8
|
+
|
9
|
+
#include <asmjit/a64.h>
|
10
|
+
#include <stdio.h>
|
11
|
+
#include <stdlib.h>
|
12
|
+
#include <string.h>
|
13
|
+
|
14
|
+
#include "./asmjit_test_compiler.h"
|
15
|
+
|
16
|
+
using namespace asmjit;
|
17
|
+
|
18
|
+
// a64::Compiler - A64TestCase
|
19
|
+
// ===========================
|
20
|
+
|
21
|
+
class A64TestCase : public TestCase {
|
22
|
+
public:
|
23
|
+
A64TestCase(const char* name = nullptr)
|
24
|
+
: TestCase(name) {}
|
25
|
+
|
26
|
+
virtual void compile(BaseCompiler& cc) override {
|
27
|
+
compile(static_cast<a64::Compiler&>(cc));
|
28
|
+
}
|
29
|
+
|
30
|
+
virtual void compile(a64::Compiler& cc) = 0;
|
31
|
+
};
|
32
|
+
|
33
|
+
// a64::Compiler - A64Test_GpArgs
|
34
|
+
// ==============================
|
35
|
+
|
36
|
+
class A64Test_GpArgs : public A64TestCase {
|
37
|
+
public:
|
38
|
+
uint32_t _argCount;
|
39
|
+
bool _preserveFP;
|
40
|
+
|
41
|
+
A64Test_GpArgs(uint32_t argCount, bool preserveFP)
|
42
|
+
: _argCount(argCount),
|
43
|
+
_preserveFP(preserveFP) {
|
44
|
+
_name.assignFormat("GpArgs {NumArgs=%u PreserveFP=%c}", argCount, preserveFP ? 'Y' : 'N');
|
45
|
+
}
|
46
|
+
|
47
|
+
static void add(TestApp& app) {
|
48
|
+
for (uint32_t i = 0; i <= 16; i++) {
|
49
|
+
app.add(new A64Test_GpArgs(i, true));
|
50
|
+
app.add(new A64Test_GpArgs(i, false));
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
virtual void compile(a64::Compiler& cc) {
|
55
|
+
uint32_t i;
|
56
|
+
uint32_t argCount = _argCount;
|
57
|
+
|
58
|
+
FuncSignatureBuilder signature;
|
59
|
+
signature.setRetT<int>();
|
60
|
+
for (i = 0; i < argCount; i++)
|
61
|
+
signature.addArgT<int>();
|
62
|
+
|
63
|
+
FuncNode* funcNode = cc.addFunc(signature);
|
64
|
+
if (_preserveFP)
|
65
|
+
funcNode->frame().setPreservedFP();
|
66
|
+
|
67
|
+
arm::Gp sum;
|
68
|
+
|
69
|
+
if (argCount) {
|
70
|
+
for (i = 0; i < argCount; i++) {
|
71
|
+
arm::Gp iReg = cc.newInt32("i%u", i);
|
72
|
+
funcNode->setArg(i, iReg);
|
73
|
+
|
74
|
+
if (i == 0)
|
75
|
+
sum = iReg;
|
76
|
+
else
|
77
|
+
cc.add(sum, sum, iReg);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
sum = cc.newInt32("i");
|
82
|
+
cc.mov(sum, 0);
|
83
|
+
}
|
84
|
+
|
85
|
+
cc.ret(sum);
|
86
|
+
cc.endFunc();
|
87
|
+
}
|
88
|
+
|
89
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
90
|
+
typedef unsigned int U;
|
91
|
+
|
92
|
+
typedef U (*Func0)();
|
93
|
+
typedef U (*Func1)(U);
|
94
|
+
typedef U (*Func2)(U, U);
|
95
|
+
typedef U (*Func3)(U, U, U);
|
96
|
+
typedef U (*Func4)(U, U, U, U);
|
97
|
+
typedef U (*Func5)(U, U, U, U, U);
|
98
|
+
typedef U (*Func6)(U, U, U, U, U, U);
|
99
|
+
typedef U (*Func7)(U, U, U, U, U, U, U);
|
100
|
+
typedef U (*Func8)(U, U, U, U, U, U, U, U);
|
101
|
+
typedef U (*Func9)(U, U, U, U, U, U, U, U, U);
|
102
|
+
typedef U (*Func10)(U, U, U, U, U, U, U, U, U, U);
|
103
|
+
typedef U (*Func11)(U, U, U, U, U, U, U, U, U, U, U);
|
104
|
+
typedef U (*Func12)(U, U, U, U, U, U, U, U, U, U, U, U);
|
105
|
+
typedef U (*Func13)(U, U, U, U, U, U, U, U, U, U, U, U, U);
|
106
|
+
typedef U (*Func14)(U, U, U, U, U, U, U, U, U, U, U, U, U, U);
|
107
|
+
typedef U (*Func15)(U, U, U, U, U, U, U, U, U, U, U, U, U, U, U);
|
108
|
+
typedef U (*Func16)(U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U);
|
109
|
+
|
110
|
+
unsigned int resultRet = 0;
|
111
|
+
unsigned int expectRet = 0;
|
112
|
+
|
113
|
+
switch (_argCount) {
|
114
|
+
case 0:
|
115
|
+
resultRet = ptr_as_func<Func0>(_func)();
|
116
|
+
expectRet = 0;
|
117
|
+
break;
|
118
|
+
case 1:
|
119
|
+
resultRet = ptr_as_func<Func1>(_func)(1);
|
120
|
+
expectRet = 1;
|
121
|
+
break;
|
122
|
+
case 2:
|
123
|
+
resultRet = ptr_as_func<Func2>(_func)(1, 2);
|
124
|
+
expectRet = 1 + 2;
|
125
|
+
break;
|
126
|
+
case 3:
|
127
|
+
resultRet = ptr_as_func<Func3>(_func)(1, 2, 3);
|
128
|
+
expectRet = 1 + 2 + 3;
|
129
|
+
break;
|
130
|
+
case 4:
|
131
|
+
resultRet = ptr_as_func<Func4>(_func)(1, 2, 3, 4);
|
132
|
+
expectRet = 1 + 2 + 3 + 4;
|
133
|
+
break;
|
134
|
+
case 5:
|
135
|
+
resultRet = ptr_as_func<Func5>(_func)(1, 2, 3, 4, 5);
|
136
|
+
expectRet = 1 + 2 + 3 + 4 + 5;
|
137
|
+
break;
|
138
|
+
case 6:
|
139
|
+
resultRet = ptr_as_func<Func6>(_func)(1, 2, 3, 4, 5, 6);
|
140
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6;
|
141
|
+
break;
|
142
|
+
case 7:
|
143
|
+
resultRet = ptr_as_func<Func7>(_func)(1, 2, 3, 4, 5, 6, 7);
|
144
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7;
|
145
|
+
break;
|
146
|
+
case 8:
|
147
|
+
resultRet = ptr_as_func<Func8>(_func)(1, 2, 3, 4, 5, 6, 7, 8);
|
148
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8;
|
149
|
+
break;
|
150
|
+
case 9:
|
151
|
+
resultRet = ptr_as_func<Func9>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9);
|
152
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9;
|
153
|
+
break;
|
154
|
+
case 10:
|
155
|
+
resultRet = ptr_as_func<Func10>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
156
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;
|
157
|
+
break;
|
158
|
+
case 11:
|
159
|
+
resultRet = ptr_as_func<Func11>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
|
160
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11;
|
161
|
+
break;
|
162
|
+
case 12:
|
163
|
+
resultRet = ptr_as_func<Func12>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
|
164
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12;
|
165
|
+
break;
|
166
|
+
case 13:
|
167
|
+
resultRet = ptr_as_func<Func13>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
|
168
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13;
|
169
|
+
break;
|
170
|
+
case 14:
|
171
|
+
resultRet = ptr_as_func<Func14>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
|
172
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14;
|
173
|
+
break;
|
174
|
+
case 15:
|
175
|
+
resultRet = ptr_as_func<Func15>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
|
176
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15;
|
177
|
+
break;
|
178
|
+
case 16:
|
179
|
+
resultRet = ptr_as_func<Func16>(_func)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
180
|
+
expectRet = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16;
|
181
|
+
break;
|
182
|
+
}
|
183
|
+
|
184
|
+
result.assignFormat("ret={%u, %u}", resultRet >> 28, resultRet & 0x0FFFFFFFu);
|
185
|
+
expect.assignFormat("ret={%u, %u}", expectRet >> 28, expectRet & 0x0FFFFFFFu);
|
186
|
+
|
187
|
+
return resultRet == expectRet;
|
188
|
+
}
|
189
|
+
};
|
190
|
+
|
191
|
+
// a64::Compiler - A64Test_Simd1
|
192
|
+
// =============================
|
193
|
+
|
194
|
+
class A64Test_Simd1 : public A64TestCase {
|
195
|
+
public:
|
196
|
+
A64Test_Simd1()
|
197
|
+
: A64TestCase("Simd1") {}
|
198
|
+
|
199
|
+
static void add(TestApp& app) {
|
200
|
+
app.add(new A64Test_Simd1());
|
201
|
+
}
|
202
|
+
|
203
|
+
virtual void compile(a64::Compiler& cc) {
|
204
|
+
FuncNode* funcNode = cc.addFunc(FuncSignatureT<void, void*, const void*, const void*>());
|
205
|
+
|
206
|
+
arm::Gp dst = cc.newUIntPtr("dst");
|
207
|
+
arm::Gp src1 = cc.newUIntPtr("src1");
|
208
|
+
arm::Gp src2 = cc.newUIntPtr("src2");
|
209
|
+
|
210
|
+
funcNode->setArg(0, dst);
|
211
|
+
funcNode->setArg(1, src1);
|
212
|
+
funcNode->setArg(2, src2);
|
213
|
+
|
214
|
+
arm::Vec v1 = cc.newVecQ("vec1");
|
215
|
+
arm::Vec v2 = cc.newVecQ("vec2");
|
216
|
+
arm::Vec v3 = cc.newVecQ("vec3");
|
217
|
+
|
218
|
+
cc.ldr(v2, arm::ptr(src1));
|
219
|
+
cc.ldr(v3, arm::ptr(src2));
|
220
|
+
cc.add(v1.b16(), v2.b16(), v3.b16());
|
221
|
+
cc.str(v1, arm::ptr(dst));
|
222
|
+
|
223
|
+
cc.endFunc();
|
224
|
+
}
|
225
|
+
|
226
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
227
|
+
typedef void (*Func)(void*, const void*, const void*);
|
228
|
+
|
229
|
+
uint32_t dst[4];
|
230
|
+
uint32_t aSrc[4] = { 0 , 1 , 2 , 255 };
|
231
|
+
uint32_t bSrc[4] = { 99, 17, 33, 1 };
|
232
|
+
|
233
|
+
// NOTE: It's a byte-add, so uint8_t(255+1) == 0.
|
234
|
+
uint32_t ref[4] = { 99, 18, 35, 0 };
|
235
|
+
|
236
|
+
ptr_as_func<Func>(_func)(dst, aSrc, bSrc);
|
237
|
+
|
238
|
+
unsigned int resultRet = 0;
|
239
|
+
unsigned int expectRet = 0;
|
240
|
+
|
241
|
+
result.assignFormat("ret={%u, %u, %u, %u}", dst[0], dst[1], dst[2], dst[3]);
|
242
|
+
expect.assignFormat("ret={%u, %u, %u, %u}", ref[0], ref[1], ref[2], ref[3]);
|
243
|
+
|
244
|
+
return resultRet == expectRet;
|
245
|
+
}
|
246
|
+
};
|
247
|
+
|
248
|
+
// a64::Compiler - A64Test_ManyRegs
|
249
|
+
// ================================
|
250
|
+
|
251
|
+
class A64Test_ManyRegs : public A64TestCase {
|
252
|
+
public:
|
253
|
+
uint32_t _regCount;
|
254
|
+
|
255
|
+
A64Test_ManyRegs(uint32_t n)
|
256
|
+
: A64TestCase(),
|
257
|
+
_regCount(n) {
|
258
|
+
_name.assignFormat("GpRegs {NumRegs=%u}", n);
|
259
|
+
}
|
260
|
+
|
261
|
+
static void add(TestApp& app) {
|
262
|
+
for (uint32_t i = 2; i < 64; i++)
|
263
|
+
app.add(new A64Test_ManyRegs(i));
|
264
|
+
}
|
265
|
+
|
266
|
+
virtual void compile(a64::Compiler& cc) {
|
267
|
+
cc.addFunc(FuncSignatureT<int>());
|
268
|
+
|
269
|
+
arm::Gp* regs = static_cast<arm::Gp*>(malloc(_regCount * sizeof(arm::Gp)));
|
270
|
+
|
271
|
+
for (uint32_t i = 0; i < _regCount; i++) {
|
272
|
+
regs[i] = cc.newUInt32("reg%u", i);
|
273
|
+
cc.mov(regs[i], i + 1);
|
274
|
+
}
|
275
|
+
|
276
|
+
arm::Gp sum = cc.newUInt32("sum");
|
277
|
+
cc.mov(sum, 0);
|
278
|
+
|
279
|
+
for (uint32_t i = 0; i < _regCount; i++) {
|
280
|
+
cc.add(sum, sum, regs[i]);
|
281
|
+
}
|
282
|
+
|
283
|
+
cc.ret(sum);
|
284
|
+
cc.endFunc();
|
285
|
+
|
286
|
+
free(regs);
|
287
|
+
}
|
288
|
+
|
289
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
290
|
+
typedef int (*Func)(void);
|
291
|
+
Func func = ptr_as_func<Func>(_func);
|
292
|
+
|
293
|
+
result.assignFormat("ret={%d}", func());
|
294
|
+
expect.assignFormat("ret={%d}", calcSum());
|
295
|
+
|
296
|
+
return result == expect;
|
297
|
+
}
|
298
|
+
|
299
|
+
uint32_t calcSum() const {
|
300
|
+
return (_regCount | 1) * ((_regCount + 1) / 2);
|
301
|
+
}
|
302
|
+
};
|
303
|
+
|
304
|
+
// a64::Compiler - A64Test_Adr
|
305
|
+
// ===========================
|
306
|
+
|
307
|
+
class A64Test_Adr : public A64TestCase {
|
308
|
+
public:
|
309
|
+
A64Test_Adr()
|
310
|
+
: A64TestCase("Adr") {}
|
311
|
+
|
312
|
+
static void add(TestApp& app) {
|
313
|
+
app.add(new A64Test_Adr());
|
314
|
+
}
|
315
|
+
|
316
|
+
virtual void compile(a64::Compiler& cc) {
|
317
|
+
cc.addFunc(FuncSignatureT<int>());
|
318
|
+
|
319
|
+
arm::Gp addr = cc.newIntPtr("addr");
|
320
|
+
arm::Gp val = cc.newIntPtr("val");
|
321
|
+
|
322
|
+
Label L_Table = cc.newLabel();
|
323
|
+
|
324
|
+
cc.adr(addr, L_Table);
|
325
|
+
cc.ldrsw(val, arm::ptr(addr, 8));
|
326
|
+
cc.ret(val);
|
327
|
+
cc.endFunc();
|
328
|
+
|
329
|
+
cc.bind(L_Table);
|
330
|
+
cc.embedInt32(1);
|
331
|
+
cc.embedInt32(2);
|
332
|
+
cc.embedInt32(3);
|
333
|
+
cc.embedInt32(4);
|
334
|
+
cc.embedInt32(5);
|
335
|
+
}
|
336
|
+
|
337
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
338
|
+
typedef int (*Func)(void);
|
339
|
+
Func func = ptr_as_func<Func>(_func);
|
340
|
+
|
341
|
+
result.assignFormat("ret={%d}", func());
|
342
|
+
expect.assignFormat("ret={%d}", 3);
|
343
|
+
|
344
|
+
return result == expect;
|
345
|
+
}
|
346
|
+
};
|
347
|
+
|
348
|
+
// a64::Compiler - A64Test_Branch1
|
349
|
+
// ===============================
|
350
|
+
|
351
|
+
class A64Test_Branch1 : public A64TestCase {
|
352
|
+
public:
|
353
|
+
A64Test_Branch1()
|
354
|
+
: A64TestCase("Branch1") {}
|
355
|
+
|
356
|
+
static void add(TestApp& app) {
|
357
|
+
app.add(new A64Test_Branch1());
|
358
|
+
}
|
359
|
+
|
360
|
+
virtual void compile(a64::Compiler& cc) {
|
361
|
+
FuncNode* funcNode = cc.addFunc(FuncSignatureT<void, void*, size_t>());
|
362
|
+
|
363
|
+
arm::Gp p = cc.newIntPtr("p");
|
364
|
+
arm::Gp count = cc.newIntPtr("count");
|
365
|
+
arm::Gp i = cc.newIntPtr("i");
|
366
|
+
Label L = cc.newLabel();
|
367
|
+
|
368
|
+
funcNode->setArg(0, p);
|
369
|
+
funcNode->setArg(1, count);
|
370
|
+
|
371
|
+
cc.mov(i, 0);
|
372
|
+
|
373
|
+
cc.bind(L);
|
374
|
+
cc.strb(i.w(), a64::ptr(p, i));
|
375
|
+
cc.add(i, i, 1);
|
376
|
+
cc.cmp(i, count);
|
377
|
+
cc.b_ne(L);
|
378
|
+
|
379
|
+
cc.endFunc();
|
380
|
+
}
|
381
|
+
|
382
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
383
|
+
typedef void (*Func)(void* p, size_t n);
|
384
|
+
Func func = ptr_as_func<Func>(_func);
|
385
|
+
|
386
|
+
uint8_t array[16];
|
387
|
+
func(array, 16);
|
388
|
+
|
389
|
+
expect.assign("ret={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}");
|
390
|
+
|
391
|
+
result.assign("ret={");
|
392
|
+
for (size_t i = 0; i < 16; i++) {
|
393
|
+
if (i)
|
394
|
+
result.append(", ");
|
395
|
+
result.appendFormat("%d", int(array[i]));
|
396
|
+
}
|
397
|
+
result.append("}");
|
398
|
+
|
399
|
+
return result == expect;
|
400
|
+
}
|
401
|
+
};
|
402
|
+
|
403
|
+
// a64::Compiler - A64Test_Invoke1
|
404
|
+
// ===============================
|
405
|
+
|
406
|
+
class A64Test_Invoke1 : public A64TestCase {
|
407
|
+
public:
|
408
|
+
A64Test_Invoke1()
|
409
|
+
: A64TestCase("Invoke1") {}
|
410
|
+
|
411
|
+
static void add(TestApp& app) {
|
412
|
+
app.add(new A64Test_Invoke1());
|
413
|
+
}
|
414
|
+
|
415
|
+
virtual void compile(a64::Compiler& cc) {
|
416
|
+
FuncNode* funcNode = cc.addFunc(FuncSignatureT<uint32_t, uint32_t, uint32_t>());
|
417
|
+
|
418
|
+
arm::Gp x = cc.newUInt32("x");
|
419
|
+
arm::Gp y = cc.newUInt32("y");
|
420
|
+
arm::Gp r = cc.newUInt32("r");
|
421
|
+
arm::Gp fn = cc.newUIntPtr("fn");
|
422
|
+
|
423
|
+
funcNode->setArg(0, x);
|
424
|
+
funcNode->setArg(1, y);
|
425
|
+
|
426
|
+
cc.mov(fn, (uint64_t)calledFunc);
|
427
|
+
|
428
|
+
InvokeNode* invokeNode;
|
429
|
+
cc.invoke(&invokeNode, fn, FuncSignatureT<uint32_t, uint32_t, uint32_t>(CallConvId::kHost));
|
430
|
+
invokeNode->setArg(0, x);
|
431
|
+
invokeNode->setArg(1, y);
|
432
|
+
invokeNode->setRet(0, r);
|
433
|
+
|
434
|
+
cc.ret(r);
|
435
|
+
cc.endFunc();
|
436
|
+
}
|
437
|
+
|
438
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
439
|
+
typedef uint32_t (*Func)(uint32_t, uint32_t);
|
440
|
+
Func func = ptr_as_func<Func>(_func);
|
441
|
+
|
442
|
+
uint32_t x = 49;
|
443
|
+
uint32_t y = 7;
|
444
|
+
|
445
|
+
result.assignFormat("ret={%u}", func(x, y));
|
446
|
+
expect.assignFormat("ret={%u}", x - y);
|
447
|
+
|
448
|
+
return result == expect;
|
449
|
+
}
|
450
|
+
|
451
|
+
static uint32_t calledFunc(uint32_t x, uint32_t y) {
|
452
|
+
return x - y;
|
453
|
+
}
|
454
|
+
};
|
455
|
+
|
456
|
+
// a64::Compiler - A64Test_Invoke2
|
457
|
+
// ===============================
|
458
|
+
|
459
|
+
class A64Test_Invoke2 : public A64TestCase {
|
460
|
+
public:
|
461
|
+
A64Test_Invoke2()
|
462
|
+
: A64TestCase("Invoke2") {}
|
463
|
+
|
464
|
+
static void add(TestApp& app) {
|
465
|
+
app.add(new A64Test_Invoke2());
|
466
|
+
}
|
467
|
+
|
468
|
+
virtual void compile(a64::Compiler& cc) {
|
469
|
+
FuncNode* funcNode = cc.addFunc(FuncSignatureT<double, double, double>());
|
470
|
+
|
471
|
+
arm::Vec x = cc.newVecD("x");
|
472
|
+
arm::Vec y = cc.newVecD("y");
|
473
|
+
arm::Vec r = cc.newVecD("r");
|
474
|
+
arm::Gp fn = cc.newUIntPtr("fn");
|
475
|
+
|
476
|
+
funcNode->setArg(0, x);
|
477
|
+
funcNode->setArg(1, y);
|
478
|
+
cc.mov(fn, (uint64_t)calledFunc);
|
479
|
+
|
480
|
+
InvokeNode* invokeNode;
|
481
|
+
cc.invoke(&invokeNode, fn, FuncSignatureT<double, double, double>(CallConvId::kHost));
|
482
|
+
invokeNode->setArg(0, x);
|
483
|
+
invokeNode->setArg(1, y);
|
484
|
+
invokeNode->setRet(0, r);
|
485
|
+
|
486
|
+
cc.ret(r);
|
487
|
+
cc.endFunc();
|
488
|
+
}
|
489
|
+
|
490
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
491
|
+
typedef double (*Func)(double, double);
|
492
|
+
Func func = ptr_as_func<Func>(_func);
|
493
|
+
|
494
|
+
double x = 49;
|
495
|
+
double y = 7;
|
496
|
+
|
497
|
+
result.assignFormat("ret={%f}", func(x, y));
|
498
|
+
expect.assignFormat("ret={%f}", calledFunc(x, y));
|
499
|
+
|
500
|
+
return result == expect;
|
501
|
+
}
|
502
|
+
|
503
|
+
static double calledFunc(double x, double y) {
|
504
|
+
return x - y;
|
505
|
+
}
|
506
|
+
};
|
507
|
+
|
508
|
+
// a64::Compiler - A64Test_Invoke3
|
509
|
+
// ===============================
|
510
|
+
|
511
|
+
class A64Test_Invoke3 : public A64TestCase {
|
512
|
+
public:
|
513
|
+
A64Test_Invoke3()
|
514
|
+
: A64TestCase("Invoke3") {}
|
515
|
+
|
516
|
+
static void add(TestApp& app) {
|
517
|
+
app.add(new A64Test_Invoke3());
|
518
|
+
}
|
519
|
+
|
520
|
+
virtual void compile(a64::Compiler& cc) {
|
521
|
+
FuncNode* funcNode = cc.addFunc(FuncSignatureT<double, double, double>());
|
522
|
+
|
523
|
+
arm::Vec x = cc.newVecD("x");
|
524
|
+
arm::Vec y = cc.newVecD("y");
|
525
|
+
arm::Vec r = cc.newVecD("r");
|
526
|
+
arm::Gp fn = cc.newUIntPtr("fn");
|
527
|
+
|
528
|
+
funcNode->setArg(0, x);
|
529
|
+
funcNode->setArg(1, y);
|
530
|
+
cc.mov(fn, (uint64_t)calledFunc);
|
531
|
+
|
532
|
+
InvokeNode* invokeNode;
|
533
|
+
cc.invoke(&invokeNode, fn, FuncSignatureT<double, double, double>(CallConvId::kHost));
|
534
|
+
invokeNode->setArg(0, y);
|
535
|
+
invokeNode->setArg(1, x);
|
536
|
+
invokeNode->setRet(0, r);
|
537
|
+
|
538
|
+
cc.ret(r);
|
539
|
+
cc.endFunc();
|
540
|
+
}
|
541
|
+
|
542
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
543
|
+
typedef double (*Func)(double, double);
|
544
|
+
Func func = ptr_as_func<Func>(_func);
|
545
|
+
|
546
|
+
double x = 49;
|
547
|
+
double y = 7;
|
548
|
+
|
549
|
+
result.assignFormat("ret={%f}", func(x, y));
|
550
|
+
expect.assignFormat("ret={%f}", calledFunc(y, x));
|
551
|
+
|
552
|
+
return result == expect;
|
553
|
+
}
|
554
|
+
|
555
|
+
static double calledFunc(double x, double y) {
|
556
|
+
return x - y;
|
557
|
+
}
|
558
|
+
};
|
559
|
+
|
560
|
+
// a64::Compiler - A64Test_JumpTable
|
561
|
+
// =================================
|
562
|
+
|
563
|
+
class A64Test_JumpTable : public A64TestCase {
|
564
|
+
public:
|
565
|
+
bool _annotated;
|
566
|
+
|
567
|
+
A64Test_JumpTable(bool annotated)
|
568
|
+
: A64TestCase("A64Test_JumpTable"),
|
569
|
+
_annotated(annotated) {
|
570
|
+
_name.assignFormat("JumpTable {%s}", annotated ? "Annotated" : "Unknown Target");
|
571
|
+
}
|
572
|
+
|
573
|
+
enum Operator {
|
574
|
+
kOperatorAdd = 0,
|
575
|
+
kOperatorSub = 1,
|
576
|
+
kOperatorMul = 2,
|
577
|
+
kOperatorDiv = 3
|
578
|
+
};
|
579
|
+
|
580
|
+
static void add(TestApp& app) {
|
581
|
+
app.add(new A64Test_JumpTable(false));
|
582
|
+
app.add(new A64Test_JumpTable(true));
|
583
|
+
}
|
584
|
+
|
585
|
+
virtual void compile(a64::Compiler& cc) {
|
586
|
+
FuncNode* funcNode = cc.addFunc(FuncSignatureT<float, float, float, uint32_t>());
|
587
|
+
|
588
|
+
arm::Vec a = cc.newVecS("a");
|
589
|
+
arm::Vec b = cc.newVecS("b");
|
590
|
+
arm::Gp op = cc.newUInt32("op");
|
591
|
+
|
592
|
+
arm::Gp target = cc.newIntPtr("target");
|
593
|
+
arm::Gp offset = cc.newIntPtr("offset");
|
594
|
+
|
595
|
+
Label L_End = cc.newLabel();
|
596
|
+
|
597
|
+
Label L_Table = cc.newLabel();
|
598
|
+
Label L_Add = cc.newLabel();
|
599
|
+
Label L_Sub = cc.newLabel();
|
600
|
+
Label L_Mul = cc.newLabel();
|
601
|
+
Label L_Div = cc.newLabel();
|
602
|
+
|
603
|
+
funcNode->setArg(0, a);
|
604
|
+
funcNode->setArg(1, b);
|
605
|
+
funcNode->setArg(2, op);
|
606
|
+
|
607
|
+
cc.adr(target, L_Table);
|
608
|
+
cc.ldrsw(offset, arm::ptr(target, op, arm::sxtw(2)));
|
609
|
+
cc.add(target, target, offset);
|
610
|
+
|
611
|
+
// JumpAnnotation allows to annotate all possible jump targets of
|
612
|
+
// instructions where it cannot be deduced from operands.
|
613
|
+
if (_annotated) {
|
614
|
+
JumpAnnotation* annotation = cc.newJumpAnnotation();
|
615
|
+
annotation->addLabel(L_Add);
|
616
|
+
annotation->addLabel(L_Sub);
|
617
|
+
annotation->addLabel(L_Mul);
|
618
|
+
annotation->addLabel(L_Div);
|
619
|
+
cc.br(target, annotation);
|
620
|
+
}
|
621
|
+
else {
|
622
|
+
cc.br(target);
|
623
|
+
}
|
624
|
+
|
625
|
+
cc.bind(L_Add);
|
626
|
+
cc.fadd(a, a, b);
|
627
|
+
cc.b(L_End);
|
628
|
+
|
629
|
+
cc.bind(L_Sub);
|
630
|
+
cc.fsub(a, a, b);
|
631
|
+
cc.b(L_End);
|
632
|
+
|
633
|
+
cc.bind(L_Mul);
|
634
|
+
cc.fmul(a, a, b);
|
635
|
+
cc.b(L_End);
|
636
|
+
|
637
|
+
cc.bind(L_Div);
|
638
|
+
cc.fdiv(a, a, b);
|
639
|
+
|
640
|
+
cc.bind(L_End);
|
641
|
+
cc.ret(a);
|
642
|
+
cc.endFunc();
|
643
|
+
|
644
|
+
cc.bind(L_Table);
|
645
|
+
cc.embedLabelDelta(L_Add, L_Table, 4);
|
646
|
+
cc.embedLabelDelta(L_Sub, L_Table, 4);
|
647
|
+
cc.embedLabelDelta(L_Mul, L_Table, 4);
|
648
|
+
cc.embedLabelDelta(L_Div, L_Table, 4);
|
649
|
+
}
|
650
|
+
|
651
|
+
virtual bool run(void* _func, String& result, String& expect) {
|
652
|
+
typedef float (*Func)(float, float, uint32_t);
|
653
|
+
Func func = ptr_as_func<Func>(_func);
|
654
|
+
|
655
|
+
float dst[4];
|
656
|
+
float ref[4];
|
657
|
+
|
658
|
+
dst[0] = func(33.0f, 14.0f, kOperatorAdd);
|
659
|
+
dst[1] = func(33.0f, 14.0f, kOperatorSub);
|
660
|
+
dst[2] = func(10.0f, 6.0f, kOperatorMul);
|
661
|
+
dst[3] = func(80.0f, 8.0f, kOperatorDiv);
|
662
|
+
|
663
|
+
ref[0] = 47.0f;
|
664
|
+
ref[1] = 19.0f;
|
665
|
+
ref[2] = 60.0f;
|
666
|
+
ref[3] = 10.0f;
|
667
|
+
|
668
|
+
result.assignFormat("ret={%f, %f, %f, %f}", dst[0], dst[1], dst[2], dst[3]);
|
669
|
+
expect.assignFormat("ret={%f, %f, %f, %f}", ref[0], ref[1], ref[2], ref[3]);
|
670
|
+
|
671
|
+
return result == expect;
|
672
|
+
}
|
673
|
+
};
|
674
|
+
|
675
|
+
// a64::Compiler - Export
|
676
|
+
// ======================
|
677
|
+
|
678
|
+
void compiler_add_a64_tests(TestApp& app) {
|
679
|
+
app.addT<A64Test_GpArgs>();
|
680
|
+
app.addT<A64Test_ManyRegs>();
|
681
|
+
app.addT<A64Test_Simd1>();
|
682
|
+
app.addT<A64Test_Adr>();
|
683
|
+
app.addT<A64Test_Branch1>();
|
684
|
+
app.addT<A64Test_Invoke1>();
|
685
|
+
app.addT<A64Test_Invoke2>();
|
686
|
+
app.addT<A64Test_Invoke3>();
|
687
|
+
app.addT<A64Test_JumpTable>();
|
688
|
+
}
|
689
|
+
|
690
|
+
#endif // !ASMJIT_NO_AARCH64 && ASMJIT_ARCH_ARM == 64
|