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_X86_X86RAPASS_P_H_INCLUDED 8 : #define ASMJIT_X86_X86RAPASS_P_H_INCLUDED 9 : 10 : #include "api-config.h" 11 : #ifndef ASMJIT_NO_COMPILER 12 : 13 : #include "compiler.h" 14 : #include "rabuilders_p.h" 15 : #include "rapass_p.h" 16 : #include "x86assembler.h" 17 : #include "x86compiler.h" 18 : #include "x86emithelper_p.h" 19 : 20 : ASMJIT_BEGIN_SUB_NAMESPACE(x86) 21 : 22 : //! \cond INTERNAL 23 : //! \addtogroup asmjit_x86 24 : //! \{ 25 : 26 : //! X86 register allocation pass. 27 : //! 28 : //! Takes care of generating function prologs and epilogs, and also performs register allocation. 29 : class X86RAPass : public BaseRAPass { 30 : public: 31 : ASMJIT_NONCOPYABLE(X86RAPass) 32 : typedef BaseRAPass Base; 33 : 34 : EmitHelper _emitHelper; 35 : 36 : //! \name Construction & Destruction 37 : //! \{ 38 : 39 : X86RAPass() noexcept; 40 : virtual ~X86RAPass() noexcept; 41 : 42 : //! \} 43 : 44 : //! \name Accessors 45 : //! \{ 46 : 47 : //! Returns the compiler casted to `x86::Compiler`. 48 153607 : inline Compiler* cc() const noexcept { return static_cast<Compiler*>(_cb); } 49 : 50 : //! Returns emit helper. 51 : inline EmitHelper* emitHelper() noexcept { return &_emitHelper; } 52 : 53 27492 : inline bool avxEnabled() const noexcept { return _emitHelper._avxEnabled; } 54 : inline bool avx512Enabled() const noexcept { return _emitHelper._avx512Enabled; } 55 : 56 : //! \} 57 : 58 : //! \name Utilities 59 : //! \{ 60 : 61 : inline uint32_t choose(uint32_t sseInstId, uint32_t avxInstId) noexcept { 62 0 : return avxEnabled() ? avxInstId : sseInstId; 63 : } 64 : 65 : //! \} 66 : 67 : //! \name Interface 68 : //! \{ 69 : 70 : void onInit() noexcept override; 71 : void onDone() noexcept override; 72 : 73 : Error buildCFG() noexcept override; 74 : 75 : Error _rewrite(BaseNode* first, BaseNode* stop) noexcept override; 76 : 77 : Error emitMove(uint32_t workId, uint32_t dstPhysId, uint32_t srcPhysId) noexcept override; 78 : Error emitSwap(uint32_t aWorkId, uint32_t aPhysId, uint32_t bWorkId, uint32_t bPhysId) noexcept override; 79 : 80 : Error emitLoad(uint32_t workId, uint32_t dstPhysId) noexcept override; 81 : Error emitSave(uint32_t workId, uint32_t srcPhysId) noexcept override; 82 : 83 : Error emitJump(const Label& label) noexcept override; 84 : Error emitPreCall(InvokeNode* invokeNode) noexcept override; 85 : 86 : //! \} 87 : }; 88 : 89 : //! \} 90 : //! \endcond 91 : 92 : ASMJIT_END_SUB_NAMESPACE 93 : 94 : #endif // !ASMJIT_NO_COMPILER 95 : #endif // ASMJIT_X86_X86RAPASS_P_H_INCLUDED 96 : 97 : #endif // __PLUMED_HAS_ASMJIT