mirror of
https://github.com/asmjit/asmjit.git
synced 2025-12-18 04:54:36 +03:00
Minor reorganization.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define ASMJIT_EXPORTS
|
||||
|
||||
// [Dependencies - AsmJit]
|
||||
#include "../base/assert.h"
|
||||
#include "../base/globals.h"
|
||||
|
||||
// [Api-Begin]
|
||||
#include "../base/apibegin.h"
|
||||
@@ -26,7 +26,7 @@ namespace asmjit {
|
||||
static const size_t kInvalidIndex = ~static_cast<size_t>(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
|
||||
|
||||
@@ -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<typename T>
|
||||
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<bool>((x >> n) & 0x1); }
|
||||
static ASMJIT_INLINE bool hasBit(uint32_t x, uint32_t n) {
|
||||
return static_cast<bool>((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<uint32_t>(i);
|
||||
}
|
||||
@@ -365,18 +365,21 @@ struct IntUtil {
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
template<typename T>
|
||||
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<typename T>
|
||||
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<typename T>
|
||||
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]
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 <stdarg.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
|
||||
|
||||
@@ -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<const Cpu*>(BaseCpu::getHost()); }
|
||||
static ASMJIT_INLINE const Cpu* getHost() {
|
||||
return static_cast<const Cpu*>(BaseCpu::getHost());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// [Members]
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user