1 2 // AsmJit - Machine code generation for C++ 3 // 4 // * Official AsmJit Home Page: https://asmjit.com 5 // * Official Github Repository: https://github.com/asmjit/asmjit 6 // 7 // Copyright (c) 2008-2020 The AsmJit Authors 8 // 9 // This software is provided 'as-is', without any express or implied 10 // warranty. In no event will the authors be held liable for any damages 11 // arising from the use of this software. 12 // 13 // Permission is granted to anyone to use this software for any purpose, 14 // including commercial applications, and to alter it and redistribute it 15 // freely, subject to the following restrictions: 16 // 17 // 1. The origin of this software must not be misrepresented; you must not 18 // claim that you wrote the original software. If you use this software 19 // in a product, an acknowledgment in the product documentation would be 20 // appreciated but is not required. 21 // 2. Altered source versions must be plainly marked as such, and must not be 22 // misrepresented as being the original software. 23 // 3. This notice may not be removed or altered from any source distribution. 24 25 #ifndef ASMJIT_CORE_EMITHELPER_P_H_INCLUDED 26 #define ASMJIT_CORE_EMITHELPER_P_H_INCLUDED 27 28 #include "../core/emitter.h" 29 #include "../core/operand.h" 30 #include "../core/type.h" 31 32 ASMJIT_BEGIN_NAMESPACE 33 34 //! \cond INTERNAL 35 //! \addtogroup asmjit_core 36 //! \{ 37 38 // ============================================================================ 39 // [asmjit::BaseEmitHelper] 40 // ============================================================================ 41 42 //! Helper class that provides utilities for each supported architecture. 43 class BaseEmitHelper { 44 public: 45 BaseEmitter* _emitter; 46 47 inline explicit BaseEmitHelper(BaseEmitter* emitter = nullptr) noexcept _emitter(emitter)48 : _emitter(emitter) {} 49 emitter()50 inline BaseEmitter* emitter() const noexcept { return _emitter; } setEmitter(BaseEmitter * emitter)51 inline void setEmitter(BaseEmitter* emitter) noexcept { _emitter = emitter; } 52 53 //! Emits a pure move operation between two registers or the same type or 54 //! between a register and its home slot. This function does not handle 55 //! register conversion. 56 virtual Error emitRegMove( 57 const Operand_& dst_, 58 const Operand_& src_, uint32_t typeId, const char* comment = nullptr) = 0; 59 60 //! Emits swap between two registers. 61 virtual Error emitRegSwap( 62 const BaseReg& a, 63 const BaseReg& b, const char* comment = nullptr) = 0; 64 65 //! Emits move from a function argument (either register or stack) to a register. 66 //! 67 //! This function can handle the necessary conversion from one argument to 68 //! another, and from one register type to another, if it's possible. Any 69 //! attempt of conversion that requires third register of a different group 70 //! (for example conversion from K to MMX on X86/X64) will fail. 71 virtual Error emitArgMove( 72 const BaseReg& dst_, uint32_t dstTypeId, 73 const Operand_& src_, uint32_t srcTypeId, const char* comment = nullptr) = 0; 74 75 Error emitArgsAssignment(const FuncFrame& frame, const FuncArgsAssignment& args); 76 }; 77 78 //! \} 79 //! \endcond 80 81 ASMJIT_END_NAMESPACE 82 83 #endif // ASMJIT_CORE_EMITHELPER_P_H_INCLUDED 84