Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 : Copyright (c) 2008-2017, Petr Kobalicek 3 : 4 : This software is provided 'as-is', without any express or implied 5 : warranty. In no event will the authors be held liable for any damages 6 : arising from the use of this software. 7 : 8 : Permission is granted to anyone to use this software for any purpose, 9 : including commercial applications, and to alter it and redistribute it 10 : freely, subject to the following restrictions: 11 : 12 : 1. The origin of this software must not be misrepresented; you must not 13 : claim that you wrote the original software. If you use this software 14 : in a product, an acknowledgment in the product documentation would be 15 : appreciated but is not required. 16 : 2. Altered source versions must be plainly marked as such, and must not be 17 : misrepresented as being the original software. 18 : 3. This notice may not be removed or altered from any source distribution. 19 : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ 20 : #ifndef __PLUMED_asmjit_inst_h 21 : #define __PLUMED_asmjit_inst_h 22 : #ifdef __PLUMED_HAS_ASMJIT 23 : #pragma GCC diagnostic push 24 : #pragma GCC diagnostic ignored "-Wpedantic" 25 : // [AsmJit] 26 : // Complete x86/x64 JIT and Remote Assembler for C++. 27 : // 28 : // [License] 29 : // Zlib - See LICENSE.md file in the package. 30 : 31 : // [Guard] 32 : #ifndef _ASMJIT_BASE_INST_H 33 : #define _ASMJIT_BASE_INST_H 34 : 35 : // [Dependencies] 36 : #include "./cpuinfo.h" 37 : #include "./operand.h" 38 : 39 : // [Api-Begin] 40 : #include "./asmjit_apibegin.h" 41 : 42 : namespace PLMD { 43 : namespace asmjit { 44 : 45 : //! \addtogroup asmjit_base 46 : //! \{ 47 : 48 : // ============================================================================ 49 : // [asmjit::Inst] 50 : // ============================================================================ 51 : 52 : //! Definitions and utilities related to instructions used by all architectures. 53 : struct Inst { 54 : ASMJIT_ENUM(Id) { 55 : kIdNone = 0 //!< Invalid or uninitialized instruction id. 56 : }; 57 : 58 : //! Describes an instruction's jump type, if any. 59 : ASMJIT_ENUM(JumpType) { 60 : kJumpTypeNone = 0, //!< Instruction doesn't jump (regular instruction). 61 : kJumpTypeDirect = 1, //!< Instruction is a unconditional (direct) jump. 62 : kJumpTypeConditional = 2, //!< Instruction is a conditional jump. 63 : kJumpTypeCall = 3, //!< Instruction is a function call. 64 : kJumpTypeReturn = 4 //!< Instruction is a function return. 65 : }; 66 : 67 : // -------------------------------------------------------------------------- 68 : // [Detail] 69 : // -------------------------------------------------------------------------- 70 : 71 : //! Instruction id, options, and extraReg packed in a single structure. This 72 : //! structure exists to simplify analysis and validation API that requires a 73 : //! lot of information about the instruction to be processed. 74 : class Detail { 75 : public: 76 : ASMJIT_INLINE Detail() noexcept 77 48254 : : instId(0), 78 : options(0), 79 48254 : extraReg() {} 80 : 81 : explicit ASMJIT_INLINE Detail(uint32_t instId, uint32_t options = 0) noexcept 82 : : instId(instId), 83 : options(options), 84 : extraReg() {} 85 : 86 : ASMJIT_INLINE Detail(uint32_t instId, uint32_t options, const RegOnly& reg) noexcept 87 0 : : instId(instId), 88 0 : options(options), 89 0 : extraReg(reg) {} 90 : 91 : ASMJIT_INLINE Detail(uint32_t instId, uint32_t options, const Reg& reg) noexcept 92 : : instId(instId), 93 : options(options) { extraReg.init(reg); } 94 : 95 : // ------------------------------------------------------------------------ 96 : // [Accessors] 97 : // ------------------------------------------------------------------------ 98 : 99 : ASMJIT_INLINE bool hasExtraReg() const noexcept { return extraReg.isValid(); } 100 : 101 : // ------------------------------------------------------------------------ 102 : // [Members] 103 : // ------------------------------------------------------------------------ 104 : 105 : uint32_t instId; 106 : uint32_t options; 107 : RegOnly extraReg; 108 : }; 109 : 110 : // -------------------------------------------------------------------------- 111 : // [API] 112 : // -------------------------------------------------------------------------- 113 : 114 : #if !defined(ASMJIT_DISABLE_VALIDATION) 115 : //! Validate the given instruction. 116 : ASMJIT_API static Error validate(uint32_t archType, const Detail& detail, const Operand_* operands, uint32_t count) noexcept; 117 : #endif // !ASMJIT_DISABLE_VALIDATION 118 : 119 : #if !defined(ASMJIT_DISABLE_EXTENSIONS) 120 : //! Check CPU features required to execute the given instruction. 121 : ASMJIT_API static Error checkFeatures(uint32_t archType, const Detail& detail, const Operand_* operands, uint32_t count, CpuFeatures& out) noexcept; 122 : #endif // !defined(ASMJIT_DISABLE_EXTENSIONS) 123 : }; 124 : 125 : //! \} 126 : 127 : } // asmjit namespace 128 : } // namespace PLMD 129 : 130 : // [Api-End] 131 : #include "./asmjit_apiend.h" 132 : 133 : // [Guard] 134 : #endif // _ASMJIT_BASE_INST_H 135 : #pragma GCC diagnostic pop 136 : #endif // __PLUMED_HAS_ASMJIT 137 : #endif