Minor reorganization.

This commit is contained in:
kobalicekp
2014-02-13 22:42:49 +01:00
parent c8cff8b16e
commit 5ea8bc00c2
17 changed files with 105 additions and 101 deletions

View File

@@ -190,8 +190,6 @@ AsmJit_AddSource(ASMJIT_SRC asmjit/base
assembler.cpp assembler.cpp
assembler.h assembler.h
assert.cpp
assert.h
codegen.cpp codegen.cpp
codegen.h codegen.h
compiler.cpp compiler.cpp
@@ -206,6 +204,7 @@ AsmJit_AddSource(ASMJIT_SRC asmjit/base
error.h error.h
func.cpp func.cpp
func.h func.h
globals.cpp
globals.h globals.h
intutil.h intutil.h
lock.h lock.h

View File

@@ -12,7 +12,6 @@
#include "build.h" #include "build.h"
#include "base/assembler.h" #include "base/assembler.h"
#include "base/assert.h"
#include "base/codegen.h" #include "base/codegen.h"
#include "base/compiler.h" #include "base/compiler.h"
#include "base/cpu.h" #include "base/cpu.h"

View File

@@ -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

View File

@@ -64,7 +64,7 @@ struct HostCpu : public x86x64::Cpu {
ASMJIT_INLINE HostCpu() : Cpu() { hostCpuDetect(this); } ASMJIT_INLINE HostCpu() : Cpu() { hostCpuDetect(this); }
}; };
#else #else
#error "asmjit/base/cpu.cpp - Unsupported CPU." #error "AsmJit - Unsupported CPU."
#endif // ASMJIT_HOST || ASMJIT_HOST_X64 #endif // ASMJIT_HOST || ASMJIT_HOST_X64
const BaseCpu* BaseCpu::getHost() const BaseCpu* BaseCpu::getHost()
@@ -72,7 +72,7 @@ const BaseCpu* BaseCpu::getHost()
#if defined(ASMJIT_HOST_X86) || defined(ASMJIT_HOST_X64) #if defined(ASMJIT_HOST_X86) || defined(ASMJIT_HOST_X64)
static HostCpu cpu; static HostCpu cpu;
#else #else
#error "asmjit/base/cpu.cpp - Unsupported CPU." #error "AsmJit - Unsupported CPU."
#endif // ASMJIT_HOST || ASMJIT_HOST_X64 #endif // ASMJIT_HOST || ASMJIT_HOST_X64
return &cpu; return &cpu;
} }

View File

@@ -8,9 +8,11 @@
#ifndef _ASMJIT_BASE_CPU_H #ifndef _ASMJIT_BASE_CPU_H
#define _ASMJIT_BASE_CPU_H #define _ASMJIT_BASE_CPU_H
// [Dependencies - AsmJit]
#include "../base/globals.h"
// [Api-Begin] // [Api-Begin]
#include "../base/apibegin.h" #include "../base/apibegin.h"
#include "../base/assert.h"
namespace asmjit { namespace asmjit {

View File

@@ -9,8 +9,8 @@
#define _ASMJIT_BASE_FUNC_H #define _ASMJIT_BASE_FUNC_H
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h"
#include "../base/defs.h" #include "../base/defs.h"
#include "../base/globals.h"
// [Api-Begin] // [Api-Begin]
#include "../base/apibegin.h" #include "../base/apibegin.h"

View File

@@ -8,7 +8,7 @@
#define ASMJIT_EXPORTS #define ASMJIT_EXPORTS
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h" #include "../base/globals.h"
// [Api-Begin] // [Api-Begin]
#include "../base/apibegin.h" #include "../base/apibegin.h"

View File

@@ -26,7 +26,7 @@ namespace asmjit {
static const size_t kInvalidIndex = ~static_cast<size_t>(0); static const size_t kInvalidIndex = ~static_cast<size_t>(0);
ASMJIT_ENUM(kGlobals) { ASMJIT_ENUM(kGlobals) {
//! @brief Invalid operand id. //! @brief Invalid value or operand id.
kInvalidValue = 0xFFFFFFFF, kInvalidValue = 0xFFFFFFFF,
//! @brief Invalid register index. //! @brief Invalid register index.
@@ -97,6 +97,29 @@ static const _Init Init = {};
struct _NoInit {}; struct _NoInit {};
static const _NoInit 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 } // asmjit namespace

View File

@@ -9,7 +9,6 @@
#define _ASMJIT_BASE_INTUTIL_H #define _ASMJIT_BASE_INTUTIL_H
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h"
#include "../base/globals.h" #include "../base/globals.h"
#if defined(_MSC_VER) #if defined(_MSC_VER)
@@ -121,8 +120,9 @@ struct IntUtil {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
template<typename T> template<typename T>
static ASMJIT_INLINE bool inInterval(const T& x, const T& start, const T& end) static ASMJIT_INLINE bool inInterval(const T& x, const T& start, const T& end) {
{ return x >= start && x <= end; } return x >= start && x <= end;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [AsmJit - IsInt/IsUInt] // [AsmJit - IsInt/IsUInt]
@@ -271,8 +271,9 @@ struct IntUtil {
// [AsmJit - HasBit] // [AsmJit - HasBit]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
static ASMJIT_INLINE bool hasBit(uint32_t x, uint32_t n) static ASMJIT_INLINE bool hasBit(uint32_t x, uint32_t n) {
{ return static_cast<bool>((x >> n) & 0x1); } return static_cast<bool>((x >> n) & 0x1);
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [AsmJit - BitCount] // [AsmJit - BitCount]
@@ -310,8 +311,7 @@ struct IntUtil {
static ASMJIT_INLINE uint32_t findFirstBit(uint32_t mask) { static ASMJIT_INLINE uint32_t findFirstBit(uint32_t mask) {
#if defined(_MSC_VER) #if defined(_MSC_VER)
DWORD i; DWORD i;
if (_BitScanForward(&i, mask)) if (_BitScanForward(&i, mask)) {
{
ASMJIT_ASSERT(findFirstBitSlow(mask) == i); ASMJIT_ASSERT(findFirstBitSlow(mask) == i);
return static_cast<uint32_t>(i); return static_cast<uint32_t>(i);
} }
@@ -365,18 +365,21 @@ struct IntUtil {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
template<typename T> template<typename T>
static ASMJIT_INLINE bool isAligned(T base, T alignment) static ASMJIT_INLINE bool isAligned(T base, T alignment) {
{ return (base % alignment) == 0; } return (base % alignment) == 0;
}
//! @brief Align @a base to @a alignment. //! @brief Align @a base to @a alignment.
template<typename T> template<typename T>
static ASMJIT_INLINE T alignTo(T base, T alignment) static ASMJIT_INLINE T alignTo(T base, T alignment) {
{ return (base + (alignment - 1)) & ~(alignment - 1); } return (base + (alignment - 1)) & ~(alignment - 1);
}
//! @brief Get delta required to align @a base to @a alignment. //! @brief Get delta required to align @a base to @a alignment.
template<typename T> template<typename T>
static ASMJIT_INLINE T deltaTo(T base, T alignment) static ASMJIT_INLINE T deltaTo(T base, T alignment) {
{ return alignTo(base, alignment) - base; } return alignTo(base, alignment) - base;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [AsmJit - Round] // [AsmJit - Round]
@@ -614,17 +617,21 @@ union UInt64 {
// [Eq] // [Eq]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ASMJIT_INLINE bool isZero() const ASMJIT_INLINE bool isZero() const {
{ return kArchHost64Bit ? u64 == 0 : (u32[0] | u32[1]) == 0; } return kArchHost64Bit ? u64 == 0 : (u32[0] | u32[1]) == 0;
}
ASMJIT_INLINE bool isNonZero() const ASMJIT_INLINE bool isNonZero() const {
{ return kArchHost64Bit ? u64 != 0 : (u32[0] | u32[1]) != 0; } return kArchHost64Bit ? u64 != 0 : (u32[0] | u32[1]) != 0;
}
ASMJIT_INLINE bool eq(uint64_t val) const ASMJIT_INLINE bool eq(uint64_t val) const {
{ return u64 == val; } return u64 == val;
}
ASMJIT_INLINE bool eq(const UInt64& val) const ASMJIT_INLINE bool eq(const UInt64& val) const {
{ return kArchHost64Bit ? u64 == val.u64 : (u32[0] == val.u32[0]) & (u32[1] == val.u32[1]); } return kArchHost64Bit ? u64 == val.u64 : (u32[0] == val.u32[0]) & (u32[1] == val.u32[1]);
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Operator Overload] // [Operator Overload]

View File

@@ -8,8 +8,8 @@
#define ASMJIT_EXPORTS #define ASMJIT_EXPORTS
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h"
#include "../base/error.h" #include "../base/error.h"
#include "../base/globals.h"
#include "../base/lock.h" #include "../base/lock.h"
#include "../base/memorymanager.h" #include "../base/memorymanager.h"
#include "../base/vmem.h" #include "../base/vmem.h"

View File

@@ -9,8 +9,8 @@
#define _ASMJIT_BASE_PODLIST_H #define _ASMJIT_BASE_PODLIST_H
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h"
#include "../base/defs.h" #include "../base/defs.h"
#include "../base/globals.h"
// [Api-Begin] // [Api-Begin]
#include "../base/apibegin.h" #include "../base/apibegin.h"

View File

@@ -9,9 +9,9 @@
#define _ASMJIT_BASE_PODVECTOR_H #define _ASMJIT_BASE_PODVECTOR_H
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h"
#include "../base/defs.h" #include "../base/defs.h"
#include "../base/error.h" #include "../base/error.h"
#include "../base/globals.h"
// [Api-Begin] // [Api-Begin]
#include "../base/apibegin.h" #include "../base/apibegin.h"

View File

@@ -9,8 +9,8 @@
#define _ASMJIT_BASE_STRING_H #define _ASMJIT_BASE_STRING_H
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h"
#include "../base/defs.h" #include "../base/defs.h"
#include "../base/globals.h"
// [Dependencies - C] // [Dependencies - C]
#include <stdarg.h> #include <stdarg.h>

View File

@@ -55,12 +55,31 @@
// [asmjit::build - Arch] // [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_X64
# define ASMJIT_HOST_LE # 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_X86
# define ASMJIT_HOST_LE # 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 #else
# warning "AsmJit - Unable to detect host architecture" # warning "AsmJit - Unable to detect host architecture"
#endif #endif

View File

@@ -157,21 +157,33 @@ struct Cpu : public BaseCpu {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
//! @brief Get processor type. //! @brief Get processor type.
ASMJIT_INLINE uint32_t getProcessorType() const { return _processorType; } ASMJIT_INLINE uint32_t getProcessorType() const {
return _processorType;
}
//! @brief Get brand index. //! @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. //! @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. //! @brief Get maximum logical processors count.
ASMJIT_INLINE uint32_t getMaxLogicalProcessors() const { return _maxLogicalProcessors; } ASMJIT_INLINE uint32_t getMaxLogicalProcessors() const {
return _maxLogicalProcessors;
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Statics] // [Statics]
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
//! @brief Get global instance of @ref X86CpuInfo. //! @brief Get global instance of @ref X86CpuInfo.
static ASMJIT_INLINE const Cpu* getHost() static ASMJIT_INLINE const Cpu* getHost() {
{ return static_cast<const Cpu*>(BaseCpu::getHost()); } return static_cast<const Cpu*>(BaseCpu::getHost());
}
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// [Members] // [Members]

View File

@@ -10,9 +10,9 @@
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assembler.h" #include "../base/assembler.h"
#include "../base/assert.h"
#include "../base/compiler.h" #include "../base/compiler.h"
#include "../base/defs.h" #include "../base/defs.h"
#include "../base/globals.h"
#include "../base/intutil.h" #include "../base/intutil.h"
#include "../base/vectypes.h" #include "../base/vectypes.h"

View File

@@ -12,7 +12,7 @@
#if defined(ASMJIT_BUILD_X86) || defined(ASMJIT_BUILD_X64) #if defined(ASMJIT_BUILD_X86) || defined(ASMJIT_BUILD_X64)
// [Dependencies - AsmJit] // [Dependencies - AsmJit]
#include "../base/assert.h" #include "../base/globals.h"
#include "../base/intutil.h" #include "../base/intutil.h"
#include "../base/string.h" #include "../base/string.h"
#include "../x86/x86defs.h" #include "../x86/x86defs.h"