diff --git a/CMakeLists.txt b/CMakeLists.txt index ee6e583..88e48dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -190,8 +190,6 @@ AsmJit_AddSource(ASMJIT_SRC asmjit/base assembler.cpp assembler.h - assert.cpp - assert.h codegen.cpp codegen.h compiler.cpp @@ -206,6 +204,7 @@ AsmJit_AddSource(ASMJIT_SRC asmjit/base error.h func.cpp func.h + globals.cpp globals.h intutil.h lock.h diff --git a/src/asmjit/base.h b/src/asmjit/base.h index 047bdd7..0fed7a4 100644 --- a/src/asmjit/base.h +++ b/src/asmjit/base.h @@ -12,7 +12,6 @@ #include "build.h" #include "base/assembler.h" -#include "base/assert.h" #include "base/codegen.h" #include "base/compiler.h" #include "base/cpu.h" diff --git a/src/asmjit/base/assert.h b/src/asmjit/base/assert.h deleted file mode 100644 index df5495b..0000000 --- a/src/asmjit/base/assert.h +++ /dev/null @@ -1,57 +0,0 @@ -// [AsmJit] -// Complete x86/x64 JIT and Remote Assembler for C++. -// -// [License] -// Zlib - See LICENSE.md file in the package. - -// [Guard] -#ifndef _ASMJIT_BASE_ASSERT_H -#define _ASMJIT_BASE_ASSERT_H - -// [Dependencies - AsmJit] -#include "../build.h" - -// [Api-Begin] -#include "../base/apibegin.h" - -namespace asmjit { - -//! @addtogroup asmjit_base -//! @{ - -// ============================================================================ -// [asmjit::Assert] -// ============================================================================ - -//! @brief Called in debug build on assertion failure. -//! -//! @param exp Expression that failed. -//! @param file Source file name where it happened. -//! @param line Line in the source file. -//! -//! If you have problems with assertions put a breakpoint at assertionFailed() -//! function (asmjit/base/assert.cpp) to see what happened. -ASMJIT_API void assertionFailed(const char* exp, const char* file, int line); - -// ============================================================================ -// [ASMJIT_ASSERT] -// ============================================================================ - -#if defined(ASMJIT_DEBUG) -#define ASMJIT_ASSERT(_Exp_) \ - do { \ - if (!(_Exp_)) ::asmjit::assertionFailed(#_Exp_, __FILE__, __LINE__); \ - } while (0) -#else -#define ASMJIT_ASSERT(_Exp_) ASMJIT_NOP() -#endif // DEBUG - -//! @} - -} // asmjit namespace - -// [Api-End] -#include "../base/apiend.h" - -// [Guard] -#endif // _ASMJIT_BASE_ASSERT_H diff --git a/src/asmjit/base/cpu.cpp b/src/asmjit/base/cpu.cpp index de24722..225c5fb 100644 --- a/src/asmjit/base/cpu.cpp +++ b/src/asmjit/base/cpu.cpp @@ -64,7 +64,7 @@ struct HostCpu : public x86x64::Cpu { ASMJIT_INLINE HostCpu() : Cpu() { hostCpuDetect(this); } }; #else -#error "asmjit/base/cpu.cpp - Unsupported CPU." +#error "AsmJit - Unsupported CPU." #endif // ASMJIT_HOST || ASMJIT_HOST_X64 const BaseCpu* BaseCpu::getHost() @@ -72,7 +72,7 @@ const BaseCpu* BaseCpu::getHost() #if defined(ASMJIT_HOST_X86) || defined(ASMJIT_HOST_X64) static HostCpu cpu; #else -#error "asmjit/base/cpu.cpp - Unsupported CPU." +#error "AsmJit - Unsupported CPU." #endif // ASMJIT_HOST || ASMJIT_HOST_X64 return &cpu; } diff --git a/src/asmjit/base/cpu.h b/src/asmjit/base/cpu.h index bffc17e..c6424b3 100644 --- a/src/asmjit/base/cpu.h +++ b/src/asmjit/base/cpu.h @@ -8,9 +8,11 @@ #ifndef _ASMJIT_BASE_CPU_H #define _ASMJIT_BASE_CPU_H +// [Dependencies - AsmJit] +#include "../base/globals.h" + // [Api-Begin] #include "../base/apibegin.h" -#include "../base/assert.h" namespace asmjit { diff --git a/src/asmjit/base/func.h b/src/asmjit/base/func.h index 19b933a..31e23db 100644 --- a/src/asmjit/base/func.h +++ b/src/asmjit/base/func.h @@ -9,8 +9,8 @@ #define _ASMJIT_BASE_FUNC_H // [Dependencies - AsmJit] -#include "../base/assert.h" #include "../base/defs.h" +#include "../base/globals.h" // [Api-Begin] #include "../base/apibegin.h" diff --git a/src/asmjit/base/assert.cpp b/src/asmjit/base/globals.cpp similarity index 95% rename from src/asmjit/base/assert.cpp rename to src/asmjit/base/globals.cpp index 8db6078..9e13c9f 100644 --- a/src/asmjit/base/assert.cpp +++ b/src/asmjit/base/globals.cpp @@ -8,7 +8,7 @@ #define ASMJIT_EXPORTS // [Dependencies - AsmJit] -#include "../base/assert.h" +#include "../base/globals.h" // [Api-Begin] #include "../base/apibegin.h" diff --git a/src/asmjit/base/globals.h b/src/asmjit/base/globals.h index 68093d3..cb0d837 100644 --- a/src/asmjit/base/globals.h +++ b/src/asmjit/base/globals.h @@ -26,7 +26,7 @@ namespace asmjit { static const size_t kInvalidIndex = ~static_cast(0); ASMJIT_ENUM(kGlobals) { - //! @brief Invalid operand id. + //! @brief Invalid value or operand id. kInvalidValue = 0xFFFFFFFF, //! @brief Invalid register index. @@ -97,6 +97,29 @@ static const _Init Init = {}; struct _NoInit {}; static const _NoInit NoInit = {}; +// ============================================================================ +// [asmjit::Assert] +// ============================================================================ + +//! @brief Called in debug build on assertion failure. +//! +//! @param exp Expression that failed. +//! @param file Source file name where it happened. +//! @param line Line in the source file. +//! +//! If you have problems with assertions put a breakpoint at assertionFailed() +//! function (asmjit/base/assert.cpp) to see what happened. +ASMJIT_API void assertionFailed(const char* exp, const char* file, int line); + +#if defined(ASMJIT_DEBUG) +#define ASMJIT_ASSERT(_Exp_) \ + do { \ + if (!(_Exp_)) ::asmjit::assertionFailed(#_Exp_, __FILE__, __LINE__); \ + } while (0) +#else +#define ASMJIT_ASSERT(_Exp_) ASMJIT_NOP() +#endif // DEBUG + //! @} } // asmjit namespace diff --git a/src/asmjit/base/intutil.h b/src/asmjit/base/intutil.h index ff40770..c8ae89a 100644 --- a/src/asmjit/base/intutil.h +++ b/src/asmjit/base/intutil.h @@ -9,7 +9,6 @@ #define _ASMJIT_BASE_INTUTIL_H // [Dependencies - AsmJit] -#include "../base/assert.h" #include "../base/globals.h" #if defined(_MSC_VER) @@ -121,8 +120,9 @@ struct IntUtil { // -------------------------------------------------------------------------- template - static ASMJIT_INLINE bool inInterval(const T& x, const T& start, const T& end) - { return x >= start && x <= end; } + static ASMJIT_INLINE bool inInterval(const T& x, const T& start, const T& end) { + return x >= start && x <= end; + } // -------------------------------------------------------------------------- // [AsmJit - IsInt/IsUInt] @@ -271,8 +271,9 @@ struct IntUtil { // [AsmJit - HasBit] // -------------------------------------------------------------------------- - static ASMJIT_INLINE bool hasBit(uint32_t x, uint32_t n) - { return static_cast((x >> n) & 0x1); } + static ASMJIT_INLINE bool hasBit(uint32_t x, uint32_t n) { + return static_cast((x >> n) & 0x1); + } // -------------------------------------------------------------------------- // [AsmJit - BitCount] @@ -310,8 +311,7 @@ struct IntUtil { static ASMJIT_INLINE uint32_t findFirstBit(uint32_t mask) { #if defined(_MSC_VER) DWORD i; - if (_BitScanForward(&i, mask)) - { + if (_BitScanForward(&i, mask)) { ASMJIT_ASSERT(findFirstBitSlow(mask) == i); return static_cast(i); } @@ -365,18 +365,21 @@ struct IntUtil { // -------------------------------------------------------------------------- template - static ASMJIT_INLINE bool isAligned(T base, T alignment) - { return (base % alignment) == 0; } + static ASMJIT_INLINE bool isAligned(T base, T alignment) { + return (base % alignment) == 0; + } //! @brief Align @a base to @a alignment. template - static ASMJIT_INLINE T alignTo(T base, T alignment) - { return (base + (alignment - 1)) & ~(alignment - 1); } + static ASMJIT_INLINE T alignTo(T base, T alignment) { + return (base + (alignment - 1)) & ~(alignment - 1); + } //! @brief Get delta required to align @a base to @a alignment. template - static ASMJIT_INLINE T deltaTo(T base, T alignment) - { return alignTo(base, alignment) - base; } + static ASMJIT_INLINE T deltaTo(T base, T alignment) { + return alignTo(base, alignment) - base; + } // -------------------------------------------------------------------------- // [AsmJit - Round] @@ -614,17 +617,21 @@ union UInt64 { // [Eq] // -------------------------------------------------------------------------- - ASMJIT_INLINE bool isZero() const - { return kArchHost64Bit ? u64 == 0 : (u32[0] | u32[1]) == 0; } + ASMJIT_INLINE bool isZero() const { + return kArchHost64Bit ? u64 == 0 : (u32[0] | u32[1]) == 0; + } - ASMJIT_INLINE bool isNonZero() const - { return kArchHost64Bit ? u64 != 0 : (u32[0] | u32[1]) != 0; } + ASMJIT_INLINE bool isNonZero() const { + return kArchHost64Bit ? u64 != 0 : (u32[0] | u32[1]) != 0; + } - ASMJIT_INLINE bool eq(uint64_t val) const - { return u64 == val; } + ASMJIT_INLINE bool eq(uint64_t val) const { + return u64 == val; + } - ASMJIT_INLINE bool eq(const UInt64& val) const - { return kArchHost64Bit ? u64 == val.u64 : (u32[0] == val.u32[0]) & (u32[1] == val.u32[1]); } + ASMJIT_INLINE bool eq(const UInt64& val) const { + return kArchHost64Bit ? u64 == val.u64 : (u32[0] == val.u32[0]) & (u32[1] == val.u32[1]); + } // -------------------------------------------------------------------------- // [Operator Overload] diff --git a/src/asmjit/base/memorymanager.cpp b/src/asmjit/base/memorymanager.cpp index 627b0a4..1eedb93 100644 --- a/src/asmjit/base/memorymanager.cpp +++ b/src/asmjit/base/memorymanager.cpp @@ -8,8 +8,8 @@ #define ASMJIT_EXPORTS // [Dependencies - AsmJit] -#include "../base/assert.h" #include "../base/error.h" +#include "../base/globals.h" #include "../base/lock.h" #include "../base/memorymanager.h" #include "../base/vmem.h" diff --git a/src/asmjit/base/podlist.h b/src/asmjit/base/podlist.h index a33c56b..dfda5a5 100644 --- a/src/asmjit/base/podlist.h +++ b/src/asmjit/base/podlist.h @@ -9,8 +9,8 @@ #define _ASMJIT_BASE_PODLIST_H // [Dependencies - AsmJit] -#include "../base/assert.h" #include "../base/defs.h" +#include "../base/globals.h" // [Api-Begin] #include "../base/apibegin.h" diff --git a/src/asmjit/base/podvector.h b/src/asmjit/base/podvector.h index 05f8cac..4c4d5aa 100644 --- a/src/asmjit/base/podvector.h +++ b/src/asmjit/base/podvector.h @@ -9,9 +9,9 @@ #define _ASMJIT_BASE_PODVECTOR_H // [Dependencies - AsmJit] -#include "../base/assert.h" #include "../base/defs.h" #include "../base/error.h" +#include "../base/globals.h" // [Api-Begin] #include "../base/apibegin.h" diff --git a/src/asmjit/base/string.h b/src/asmjit/base/string.h index c4f3c2e..90797ad 100644 --- a/src/asmjit/base/string.h +++ b/src/asmjit/base/string.h @@ -9,8 +9,8 @@ #define _ASMJIT_BASE_STRING_H // [Dependencies - AsmJit] -#include "../base/assert.h" #include "../base/defs.h" +#include "../base/globals.h" // [Dependencies - C] #include diff --git a/src/asmjit/build.h b/src/asmjit/build.h index d2c402d..8fed2ce 100644 --- a/src/asmjit/build.h +++ b/src/asmjit/build.h @@ -55,12 +55,31 @@ // [asmjit::build - Arch] // ============================================================================ -#if defined(__x86_64__) || defined(__LP64) || defined(__IA64__) || defined(_M_X64) || defined(_WIN64) +#if defined(_M_X64 ) || \ + defined(_M_AMD64 ) || \ + defined(_WIN64 ) || \ + defined(__amd64__ ) || \ + defined(__LP64 ) || \ + defined(__x86_64__) # define ASMJIT_HOST_X64 # define ASMJIT_HOST_LE -#elif defined(_M_IX86) || defined(__INTEL__) || defined(__i386__) +#elif \ + defined(_M_IX86 ) || \ + defined(__INTEL__) || \ + defined(__i386__ ) # define ASMJIT_HOST_X86 # define ASMJIT_HOST_LE +#elif \ + defined(_ARM ) || \ + defined(_M_ARM_FP ) || \ + defined(__ARM_NEON__ ) || \ + defined(__arm ) || \ + defined(__arm__ ) || \ + defined(__TARGET_ARCH_ARM ) || \ + defined(__TARGET_ARCH_THUMB) || \ + defined(__thumb__ ) +# define ASMJIT_HOST_ARM +# define ASMJIT_HOST_LE #else # warning "AsmJit - Unable to detect host architecture" #endif diff --git a/src/asmjit/x86/x86cpu.h b/src/asmjit/x86/x86cpu.h index c8d31c1..c956cee 100644 --- a/src/asmjit/x86/x86cpu.h +++ b/src/asmjit/x86/x86cpu.h @@ -157,21 +157,33 @@ struct Cpu : public BaseCpu { // -------------------------------------------------------------------------- //! @brief Get processor type. - ASMJIT_INLINE uint32_t getProcessorType() const { return _processorType; } + ASMJIT_INLINE uint32_t getProcessorType() const { + return _processorType; + } + //! @brief Get brand index. - ASMJIT_INLINE uint32_t getBrandIndex() const { return _brandIndex; } + ASMJIT_INLINE uint32_t getBrandIndex() const { + return _brandIndex; + } + //! @brief Get flush cache line size. - ASMJIT_INLINE uint32_t getFlushCacheLineSize() const { return _flushCacheLineSize; } + ASMJIT_INLINE uint32_t getFlushCacheLineSize() const { + return _flushCacheLineSize; + } + //! @brief Get maximum logical processors count. - ASMJIT_INLINE uint32_t getMaxLogicalProcessors() const { return _maxLogicalProcessors; } + ASMJIT_INLINE uint32_t getMaxLogicalProcessors() const { + return _maxLogicalProcessors; + } // -------------------------------------------------------------------------- // [Statics] // -------------------------------------------------------------------------- //! @brief Get global instance of @ref X86CpuInfo. - static ASMJIT_INLINE const Cpu* getHost() - { return static_cast(BaseCpu::getHost()); } + static ASMJIT_INLINE const Cpu* getHost() { + return static_cast(BaseCpu::getHost()); + } // -------------------------------------------------------------------------- // [Members] diff --git a/src/asmjit/x86/x86defs.h b/src/asmjit/x86/x86defs.h index c83f50e..0ac4a76 100644 --- a/src/asmjit/x86/x86defs.h +++ b/src/asmjit/x86/x86defs.h @@ -10,9 +10,9 @@ // [Dependencies - AsmJit] #include "../base/assembler.h" -#include "../base/assert.h" #include "../base/compiler.h" #include "../base/defs.h" +#include "../base/globals.h" #include "../base/intutil.h" #include "../base/vectypes.h" diff --git a/src/asmjit/x86/x86func.cpp b/src/asmjit/x86/x86func.cpp index f5d43ce..6d9620b 100644 --- a/src/asmjit/x86/x86func.cpp +++ b/src/asmjit/x86/x86func.cpp @@ -12,7 +12,7 @@ #if defined(ASMJIT_BUILD_X86) || defined(ASMJIT_BUILD_X64) // [Dependencies - AsmJit] -#include "../base/assert.h" +#include "../base/globals.h" #include "../base/intutil.h" #include "../base/string.h" #include "../x86/x86defs.h"