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 : #if !defined(ASMJIT_NO_AARCH64) && !defined(ASMJIT_NO_COMPILER) 9 : 10 : #include "a64assembler.h" 11 : #include "a64compiler.h" 12 : #include "a64emithelper_p.h" 13 : #include "a64rapass_p.h" 14 : 15 : ASMJIT_BEGIN_SUB_NAMESPACE(a64) 16 : 17 : // a64::Compiler - Construction & Destruction 18 : // ========================================== 19 : 20 0 : Compiler::Compiler(CodeHolder* code) noexcept : BaseCompiler() { 21 0 : _archMask = uint64_t(1) << uint32_t(Arch::kAArch64); 22 0 : assignEmitterFuncs(this); 23 : 24 0 : if (code) 25 0 : code->attach(this); 26 0 : } 27 0 : Compiler::~Compiler() noexcept {} 28 : 29 : // a64::Compiler - Events 30 : // ====================== 31 : 32 0 : Error Compiler::onAttach(CodeHolder* code) noexcept { 33 0 : ASMJIT_PROPAGATE(Base::onAttach(code)); 34 0 : Error err = addPassT<ARMRAPass>(); 35 : 36 0 : if (ASMJIT_UNLIKELY(err)) { 37 0 : onDetach(code); 38 0 : return err; 39 : } 40 : 41 : return kErrorOk; 42 : } 43 : 44 0 : Error Compiler::onDetach(CodeHolder* code) noexcept { 45 0 : return Base::onDetach(code); 46 : } 47 : 48 : // a64::Compiler - Finalize 49 : // ======================== 50 : 51 0 : Error Compiler::finalize() { 52 0 : ASMJIT_PROPAGATE(runPasses()); 53 0 : Assembler a(_code); 54 : a.addEncodingOptions(encodingOptions()); 55 0 : a.addDiagnosticOptions(diagnosticOptions()); 56 0 : return serializeTo(&a); 57 0 : } 58 : 59 : ASMJIT_END_SUB_NAMESPACE 60 : 61 : #endif // !ASMJIT_NO_AARCH64 && !ASMJIT_NO_COMPILER 62 : 63 : #endif // __PLUMED_HAS_ASMJIT