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 : #ifndef ASMJIT_CORE_EMITTERUTILS_P_H_INCLUDED
8 : #define ASMJIT_CORE_EMITTERUTILS_P_H_INCLUDED
9 :
10 : #include "emitter.h"
11 : #include "operand.h"
12 :
13 : ASMJIT_BEGIN_NAMESPACE
14 :
15 : class BaseAssembler;
16 : class FormatOptions;
17 :
18 : //! \cond INTERNAL
19 : //! \addtogroup asmjit_core
20 : //! \{
21 :
22 : //! Utilities used by various emitters, mostly Assembler implementations.
23 : namespace EmitterUtils {
24 :
25 : //! Default paddings used by Emitter utils and Formatter.
26 :
27 : static constexpr Operand noExt[3];
28 :
29 : enum kOpIndex : uint32_t {
30 : kOp3 = 0,
31 : kOp4 = 1,
32 : kOp5 = 2
33 : };
34 :
35 : static ASMJIT_FORCE_INLINE uint32_t opCountFromEmitArgs(const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_* opExt) noexcept {
36 : uint32_t opCount = 0;
37 :
38 382370 : if (opExt[kOp3].isNone()) {
39 380237 : if (!o0.isNone()) opCount = 1;
40 380237 : if (!o1.isNone()) opCount = 2;
41 380237 : if (!o2.isNone()) opCount = 3;
42 : }
43 : else {
44 : opCount = 4;
45 2133 : if (!opExt[kOp4].isNone()) {
46 0 : opCount = 5 + uint32_t(!opExt[kOp5].isNone());
47 : }
48 : }
49 :
50 : return opCount;
51 : }
52 :
53 : static ASMJIT_FORCE_INLINE void opArrayFromEmitArgs(Operand_ dst[Globals::kMaxOpCount], const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_* opExt) noexcept {
54 0 : dst[0].copyFrom(o0);
55 0 : dst[1].copyFrom(o1);
56 0 : dst[2].copyFrom(o2);
57 0 : dst[3].copyFrom(opExt[kOp3]);
58 0 : dst[4].copyFrom(opExt[kOp4]);
59 0 : dst[5].copyFrom(opExt[kOp5]);
60 : }
61 :
62 : #ifndef ASMJIT_NO_LOGGING
63 : Error finishFormattedLine(String& sb, const FormatOptions& formatOptions, const uint8_t* binData, size_t binSize, size_t offsetSize, size_t immSize, const char* comment) noexcept;
64 :
65 : void logLabelBound(BaseAssembler* self, const Label& label) noexcept;
66 :
67 : void logInstructionEmitted(
68 : BaseAssembler* self,
69 : InstId instId,
70 : InstOptions options,
71 : const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_* opExt,
72 : uint32_t relSize, uint32_t immSize, uint8_t* afterCursor);
73 :
74 : Error logInstructionFailed(
75 : BaseAssembler* self,
76 : Error err,
77 : InstId instId,
78 : InstOptions options,
79 : const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_* opExt);
80 : #endif
81 :
82 : }
83 :
84 : //! \}
85 : //! \endcond
86 :
87 : ASMJIT_END_NAMESPACE
88 :
89 : #endif // ASMJIT_CORE_EMITTERUTILS_P_H_INCLUDED
90 :
91 :
92 : #endif // __PLUMED_HAS_ASMJIT
|