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,58 @@
|
|
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
|
+
#ifndef ASMJIT_X86_X86FORMATTER_P_H_INCLUDED
|
7
|
+
#define ASMJIT_X86_X86FORMATTER_P_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/api-config.h"
|
10
|
+
#ifndef ASMJIT_NO_LOGGING
|
11
|
+
|
12
|
+
#include "../core/formatter.h"
|
13
|
+
#include "../core/string.h"
|
14
|
+
#include "../x86/x86globals.h"
|
15
|
+
|
16
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(x86)
|
17
|
+
|
18
|
+
//! \cond INTERNAL
|
19
|
+
//! \addtogroup asmjit_x86
|
20
|
+
//! \{
|
21
|
+
|
22
|
+
namespace FormatterInternal {
|
23
|
+
|
24
|
+
Error ASMJIT_CDECL formatFeature(
|
25
|
+
String& sb,
|
26
|
+
uint32_t featureId) noexcept;
|
27
|
+
|
28
|
+
Error ASMJIT_CDECL formatRegister(
|
29
|
+
String& sb,
|
30
|
+
FormatFlags flags,
|
31
|
+
const BaseEmitter* emitter,
|
32
|
+
Arch arch,
|
33
|
+
RegType regType,
|
34
|
+
uint32_t regId) noexcept;
|
35
|
+
|
36
|
+
Error ASMJIT_CDECL formatOperand(
|
37
|
+
String& sb,
|
38
|
+
FormatFlags flags,
|
39
|
+
const BaseEmitter* emitter,
|
40
|
+
Arch arch,
|
41
|
+
const Operand_& op) noexcept;
|
42
|
+
|
43
|
+
Error ASMJIT_CDECL formatInstruction(
|
44
|
+
String& sb,
|
45
|
+
FormatFlags flags,
|
46
|
+
const BaseEmitter* emitter,
|
47
|
+
Arch arch,
|
48
|
+
const BaseInst& inst, const Operand_* operands, size_t opCount) noexcept;
|
49
|
+
|
50
|
+
} // {FormatterInternal}
|
51
|
+
|
52
|
+
//! \}
|
53
|
+
//! \endcond
|
54
|
+
|
55
|
+
ASMJIT_END_SUB_NAMESPACE
|
56
|
+
|
57
|
+
#endif // !ASMJIT_NO_LOGGING
|
58
|
+
#endif // ASMJIT_X86_X86FORMATTER_P_H_INCLUDED
|
@@ -0,0 +1,503 @@
|
|
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 "../core/api-build_p.h"
|
7
|
+
#if !defined(ASMJIT_NO_X86)
|
8
|
+
|
9
|
+
#include "../x86/x86func_p.h"
|
10
|
+
#include "../x86/x86emithelper_p.h"
|
11
|
+
#include "../x86/x86operand.h"
|
12
|
+
|
13
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(x86)
|
14
|
+
|
15
|
+
namespace FuncInternal {
|
16
|
+
|
17
|
+
static inline bool shouldThreatAsCDeclIn64BitMode(CallConvId ccId) noexcept {
|
18
|
+
return ccId == CallConvId::kCDecl ||
|
19
|
+
ccId == CallConvId::kStdCall ||
|
20
|
+
ccId == CallConvId::kThisCall ||
|
21
|
+
ccId == CallConvId::kFastCall ||
|
22
|
+
ccId == CallConvId::kRegParm1 ||
|
23
|
+
ccId == CallConvId::kRegParm2 ||
|
24
|
+
ccId == CallConvId::kRegParm3;
|
25
|
+
}
|
26
|
+
|
27
|
+
ASMJIT_FAVOR_SIZE Error initCallConv(CallConv& cc, CallConvId ccId, const Environment& environment) noexcept {
|
28
|
+
constexpr uint32_t kZax = Gp::kIdAx;
|
29
|
+
constexpr uint32_t kZbx = Gp::kIdBx;
|
30
|
+
constexpr uint32_t kZcx = Gp::kIdCx;
|
31
|
+
constexpr uint32_t kZdx = Gp::kIdDx;
|
32
|
+
constexpr uint32_t kZsp = Gp::kIdSp;
|
33
|
+
constexpr uint32_t kZbp = Gp::kIdBp;
|
34
|
+
constexpr uint32_t kZsi = Gp::kIdSi;
|
35
|
+
constexpr uint32_t kZdi = Gp::kIdDi;
|
36
|
+
|
37
|
+
bool winABI = environment.isPlatformWindows() || environment.isMSVC();
|
38
|
+
|
39
|
+
cc.setArch(environment.arch());
|
40
|
+
cc.setSaveRestoreRegSize(RegGroup::kVec, 16);
|
41
|
+
cc.setSaveRestoreRegSize(RegGroup::kX86_MM, 8);
|
42
|
+
cc.setSaveRestoreRegSize(RegGroup::kX86_K, 8);
|
43
|
+
cc.setSaveRestoreAlignment(RegGroup::kVec, 16);
|
44
|
+
cc.setSaveRestoreAlignment(RegGroup::kX86_MM, 8);
|
45
|
+
cc.setSaveRestoreAlignment(RegGroup::kX86_K, 8);
|
46
|
+
|
47
|
+
if (environment.is32Bit()) {
|
48
|
+
bool isStandardCallConv = true;
|
49
|
+
|
50
|
+
cc.setSaveRestoreRegSize(RegGroup::kGp, 4);
|
51
|
+
cc.setSaveRestoreAlignment(RegGroup::kGp, 4);
|
52
|
+
|
53
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::bitMask(Gp::kIdBx, Gp::kIdSp, Gp::kIdBp, Gp::kIdSi, Gp::kIdDi));
|
54
|
+
cc.setNaturalStackAlignment(4);
|
55
|
+
|
56
|
+
switch (ccId) {
|
57
|
+
case CallConvId::kCDecl:
|
58
|
+
break;
|
59
|
+
|
60
|
+
case CallConvId::kStdCall:
|
61
|
+
cc.setFlags(CallConvFlags::kCalleePopsStack);
|
62
|
+
break;
|
63
|
+
|
64
|
+
case CallConvId::kFastCall:
|
65
|
+
cc.setFlags(CallConvFlags::kCalleePopsStack);
|
66
|
+
cc.setPassedOrder(RegGroup::kGp, kZcx, kZdx);
|
67
|
+
break;
|
68
|
+
|
69
|
+
case CallConvId::kVectorCall:
|
70
|
+
cc.setFlags(CallConvFlags::kCalleePopsStack);
|
71
|
+
cc.setPassedOrder(RegGroup::kGp, kZcx, kZdx);
|
72
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3, 4, 5);
|
73
|
+
break;
|
74
|
+
|
75
|
+
case CallConvId::kThisCall:
|
76
|
+
// NOTE: Even MINGW (starting with GCC 4.7.0) now uses __thiscall on MS Windows, so we won't bail to any
|
77
|
+
// other calling convention if __thiscall was specified.
|
78
|
+
if (winABI) {
|
79
|
+
cc.setFlags(CallConvFlags::kCalleePopsStack);
|
80
|
+
cc.setPassedOrder(RegGroup::kGp, kZcx);
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
ccId = CallConvId::kCDecl;
|
84
|
+
}
|
85
|
+
break;
|
86
|
+
|
87
|
+
case CallConvId::kRegParm1:
|
88
|
+
cc.setPassedOrder(RegGroup::kGp, kZax);
|
89
|
+
break;
|
90
|
+
|
91
|
+
case CallConvId::kRegParm2:
|
92
|
+
cc.setPassedOrder(RegGroup::kGp, kZax, kZdx);
|
93
|
+
break;
|
94
|
+
|
95
|
+
case CallConvId::kRegParm3:
|
96
|
+
cc.setPassedOrder(RegGroup::kGp, kZax, kZdx, kZcx);
|
97
|
+
break;
|
98
|
+
|
99
|
+
case CallConvId::kLightCall2:
|
100
|
+
case CallConvId::kLightCall3:
|
101
|
+
case CallConvId::kLightCall4: {
|
102
|
+
uint32_t n = uint32_t(ccId) - uint32_t(CallConvId::kLightCall2) + 2;
|
103
|
+
|
104
|
+
cc.setFlags(CallConvFlags::kPassFloatsByVec);
|
105
|
+
cc.setPassedOrder(RegGroup::kGp, kZax, kZdx, kZcx, kZsi, kZdi);
|
106
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3, 4, 5, 6, 7);
|
107
|
+
cc.setPassedOrder(RegGroup::kX86_K, 0, 1, 2, 3, 4, 5, 6, 7);
|
108
|
+
cc.setPassedOrder(RegGroup::kX86_MM, 0, 1, 2, 3, 4, 5, 6, 7);
|
109
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::lsbMask<uint32_t>(8));
|
110
|
+
cc.setPreservedRegs(RegGroup::kVec, Support::lsbMask<uint32_t>(8) & ~Support::lsbMask<uint32_t>(n));
|
111
|
+
|
112
|
+
cc.setNaturalStackAlignment(16);
|
113
|
+
isStandardCallConv = false;
|
114
|
+
break;
|
115
|
+
}
|
116
|
+
|
117
|
+
default:
|
118
|
+
return DebugUtils::errored(kErrorInvalidArgument);
|
119
|
+
}
|
120
|
+
|
121
|
+
if (isStandardCallConv) {
|
122
|
+
// MMX arguments is something where compiler vendors disagree. For example GCC and MSVC would pass first three
|
123
|
+
// via registers and the rest via stack, however Clang passes all via stack. Returning MMX registers is even
|
124
|
+
// more fun, where GCC uses MM0, but Clang uses EAX:EDX pair. I'm not sure it's something we should be worried
|
125
|
+
// about as MMX is deprecated anyway.
|
126
|
+
cc.setPassedOrder(RegGroup::kX86_MM, 0, 1, 2);
|
127
|
+
|
128
|
+
// Vector arguments (XMM|YMM|ZMM) are passed via registers. However, if the function is variadic then they have
|
129
|
+
// to be passed via stack.
|
130
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2);
|
131
|
+
|
132
|
+
// Functions with variable arguments always use stack for MM and vector arguments.
|
133
|
+
cc.addFlags(CallConvFlags::kPassVecByStackIfVA);
|
134
|
+
}
|
135
|
+
|
136
|
+
if (ccId == CallConvId::kCDecl) {
|
137
|
+
cc.addFlags(CallConvFlags::kVarArgCompatible);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
cc.setSaveRestoreRegSize(RegGroup::kGp, 8);
|
142
|
+
cc.setSaveRestoreAlignment(RegGroup::kGp, 8);
|
143
|
+
|
144
|
+
// Preprocess the calling convention into a common id as many conventions are normally ignored even by C/C++
|
145
|
+
// compilers and treated as `__cdecl`.
|
146
|
+
if (shouldThreatAsCDeclIn64BitMode(ccId))
|
147
|
+
ccId = winABI ? CallConvId::kX64Windows : CallConvId::kX64SystemV;
|
148
|
+
|
149
|
+
switch (ccId) {
|
150
|
+
case CallConvId::kX64SystemV: {
|
151
|
+
cc.setFlags(CallConvFlags::kPassFloatsByVec |
|
152
|
+
CallConvFlags::kPassMmxByXmm |
|
153
|
+
CallConvFlags::kVarArgCompatible);
|
154
|
+
cc.setNaturalStackAlignment(16);
|
155
|
+
cc.setRedZoneSize(128);
|
156
|
+
cc.setPassedOrder(RegGroup::kGp, kZdi, kZsi, kZdx, kZcx, 8, 9);
|
157
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3, 4, 5, 6, 7);
|
158
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::bitMask(kZbx, kZsp, kZbp, 12, 13, 14, 15));
|
159
|
+
break;
|
160
|
+
}
|
161
|
+
|
162
|
+
case CallConvId::kX64Windows: {
|
163
|
+
cc.setStrategy(CallConvStrategy::kX64Windows);
|
164
|
+
cc.setFlags(CallConvFlags::kPassFloatsByVec |
|
165
|
+
CallConvFlags::kIndirectVecArgs |
|
166
|
+
CallConvFlags::kPassMmxByGp |
|
167
|
+
CallConvFlags::kVarArgCompatible);
|
168
|
+
cc.setNaturalStackAlignment(16);
|
169
|
+
// Maximum 4 arguments in registers, each adds 8 bytes to the spill zone.
|
170
|
+
cc.setSpillZoneSize(4 * 8);
|
171
|
+
cc.setPassedOrder(RegGroup::kGp, kZcx, kZdx, 8, 9);
|
172
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3);
|
173
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::bitMask(kZbx, kZsp, kZbp, kZsi, kZdi, 12, 13, 14, 15));
|
174
|
+
cc.setPreservedRegs(RegGroup::kVec, Support::bitMask(6, 7, 8, 9, 10, 11, 12, 13, 14, 15));
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
|
178
|
+
case CallConvId::kVectorCall: {
|
179
|
+
cc.setStrategy(CallConvStrategy::kX64VectorCall);
|
180
|
+
cc.setFlags(CallConvFlags::kPassFloatsByVec |
|
181
|
+
CallConvFlags::kPassMmxByGp );
|
182
|
+
cc.setNaturalStackAlignment(16);
|
183
|
+
// Maximum 6 arguments in registers, each adds 8 bytes to the spill zone.
|
184
|
+
cc.setSpillZoneSize(6 * 8);
|
185
|
+
cc.setPassedOrder(RegGroup::kGp, kZcx, kZdx, 8, 9);
|
186
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3, 4, 5);
|
187
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::bitMask(kZbx, kZsp, kZbp, kZsi, kZdi, 12, 13, 14, 15));
|
188
|
+
cc.setPreservedRegs(RegGroup::kVec, Support::bitMask(6, 7, 8, 9, 10, 11, 12, 13, 14, 15));
|
189
|
+
break;
|
190
|
+
}
|
191
|
+
|
192
|
+
case CallConvId::kLightCall2:
|
193
|
+
case CallConvId::kLightCall3:
|
194
|
+
case CallConvId::kLightCall4: {
|
195
|
+
uint32_t n = uint32_t(ccId) - uint32_t(CallConvId::kLightCall2) + 2;
|
196
|
+
|
197
|
+
cc.setFlags(CallConvFlags::kPassFloatsByVec);
|
198
|
+
cc.setNaturalStackAlignment(16);
|
199
|
+
cc.setPassedOrder(RegGroup::kGp, kZax, kZdx, kZcx, kZsi, kZdi);
|
200
|
+
cc.setPassedOrder(RegGroup::kVec, 0, 1, 2, 3, 4, 5, 6, 7);
|
201
|
+
cc.setPassedOrder(RegGroup::kX86_K, 0, 1, 2, 3, 4, 5, 6, 7);
|
202
|
+
cc.setPassedOrder(RegGroup::kX86_MM, 0, 1, 2, 3, 4, 5, 6, 7);
|
203
|
+
|
204
|
+
cc.setPreservedRegs(RegGroup::kGp, Support::lsbMask<uint32_t>(16));
|
205
|
+
cc.setPreservedRegs(RegGroup::kVec, ~Support::lsbMask<uint32_t>(n));
|
206
|
+
break;
|
207
|
+
}
|
208
|
+
|
209
|
+
default:
|
210
|
+
return DebugUtils::errored(kErrorInvalidArgument);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
cc.setId(ccId);
|
215
|
+
return kErrorOk;
|
216
|
+
}
|
217
|
+
|
218
|
+
ASMJIT_FAVOR_SIZE void unpackValues(FuncDetail& func, FuncValuePack& pack) noexcept {
|
219
|
+
TypeId typeId = pack[0].typeId();
|
220
|
+
switch (typeId) {
|
221
|
+
case TypeId::kInt64:
|
222
|
+
case TypeId::kUInt64: {
|
223
|
+
if (Environment::is32Bit(func.callConv().arch())) {
|
224
|
+
// Convert a 64-bit return value to two 32-bit return values.
|
225
|
+
pack[0].initTypeId(TypeId::kUInt32);
|
226
|
+
pack[1].initTypeId(TypeId(uint32_t(typeId) - 2));
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
break;
|
230
|
+
}
|
231
|
+
|
232
|
+
default: {
|
233
|
+
break;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
ASMJIT_FAVOR_SIZE Error initFuncDetail(FuncDetail& func, const FuncSignature& signature, uint32_t registerSize) noexcept {
|
239
|
+
const CallConv& cc = func.callConv();
|
240
|
+
Arch arch = cc.arch();
|
241
|
+
uint32_t stackOffset = cc._spillZoneSize;
|
242
|
+
uint32_t argCount = func.argCount();
|
243
|
+
|
244
|
+
// Up to two return values can be returned in GP registers.
|
245
|
+
static const uint8_t gpReturnIndexes[4] = {
|
246
|
+
uint8_t(Gp::kIdAx),
|
247
|
+
uint8_t(Gp::kIdDx),
|
248
|
+
uint8_t(BaseReg::kIdBad),
|
249
|
+
uint8_t(BaseReg::kIdBad)
|
250
|
+
};
|
251
|
+
|
252
|
+
if (func.hasRet()) {
|
253
|
+
unpackValues(func, func._rets);
|
254
|
+
for (uint32_t valueIndex = 0; valueIndex < Globals::kMaxValuePack; valueIndex++) {
|
255
|
+
TypeId typeId = func._rets[valueIndex].typeId();
|
256
|
+
|
257
|
+
// Terminate at the first void type (end of the pack).
|
258
|
+
if (typeId == TypeId::kVoid)
|
259
|
+
break;
|
260
|
+
|
261
|
+
switch (typeId) {
|
262
|
+
case TypeId::kInt64:
|
263
|
+
case TypeId::kUInt64: {
|
264
|
+
if (gpReturnIndexes[valueIndex] != BaseReg::kIdBad)
|
265
|
+
func._rets[valueIndex].initReg(RegType::kX86_Gpq, gpReturnIndexes[valueIndex], typeId);
|
266
|
+
else
|
267
|
+
return DebugUtils::errored(kErrorInvalidState);
|
268
|
+
break;
|
269
|
+
}
|
270
|
+
|
271
|
+
case TypeId::kInt8:
|
272
|
+
case TypeId::kInt16:
|
273
|
+
case TypeId::kInt32: {
|
274
|
+
if (gpReturnIndexes[valueIndex] != BaseReg::kIdBad)
|
275
|
+
func._rets[valueIndex].initReg(RegType::kX86_Gpd, gpReturnIndexes[valueIndex], TypeId::kInt32);
|
276
|
+
else
|
277
|
+
return DebugUtils::errored(kErrorInvalidState);
|
278
|
+
break;
|
279
|
+
}
|
280
|
+
|
281
|
+
case TypeId::kUInt8:
|
282
|
+
case TypeId::kUInt16:
|
283
|
+
case TypeId::kUInt32: {
|
284
|
+
if (gpReturnIndexes[valueIndex] != BaseReg::kIdBad)
|
285
|
+
func._rets[valueIndex].initReg(RegType::kX86_Gpd, gpReturnIndexes[valueIndex], TypeId::kUInt32);
|
286
|
+
else
|
287
|
+
return DebugUtils::errored(kErrorInvalidState);
|
288
|
+
break;
|
289
|
+
}
|
290
|
+
|
291
|
+
case TypeId::kFloat32:
|
292
|
+
case TypeId::kFloat64: {
|
293
|
+
RegType regType = Environment::is32Bit(arch) ? RegType::kX86_St : RegType::kX86_Xmm;
|
294
|
+
func._rets[valueIndex].initReg(regType, valueIndex, typeId);
|
295
|
+
break;
|
296
|
+
}
|
297
|
+
|
298
|
+
case TypeId::kFloat80: {
|
299
|
+
// 80-bit floats are always returned by FP0.
|
300
|
+
func._rets[valueIndex].initReg(RegType::kX86_St, valueIndex, typeId);
|
301
|
+
break;
|
302
|
+
}
|
303
|
+
|
304
|
+
case TypeId::kMmx32:
|
305
|
+
case TypeId::kMmx64: {
|
306
|
+
// MM registers are returned through XMM (SystemV) or GPQ (Win64).
|
307
|
+
RegType regType = RegType::kX86_Mm;
|
308
|
+
uint32_t regIndex = valueIndex;
|
309
|
+
if (Environment::is64Bit(arch)) {
|
310
|
+
regType = cc.strategy() == CallConvStrategy::kDefault ? RegType::kX86_Xmm : RegType::kX86_Gpq;
|
311
|
+
regIndex = cc.strategy() == CallConvStrategy::kDefault ? valueIndex : gpReturnIndexes[valueIndex];
|
312
|
+
|
313
|
+
if (regIndex == BaseReg::kIdBad)
|
314
|
+
return DebugUtils::errored(kErrorInvalidState);
|
315
|
+
}
|
316
|
+
|
317
|
+
func._rets[valueIndex].initReg(regType, regIndex, typeId);
|
318
|
+
break;
|
319
|
+
}
|
320
|
+
|
321
|
+
default: {
|
322
|
+
func._rets[valueIndex].initReg(vecTypeIdToRegType(typeId), valueIndex, typeId);
|
323
|
+
break;
|
324
|
+
}
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
switch (cc.strategy()) {
|
330
|
+
case CallConvStrategy::kDefault: {
|
331
|
+
uint32_t gpzPos = 0;
|
332
|
+
uint32_t vecPos = 0;
|
333
|
+
|
334
|
+
for (uint32_t argIndex = 0; argIndex < argCount; argIndex++) {
|
335
|
+
unpackValues(func, func._args[argIndex]);
|
336
|
+
|
337
|
+
for (uint32_t valueIndex = 0; valueIndex < Globals::kMaxValuePack; valueIndex++) {
|
338
|
+
FuncValue& arg = func._args[argIndex][valueIndex];
|
339
|
+
|
340
|
+
// Terminate if there are no more arguments in the pack.
|
341
|
+
if (!arg)
|
342
|
+
break;
|
343
|
+
|
344
|
+
TypeId typeId = arg.typeId();
|
345
|
+
|
346
|
+
if (TypeUtils::isInt(typeId)) {
|
347
|
+
uint32_t regId = BaseReg::kIdBad;
|
348
|
+
|
349
|
+
if (gpzPos < CallConv::kMaxRegArgsPerGroup)
|
350
|
+
regId = cc._passedOrder[RegGroup::kGp].id[gpzPos];
|
351
|
+
|
352
|
+
if (regId != BaseReg::kIdBad) {
|
353
|
+
RegType regType = typeId <= TypeId::kUInt32 ? RegType::kX86_Gpd : RegType::kX86_Gpq;
|
354
|
+
arg.assignRegData(regType, regId);
|
355
|
+
func.addUsedRegs(RegGroup::kGp, Support::bitMask(regId));
|
356
|
+
gpzPos++;
|
357
|
+
}
|
358
|
+
else {
|
359
|
+
uint32_t size = Support::max<uint32_t>(TypeUtils::sizeOf(typeId), registerSize);
|
360
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
361
|
+
stackOffset += size;
|
362
|
+
}
|
363
|
+
continue;
|
364
|
+
}
|
365
|
+
|
366
|
+
if (TypeUtils::isFloat(typeId) || TypeUtils::isVec(typeId)) {
|
367
|
+
uint32_t regId = BaseReg::kIdBad;
|
368
|
+
|
369
|
+
if (vecPos < CallConv::kMaxRegArgsPerGroup)
|
370
|
+
regId = cc._passedOrder[RegGroup::kVec].id[vecPos];
|
371
|
+
|
372
|
+
if (TypeUtils::isFloat(typeId)) {
|
373
|
+
// If this is a float, but `kFlagPassFloatsByVec` is false, we have to use stack instead. This should
|
374
|
+
// be only used by 32-bit calling conventions.
|
375
|
+
if (!cc.hasFlag(CallConvFlags::kPassFloatsByVec))
|
376
|
+
regId = BaseReg::kIdBad;
|
377
|
+
}
|
378
|
+
else {
|
379
|
+
// Pass vector registers via stack if this is a variable arguments function. This should be only used
|
380
|
+
// by 32-bit calling conventions.
|
381
|
+
if (signature.hasVarArgs() && cc.hasFlag(CallConvFlags::kPassVecByStackIfVA))
|
382
|
+
regId = BaseReg::kIdBad;
|
383
|
+
}
|
384
|
+
|
385
|
+
if (regId != BaseReg::kIdBad) {
|
386
|
+
arg.initTypeId(typeId);
|
387
|
+
arg.assignRegData(vecTypeIdToRegType(typeId), regId);
|
388
|
+
func.addUsedRegs(RegGroup::kVec, Support::bitMask(regId));
|
389
|
+
vecPos++;
|
390
|
+
}
|
391
|
+
else {
|
392
|
+
uint32_t size = TypeUtils::sizeOf(typeId);
|
393
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
394
|
+
stackOffset += size;
|
395
|
+
}
|
396
|
+
continue;
|
397
|
+
}
|
398
|
+
}
|
399
|
+
}
|
400
|
+
break;
|
401
|
+
}
|
402
|
+
|
403
|
+
case CallConvStrategy::kX64Windows:
|
404
|
+
case CallConvStrategy::kX64VectorCall: {
|
405
|
+
// Both X64 and VectorCall behave similarly - arguments are indexed from left to right. The position of the
|
406
|
+
// argument determines in which register the argument is allocated, so it's either GP or one of XMM/YMM/ZMM
|
407
|
+
// registers.
|
408
|
+
//
|
409
|
+
// [ X64 ] [VecCall]
|
410
|
+
// Index: #0 #1 #2 #3 #4 #5
|
411
|
+
//
|
412
|
+
// GP : RCX RDX R8 R9
|
413
|
+
// VEC : XMM0 XMM1 XMM2 XMM3 XMM4 XMM5
|
414
|
+
//
|
415
|
+
// For example function `f(int a, double b, int c, double d)` will be:
|
416
|
+
//
|
417
|
+
// (a) (b) (c) (d)
|
418
|
+
// RCX XMM1 R8 XMM3
|
419
|
+
//
|
420
|
+
// Unused vector registers are used by HVA.
|
421
|
+
bool isVectorCall = (cc.strategy() == CallConvStrategy::kX64VectorCall);
|
422
|
+
|
423
|
+
for (uint32_t argIndex = 0; argIndex < argCount; argIndex++) {
|
424
|
+
unpackValues(func, func._args[argIndex]);
|
425
|
+
|
426
|
+
for (uint32_t valueIndex = 0; valueIndex < Globals::kMaxValuePack; valueIndex++) {
|
427
|
+
FuncValue& arg = func._args[argIndex][valueIndex];
|
428
|
+
|
429
|
+
// Terminate if there are no more arguments in the pack.
|
430
|
+
if (!arg)
|
431
|
+
break;
|
432
|
+
|
433
|
+
TypeId typeId = arg.typeId();
|
434
|
+
uint32_t size = TypeUtils::sizeOf(typeId);
|
435
|
+
|
436
|
+
if (TypeUtils::isInt(typeId) || TypeUtils::isMmx(typeId)) {
|
437
|
+
uint32_t regId = BaseReg::kIdBad;
|
438
|
+
|
439
|
+
if (argIndex < CallConv::kMaxRegArgsPerGroup)
|
440
|
+
regId = cc._passedOrder[RegGroup::kGp].id[argIndex];
|
441
|
+
|
442
|
+
if (regId != BaseReg::kIdBad) {
|
443
|
+
RegType regType = size <= 4 && !TypeUtils::isMmx(typeId) ? RegType::kX86_Gpd : RegType::kX86_Gpq;
|
444
|
+
arg.assignRegData(regType, regId);
|
445
|
+
func.addUsedRegs(RegGroup::kGp, Support::bitMask(regId));
|
446
|
+
}
|
447
|
+
else {
|
448
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
449
|
+
stackOffset += 8;
|
450
|
+
}
|
451
|
+
continue;
|
452
|
+
}
|
453
|
+
|
454
|
+
if (TypeUtils::isFloat(typeId) || TypeUtils::isVec(typeId)) {
|
455
|
+
uint32_t regId = BaseReg::kIdBad;
|
456
|
+
|
457
|
+
if (argIndex < CallConv::kMaxRegArgsPerGroup)
|
458
|
+
regId = cc._passedOrder[RegGroup::kVec].id[argIndex];
|
459
|
+
|
460
|
+
if (regId != BaseReg::kIdBad) {
|
461
|
+
// X64-ABI doesn't allow vector types (XMM|YMM|ZMM) to be passed via registers, however, VectorCall
|
462
|
+
// was designed for that purpose.
|
463
|
+
if (TypeUtils::isFloat(typeId) || isVectorCall) {
|
464
|
+
RegType regType = vecTypeIdToRegType(typeId);
|
465
|
+
arg.assignRegData(regType, regId);
|
466
|
+
func.addUsedRegs(RegGroup::kVec, Support::bitMask(regId));
|
467
|
+
continue;
|
468
|
+
}
|
469
|
+
}
|
470
|
+
|
471
|
+
// Passed via stack if the argument is float/double or indirectly. The trap is - if the argument is
|
472
|
+
// passed indirectly, the address can be passed via register, if the argument's index has GP one.
|
473
|
+
if (TypeUtils::isFloat(typeId)) {
|
474
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
475
|
+
}
|
476
|
+
else {
|
477
|
+
uint32_t gpRegId = cc._passedOrder[RegGroup::kGp].id[argIndex];
|
478
|
+
if (gpRegId != BaseReg::kIdBad)
|
479
|
+
arg.assignRegData(RegType::kX86_Gpq, gpRegId);
|
480
|
+
else
|
481
|
+
arg.assignStackOffset(int32_t(stackOffset));
|
482
|
+
arg.addFlags(FuncValue::kFlagIsIndirect);
|
483
|
+
}
|
484
|
+
|
485
|
+
// Always 8 bytes (float/double/pointer).
|
486
|
+
stackOffset += 8;
|
487
|
+
continue;
|
488
|
+
}
|
489
|
+
}
|
490
|
+
}
|
491
|
+
break;
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
495
|
+
func._argStackSize = stackOffset;
|
496
|
+
return kErrorOk;
|
497
|
+
}
|
498
|
+
|
499
|
+
} // {FuncInternal}
|
500
|
+
|
501
|
+
ASMJIT_END_SUB_NAMESPACE
|
502
|
+
|
503
|
+
#endif // !ASMJIT_NO_X86
|
@@ -0,0 +1,33 @@
|
|
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
|
+
#ifndef ASMJIT_X86_X86FUNC_P_H_INCLUDED
|
7
|
+
#define ASMJIT_X86_X86FUNC_P_H_INCLUDED
|
8
|
+
|
9
|
+
#include "../core/func.h"
|
10
|
+
|
11
|
+
ASMJIT_BEGIN_SUB_NAMESPACE(x86)
|
12
|
+
|
13
|
+
//! \cond INTERNAL
|
14
|
+
//! \addtogroup asmjit_x86
|
15
|
+
//! \{
|
16
|
+
|
17
|
+
//! X86-specific function API (calling conventions and other utilities).
|
18
|
+
namespace FuncInternal {
|
19
|
+
|
20
|
+
//! Initialize `CallConv` structure (X86 specific).
|
21
|
+
Error initCallConv(CallConv& cc, CallConvId ccId, const Environment& environment) noexcept;
|
22
|
+
|
23
|
+
//! Initialize `FuncDetail` (X86 specific).
|
24
|
+
Error initFuncDetail(FuncDetail& func, const FuncSignature& signature, uint32_t registerSize) noexcept;
|
25
|
+
|
26
|
+
} // {FuncInternal}
|
27
|
+
|
28
|
+
//! \}
|
29
|
+
//! \endcond
|
30
|
+
|
31
|
+
ASMJIT_END_SUB_NAMESPACE
|
32
|
+
|
33
|
+
#endif // ASMJIT_X86_X86FUNC_P_H_INCLUDED
|