LCOV - code coverage report
Current view: top level - asmjit - assembler.h (source / functions) Hit Total Coverage
Test: plumed test coverage (other modules) Lines: 1 2 50.0 %
Date: 2024-10-11 08:09:49 Functions: 0 0 -

          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_assembler_h
      21             : #define __PLUMED_asmjit_assembler_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_ASSEMBLER_H
      33             : #define _ASMJIT_BASE_ASSEMBLER_H
      34             : 
      35             : // [Dependencies]
      36             : #include "./codeemitter.h"
      37             : #include "./codeholder.h"
      38             : #include "./operand.h"
      39             : #include "./simdtypes.h"
      40             : 
      41             : // [Api-Begin]
      42             : #include "./asmjit_apibegin.h"
      43             : 
      44             : namespace PLMD {
      45             : namespace asmjit {
      46             : 
      47             : //! \addtogroup asmjit_base
      48             : //! \{
      49             : 
      50             : // ============================================================================
      51             : // [asmjit::Assembler]
      52             : // ============================================================================
      53             : 
      54             : //! Base assembler.
      55             : //!
      56             : //! This class implements a base interface that is used by architecture
      57             : //! specific assemblers.
      58             : //!
      59             : //! \sa CodeCompiler.
      60             : class ASMJIT_VIRTAPI Assembler : public CodeEmitter {
      61             : public:
      62             :   ASMJIT_NONCOPYABLE(Assembler)
      63             :   typedef CodeEmitter Base;
      64             : 
      65             :   // --------------------------------------------------------------------------
      66             :   // [Construction / Destruction]
      67             :   // --------------------------------------------------------------------------
      68             : 
      69             :   //! Create a new `Assembler` instance.
      70             :   ASMJIT_API Assembler() noexcept;
      71             :   //! Destroy the `Assembler` instance.
      72             :   ASMJIT_API virtual ~Assembler() noexcept;
      73             : 
      74             :   // --------------------------------------------------------------------------
      75             :   // [Events]
      76             :   // --------------------------------------------------------------------------
      77             : 
      78             :   ASMJIT_API Error onAttach(CodeHolder* code) noexcept override;
      79             :   ASMJIT_API Error onDetach(CodeHolder* code) noexcept override;
      80             : 
      81             :   // --------------------------------------------------------------------------
      82             :   // [Code-Generation]
      83             :   // --------------------------------------------------------------------------
      84             : 
      85             :   using CodeEmitter::_emit;
      86             : 
      87             :   ASMJIT_API Error _emit(uint32_t instId, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_& o3, const Operand_& o4, const Operand_& o5) override;
      88             :   ASMJIT_API Error _emitOpArray(uint32_t instId, const Operand_* opArray, size_t opCount) override;
      89             : 
      90             :   // --------------------------------------------------------------------------
      91             :   // [Code-Buffer]
      92             :   // --------------------------------------------------------------------------
      93             : 
      94             :   //! Called by \ref CodeHolder::sync().
      95             :   ASMJIT_API virtual void sync() noexcept;
      96             : 
      97             :   //! Get the capacity of the current CodeBuffer.
      98             :   ASMJIT_INLINE size_t getBufferCapacity() const noexcept { return (size_t)(_bufferEnd - _bufferData); }
      99             :   //! Get the number of remaining bytes in the current CodeBuffer.
     100           0 :   ASMJIT_INLINE size_t getRemainingSpace() const noexcept { return (size_t)(_bufferEnd - _bufferPtr); }
     101             : 
     102             :   //! Get the current position in the CodeBuffer.
     103        5832 :   ASMJIT_INLINE size_t getOffset() const noexcept { return (size_t)(_bufferPtr - _bufferData); }
     104             :   //! Set the current position in the CodeBuffer to `offset`.
     105             :   //!
     106             :   //! NOTE: The `offset` cannot be outside of the buffer length (even if it's
     107             :   //! within buffer's capacity).
     108             :   ASMJIT_API Error setOffset(size_t offset);
     109             : 
     110             :   //! Get start of the CodeBuffer of the current section.
     111             :   ASMJIT_INLINE uint8_t* getBufferData() const noexcept { return _bufferData; }
     112             :   //! Get end (first invalid byte) of the current section.
     113             :   ASMJIT_INLINE uint8_t* getBufferEnd() const noexcept { return _bufferEnd; }
     114             :   //! Get pointer in the CodeBuffer of the current section.
     115             :   ASMJIT_INLINE uint8_t* getBufferPtr() const noexcept { return _bufferPtr; }
     116             : 
     117             :   // --------------------------------------------------------------------------
     118             :   // [Code-Generation]
     119             :   // --------------------------------------------------------------------------
     120             : 
     121             :   ASMJIT_API Label newLabel() override;
     122             :   ASMJIT_API Label newNamedLabel(
     123             :     const char* name,
     124             :     size_t nameLength = Globals::kInvalidIndex,
     125             :     uint32_t type = Label::kTypeGlobal,
     126             :     uint32_t parentId = 0) override;
     127             :   ASMJIT_API Error bind(const Label& label) override;
     128             :   ASMJIT_API Error embed(const void* data, uint32_t size) override;
     129             :   ASMJIT_API Error embedLabel(const Label& label) override;
     130             :   ASMJIT_API Error embedConstPool(const Label& label, const ConstPool& pool) override;
     131             :   ASMJIT_API Error comment(const char* s, size_t len = Globals::kInvalidIndex) override;
     132             : 
     133             :   // --------------------------------------------------------------------------
     134             :   // [Emit-Helpers]
     135             :   // --------------------------------------------------------------------------
     136             : 
     137             : protected:
     138             : #if !defined(ASMJIT_DISABLE_LOGGING)
     139             :   void _emitLog(
     140             :     uint32_t instId, uint32_t options, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_& o3,
     141             :     uint32_t relSize, uint32_t imLen, uint8_t* afterCursor);
     142             : 
     143             :   Error _emitFailed(
     144             :     Error err,
     145             :     uint32_t instId, uint32_t options, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_& o3);
     146             : #else
     147             :   ASMJIT_INLINE Error _emitFailed(
     148             :     uint32_t err,
     149             :     uint32_t instId, uint32_t options, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_& o3) {
     150             : 
     151             :     resetOptions();
     152             :     resetInlineComment();
     153             :     return setLastError(err);
     154             :   }
     155             : #endif
     156             : 
     157             :   // --------------------------------------------------------------------------
     158             :   // [Members]
     159             :   // --------------------------------------------------------------------------
     160             : 
     161             : public:
     162             :   SectionEntry* _section;                //!< Current section where the assembling happens.
     163             :   uint8_t* _bufferData;                  //!< Start of the CodeBuffer of the current section.
     164             :   uint8_t* _bufferEnd;                   //!< End (first invalid byte) of the current section.
     165             :   uint8_t* _bufferPtr;                   //!< Pointer in the CodeBuffer of the current section.
     166             : 
     167             :   Operand_ _op4;                         //!< 5th operand data, used only temporarily.
     168             :   Operand_ _op5;                         //!< 6th operand data, used only temporarily.
     169             : };
     170             : 
     171             : //! \}
     172             : 
     173             : } // asmjit namespace
     174             : } // namespace PLMD
     175             : 
     176             : // [Api-End]
     177             : #include "./asmjit_apiend.h"
     178             : 
     179             : // [Guard]
     180             : #endif // _ASMJIT_BASE_ASSEMBLER_H
     181             : #pragma GCC diagnostic pop
     182             : #endif // __PLUMED_HAS_ASMJIT
     183             : #endif

Generated by: LCOV version 1.15