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 #ifdef __PLUMED_HAS_ASMJIT
21 #pragma GCC diagnostic push
22 #pragma GCC diagnostic ignored "-Wpedantic"
23 // [AsmJit]
24 // Complete x86/x64 JIT and Remote Assembler for C++.
25 //
26 // [License]
27 // Zlib - See LICENSE.md file in the package.
28 
29 // [Export]
30 #define ASMJIT_EXPORTS
31 
32 // [Guard]
33 #include "./asmjit_build.h"
34 #if defined(ASMJIT_BUILD_X86) && !defined(ASMJIT_DISABLE_COMPILER)
35 
36 // [Dependencies]
37 #include "./x86builder.h"
38 
39 // [Api-Begin]
40 #include "./asmjit_apibegin.h"
41 
42 namespace PLMD {
43 namespace asmjit {
44 
45 // ============================================================================
46 // [asmjit::X86Builder - Construction / Destruction]
47 // ============================================================================
48 
X86Builder(CodeHolder * code)49 X86Builder::X86Builder(CodeHolder* code) noexcept : CodeBuilder() {
50   if (code)
51     code->attach(this);
52 }
~X86Builder()53 X86Builder::~X86Builder() noexcept {}
54 
55 // ============================================================================
56 // [asmjit::X86Builder - Events]
57 // ============================================================================
58 
onAttach(CodeHolder * code)59 Error X86Builder::onAttach(CodeHolder* code) noexcept {
60   uint32_t archType = code->getArchType();
61   if (!ArchInfo::isX86Family(archType))
62     return DebugUtils::errored(kErrorInvalidArch);
63 
64   ASMJIT_PROPAGATE(Base::onAttach(code));
65 
66   if (archType == ArchInfo::kTypeX86)
67     _nativeGpArray = x86OpData.gpd;
68   else
69     _nativeGpArray = x86OpData.gpq;
70   _nativeGpReg = _nativeGpArray[0];
71   return kErrorOk;
72 }
73 
74 // ============================================================================
75 // [asmjit::X86Builder - Inst]
76 // ============================================================================
77 
_emit(uint32_t instId,const Operand_ & o0,const Operand_ & o1,const Operand_ & o2,const Operand_ & o3)78 Error X86Builder::_emit(uint32_t instId, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_& o3) {
79   // TODO:
80   return kErrorOk;
81 }
82 
83 } // asmjit namespace
84 } // namespace PLMD
85 
86 // [Api-End]
87 #include "./asmjit_apiend.h"
88 
89 // [Guard]
90 #endif // ASMJIT_BUILD_X86 && !ASMJIT_DISABLE_COMPILER
91 #pragma GCC diagnostic pop
92 #endif // __PLUMED_HAS_ASMJIT
93