Line data Source code
1 : #ifdef __PLUMED_HAS_ASMJIT
2 : // This file is part of AsmJit project <https://asmjit.com>
3 : //
4 : // See asmjit.h or LICENSE.md for license and copyright information
5 : // SPDX-License-Identifier: Zlib
6 :
7 : #include "api-build_p.h"
8 : #include "archtraits.h"
9 : #include "inst.h"
10 :
11 : #if !defined(ASMJIT_NO_X86)
12 : #include "x86instapi_p.h"
13 : #endif
14 :
15 : #if !defined(ASMJIT_NO_AARCH64)
16 : #include "a64instapi_p.h"
17 : #endif
18 :
19 : ASMJIT_BEGIN_NAMESPACE
20 :
21 : // InstAPI - InstId <-> String
22 : // ===========================
23 :
24 : #ifndef ASMJIT_NO_TEXT
25 0 : Error InstAPI::instIdToString(Arch arch, InstId instId, String& output) noexcept {
26 : #if !defined(ASMJIT_NO_X86)
27 0 : if (Environment::isFamilyX86(arch))
28 0 : return x86::InstInternal::instIdToString(arch, instId, output);
29 : #endif
30 :
31 : #if !defined(ASMJIT_NO_AARCH64)
32 0 : if (Environment::isFamilyAArch64(arch))
33 0 : return a64::InstInternal::instIdToString(arch, instId, output);
34 : #endif
35 :
36 : return DebugUtils::errored(kErrorInvalidArch);
37 : }
38 :
39 0 : InstId InstAPI::stringToInstId(Arch arch, const char* s, size_t len) noexcept {
40 : #if !defined(ASMJIT_NO_X86)
41 0 : if (Environment::isFamilyX86(arch))
42 0 : return x86::InstInternal::stringToInstId(arch, s, len);
43 : #endif
44 :
45 : #if !defined(ASMJIT_NO_AARCH64)
46 0 : if (Environment::isFamilyAArch64(arch))
47 0 : return a64::InstInternal::stringToInstId(arch, s, len);
48 : #endif
49 :
50 : return 0;
51 : }
52 : #endif // !ASMJIT_NO_TEXT
53 :
54 : // InstAPI - Validate
55 : // ==================
56 :
57 : #ifndef ASMJIT_NO_VALIDATION
58 0 : Error InstAPI::validate(Arch arch, const BaseInst& inst, const Operand_* operands, size_t opCount, ValidationFlags validationFlags) noexcept {
59 : #if !defined(ASMJIT_NO_X86)
60 0 : if (Environment::isFamilyX86(arch))
61 0 : return x86::InstInternal::validate(arch, inst, operands, opCount, validationFlags);
62 : #endif
63 :
64 : #if !defined(ASMJIT_NO_AARCH64)
65 0 : if (Environment::isFamilyAArch64(arch))
66 0 : return a64::InstInternal::validate(arch, inst, operands, opCount, validationFlags);
67 : #endif
68 :
69 : return DebugUtils::errored(kErrorInvalidArch);
70 : }
71 : #endif // !ASMJIT_NO_VALIDATION
72 :
73 : // InstAPI - QueryRWInfo
74 : // =====================
75 :
76 : #ifndef ASMJIT_NO_INTROSPECTION
77 0 : Error InstAPI::queryRWInfo(Arch arch, const BaseInst& inst, const Operand_* operands, size_t opCount, InstRWInfo* out) noexcept {
78 0 : if (ASMJIT_UNLIKELY(opCount > Globals::kMaxOpCount))
79 : return DebugUtils::errored(kErrorInvalidArgument);
80 :
81 : #if !defined(ASMJIT_NO_X86)
82 0 : if (Environment::isFamilyX86(arch))
83 0 : return x86::InstInternal::queryRWInfo(arch, inst, operands, opCount, out);
84 : #endif
85 :
86 : #if !defined(ASMJIT_NO_AARCH64)
87 0 : if (Environment::isFamilyAArch64(arch))
88 0 : return a64::InstInternal::queryRWInfo(arch, inst, operands, opCount, out);
89 : #endif
90 :
91 : return DebugUtils::errored(kErrorInvalidArch);
92 : }
93 : #endif // !ASMJIT_NO_INTROSPECTION
94 :
95 : // InstAPI - QueryFeatures
96 : // =======================
97 :
98 : #ifndef ASMJIT_NO_INTROSPECTION
99 0 : Error InstAPI::queryFeatures(Arch arch, const BaseInst& inst, const Operand_* operands, size_t opCount, CpuFeatures* out) noexcept {
100 : #if !defined(ASMJIT_NO_X86)
101 0 : if (Environment::isFamilyX86(arch))
102 0 : return x86::InstInternal::queryFeatures(arch, inst, operands, opCount, out);
103 : #endif
104 :
105 : #if !defined(ASMJIT_NO_AARCH64)
106 0 : if (Environment::isFamilyAArch64(arch))
107 0 : return a64::InstInternal::queryFeatures(arch, inst, operands, opCount, out);
108 : #endif
109 :
110 : return DebugUtils::errored(kErrorInvalidArch);
111 : }
112 : #endif // !ASMJIT_NO_INTROSPECTION
113 :
114 : ASMJIT_END_NAMESPACE
115 :
116 : #endif // __PLUMED_HAS_ASMJIT
|