diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c41ef7..898fd51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,14 +41,12 @@ jobs: - { title: "linux/ubsan" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1", diagnostics: "ubsan", } - { title: "linux/hardened" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1", diagnostics: "hardened", } - { title: "linux/valgrind" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1", diagnostics: "valgrind", } - - { title: "linux/no-deprecated" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_DEPRECATED=1" } - { title: "linux/no-logging" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_LOGGING=1" } - { title: "linux/no-logging-text" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_LOGGING=1,ASMJIT_NO_TEXT=1" } - { title: "linux/no-builder" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_BUILDER=1" } - { title: "linux/no-compiler" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_COMPILER=1" } - { title: "linux/no-introspection", host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_COMPILER=1,ASMJIT_NO_INTROSPECTION=1" } - { title: "linux/no-jit" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_JIT=1" } - - { title: "linux/no-validation" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_VALIDATION=1" } - { title: "linux/no-x86" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_X86=1" } - { title: "linux/no-aarch64" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Release", defs: "ASMJIT_TEST=1,ASMJIT_NO_AARCH64=1" } - { title: "linux/use-c++20" , host: "ubuntu-24.04" , arch: "x64" , cc: "clang-19", conf: "Debug" , defs: "ASMJIT_TEST=1,CMAKE_CXX_FLAGS=-std=c++20" } diff --git a/CMakeLists.txt b/CMakeLists.txt index 064b255..5d74653 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,53 @@ # AsmJit # ====== -# To consume asmjit as a dependency, use asmjit::asmjit alias. +# AsmJit library provides a single alias that can use used to consume it as a dependency: +# +# `asmjit::asmjit` +# +# Depending on options, the alias would be either a static or shared library (depending on +# `ASMJIT_STATIC=ON|OFF` options) or it would be an interface library if `ASMJIT_EMBED=ON`. +# +# NOTE: When `ASMJIT_EMBED=ON` AsmJit won't add any installation instructions of libraries +# or header files. Embed is literally for users that want to consume AsmJit as source code +# without creating an intermediate static library. C++ flags, which used by the consuming +# target will then be used to compile the embedded AsmJit source code as well. This option +# improves the control of how AsmJit is both compiled and consumed. +# +# Consuming AsmJit +# ---------------- +# +# The recommended scenario to consume AsmJit is to clone it to a directory where third +# party libraries are placed (this can be done even if you use a package manager such as +# vcpkg or conan to manage other dependencies). Usually, the directory is called '3rdparty' +# and it resides in your project's root, but it's just a recommendation, not a convention. +# In such case, consuming a cloned AsmJit from your own project would look like this: +# +# # == Configure AsmJit options == +# set(ASMJIT_EMBED ON or OFF) # AsmJit uses ASMJIT_EMBED=OFF by default. +# set(ASMJIT_STATIC ON or OFF) # AsmJit uses ASMJIT_STATIC=OFF by default. +# add_subdirectory(3rdparty/asmjit asmjit) # Adds AsmJit as a sub-project. +# +# # == Consume AsmJit as a CMake dependency == +# add_executable(test_app main.cpp) # Target executable having main.cpp +# target_link_libraries(test_app asmjit::asmjit) # Adds AsmJit as a dependency to test_app. +# +# Developing & Testing AsmJit +# --------------------------- +# +# There are sample configure scripts provided, which reside in project root. In general, to +# develop AsmJit it must be configured with `ASMJIT_TEST=ON` to build AsmJit tests and they +# have to pass. Here is a simple cmake invocation to build AsmJit with tests enabled: +# +# cmake . -B build/Debug -DCMAKE_BUILD_TYPE=Debug -DASMJIT_TEST=ON +# +# See for more details. cmake_minimum_required(VERSION 3.24 FATAL_ERROR) +# AsmJit - Project & Configuration +# ================================ + # Don't create a project if it was already created by another CMakeLists.txt. This makes # it possible to support both add_subdirectory() and include() ways of using AsmJit as a # dependency. @@ -15,339 +58,56 @@ if (NOT CMAKE_PROJECT_NAME OR "${CMAKE_PROJECT_NAME}" STREQUAL "asmjit") HOMEPAGE_URL "https://asmjit.com") endif() -include(CheckCXXCompilerFlag) -include(CheckCXXSourceCompiles) -include(GNUInstallDirs) +set(ASMJIT_SANITIZE "" CACHE STRING "Sanitizers to use (development)") +set(ASMJIT_SANITIZE_OPTS "" CACHE STRING "Extra flags for sanitizers (development)") -# AsmJit - Configuration - Build -# ============================== +option(ASMJIT_EMBED "Embed 'asmjit' as an interface library (no static/shared library)" OFF) +option(ASMJIT_STATIC "Build 'asmjit' as a static library (implied by ASMJIT_EMBED)" ${ASMJIT_EMBED}) +option(ASMJIT_TEST "Build 'asmjit' tests and benchmarks (development)" OFF) -if (NOT DEFINED ASMJIT_TEST) - set(ASMJIT_TEST FALSE) -endif() +option(ASMJIT_NO_NATVIS "Disable natvis support (embedding asmjit.natvis in PDB)" OFF) +option(ASMJIT_NO_CUSTOM_FLAGS "Disable extra compilation flags added by AsmJit to its targets" OFF) +option(ASMJIT_NO_ABI_NAMESPACE "Disable the use of inline ABI namespace {asmjit::v...}" OFF) +option(ASMJIT_NO_SHM_OPEN "Disable the use of shm_open() (some platforms have better options)" OFF) +option(ASMJIT_NO_X86 "Disable X86/X64 backend" OFF) +option(ASMJIT_NO_AARCH64 "Disable AArch64 backend" OFF) +option(ASMJIT_NO_FOREIGN "Disable all foreign backends (enables only a backend that matches the target)" OFF) +option(ASMJIT_NO_JIT "Disable VirtMem, JitAllocator, and JitRuntime at build time" OFF) +option(ASMJIT_NO_TEXT "Disable textual representation of instructions, enums, cpu features, ..." OFF) +option(ASMJIT_NO_LOGGING "Disable logging features (build feature)" ${ASMJIT_NO_TEXT}) +option(ASMJIT_NO_INTROSPECTION "Disable instruction validation and introspection API (build feature)" OFF) +option(ASMJIT_NO_BUILDER "Disable AsmJit's Builder emitter (build feature)" OFF) -if (NOT DEFINED ASMJIT_EMBED) - set(ASMJIT_EMBED FALSE) -endif() - -if (NOT DEFINED ASMJIT_STATIC) - set(ASMJIT_STATIC ${ASMJIT_EMBED}) -endif() - -if (NOT DEFINED ASMJIT_SANITIZE) - set(ASMJIT_SANITIZE FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_CUSTOM_FLAGS) - set(ASMJIT_NO_CUSTOM_FLAGS FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_NATVIS) - set(ASMJIT_NO_NATVIS FALSE) -endif() - -# EMBED implies STATIC. -if (ASMJIT_EMBED AND NOT ASMJIT_STATIC) - set(ASMJIT_STATIC TRUE) -endif() - -if (NOT DEFINED ASMJIT_NO_DEPRECATED) - set(ASMJIT_NO_DEPRECATED FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_ABI_NAMESPACE) - set(ASMJIT_NO_ABI_NAMESPACE FALSE) -endif() - -# AsmJit - Configuration - Backend -# ================================ - -if (NOT DEFINED ASMJIT_NO_X86) - set(ASMJIT_NO_X86 FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_AARCH64) - set(ASMJIT_NO_AARCH64 FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_FOREIGN) - set(ASMJIT_NO_FOREIGN FALSE) -endif() - -# AsmJit - Configuration - Features -# ================================= - -if (NOT DEFINED ASMJIT_NO_SHM_OPEN) - set(ASMJIT_NO_SHM_OPEN FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_JIT) - set(ASMJIT_NO_JIT FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_TEXT) - set(ASMJIT_NO_TEXT FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_LOGGING) - set(ASMJIT_NO_LOGGING ${ASMJIT_NO_TEXT}) -endif() - -if (NOT DEFINED ASMJIT_NO_VALIDATION) - set(ASMJIT_NO_VALIDATION FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_INTROSPECTION) - set(ASMJIT_NO_INTROSPECTION FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_BUILDER) - set(ASMJIT_NO_BUILDER FALSE) -endif() - -if (NOT DEFINED ASMJIT_NO_COMPILER) - if (ASMJIT_NO_BUILDER OR ASMJIT_NO_INTROSPECTION) - set(ASMJIT_NO_COMPILER TRUE) - else() - set(ASMJIT_NO_COMPILER FALSE) - endif() -endif() - -if (NOT DEFINED ASMJIT_NO_UJIT) - if (ASMJIT_NO_COMPILER) - set(ASMJIT_NO_UJIT TRUE) - else() - set(ASMJIT_NO_UJIT FALSE) - endif() -endif() - -# AsmJit - Configuration - CMake Introspection -# ============================================ - -set(ASMJIT_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Location of 'asmjit'") -set(ASMJIT_TEST "${ASMJIT_TEST}" CACHE BOOL "Build 'asmjit' test applications") -set(ASMJIT_EMBED "${ASMJIT_EMBED}" CACHE BOOL "Embed 'asmjit' library (no targets)") -set(ASMJIT_STATIC "${ASMJIT_STATIC}" CACHE BOOL "Build 'asmjit' library as static") -set(ASMJIT_SANITIZE "${ASMJIT_SANITIZE}" CACHE STRING "Build with sanitizers: 'address', 'undefined', etc...") -set(ASMJIT_NO_NATVIS "${ASMJIT_NO_NATVIS}" CACHE BOOL "Disable natvis support (embedding asmjit.natvis in PDB)") -set(ASMJIT_NO_CUSTOM_FLAGS "${ASMJIT_NO_CUSTOM_FLAGS}" CACHE BOOL "Disable extra compilation flags added by AsmJit to its targets") - -set(ASMJIT_NO_X86 "${ASMJIT_NO_X86}" CACHE BOOL "Disable X86/X64 backend") -set(ASMJIT_NO_AARCH64 "${ASMJIT_NO_AARCH64}" CACHE BOOL "Disable AArch64 backend") -set(ASMJIT_NO_FOREIGN "${ASMJIT_NO_FOREIGN}" CACHE BOOL "Disable all foreign architectures (enables only a target architecture)") - -set(ASMJIT_NO_DEPRECATED "${ASMJIT_NO_DEPRECATED}" CACHE BOOL "Disable deprecated API at build time") -set(ASMJIT_NO_ABI_NAMESPACE "${ASMJIT_NO_ABI_NAMESPACE}" CACHE BOOL "Disable the use of ABI namespace (inline namespace in {asmjit} adding ABI version)") - -set(ASMJIT_NO_SHM_OPEN "${ASMJIT_NO_SHM_OPEN}" CACHE BOOL "Disable the use of shm_open() even on platforms where it's supported") -set(ASMJIT_NO_JIT "${ASMJIT_NO_JIT}" CACHE BOOL "Disable VirtMem, JitAllocator, and JitRuntime at build time") -set(ASMJIT_NO_TEXT "${ASMJIT_NO_TEXT}" CACHE BOOL "Disable textual representation of instructions, enums, cpu features, ...") -set(ASMJIT_NO_LOGGING "${ASMJIT_NO_LOGGING}" CACHE BOOL "Disable logging features at build time") -set(ASMJIT_NO_VALIDATION "${ASMJIT_NO_VALIDATION}" CACHE BOOL "Disable instruction validation API at build time") -set(ASMJIT_NO_INTROSPECTION "${ASMJIT_NO_INTROSPECTION}" CACHE BOOL "Disable instruction introspection API at build time") -set(ASMJIT_NO_BUILDER "${ASMJIT_NO_BUILDER}" CACHE BOOL "Disable Builder at build time") -set(ASMJIT_NO_COMPILER "${ASMJIT_NO_COMPILER}" CACHE BOOL "Disable Compiler at build time") -set(ASMJIT_NO_UJIT "${ASMJIT_NO_UJIT}" CACHE BOOL "Disable UniCompiler at build time") - -# AsmJit - Project -# ================ - -set(ASMJIT_INCLUDE_DIRS "${ASMJIT_DIR}/src") # Include directory is the same as source dir. -set(ASMJIT_DEPS "") # AsmJit dependencies (libraries) for the linker. -set(ASMJIT_LIBS "") # Dependencies of libs/apps that want to use AsmJit. -set(ASMJIT_CFLAGS "") # Public compiler flags. -set(ASMJIT_PRIVATE_CFLAGS "") # Private compiler flags independent of build type. -set(ASMJIT_PRIVATE_CFLAGS_DBG "") # Private compiler flags used by debug builds. -set(ASMJIT_PRIVATE_CFLAGS_REL "") # Private compiler flags used by release builds. -set(ASMJIT_SANITIZE_CFLAGS "") # Compiler flags required by currently enabled sanitizers. -set(ASMJIT_SANITIZE_LFLAGS "") # Linker flags required by currently enabled sanitizers. - -# AsmJit - Utilities -# ================== - -function(asmjit_detect_cflags out) - set(out_array ${${out}}) - foreach(flag ${ARGN}) - string(REGEX REPLACE "[+]" "x" flag_signature "${flag}") - string(REGEX REPLACE "[-=:;/.\]" "_" flag_signature "${flag_signature}") - check_cxx_compiler_flag(${flag} "__CxxFlag_${flag_signature}") - if (${__CxxFlag_${flag_signature}}) - list(APPEND out_array "${flag}") - endif() - endforeach() - set(${out} "${out_array}" PARENT_SCOPE) -endfunction() - -# Support for various sanitizers provided by C/C++ compilers. -function(asmjit_detect_sanitizers out) - set(_out_array ${${out}}) - set(_flags "") - - foreach(_arg ${ARGN}) - string(REPLACE "," ";" _arg "${_arg}") - list(APPEND _flags ${_arg}) - endforeach() - - foreach(_flag ${_flags}) - if (NOT "${_flag}" MATCHES "^-fsanitize=") - SET(_flag "-fsanitize=${_flag}") - endif() - - # Sanitizers also require link flags, see CMAKE_REQUIRED_FLAGS. - set(CMAKE_REQUIRED_FLAGS "${_flag}") - asmjit_detect_cflags(_out_array ${_flag}) - unset(CMAKE_REQUIRED_FLAGS) - endforeach() - - set(${out} "${_out_array}" PARENT_SCOPE) -endfunction() - -function(asmjit_addapp target target_type) - set(single_val "") - set(multi_val SOURCES LIBRARIES CFLAGS CFLAGS_DBG CFLAGS_REL) - cmake_parse_arguments("X" "" "${single_val}" "${multi_val}" ${ARGN}) - - if ("${target_type}" MATCHES "^(EXECUTABLE|TEST)$") - add_executable(${target} ${X_SOURCES}) - else() - add_library(${target} ${target_type} ${X_SOURCES}) - endif() - - set_target_properties(${target} - PROPERTIES - DEFINE_SYMBOL "" - CXX_VISIBILITY_PRESET hidden) - target_compile_options(${target} PRIVATE ${X_CFLAGS} ${ASMJIT_SANITIZE_CFLAGS} $<$:${X_CFLAGS_DBG}> $<$>:${X_CFLAGS_REL}>) - target_compile_features(${target} PUBLIC cxx_std_17) - target_link_options(${target} PRIVATE ${ASMJIT_PRIVATE_LFLAGS}) - target_link_libraries(${target} PRIVATE ${X_LIBRARIES}) - - if ("${target_type}" STREQUAL "TEST") - add_test(NAME ${target} COMMAND ${target}) - endif() -endfunction() - -# AsmJit - Compiler Support -# ========================= - -# We will have to keep this most likely forever as some users may still be using it. -set(ASMJIT_INCLUDE_DIR "${ASMJIT_INCLUDE_DIRS}") - -if (NOT ASMJIT_NO_CUSTOM_FLAGS) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") - list(APPEND ASMJIT_PRIVATE_CFLAGS -W4) # [+] Warning level 4. - - list(APPEND ASMJIT_PRIVATE_CFLAGS -MP) # [+] Multi-Process Compilation. - list(APPEND ASMJIT_PRIVATE_CFLAGS -GF) # [+] Eliminate duplicate strings. - list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:__cplusplus) # [+] Conforming __cplusplus definition. - list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:inline) # [+] Remove unreferenced COMDAT. - list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:strictStrings) # [+] Strict const qualification of string literals. - list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:threadSafeInit-) # [-] Thread-safe statics. - - list(APPEND ASMJIT_PRIVATE_CFLAGS_DBG -GS) # [+] Buffer security-check. - list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -GS-) # [-] Buffer security-check. - list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -O2) # [+] Favor speed over size. - list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -Oi) # [+] Generate intrinsic functions. - elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") - list(APPEND ASMJIT_PRIVATE_CFLAGS -Wall -Wextra -Wconversion) # [+] Add baseline warnings that can be used safely even with system headers. - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wdouble-promotion) # [+] Warn about double promotions. - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wduplicated-cond) # [+] Warn about duplicate conditions. - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wduplicated-branches) # [+] Warn about duplicate branches. - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wlogical-op) # [+] Warn about suspicious uses of logical operators in expressions. - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wlogical-not-parentheses) # [+] Warn about logical not used on the left hand side operand of a comparison. - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wrestrict) - - list(APPEND ASMJIT_PRIVATE_CFLAGS -fno-math-errno) # [-] Disable math functions setting errno (performance reasons). - list(APPEND ASMJIT_PRIVATE_CFLAGS -fno-threadsafe-statics) # [-] Don't add guards when initializing statics (we don't need it). - list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -O2) # [+] Compiling with -O2 in release mode is what we generally want. - list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -fmerge-all-constants) # [+] We don't need unique address per constant (merging improves library size). - - # -fno-semantic-interposition is not available on apple - the compiler issues a warning, which is not detected. - if (NOT APPLE) - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -fno-semantic-interposition) - endif() - - if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS") - asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS_REL -fno-enforce-eh-specs) # [-] Don't enforce termination if noexcept function throws. - endif() - endif() -endif() - -# Support for sanitizers. -if (ASMJIT_SANITIZE) - asmjit_detect_sanitizers(ASMJIT_SANITIZE_CFLAGS ${ASMJIT_SANITIZE}) - if (ASMJIT_SANITIZE_CFLAGS) - message("-- Enabling sanitizers: '${ASMJIT_SANITIZE_CFLAGS}'") - - # Linker must receive the same flags as the compiler when it comes to sanitizers. - set(ASMJIT_SANITIZE_LFLAGS ${ASMJIT_SANITIZE_CFLAGS}) - - # Don't omit frame pointer if sanitizers are enabled. - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") - list(APPEND ASMJIT_SANITIZE_CFLAGS -Oy-) - else() - list(APPEND ASMJIT_SANITIZE_CFLAGS -fno-omit-frame-pointer -g) - endif() - - list(APPEND ASMJIT_PRIVATE_CFLAGS ${ASMJIT_SANITIZE_CFLAGS}) - list(APPEND ASMJIT_PRIVATE_LFLAGS ${ASMJIT_SANITIZE_LFLAGS}) - endif() -endif() - -if (WIN32) - # Dependency: nothing extra at the moment. -elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") - # Dependency: libc is the only required library on Android as it also provides libthread. - message("-- Dependency: adding libc (Android target detected)") - list(APPEND ASMJIT_DEPS c) -elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku") - # Dependency: libroot is used by Haiku instead of libc, so link to libroot and libpthread. - message("-- Dependency: adding libroot and libpthread (Haiku target detected)") - list(APPEND ASMJIT_DEPS root pthread) +if (NOT ASMJIT_NO_BUILDER AND NOT ASMJIT_NO_INTROSPECTION) + option(ASMJIT_NO_COMPILER "Disable AsmJit's Compiler emitter (build feature)" OFF) else() - # Dependency: libc is always required. - message("-- Dependency: adding libc (Linux, BSD, or other UNIX/POSIX environment)") - list(APPEND ASMJIT_DEPS c) - - # Dependency: pthread (required so AsmJit can use pthread_lock). - check_cxx_source_compiles(" - #include - int main() { - pthread_mutex_t m; - pthread_mutex_init(&m, nullptr); - return pthread_mutex_destroy(&m); - } - " ASMJIT_LIBC_HAS_LIBPTHREAD) - if (ASMJIT_LIBC_HAS_LIBPTHREAD) - message("-- Dependency: libpthread provided by libc (not linking to libpthread)") - else() - message("-- Dependency: libpthread not provided by libc, linking to libpthread") - list(APPEND ASMJIT_DEPS pthread) - endif() - - # Dependency: shm_open (required so AsmJit can use shm_open on supported platforms). - if ("${CMAKE_SYSTEM_NAME}" MATCHES "^(Linux|NetBSD)$" AND NOT ASMJIT_NO_SHM_OPEN) - check_cxx_source_compiles(" - #include - int main() { - const char file_name[1] {}; - return shm_open(file_name, 0, 0); - } - " ASMJIT_LIBC_HAS_LIBRT) - if (ASMJIT_LIBC_HAS_LIBRT) - message("-- Dependency: shm_open provided by libc (not linking to librt)") - else() - message("-- Dependency: shm_open not provided by libc, linking to librt") - list(APPEND ASMJIT_DEPS rt) - endif() + if (NOT ASMJIT_NO_COMPILER) + unset(ASMJIT_NO_COMPILER CACHE) endif() + option(ASMJIT_NO_COMPILER "Disable AsmJit's Compiler emitter (build feature)" ON) endif() -set(ASMJIT_LIBS ${ASMJIT_DEPS}) -if (NOT ASMJIT_EMBED) - list(INSERT ASMJIT_LIBS 0 asmjit) +if (NOT ASMJIT_NO_COMPILER) + option(ASMJIT_NO_UJIT "Disable AsmJit's UniCompiler backend (build feature)" OFF) +else() + if (NOT ASMJIT_NO_UJIT) + unset(ASMJIT_NO_UJIT CACHE) + endif() + option(ASMJIT_NO_UJIT "Disable AsmJit's UniCompiler backend (build feature)" ON) endif() +# AsmJit - Build Definitions and Source Files +# =========================================== + +set(ASMJIT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}") # AsmJit include directory is the same as directory. +set(ASMJIT_LIBS "") # AsmJit library dependencies for the linker. +set(ASMJIT_CFLAGS "") # Public compiler flags. +set(ASMJIT_PRIVATE_CFLAGS "") # Private compiler flags independent of build type. +set(ASMJIT_PRIVATE_CFLAGS_DBG "") # Private compiler flags used by debug builds. +set(ASMJIT_PRIVATE_CFLAGS_REL "") # Private compiler flags used by release builds. +set(ASMJIT_SANITIZE_CFLAGS "") # Compiler flags required by currently enabled sanitizers. +set(ASMJIT_SANITIZE_LFLAGS "") # Linker flags required by currently enabled sanitizers. + if (ASMJIT_EMBED) set(ASMJIT_TARGET_TYPE "EMBED") elseif (ASMJIT_STATIC) @@ -355,44 +115,9 @@ elseif (ASMJIT_STATIC) else() set(ASMJIT_TARGET_TYPE "SHARED") endif() +message(STATUS "[asmjit] == Configuring AsmJit ('ASMJIT_TARGET_TYPE=${ASMJIT_TARGET_TYPE}') ==") -foreach(build_option # AsmJit build options. - ASMJIT_STATIC - ASMJIT_NO_DEPRECATED - ASMJIT_NO_ABI_NAMESPACE - # AsmJit backends selection. - ASMJIT_NO_X86 - ASMJIT_NO_AARCH64 - ASMJIT_NO_FOREIGN - # AsmJit features selection. - ASMJIT_NO_SHM_OPEN - ASMJIT_NO_JIT - ASMJIT_NO_TEXT - ASMJIT_NO_LOGGING - ASMJIT_NO_INTROSPECTION - ASMJIT_NO_VALIDATION - ASMJIT_NO_BUILDER - ASMJIT_NO_COMPILER - ASMJIT_NO_UJIT) - if (${build_option}) - List(APPEND ASMJIT_CFLAGS "-D${build_option}") - List(APPEND ASMJIT_PRIVATE_CFLAGS "-D${build_option}") - endif() -endforeach() - -# AsmJit - Linker Support -# ======================= - -if (WIN32) - if (CMAKE_LINKER MATCHES "link\\.exe" OR CMAKE_LINKER MATCHES "lld-link\\.exe") - set(ASMJIT_LINKER_SUPPORTS_NATVIS TRUE) - endif() -endif() - -# AsmJit - Source -# =============== - -set(ASMJIT_SRC_LIST +set(ASMJIT_SRC asmjit/asmjit.h asmjit/asmjit-scope-begin.h asmjit/asmjit-scope-end.h @@ -400,20 +125,6 @@ set(ASMJIT_SRC_LIST asmjit/core.h asmjit/core/api-build_p.h asmjit/core/api-config.h - asmjit/core/arena.cpp - asmjit/core/arena.h - asmjit/core/arenabitset.cpp - asmjit/core/arenabitset_p.h - asmjit/core/arenahash.cpp - asmjit/core/arenahash.h - asmjit/core/arenalist.cpp - asmjit/core/arenalist.h - asmjit/core/arenapool.h - asmjit/core/arenastring.h - asmjit/core/arenatree.cpp - asmjit/core/arenatree.h - asmjit/core/arenavector.cpp - asmjit/core/arenavector.h asmjit/core/archtraits.cpp asmjit/core/archtraits.h asmjit/core/archcommons.h @@ -480,11 +191,8 @@ set(ASMJIT_SRC_LIST asmjit/core/rapass_p.h asmjit/core/rastack.cpp asmjit/core/rastack_p.h - asmjit/core/span.h asmjit/core/string.cpp asmjit/core/string.h - asmjit/core/support.cpp - asmjit/core/support.h asmjit/core/target.cpp asmjit/core/target.h asmjit/core/type.cpp @@ -492,6 +200,25 @@ set(ASMJIT_SRC_LIST asmjit/core/virtmem.cpp asmjit/core/virtmem.h + asmjit/support/arena.cpp + asmjit/support/arena.h + asmjit/support/arenabitset.cpp + asmjit/support/arenabitset_p.h + asmjit/support/arenahash.cpp + asmjit/support/arenahash.h + asmjit/support/arenalist.cpp + asmjit/support/arenalist.h + asmjit/support/arenapool.h + asmjit/support/arenastring.h + asmjit/support/arenatree.cpp + asmjit/support/arenatree.h + asmjit/support/arenavector.cpp + asmjit/support/arenavector.h + asmjit/support/span.h + asmjit/support/support.cpp + asmjit/support/support.h + asmjit/support/support_p.h + asmjit/a64.h asmjit/arm.h asmjit/arm/armformatter.cpp @@ -558,110 +285,345 @@ set(ASMJIT_SRC_LIST asmjit/ujit/vecconsttable.h ) -if (MSVC AND NOT ASMJIT_NO_NATVIS) - list(APPEND ASMJIT_SRC_LIST asmjit.natvis) +# AsmJit - CMake Utilities +# ======================== + +include(CheckCXXCompilerFlag) +include(CheckCXXSourceCompiles) +include(GNUInstallDirs) + +# Detects target architecture - since the code doesn't run it works also for cross-compilation. +function(asmjit_detect_target_arch out) + set(${out} "unknown" PARENT_SCOPE) + foreach(target_arch "X86_64" "AARCH64" "X86" "AARCH32") + check_cxx_source_compiles(" + #if defined(_M_X64) || defined(__x86_64__) + static int target_arch_is_X86_64() { return 1; } + #elif defined(_M_IX86) || defined(__X86__) || defined(__i386__) + static int target_arch_is_X86() { return 1; } + #elif defined(_M_ARM64) || defined(__arm64__) || defined(__aarch64__) + static int target_arch_is_AARCH64() { return 1; } + #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__) || defined(__thumb2__) + static int target_arch_is_AARCH32() { return 1; } + #endif + int main(void) { return target_arch_is_${target_arch}(); }" "${out}_${target_arch}") + if (${${out}_${target_arch}}) + set(${out} "${target_arch}" PARENT_SCOPE) + return() + endif() + endforeach() +endfunction() + +# Detects C++ compile flags and appends all detected ones to `out`. +function(asmjit_detect_cflags out) + set(out_array ${${out}}) + foreach(flag ${ARGN}) + string(REGEX REPLACE "[+]" "x" flag_signature "${flag}") + string(REGEX REPLACE "[-=:;/.\]" "_" flag_signature "${flag_signature}") + check_cxx_compiler_flag(${flag} "__CxxFlag_${flag_signature}") + if (${__CxxFlag_${flag_signature}}) + list(APPEND out_array "${flag}") + endif() + endforeach() + set(${out} "${out_array}" PARENT_SCOPE) +endfunction() + +# Support for various sanitizers provided by C/C++ compilers. +function(asmjit_detect_sanitizers out) + set(_out_array ${${out}}) + set(_flags "") + + foreach(_arg ${ARGN}) + string(REPLACE "," ";" _arg "${_arg}") + list(APPEND _flags ${_arg}) + endforeach() + + foreach(_flag ${_flags}) + if (NOT "${_flag}" MATCHES "^-fsanitize=") + SET(_flag "-fsanitize=${_flag}") + endif() + + # Sanitizers also require link flags, see CMAKE_REQUIRED_FLAGS. + set(CMAKE_REQUIRED_FLAGS "${_flag}") + asmjit_detect_cflags(_out_array ${_flag}) + unset(CMAKE_REQUIRED_FLAGS) + endforeach() + + set(${out} "${_out_array}" PARENT_SCOPE) +endfunction() + +function(asmjit_add_target target target_type) + set(single_val "") + set(multi_val SOURCES LIBRARIES CFLAGS CFLAGS_DBG CFLAGS_REL) + cmake_parse_arguments("X" "" "${single_val}" "${multi_val}" ${ARGN}) + + if ("${target_type}" MATCHES "^(EXECUTABLE|TEST)$") + add_executable(${target} ${X_SOURCES}) + else() + add_library(${target} ${target_type} ${X_SOURCES}) + endif() + + set_target_properties(${target} + PROPERTIES + DEFINE_SYMBOL "" + CXX_VISIBILITY_PRESET hidden) + target_compile_options(${target} PRIVATE ${X_CFLAGS} ${ASMJIT_SANITIZE_CFLAGS} $<$:${X_CFLAGS_DBG}> $<$>:${X_CFLAGS_REL}>) + target_compile_features(${target} PUBLIC cxx_std_17) + target_link_options(${target} PRIVATE ${ASMJIT_PRIVATE_LFLAGS}) + target_link_libraries(${target} PRIVATE ${X_LIBRARIES}) + + if ("${target_type}" STREQUAL "TEST") + add_test(NAME ${target} COMMAND ${target}) + endif() +endfunction() + +# AsmJit - Compiler Support +# ========================= + +if (NOT ASMJIT_EMBED) + if (NOT ASMJIT_NO_CUSTOM_FLAGS) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + list(APPEND ASMJIT_PRIVATE_CFLAGS -W4) # [+] Warning level 4. + + list(APPEND ASMJIT_PRIVATE_CFLAGS -MP) # [+] Multi-Process Compilation. + list(APPEND ASMJIT_PRIVATE_CFLAGS -GF) # [+] Eliminate duplicate strings. + list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:__cplusplus) # [+] Conforming __cplusplus definition. + list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:inline) # [+] Remove unreferenced COMDAT. + list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:strictStrings) # [+] Strict const qualification of string literals. + list(APPEND ASMJIT_PRIVATE_CFLAGS -Zc:threadSafeInit-) # [-] Thread-safe statics. + + list(APPEND ASMJIT_PRIVATE_CFLAGS_DBG -GS) # [+] Buffer security-check. + list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -GS-) # [-] Buffer security-check. + list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -O2) # [+] Favor speed over size. + list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -Oi) # [+] Generate intrinsic functions. + elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang") + list(APPEND ASMJIT_PRIVATE_CFLAGS -Wall -Wextra -Wconversion) # [+] Add baseline warnings that can be used safely even with system headers. + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wdouble-promotion) # [+] Warn about double promotions. + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wduplicated-cond) # [+] Warn about duplicate conditions. + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wduplicated-branches) # [+] Warn about duplicate branches. + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wlogical-op) # [+] Warn about suspicious uses of logical operators in expressions. + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wlogical-not-parentheses) # [+] Warn about logical not used on the left hand side operand of a comparison. + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -Wrestrict) + + list(APPEND ASMJIT_PRIVATE_CFLAGS -fno-math-errno) # [-] Disable math functions setting errno (performance reasons). + list(APPEND ASMJIT_PRIVATE_CFLAGS -fno-threadsafe-statics) # [-] Don't add guards when initializing statics (we don't need it). + list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -O2) # [+] Compiling with -O2 in release mode is what we generally want. + list(APPEND ASMJIT_PRIVATE_CFLAGS_REL -fmerge-all-constants) # [+] We don't need unique address per constant (merging improves library size). + + # -fno-semantic-interposition is not available on apple - the compiler issues a warning, which is not detected. + if (NOT APPLE) + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS -fno-semantic-interposition) + endif() + + if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "iOS") + asmjit_detect_cflags(ASMJIT_PRIVATE_CFLAGS_REL -fno-enforce-eh-specs) # [-] Don't enforce termination if noexcept function throws. + endif() + endif() + endif() + + # Support for sanitizers. + if (ASMJIT_SANITIZE) + asmjit_detect_sanitizers(ASMJIT_SANITIZE_CFLAGS ${ASMJIT_SANITIZE}) + if (ASMJIT_SANITIZE_CFLAGS) + message(STATUS "[asmjit] Enabling sanitizers: '${ASMJIT_SANITIZE_CFLAGS}'") + + # Linker must receive the same flags as the compiler when it comes to sanitizers. + set(ASMJIT_SANITIZE_LFLAGS ${ASMJIT_SANITIZE_CFLAGS}) + + # Don't omit frame pointer if sanitizers are enabled. + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") + list(APPEND ASMJIT_SANITIZE_CFLAGS -Oy-) + else() + list(APPEND ASMJIT_SANITIZE_CFLAGS -fno-omit-frame-pointer -g) + endif() + + list(APPEND ASMJIT_PRIVATE_CFLAGS ${ASMJIT_SANITIZE_CFLAGS}) + list(APPEND ASMJIT_PRIVATE_LFLAGS ${ASMJIT_SANITIZE_LFLAGS}) + endif() + endif() endif() -set(ASMJIT_SRC "") -foreach(src_file ${ASMJIT_SRC_LIST}) - set(src_file "${ASMJIT_DIR}/src/${src_file}") - list(APPEND ASMJIT_SRC ${src_file}) +if ("${CMAKE_SYSTEM_NAME}" MATCHES "^Windows") + # Dependency: Windows target needs no extra dependencies, however, we have to check for .natvis support. + if(CMAKE_LINKER MATCHES "^(lld-link|link)\\.exe$") + set(ASMJIT_LINKER_SUPPORTS_NATVIS TRUE) + endif() +elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") + # Dependency: libc is the only required library on Android as it also provides libpthread. + message(STATUS "[asmjit] Adding 'libc' dependency (Android)") + list(APPEND ASMJIT_LIBS c) +elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Haiku") + # Dependency: libroot is used by Haiku instead of libc, so link to libroot and libpthread. + message(STATUS "[asmjit] Adding 'libroot' and 'libpthread' dependencies (Haiku)") + list(APPEND ASMJIT_LIBS root pthread) +else() + # Dependency: libc is always required. + message(STATUS "[asmjit] Adding 'libc' dependency (Linux, BSD, or other UNIX/POSIX environment)") + list(APPEND ASMJIT_LIBS c) - if ("${src_file}" MATCHES "\\.natvis") - if (ASMJIT_LINKER_SUPPORTS_NATVIS) - list(APPEND ASMJIT_PRIVATE_LFLAGS "-natvis:${src_file}") + # Dependency: pthread (required so AsmJit can use pthread_lock). + check_cxx_source_compiles(" + #include + int main() { + pthread_mutex_t m; + pthread_mutex_init(&m, nullptr); + return pthread_mutex_destroy(&m); + } + " ASMJIT_LIBC_HAS_LIBPTHREAD) + if (ASMJIT_LIBC_HAS_LIBPTHREAD) + message(STATUS "[asmjit] Library 'libpthread' provided by 'libc' (not linking to libpthread)") + else() + message(STATUS "[asmjit] Library 'libpthread' not provided by 'libc' (linking to libpthread)") + list(APPEND ASMJIT_LIBS pthread) + endif() + + # Dependency: shm_open (required so AsmJit can use shm_open on supported platforms). + if ("${CMAKE_SYSTEM_NAME}" MATCHES "^(Linux|NetBSD)$" AND NOT ASMJIT_NO_SHM_OPEN) + check_cxx_source_compiles(" + #include + int main() { + const char file_name[1] {}; + return shm_open(file_name, 0, 0); + } + " ASMJIT_LIBC_HAS_LIBRT) + if (ASMJIT_LIBC_HAS_LIBRT) + message(STATUS "[asmjit] Symbol 'shm_open' provided by libc (not linking to librt)") + else() + message(STATUS "[asmjit] Symbol 'shm_open' not provided by libc, linking to librt") + list(APPEND ASMJIT_LIBS rt) endif() endif() +endif() + +if (ASMJIT_STATIC OR ASMJIT_EMBED) + list(APPEND ASMJIT_CFLAGS -DASMJIT_STATIC) +endif() + +if (ASMJIT_NO_SHM_OPEN) + list(APPEND ASMJIT_PRIVATE_CFLAGS -DASMJIT_NO_SHM_OPEN) +endif() + +foreach(build_option ASMJIT_NO_X86 + ASMJIT_NO_AARCH64 + ASMJIT_NO_FOREIGN + ASMJIT_NO_ABI_NAMESPACE + ASMJIT_NO_JIT + ASMJIT_NO_TEXT + ASMJIT_NO_LOGGING + ASMJIT_NO_INTROSPECTION + ASMJIT_NO_BUILDER + ASMJIT_NO_COMPILER + ASMJIT_NO_UJIT) + if (${build_option}) + list(APPEND ASMJIT_CFLAGS "-D${build_option}") + endif() endforeach() -source_group(TREE "${ASMJIT_DIR}" FILES ${ASMJIT_SRC}) +if (ASMJIT_LINKER_SUPPORTS_NATVIS AND NOT ASMJIT_NO_NATVIS) + list(APPEND ASMJIT_SRC asmjit/asmjit.natvis) + list(APPEND ASMJIT_PRIVATE_LFLAGS "-natvis:${CMAKE_CURRENT_LIST_DIR}/asmjit/asmjit.natvis") +endif() -# AsmJit - Summary -# ================ - -message("** AsmJit Summary **") -message(" ASMJIT_DIR=${ASMJIT_DIR}") -message(" ASMJIT_TEST=${ASMJIT_TEST}") -message(" ASMJIT_TARGET_TYPE=${ASMJIT_TARGET_TYPE}") -message(" ASMJIT_DEPS=${ASMJIT_DEPS}") -message(" ASMJIT_LIBS=${ASMJIT_LIBS}") -message(" ASMJIT_CFLAGS=${ASMJIT_CFLAGS}") -message(" ASMJIT_PRIVATE_CFLAGS=${ASMJIT_PRIVATE_CFLAGS}") -message(" ASMJIT_PRIVATE_CFLAGS_DBG=${ASMJIT_PRIVATE_CFLAGS_DBG}") -message(" ASMJIT_PRIVATE_CFLAGS_REL=${ASMJIT_PRIVATE_CFLAGS_REL}") +source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${ASMJIT_SRC}) # AsmJit - Targets # ================ -if (NOT ASMJIT_EMBED) - # Add AsmJit target. - asmjit_addapp(asmjit "${ASMJIT_TARGET_TYPE}" +message(STATUS "[asmjit] Adding 'asmjit::asmjit' target ('ASMJIT_TARGET_TYPE=${ASMJIT_TARGET_TYPE}')") + +if (ASMJIT_EMBED) + add_library(asmjit_embed INTERFACE) + target_sources(asmjit_embed INTERFACE ${ASMJIT_SRC}) + target_link_libraries(asmjit_embed INTERFACE ${ASMJIT_LIBS}) + target_compile_options(asmjit_embed INTERFACE ${ASMJIT_CFLAGS}) + target_include_directories(asmjit_embed BEFORE INTERFACE ${ASMJIT_INCLUDE_DIRS}) + add_library(asmjit::asmjit ALIAS asmjit_embed) +else() + foreach(v "ASMJIT_LIBS" + "ASMJIT_CFLAGS" + "ASMJIT_PRIVATE_CFLAGS" + "ASMJIT_PRIVATE_CFLAGS_DBG" + "ASMJIT_PRIVATE_CFLAGS_REL" + "ASMJIT_SANITIZE_CFLAGS" + "ASMJIT_SANITIZE_LFLAGS") + if (NOT "${${v}}" STREQUAL "") + message(" ${v}=${${v}}") + endif() + endforeach() + + asmjit_add_target(asmjit "${ASMJIT_TARGET_TYPE}" SOURCES ${ASMJIT_SRC} - LIBRARIES ${ASMJIT_DEPS} + LIBRARIES ${ASMJIT_LIBS} CFLAGS ${ASMJIT_PRIVATE_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} CFLAGS_REL ${ASMJIT_PRIVATE_CFLAGS_REL}) - target_compile_options(asmjit INTERFACE ${ASMJIT_CFLAGS}) - target_include_directories(asmjit BEFORE INTERFACE - $ - $) - - # Create an asmjit::asmjit alias. + target_compile_options(asmjit PUBLIC ${ASMJIT_CFLAGS}) + target_include_directories(asmjit BEFORE PUBLIC $ + $) add_library(asmjit::asmjit ALIAS asmjit) - # Add AsmJit install instructions (library and public headers). + # AsmJit - Install Instructions + # ----------------------------- + if (NOT ASMJIT_NO_INSTALL) + message(STATUS "[asmjit] Enabling install support ('ASMJIT_NO_INSTALL=OFF')") + install(TARGETS asmjit EXPORT asmjit-config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") + install(EXPORT asmjit-config NAMESPACE asmjit:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/asmjit") - foreach(_src_file ${ASMJIT_SRC_LIST}) + foreach(_src_file ${ASMJIT_SRC}) if ("${_src_file}" MATCHES "\\.h$" AND NOT "${_src_file}" MATCHES "_p\\.h$") get_filename_component(_src_dir ${_src_file} PATH) - install(FILES "${ASMJIT_DIR}/src/${_src_file}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_src_dir}") + install(FILES "${CMAKE_CURRENT_LIST_DIR}/${_src_file}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_src_dir}") endif() endforeach() endif() - # Add AsmJit tests. + # AsmJit - Tests & Benchmarks + # --------------------------- + if (ASMJIT_TEST) enable_testing() + message(STATUS "[asmjit] Enabling AsmJit tests ('ASMJIT_TEST=${ASMJIT_TEST}')") # Special target that always uses embedded AsmJit. - asmjit_addapp(asmjit_test_runner TEST + asmjit_add_target(asmjit_test_runner TEST SOURCES ${ASMJIT_SRC} - testing/tests/asmjit_test_runner.cpp - testing/tests/broken.cpp - testing/tests/broken.h - LIBRARIES ${ASMJIT_DEPS} - CFLAGS ${ASMJIT_PRIVATE_CFLAGS} + asmjit-testing/tests/asmjit_test_runner.cpp + asmjit-testing/tests/broken.cpp + asmjit-testing/tests/broken.h + LIBRARIES ${ASMJIT_LIBS} + CFLAGS ${ASMJIT_CFLAGS} + ${ASMJIT_PRIVATE_CFLAGS} -DASMJIT_TEST -DASMJIT_STATIC CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} CFLAGS_REL ${ASMJIT_PRIVATE_CFLAGS_REL}) target_include_directories(asmjit_test_runner BEFORE PRIVATE ${ASMJIT_INCLUDE_DIRS}) - asmjit_addapp(asmjit_test_assembler TEST - SOURCES testing/tests/asmjit_test_assembler.cpp - testing/tests/asmjit_test_assembler.h - testing/tests/asmjit_test_assembler_a64.cpp - testing/tests/asmjit_test_assembler_x64.cpp - testing/tests/asmjit_test_assembler_x86.cpp + asmjit_add_target(asmjit_test_assembler TEST + SOURCES asmjit-testing/tests/asmjit_test_assembler.cpp + asmjit-testing/tests/asmjit_test_assembler.h + asmjit-testing/tests/asmjit_test_assembler_a64.cpp + asmjit-testing/tests/asmjit_test_assembler_x64.cpp + asmjit-testing/tests/asmjit_test_assembler_x86.cpp LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} CFLAGS_REL ${ASMJIT_PRIVATE_CFLAGS_REL}) foreach(app asmjit_test_environment asmjit_test_emitters asmjit_test_x86_sections) - asmjit_addapp(${app} TEST - SOURCES testing/tests/${app}.cpp + asmjit_add_target(${app} TEST + SOURCES asmjit-testing/tests/${app}.cpp LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} @@ -669,8 +631,8 @@ if (NOT ASMJIT_EMBED) endforeach() if (NOT ASMJIT_NO_INTROSPECTION) - asmjit_addapp(asmjit_test_instinfo TEST - SOURCES testing/tests/asmjit_test_instinfo.cpp + asmjit_add_target(asmjit_test_instinfo TEST + SOURCES asmjit-testing/tests/asmjit_test_instinfo.cpp LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} @@ -682,45 +644,30 @@ if (NOT ASMJIT_EMBED) # Some compilers don't like passing -msse2 for 64-bit targets, and some compilers targeting non-x86 # would pass "-msse2" compile flag check, but with a warning not detected by CMake. Thus, verify that # our target is really 32-bit X86 and only use -msse2 or -arch:SSE2 flags when necessary. + asmjit_detect_target_arch(ASMJIT_TARGET_ARCH) + set(ASMJIT_SSE2_CFLAGS "") - - check_cxx_source_compiles(" - #if defined(_M_X64) || defined(__x86_64__) - // Skip... - #elif defined(_M_IX86) || defined(__X86__) || defined(__i386__) - int target_arch_is_x86() { return 1; } - #endif - int main() { return target_arch_is_x86(); } - " ASMJIT_TARGET_ARCH_X86) - - check_cxx_source_compiles(" - #if defined(_M_X64) || defined(__x86_64__) - int target_arch_is_x86_64() { return 1; } - #endif - int main() { return target_arch_is_x86_64(); } - " ASMJIT_TARGET_ARCH_X86_64) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC") - if (ASMJIT_TARGET_ARCH_X86) + if (ASMJIT_TARGET_ARCH STREQUAL "X86") asmjit_detect_cflags(ASMJIT_SSE2_CFLAGS -arch:SSE2) endif() - if (ASMJIT_TARGET_ARCH_X86 OR ASMJIT_TARGET_ARCH_X86_64) + if (ASMJIT_TARGET_ARCH MATCHES "^(X86|X86_64)$") asmjit_detect_cflags(ASMJIT_AVX2FMA_CFLAGS -arch:AVX2) endif() else() - if (ASMJIT_TARGET_ARCH_X86) + if (ASMJIT_TARGET_ARCH STREQUAL "X86") asmjit_detect_cflags(ASMJIT_SSE2_CFLAGS -msse2) endif() - if (ASMJIT_TARGET_ARCH_X86 OR ASMJIT_TARGET_ARCH_X86_64) + if (ASMJIT_TARGET_ARCH MATCHES "^(X86|X86_64)$") asmjit_detect_cflags(ASMJIT_AVX2FMA_CFLAGS -mavx2 -mfma) endif() endif() - asmjit_addapp(asmjit_test_compiler TEST - SOURCES testing/tests/asmjit_test_compiler.cpp - testing/tests/asmjit_test_compiler.h - testing/tests/asmjit_test_compiler_a64.cpp - testing/tests/asmjit_test_compiler_x86.cpp + asmjit_add_target(asmjit_test_compiler TEST + SOURCES asmjit-testing/tests/asmjit_test_compiler.cpp + asmjit-testing/tests/asmjit_test_compiler.h + asmjit-testing/tests/asmjit_test_compiler_a64.cpp + asmjit-testing/tests/asmjit_test_compiler_x86.cpp LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} ${ASMJIT_SSE2_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} @@ -728,31 +675,31 @@ if (NOT ASMJIT_EMBED) endif() if (NOT ASMJIT_NO_UJIT) - asmjit_addapp(asmjit_test_unicompiler TEST - SOURCES testing/tests/asmjit_test_unicompiler.cpp - testing/tests/asmjit_test_unicompiler_sse2.cpp - testing/tests/asmjit_test_unicompiler_avx2fma.cpp - testing/tests/broken.cpp + asmjit_add_target(asmjit_test_unicompiler TEST + SOURCES asmjit-testing/tests/asmjit_test_unicompiler.cpp + asmjit-testing/tests/asmjit_test_unicompiler_sse2.cpp + asmjit-testing/tests/asmjit_test_unicompiler_avx2fma.cpp + asmjit-testing/tests/broken.cpp LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} ${ASMJIT_SSE2_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} CFLAGS_REL ${ASMJIT_PRIVATE_CFLAGS_REL}) - set_property(SOURCE testing/tests/asmjit_test_unicompiler_avx2fma.cpp APPEND PROPERTY COMPILE_OPTIONS ${ASMJIT_AVX2FMA_CFLAGS}) + set_property(SOURCE asmjit-testing/tests/asmjit_test_unicompiler_avx2fma.cpp APPEND PROPERTY COMPILE_OPTIONS ${ASMJIT_AVX2FMA_CFLAGS}) endif() - asmjit_addapp(asmjit_bench_codegen EXECUTABLE - SOURCES testing/bench/asmjit_bench_codegen.cpp - testing/bench/asmjit_bench_codegen_a64.cpp - testing/bench/asmjit_bench_codegen_x86.cpp - SOURCES testing/bench/asmjit_bench_codegen.h + asmjit_add_target(asmjit_bench_codegen EXECUTABLE + SOURCES asmjit-testing/bench/asmjit_bench_codegen.cpp + asmjit-testing/bench/asmjit_bench_codegen_a64.cpp + asmjit-testing/bench/asmjit_bench_codegen_x86.cpp + SOURCES asmjit-testing/bench/asmjit_bench_codegen.h LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} CFLAGS_REL ${ASMJIT_PRIVATE_CFLAGS_REL}) foreach(app asmjit_bench_overhead asmjit_bench_regalloc) - asmjit_addapp(${app} TEST - SOURCES testing/bench/${app}.cpp + asmjit_add_target(${app} TEST + SOURCES asmjit-testing/bench/${app}.cpp LIBRARIES asmjit::asmjit CFLAGS ${ASMJIT_PRIVATE_CFLAGS} CFLAGS_DBG ${ASMJIT_PRIVATE_CFLAGS_DBG} @@ -761,3 +708,5 @@ if (NOT ASMJIT_EMBED) endif() endif() + +message(STATUS "[asmjit] == Configuring done ==") diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..bc3d59a --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,51 @@ +{ + "version": 10, + "configurePresets": [ + { + "name": "conf-base", + "hidden": true, + "description": "${presetName}", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" } + }, + + { + "name": "conf-debug", + "hidden": true, + "inherits": "conf-base", + "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + }, + + { + "name": "conf-release", + "hidden": true, + "inherits": "conf-base", + "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", "CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON" } + }, + + { "name": "conf-test" , "hidden": true, "cacheVariables": { "ASMJIT_TEST": "ON" } }, + { "name": "conf-static" , "hidden": true, "cacheVariables": { "ASMJIT_STATIC": "ON" } }, + { "name": "conf-shared" , "hidden": true, "cacheVariables": { "ASMJIT_STATIC": "OFF" } }, + { "name": "conf-asan" , "hidden": true, "cacheVariables": { "ASMJIT_SANITIZE": "address" } }, + { "name": "conf-msan" , "hidden": true, "cacheVariables": { "ASMJIT_SANITIZE": "memory" } }, + { "name": "conf-tsan" , "hidden": true, "cacheVariables": { "ASMJIT_SANITIZE": "thread" } }, + { "name": "conf-ubsan" , "hidden": true, "cacheVariables": { "ASMJIT_SANITIZE": "undefined" } }, + { "name": "conf-32" , "hidden": true, "environment": { "CFLAGS": "-m32", "CXXFLAGS": "-m32" } }, + + { "name": "debug" , "inherits": ["conf-debug", "conf-test", "conf-static"] }, + { "name": "debug-asan" , "inherits": ["conf-debug", "conf-test", "conf-static", "conf-asan"] }, + { "name": "debug-msan" , "inherits": ["conf-debug", "conf-test", "conf-static", "conf-msan"] }, + { "name": "debug-ubsan" , "inherits": ["conf-debug", "conf-test", "conf-static", "conf-ubsan"] }, + { "name": "debug-32" , "inherits": ["conf-debug", "conf-test", "conf-static", "conf-32"] }, + { "name": "debug-shared" , "inherits": ["conf-debug", "conf-test", "conf-shared"] }, + { "name": "debug-shared-32" , "inherits": ["conf-debug", "conf-test", "conf-shared", "conf-32"] }, + + { "name": "release" , "inherits": ["conf-release", "conf-test", "conf-static"] }, + { "name": "release-asan" , "inherits": ["conf-release", "conf-test", "conf-static", "conf-asan"] }, + { "name": "release-msan" , "inherits": ["conf-release", "conf-test", "conf-static", "conf-msan"] }, + { "name": "release-ubsan" , "inherits": ["conf-release", "conf-test", "conf-static", "conf-ubsan"] }, + { "name": "release-32" , "inherits": ["conf-release", "conf-test", "conf-static", "conf-32"] }, + { "name": "release-shared" , "inherits": ["conf-release", "conf-test", "conf-shared"] }, + { "name": "release-shared-32", "inherits": ["conf-release", "conf-test", "conf-shared", "conf-32"] } + ] +} diff --git a/README.md b/README.md index fb03e75..c6385cb 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ AsmJit is a library for low-latency machine code generation written in C++. * [Official Home Page (asmjit.com)](https://asmjit.com) * [Official Repository (asmjit/asmjit)](https://github.com/asmjit/asmjit) - * [Public Chat Channel](https://app.gitter.im/#/room/#asmjit:gitter.im) + * [Public Chat Channel](https://app.element.io/#/room/#asmjit:gitter.im) * [Zlib License](./LICENSE.md) See [asmjit.com](https://asmjit.com) page for more details, examples, and documentation. @@ -13,19 +13,20 @@ See [asmjit.com](https://asmjit.com) page for more details, examples, and docume Project Organization -------------------- - * **`/`** - Project root - * **src** - Source code - * **asmjit** - Source code and headers (always point include path in here) - * **core** - Core API, backend independent except relocations - * **arm** - ARM specific API, designed to be common for both AArch32 and AArch64 - * **a64** - AArch64 specific API, used only by AArch64 backends - * **x86** - X86 specific API, used only by X86 and X64 backends - * **ujit** - Universal JIT API - * **testing** - Unit tests, integration tests, and benchmarks (don't embed in your project) - * **commons** - Common utilities shared between tests and benchmarks - * **bench** - Benchmarks - * **tests** - Unit tests and integration tests - * **tools** - Tools used to re-regenerate generated files (instruction DB, enum strings) + * **`/`** - Project root - project files and scripts, `include` path points here + * **asmjit** - AsmJit source code and headers + * **core** - Core API, backend independent except relocations + * **support** - Support classes and functions + * **arm** - ARM specific API, designed to be common for both AArch32 and AArch64 + * **a64** - AArch64 specific API, used only by AArch64 backends + * **x86** - X86 specific API, used only by X86 and X64 backends + * **ujit** - Universal JIT API + * **asmjit-testing** - Unit tests, integration tests, and benchmarks (don't embed in your project) + * **commons** - Common utilities shared between tests and benchmarks + * **bench** - Benchmarks + * **tests** - Unit tests and integration tests + * **db** - Instruction database + * **tools** - Tools used to re-regenerate generated files (instruction DB, enum strings) Roadmap ------- @@ -55,11 +56,11 @@ Breaking the API is sometimes inevitable, what to do? * See [Breaking Changes Guide](https://asmjit.com/doc/group__asmjit__breaking__changes.html), which is now part of AsmJit documentation * See asmjit tests, they always compile and provide implementation of many use-cases: - * [asmjit_test_emitters.cpp](./testing/tests/asmjit_test_emitters.cpp) - Tests that demonstrate the purpose of emitters - * [asmjit_test_assembler_x86.cpp](./testing/tests/asmjit_test_assembler_x86.cpp) - Tests targeting AsmJit's Assembler (x86/x64) - * [asmjit_test_compiler_x86.cpp](./testing/tests/asmjit_test_compiler_x86.cpp) - Tests targeting AsmJit's Compiler (x86/x64) - * [asmjit_test_instinfo.cpp](./testing/tests/asmjit_test_instinfo.cpp) - Tests that query instruction information - * [asmjit_test_x86_sections.cpp](./testing/tests/asmjit_test_x86_sections.cpp) - Multiple sections test + * [asmjit_test_emitters.cpp](./asmjit-testing/tests/asmjit_test_emitters.cpp) - Tests that demonstrate the purpose of emitters + * [asmjit_test_assembler_x86.cpp](./asmjit-testing/tests/asmjit_test_assembler_x86.cpp) - Tests targeting AsmJit's Assembler (x86/x64) + * [asmjit_test_compiler_x86.cpp](./asmjit-testing/tests/asmjit_test_compiler_x86.cpp) - Tests targeting AsmJit's Compiler (x86/x64) + * [asmjit_test_instinfo.cpp](./asmjit-testing/tests/asmjit_test_instinfo.cpp) - Tests that query instruction information + * [asmjit_test_x86_sections.cpp](./asmjit-testing/tests/asmjit_test_x86_sections.cpp) - Multiple sections test * Visit our [Gitter Chat](https://app.gitter.im/#/room/#asmjit:gitter.im) if you need a quick help Support diff --git a/testing/bench/asmjit_bench_codegen.cpp b/asmjit-testing/bench/asmjit_bench_codegen.cpp similarity index 95% rename from testing/bench/asmjit_bench_codegen.cpp rename to asmjit-testing/bench/asmjit_bench_codegen.cpp index 3f4933a..89e71a3 100644 --- a/testing/bench/asmjit_bench_codegen.cpp +++ b/asmjit-testing/bench/asmjit_bench_codegen.cpp @@ -4,13 +4,14 @@ // SPDX-License-Identifier: Zlib #include + +#include +#include + #include #include #include -#include "../commons/asmjitutils.h" -#include "../commons/cmdline.h" - using namespace asmjit; static void print_app_info() noexcept { diff --git a/testing/bench/asmjit_bench_codegen.h b/asmjit-testing/bench/asmjit_bench_codegen.h similarity index 96% rename from testing/bench/asmjit_bench_codegen.h rename to asmjit-testing/bench/asmjit_bench_codegen.h index 9df289c..ae6b372 100644 --- a/testing/bench/asmjit_bench_codegen.h +++ b/asmjit-testing/bench/asmjit_bench_codegen.h @@ -8,8 +8,8 @@ #include -#include "../commons/asmjitutils.h" -#include "../commons/performancetimer.h" +#include +#include namespace asmjit_perf_utils { diff --git a/testing/bench/asmjit_bench_codegen_a64.cpp b/asmjit-testing/bench/asmjit_bench_codegen_a64.cpp similarity index 99% rename from testing/bench/asmjit_bench_codegen_a64.cpp rename to asmjit-testing/bench/asmjit_bench_codegen_a64.cpp index a49db19..7bb8535 100644 --- a/testing/bench/asmjit_bench_codegen_a64.cpp +++ b/asmjit-testing/bench/asmjit_bench_codegen_a64.cpp @@ -8,12 +8,12 @@ #if !defined(ASMJIT_NO_AARCH64) #include +#include + #include #include #include -#include "asmjit_bench_codegen.h" - using namespace asmjit; // Generates a long sequence of GP instructions. diff --git a/testing/bench/asmjit_bench_codegen_x86.cpp b/asmjit-testing/bench/asmjit_bench_codegen_x86.cpp similarity index 99% rename from testing/bench/asmjit_bench_codegen_x86.cpp rename to asmjit-testing/bench/asmjit_bench_codegen_x86.cpp index 0620931..586420b 100644 --- a/testing/bench/asmjit_bench_codegen_x86.cpp +++ b/asmjit-testing/bench/asmjit_bench_codegen_x86.cpp @@ -8,13 +8,13 @@ #if !defined(ASMJIT_NO_X86) #include +#include +#include + #include #include #include -#include "asmjit_bench_codegen.h" -#include "../tests/asmjit_test_misc.h" - using namespace asmjit; enum class InstForm { diff --git a/testing/bench/asmjit_bench_overhead.cpp b/asmjit-testing/bench/asmjit_bench_overhead.cpp similarity index 98% rename from testing/bench/asmjit_bench_overhead.cpp rename to asmjit-testing/bench/asmjit_bench_overhead.cpp index a964c30..471733e 100644 --- a/testing/bench/asmjit_bench_overhead.cpp +++ b/asmjit-testing/bench/asmjit_bench_overhead.cpp @@ -1,9 +1,10 @@ -#include #include -#include "../commons/asmjitutils.h" -#include "../commons/cmdline.h" -#include "../commons/performancetimer.h" +#include +#include +#include + +#include using namespace asmjit; diff --git a/testing/bench/asmjit_bench_regalloc.cpp b/asmjit-testing/bench/asmjit_bench_regalloc.cpp similarity index 98% rename from testing/bench/asmjit_bench_regalloc.cpp rename to asmjit-testing/bench/asmjit_bench_regalloc.cpp index 32379cd..60c52c7 100644 --- a/testing/bench/asmjit_bench_regalloc.cpp +++ b/asmjit-testing/bench/asmjit_bench_regalloc.cpp @@ -13,6 +13,14 @@ #include #endif // !ASMJIT_NO_AARCH64 +#include + +#if !defined(ASMJIT_NO_COMPILER) + #include + #include + #include +#endif + #include #include #include @@ -20,14 +28,6 @@ #include #include -#include "../commons/asmjitutils.h" - -#if !defined(ASMJIT_NO_COMPILER) - #include "../commons/cmdline.h" - #include "../commons/performancetimer.h" - #include "../commons/random.h" -#endif - using namespace asmjit; static void print_app_info() { diff --git a/testing/commons/asmjitutils.h b/asmjit-testing/commons/asmjitutils.h similarity index 94% rename from testing/commons/asmjitutils.h rename to asmjit-testing/commons/asmjitutils.h index 87c05c1..90d9d01 100644 --- a/testing/commons/asmjitutils.h +++ b/asmjit-testing/commons/asmjitutils.h @@ -146,12 +146,6 @@ static void print_build_options() { constexpr bool no_foreign = false; #endif -#if defined(ASMJIT_NO_DEPRECATED) - constexpr bool no_deprecated = true; -#else - constexpr bool no_deprecated = false; -#endif - #if defined(ASMJIT_NO_ABI_NAMESPACE) constexpr bool no_abi_namespace = true; #else @@ -182,12 +176,6 @@ static void print_build_options() { constexpr bool no_logging = false; #endif -#if defined(ASMJIT_NO_VALIDATION) - constexpr bool no_validation = true; -#else - constexpr bool no_validation = false; -#endif - #if defined(ASMJIT_NO_INTROSPECTION) constexpr bool no_introspection = true; #else @@ -214,8 +202,8 @@ static void print_build_options() { printf("Build Options:\n"); printf(" BUILD_TYPE : %s\n", asmjit_build_type()); - printf(" ASMJIT_NO_DEPRECATED : %s\n", stringify_build_definition(no_deprecated)); printf(" ASMJIT_NO_ABI_NAMESPACE: %s\n", stringify_build_definition(no_abi_namespace)); + printf(" ASMJIT_NO_SHM_OPEN : %s\n", stringify_build_definition(no_shm_open)); printf("\n"); printf("Build Backends:\n"); @@ -225,11 +213,9 @@ static void print_build_options() { printf("\n"); printf("Build Features:\n"); - printf(" ASMJIT_NO_SHM_OPEN : %s\n", stringify_build_definition(no_shm_open)); printf(" ASMJIT_NO_JIT : %s\n", stringify_build_definition(no_jit)); printf(" ASMJIT_NO_TEXT : %s\n", stringify_build_definition(no_text)); printf(" ASMJIT_NO_LOGGING : %s\n", stringify_build_definition(no_logging)); - printf(" ASMJIT_NO_VALIDATION : %s\n", stringify_build_definition(no_validation)); printf(" ASMJIT_NO_INTROSPECTION: %s\n", stringify_build_definition(no_introspection)); printf(" ASMJIT_NO_BUILDER : %s\n", stringify_build_definition(no_builder)); printf(" ASMJIT_NO_COMPILER : %s\n", stringify_build_definition(no_compiler)); diff --git a/testing/commons/cmdline.h b/asmjit-testing/commons/cmdline.h similarity index 100% rename from testing/commons/cmdline.h rename to asmjit-testing/commons/cmdline.h diff --git a/testing/commons/performancetimer.h b/asmjit-testing/commons/performancetimer.h similarity index 96% rename from testing/commons/performancetimer.h rename to asmjit-testing/commons/performancetimer.h index 980ffab..8041498 100644 --- a/testing/commons/performancetimer.h +++ b/asmjit-testing/commons/performancetimer.h @@ -6,7 +6,6 @@ #ifndef PERFORMANCETIMER_H_INCLUDED #define PERFORMANCETIMER_H_INCLUDED -#include #include class PerformanceTimer { diff --git a/testing/commons/random.h b/asmjit-testing/commons/random.h similarity index 100% rename from testing/commons/random.h rename to asmjit-testing/commons/random.h diff --git a/testing/tests/asmjit_test_assembler.cpp b/asmjit-testing/tests/asmjit_test_assembler.cpp similarity index 95% rename from testing/tests/asmjit_test_assembler.cpp rename to asmjit-testing/tests/asmjit_test_assembler.cpp index 32dfd1e..6e15697 100644 --- a/testing/tests/asmjit_test_assembler.cpp +++ b/asmjit-testing/tests/asmjit_test_assembler.cpp @@ -4,15 +4,15 @@ // SPDX-License-Identifier: Zlib #include + +#include +#include +#include + #include #include #include -#include "asmjit_test_assembler.h" - -#include "../commons/asmjitutils.h" -#include "../commons/cmdline.h" - using namespace asmjit; #if !defined(ASMJIT_NO_X86) diff --git a/testing/tests/asmjit_test_assembler.h b/asmjit-testing/tests/asmjit_test_assembler.h similarity index 99% rename from testing/tests/asmjit_test_assembler.h rename to asmjit-testing/tests/asmjit_test_assembler.h index e507de5..f57b706 100644 --- a/testing/tests/asmjit_test_assembler.h +++ b/asmjit-testing/tests/asmjit_test_assembler.h @@ -7,6 +7,7 @@ #define ASMJIT_TEST_ASSEMBLER_H_INCLUDED #include + #include struct TestSettings { diff --git a/testing/tests/asmjit_test_assembler_a64.cpp b/asmjit-testing/tests/asmjit_test_assembler_a64.cpp similarity index 99% rename from testing/tests/asmjit_test_assembler_a64.cpp rename to asmjit-testing/tests/asmjit_test_assembler_a64.cpp index 7354291..27112ce 100644 --- a/testing/tests/asmjit_test_assembler_a64.cpp +++ b/asmjit-testing/tests/asmjit_test_assembler_a64.cpp @@ -7,12 +7,13 @@ #if !defined(ASMJIT_NO_AARCH64) #include + +#include + #include #include #include -#include "asmjit_test_assembler.h" - using namespace asmjit; #define TEST_INSTRUCTION(OPCODE, ...) \ diff --git a/testing/tests/asmjit_test_assembler_x64.cpp b/asmjit-testing/tests/asmjit_test_assembler_x64.cpp similarity index 99% rename from testing/tests/asmjit_test_assembler_x64.cpp rename to asmjit-testing/tests/asmjit_test_assembler_x64.cpp index 7de00e2..0fa2345 100644 --- a/testing/tests/asmjit_test_assembler_x64.cpp +++ b/asmjit-testing/tests/asmjit_test_assembler_x64.cpp @@ -7,12 +7,13 @@ #if !defined(ASMJIT_NO_X86) #include + +#include + #include #include #include -#include "asmjit_test_assembler.h" - using namespace asmjit; #define TEST_INSTRUCTION(OPCODE, ...) \ diff --git a/testing/tests/asmjit_test_assembler_x86.cpp b/asmjit-testing/tests/asmjit_test_assembler_x86.cpp similarity index 99% rename from testing/tests/asmjit_test_assembler_x86.cpp rename to asmjit-testing/tests/asmjit_test_assembler_x86.cpp index 0362060..c273d17 100644 --- a/testing/tests/asmjit_test_assembler_x86.cpp +++ b/asmjit-testing/tests/asmjit_test_assembler_x86.cpp @@ -7,12 +7,13 @@ #if !defined(ASMJIT_NO_X86) #include + +#include + #include #include #include -#include "asmjit_test_assembler.h" - using namespace asmjit; #define TEST_INSTRUCTION(OPCODE, ...) \ diff --git a/testing/tests/asmjit_test_compiler.cpp b/asmjit-testing/tests/asmjit_test_compiler.cpp similarity index 98% rename from testing/tests/asmjit_test_compiler.cpp rename to asmjit-testing/tests/asmjit_test_compiler.cpp index b5940b0..13765e0 100644 --- a/testing/tests/asmjit_test_compiler.cpp +++ b/asmjit-testing/tests/asmjit_test_compiler.cpp @@ -15,11 +15,10 @@ #if !defined(ASMJIT_NO_COMPILER) -#include "../commons/asmjitutils.h" -#include "../commons/cmdline.h" -#include "../commons/performancetimer.h" - -#include "asmjit_test_compiler.h" +#include +#include +#include +#include #if !defined(ASMJIT_NO_X86) #include diff --git a/testing/tests/asmjit_test_compiler.h b/asmjit-testing/tests/asmjit_test_compiler.h similarity index 100% rename from testing/tests/asmjit_test_compiler.h rename to asmjit-testing/tests/asmjit_test_compiler.h diff --git a/testing/tests/asmjit_test_compiler_a64.cpp b/asmjit-testing/tests/asmjit_test_compiler_a64.cpp similarity index 99% rename from testing/tests/asmjit_test_compiler_a64.cpp rename to asmjit-testing/tests/asmjit_test_compiler_a64.cpp index 460999f..d714f7e 100644 --- a/testing/tests/asmjit_test_compiler_a64.cpp +++ b/asmjit-testing/tests/asmjit_test_compiler_a64.cpp @@ -7,12 +7,13 @@ #if !defined(ASMJIT_NO_COMPILER) && !defined(ASMJIT_NO_AARCH64) #include + +#include + #include #include #include -#include "asmjit_test_compiler.h" - using namespace asmjit; // a64::Compiler - A64TestCase diff --git a/testing/tests/asmjit_test_compiler_x86.cpp b/asmjit-testing/tests/asmjit_test_compiler_x86.cpp similarity index 99% rename from testing/tests/asmjit_test_compiler_x86.cpp rename to asmjit-testing/tests/asmjit_test_compiler_x86.cpp index 99cc492..b586a4b 100644 --- a/testing/tests/asmjit_test_compiler_x86.cpp +++ b/asmjit-testing/tests/asmjit_test_compiler_x86.cpp @@ -7,6 +7,10 @@ #if !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_COMPILER) #include + +#include +#include + #include #include #include @@ -17,9 +21,6 @@ #include #endif -#include "asmjit_test_misc.h" -#include "asmjit_test_compiler.h" - #ifdef _MSC_VER // Interaction between '_setjmp' and C++ object destruction is non-portable. #pragma warning(disable: 4611) diff --git a/testing/tests/asmjit_test_emitters.cpp b/asmjit-testing/tests/asmjit_test_emitters.cpp similarity index 99% rename from testing/tests/asmjit_test_emitters.cpp rename to asmjit-testing/tests/asmjit_test_emitters.cpp index 897436b..0386652 100644 --- a/testing/tests/asmjit_test_emitters.cpp +++ b/asmjit-testing/tests/asmjit_test_emitters.cpp @@ -8,7 +8,6 @@ #include #include -#include "../commons/asmjitutils.h" #if ASMJIT_ARCH_X86 != 0 #include @@ -18,6 +17,8 @@ #include #endif +#include + using namespace asmjit; static void print_app_info() noexcept { diff --git a/testing/tests/asmjit_test_environment.cpp b/asmjit-testing/tests/asmjit_test_environment.cpp similarity index 99% rename from testing/tests/asmjit_test_environment.cpp rename to asmjit-testing/tests/asmjit_test_environment.cpp index a3b86e1..be39d51 100644 --- a/testing/tests/asmjit_test_environment.cpp +++ b/asmjit-testing/tests/asmjit_test_environment.cpp @@ -13,7 +13,7 @@ #include #endif -#include "../commons/asmjitutils.h" +#include using namespace asmjit; diff --git a/testing/tests/asmjit_test_instinfo.cpp b/asmjit-testing/tests/asmjit_test_instinfo.cpp similarity index 99% rename from testing/tests/asmjit_test_instinfo.cpp rename to asmjit-testing/tests/asmjit_test_instinfo.cpp index 8c794c8..a7c2924 100644 --- a/testing/tests/asmjit_test_instinfo.cpp +++ b/asmjit-testing/tests/asmjit_test_instinfo.cpp @@ -11,7 +11,7 @@ #include -#include "../commons/asmjitutils.h" +#include using namespace asmjit; diff --git a/testing/tests/asmjit_test_misc.h b/asmjit-testing/tests/asmjit_test_misc.h similarity index 100% rename from testing/tests/asmjit_test_misc.h rename to asmjit-testing/tests/asmjit_test_misc.h diff --git a/testing/tests/asmjit_test_runner.cpp b/asmjit-testing/tests/asmjit_test_runner.cpp similarity index 97% rename from testing/tests/asmjit_test_runner.cpp rename to asmjit-testing/tests/asmjit_test_runner.cpp index ed831b4..6e02b88 100644 --- a/testing/tests/asmjit_test_runner.cpp +++ b/asmjit-testing/tests/asmjit_test_runner.cpp @@ -13,8 +13,8 @@ #include #endif -#include "broken.h" -#include "../commons/asmjitutils.h" +#include +#include #if !defined(ASMJIT_NO_COMPILER) #include diff --git a/testing/tests/asmjit_test_unicompiler.cpp b/asmjit-testing/tests/asmjit_test_unicompiler.cpp similarity index 99% rename from testing/tests/asmjit_test_unicompiler.cpp rename to asmjit-testing/tests/asmjit_test_unicompiler.cpp index 5d1fb6c..3ceba1a 100644 --- a/testing/tests/asmjit_test_unicompiler.cpp +++ b/asmjit-testing/tests/asmjit_test_unicompiler.cpp @@ -5,13 +5,13 @@ #include +#include +#include + #include #include #include -#include "../commons/asmjitutils.h" -#include "../commons/random.h" - static void print_app_info() noexcept { printf("AsmJit UniCompiler Test Suite v%u.%u.%u [Arch=%s] [Mode=%s]\n\n", unsigned((ASMJIT_LIBRARY_VERSION >> 16) ), @@ -24,7 +24,7 @@ static void print_app_info() noexcept { #if !defined(ASMJIT_NO_UJIT) && !defined(ASMJIT_NO_JIT) -#include "broken.h" +#include namespace UniCompilerTests { diff --git a/testing/tests/asmjit_test_unicompiler_avx2fma.cpp b/asmjit-testing/tests/asmjit_test_unicompiler_avx2fma.cpp similarity index 100% rename from testing/tests/asmjit_test_unicompiler_avx2fma.cpp rename to asmjit-testing/tests/asmjit_test_unicompiler_avx2fma.cpp diff --git a/testing/tests/asmjit_test_unicompiler_sse2.cpp b/asmjit-testing/tests/asmjit_test_unicompiler_sse2.cpp similarity index 100% rename from testing/tests/asmjit_test_unicompiler_sse2.cpp rename to asmjit-testing/tests/asmjit_test_unicompiler_sse2.cpp diff --git a/testing/tests/asmjit_test_x86_sections.cpp b/asmjit-testing/tests/asmjit_test_x86_sections.cpp similarity index 100% rename from testing/tests/asmjit_test_x86_sections.cpp rename to asmjit-testing/tests/asmjit_test_x86_sections.cpp diff --git a/testing/tests/broken.cpp b/asmjit-testing/tests/broken.cpp similarity index 100% rename from testing/tests/broken.cpp rename to asmjit-testing/tests/broken.cpp diff --git a/testing/tests/broken.h b/asmjit-testing/tests/broken.h similarity index 100% rename from testing/tests/broken.h rename to asmjit-testing/tests/broken.h diff --git a/src/asmjit/a64.h b/asmjit/a64.h similarity index 81% rename from src/asmjit/a64.h rename to asmjit/a64.h index a2fd47b..0128789 100644 --- a/src/asmjit/a64.h +++ b/asmjit/a64.h @@ -39,17 +39,17 @@ //! - \ref arm::Shift - Shift operation and value. //! - \ref arm::Utils - Utilities that can help during code generation for AArch32 and AArch64. -#include "./arm.h" +#include -#include "asmjit-scope-begin.h" -#include "arm/a64assembler.h" -#include "arm/a64builder.h" -#include "arm/a64compiler.h" -#include "arm/a64emitter.h" -#include "arm/a64globals.h" -#include "arm/a64instdb.h" -#include "arm/a64operand.h" -#include "asmjit-scope-end.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // ASMJIT_A64_H_INCLUDED diff --git a/src/asmjit/arm.h b/asmjit/arm.h similarity index 92% rename from src/asmjit/arm.h rename to asmjit/arm.h index a4cd5fa..af5d736 100644 --- a/src/asmjit/arm.h +++ b/asmjit/arm.h @@ -47,11 +47,11 @@ //! - \ref arm::Shift - Shift operation and value (both AArch32 and AArch64). //! - \ref arm::Utils - Utilities that can help during code generation for AArch32 and AArch64. -#include "core.h" +#include -#include "asmjit-scope-begin.h" -#include "arm/armglobals.h" -#include "arm/armutils.h" -#include "asmjit-scope-end.h" +#include +#include +#include +#include #endif // ASMJIT_ARM_H_INCLUDED diff --git a/src/asmjit/arm/a64archtraits_p.h b/asmjit/arm/a64archtraits_p.h similarity index 94% rename from src/asmjit/arm/a64archtraits_p.h rename to asmjit/arm/a64archtraits_p.h index 9b279e0..ce1e943 100644 --- a/src/asmjit/arm/a64archtraits_p.h +++ b/asmjit/arm/a64archtraits_p.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_ARM_A64ARCHTRAITS_P_H_INCLUDED #define ASMJIT_ARM_A64ARCHTRAITS_P_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/misc_p.h" -#include "../core/type.h" -#include "../arm/a64globals.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64assembler.cpp b/asmjit/arm/a64assembler.cpp similarity index 99% rename from src/asmjit/arm/a64assembler.cpp rename to asmjit/arm/a64assembler.cpp index a35c1ad..c4070a1 100644 --- a/src/asmjit/arm/a64assembler.cpp +++ b/asmjit/arm/a64assembler.cpp @@ -3,22 +3,21 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) -#include "../core/codewriter_p.h" -#include "../core/cpuinfo.h" -#include "../core/emitterutils_p.h" -#include "../core/formatter.h" -#include "../core/logger.h" -#include "../core/misc_p.h" -#include "../core/support.h" - -#include "../arm/armformatter_p.h" -#include "../arm/armutils.h" -#include "../arm/a64assembler.h" -#include "../arm/a64emithelper_p.h" -#include "../arm/a64instdb_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) @@ -835,7 +834,7 @@ Error Assembler::_emit(InstId inst_id, const Operand_& o0, const Operand_& o1, c goto Failed; } -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION // Strict validation. if (has_diagnostic_option(DiagnosticOptions::kValidateAssembler)) { Operand_ op_array[Globals::kMaxOpCount]; @@ -5168,7 +5167,7 @@ EmitOp_DispImm: } int64_t disp_imm64 = int64_t(offset_value) >> offset_format.imm_discard_lsb(); - if (!Support::is_encodable_offset_64(disp_imm64, offset_format.imm_bit_count())) { + if (!EmitterUtils::is_encodable_offset_64(disp_imm64, offset_format.imm_bit_count())) { goto InvalidDisplacement; } diff --git a/src/asmjit/arm/a64assembler.h b/asmjit/arm/a64assembler.h similarity index 92% rename from src/asmjit/arm/a64assembler.h rename to asmjit/arm/a64assembler.h index 44afdcb..d6723a8 100644 --- a/src/asmjit/arm/a64assembler.h +++ b/asmjit/arm/a64assembler.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_ARM_A64ASSEMBLER_H_INCLUDED #define ASMJIT_ARM_A64ASSEMBLER_H_INCLUDED -#include "../core/assembler.h" -#include "../arm/a64emitter.h" -#include "../arm/a64operand.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64builder.cpp b/asmjit/arm/a64builder.cpp similarity index 89% rename from src/asmjit/arm/a64builder.cpp rename to asmjit/arm/a64builder.cpp index fa13cc5..470f66f 100644 --- a/src/asmjit/arm/a64builder.cpp +++ b/asmjit/arm/a64builder.cpp @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) && !defined(ASMJIT_NO_BUILDER) -#include "../arm/a64assembler.h" -#include "../arm/a64builder.h" -#include "../arm/a64emithelper_p.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64builder.h b/asmjit/arm/a64builder.h similarity index 91% rename from src/asmjit/arm/a64builder.h rename to asmjit/arm/a64builder.h index c154547..c3708f9 100644 --- a/src/asmjit/arm/a64builder.h +++ b/asmjit/arm/a64builder.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_ARM_A64BUILDER_H_INCLUDED #define ASMJIT_ARM_A64BUILDER_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_BUILDER -#include "../core/builder.h" -#include "../arm/a64emitter.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64compiler.cpp b/asmjit/arm/a64compiler.cpp similarity index 89% rename from src/asmjit/arm/a64compiler.cpp rename to asmjit/arm/a64compiler.cpp index 858e1db..83157bb 100644 --- a/src/asmjit/arm/a64compiler.cpp +++ b/asmjit/arm/a64compiler.cpp @@ -3,13 +3,13 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) && !defined(ASMJIT_NO_COMPILER) -#include "../arm/a64assembler.h" -#include "../arm/a64compiler.h" -#include "../arm/a64emithelper_p.h" -#include "../arm/a64rapass_p.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64compiler.h b/asmjit/arm/a64compiler.h similarity index 98% rename from src/asmjit/arm/a64compiler.h rename to asmjit/arm/a64compiler.h index 1d928c6..c9deaff 100644 --- a/src/asmjit/arm/a64compiler.h +++ b/asmjit/arm/a64compiler.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_ARM_A64COMPILER_H_INCLUDED #define ASMJIT_ARM_A64COMPILER_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/compiler.h" -#include "../core/type.h" -#include "../arm/a64emitter.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64emithelper.cpp b/asmjit/arm/a64emithelper.cpp similarity index 97% rename from src/asmjit/arm/a64emithelper.cpp rename to asmjit/arm/a64emithelper.cpp index 26b1602..3e4049c 100644 --- a/src/asmjit/arm/a64emithelper.cpp +++ b/asmjit/arm/a64emithelper.cpp @@ -3,18 +3,18 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) -#include "../core/formatter.h" -#include "../core/funcargscontext_p.h" -#include "../core/string.h" -#include "../core/support.h" -#include "../core/type.h" -#include "../arm/a64emithelper_p.h" -#include "../arm/a64formatter_p.h" -#include "../arm/a64instapi_p.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) @@ -471,7 +471,7 @@ void init_emitter_funcs(BaseEmitter* emitter) { emitter->_funcs.format_instruction = FormatterInternal::format_instruction; #endif -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION emitter->_funcs.validate = InstInternal::validate; #endif } diff --git a/src/asmjit/arm/a64emithelper_p.h b/asmjit/arm/a64emithelper_p.h similarity index 89% rename from src/asmjit/arm/a64emithelper_p.h rename to asmjit/arm/a64emithelper_p.h index aad0e90..1648a0c 100644 --- a/src/asmjit/arm/a64emithelper_p.h +++ b/asmjit/arm/a64emithelper_p.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_ARM_A64EMITHELPER_P_H_INCLUDED #define ASMJIT_ARM_A64EMITHELPER_P_H_INCLUDED -#include "../core/api-config.h" +#include -#include "../core/emithelper_p.h" -#include "../core/func.h" -#include "../arm/a64emitter.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64emitter.h b/asmjit/arm/a64emitter.h similarity index 99% rename from src/asmjit/arm/a64emitter.h rename to asmjit/arm/a64emitter.h index 34fe092..b511d04 100644 --- a/src/asmjit/arm/a64emitter.h +++ b/asmjit/arm/a64emitter.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_ARM_A64EMITTER_H_INCLUDED #define ASMJIT_ARM_A64EMITTER_H_INCLUDED -#include "../core/emitter.h" -#include "../core/support.h" -#include "../arm/a64instdb.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include // MSVC targeting AArch64 defines a lot of macros without underscores clashing // with AArch64 instruction names. We have to workaround until it's fixed in SDK. diff --git a/src/asmjit/arm/a64formatter.cpp b/asmjit/arm/a64formatter.cpp similarity index 85% rename from src/asmjit/arm/a64formatter.cpp rename to asmjit/arm/a64formatter.cpp index baed661..76fd7eb 100644 --- a/src/asmjit/arm/a64formatter.cpp +++ b/asmjit/arm/a64formatter.cpp @@ -3,18 +3,18 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) && !defined(ASMJIT_NO_LOGGING) -#include "../core/misc_p.h" -#include "../core/support.h" -#include "../arm/a64formatter_p.h" -#include "../arm/a64instapi_p.h" -#include "../arm/a64instdb_p.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include +#include +#include #ifndef ASMJIT_NO_COMPILER - #include "../core/compiler.h" + #include #endif ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64formatter_p.h b/asmjit/arm/a64formatter_p.h similarity index 78% rename from src/asmjit/arm/a64formatter_p.h rename to asmjit/arm/a64formatter_p.h index 9b59f3d..39af75a 100644 --- a/src/asmjit/arm/a64formatter_p.h +++ b/asmjit/arm/a64formatter_p.h @@ -6,14 +6,14 @@ #ifndef ASMJIT_ARM_A64FORMATTER_P_H_INCLUDED #define ASMJIT_ARM_A64FORMATTER_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_LOGGING -#include "../core/formatter.h" -#include "../core/span.h" -#include "../core/string.h" -#include "../arm/armformatter_p.h" -#include "../arm/a64globals.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64func.cpp b/asmjit/arm/a64func.cpp similarity index 98% rename from src/asmjit/arm/a64func.cpp rename to asmjit/arm/a64func.cpp index a07321f..afa05a8 100644 --- a/src/asmjit/arm/a64func.cpp +++ b/asmjit/arm/a64func.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) -#include "../arm/a64func_p.h" -#include "../arm/a64operand.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64func_p.h b/asmjit/arm/a64func_p.h similarity index 96% rename from src/asmjit/arm/a64func_p.h rename to asmjit/arm/a64func_p.h index 907acbb..a322a48 100644 --- a/src/asmjit/arm/a64func_p.h +++ b/asmjit/arm/a64func_p.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_ARM_A64FUNC_P_H_INCLUDED #define ASMJIT_ARM_A64FUNC_P_H_INCLUDED -#include "../core/func.h" +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64globals.h b/asmjit/arm/a64globals.h similarity index 99% rename from src/asmjit/arm/a64globals.h rename to asmjit/arm/a64globals.h index 5f22c1d..9abf069 100644 --- a/src/asmjit/arm/a64globals.h +++ b/asmjit/arm/a64globals.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_ARM_A64GLOBALS_H_INCLUDED #define ASMJIT_ARM_A64GLOBALS_H_INCLUDED -#include "../arm/armglobals.h" +#include //! \namespace asmjit::a64 //! \ingroup asmjit_a64 diff --git a/src/asmjit/arm/a64instapi.cpp b/asmjit/arm/a64instapi.cpp similarity index 95% rename from src/asmjit/arm/a64instapi.cpp rename to asmjit/arm/a64instapi.cpp index 21d9bb9..a7f3229 100644 --- a/src/asmjit/arm/a64instapi.cpp +++ b/asmjit/arm/a64instapi.cpp @@ -3,15 +3,15 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) -#include "../core/cpuinfo.h" -#include "../core/misc_p.h" -#include "../core/support_p.h" -#include "../arm/a64instapi_p.h" -#include "../arm/a64instdb_p.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) @@ -50,13 +50,13 @@ InstId string_to_inst_id(const char* s, size_t len) noexcept { // a64::InstInternal - Validate // ============================ -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION ASMJIT_FAVOR_SIZE Error validate(const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags) noexcept { // TODO: Support::maybe_unused(inst, operands, op_count, validation_flags); return Error::kOk; } -#endif // !ASMJIT_NO_VALIDATION +#endif // !ASMJIT_NO_INTROSPECTION // a64::InstInternal - QueryRWInfo // =============================== diff --git a/src/asmjit/arm/a64instapi_p.h b/asmjit/arm/a64instapi_p.h similarity index 90% rename from src/asmjit/arm/a64instapi_p.h rename to asmjit/arm/a64instapi_p.h index 938d2be..90290a8 100644 --- a/src/asmjit/arm/a64instapi_p.h +++ b/asmjit/arm/a64instapi_p.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_ARM_A64INSTAPI_P_H_INCLUDED #define ASMJIT_ARM_A64INSTAPI_P_H_INCLUDED -#include "../core/inst.h" -#include "../core/operand.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) @@ -22,11 +22,8 @@ Error ASMJIT_CDECL inst_id_to_string(InstId inst_id, InstStringifyOptions option InstId ASMJIT_CDECL string_to_inst_id(const char* s, size_t len) noexcept; #endif // !ASMJIT_NO_TEXT -#ifndef ASMJIT_NO_VALIDATION -Error ASMJIT_CDECL validate(const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags) noexcept; -#endif // !ASMJIT_NO_VALIDATION - #ifndef ASMJIT_NO_INTROSPECTION +Error ASMJIT_CDECL validate(const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags) noexcept; Error ASMJIT_CDECL query_rw_info(const BaseInst& inst, const Operand_* operands, size_t op_count, InstRWInfo* out) noexcept; Error ASMJIT_CDECL query_features(const BaseInst& inst, const Operand_* operands, size_t op_count, CpuFeatures* out) noexcept; #endif // !ASMJIT_NO_INTROSPECTION diff --git a/src/asmjit/arm/a64instdb.cpp b/asmjit/arm/a64instdb.cpp similarity index 99% rename from src/asmjit/arm/a64instdb.cpp rename to asmjit/arm/a64instdb.cpp index 3f33dcb..2ebb1ee 100644 --- a/src/asmjit/arm/a64instdb.cpp +++ b/asmjit/arm/a64instdb.cpp @@ -3,13 +3,13 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) -#include "../core/codeholder.h" -#include "../core/support.h" -#include "../arm/a64instdb_p.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64instdb.h b/asmjit/arm/a64instdb.h similarity index 98% rename from src/asmjit/arm/a64instdb.h rename to asmjit/arm/a64instdb.h index ac6ea07..e044aca 100644 --- a/src/asmjit/arm/a64instdb.h +++ b/asmjit/arm/a64instdb.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_ARM_A64INSTDB_H_INCLUDED #define ASMJIT_ARM_A64INSTDB_H_INCLUDED -#include "../arm/a64globals.h" +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64instdb_p.h b/asmjit/arm/a64instdb_p.h similarity index 99% rename from src/asmjit/arm/a64instdb_p.h rename to asmjit/arm/a64instdb_p.h index 85f633e..b4b4528 100644 --- a/src/asmjit/arm/a64instdb_p.h +++ b/asmjit/arm/a64instdb_p.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_ARM_A64INSTDB_H_P_INCLUDED #define ASMJIT_ARM_A64INSTDB_H_P_INCLUDED -#include "../core/codeholder.h" -#include "../core/instdb_p.h" -#include "../arm/a64instdb.h" -#include "../arm/a64operand.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64operand.cpp b/asmjit/arm/a64operand.cpp similarity index 96% rename from src/asmjit/arm/a64operand.cpp rename to asmjit/arm/a64operand.cpp index bd48969..f1eddb5 100644 --- a/src/asmjit/arm/a64operand.cpp +++ b/asmjit/arm/a64operand.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) -#include "../core/misc_p.h" -#include "../arm/a64operand.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/a64operand.h b/asmjit/arm/a64operand.h similarity index 99% rename from src/asmjit/arm/a64operand.h rename to asmjit/arm/a64operand.h index b84333b..ba5f98b 100644 --- a/src/asmjit/arm/a64operand.h +++ b/asmjit/arm/a64operand.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_ARM_A64OPERAND_H_INCLUDED #define ASMJIT_ARM_A64OPERAND_H_INCLUDED -#include "../core/operand.h" -#include "../arm/armglobals.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) @@ -651,24 +651,6 @@ public: //! \} }; -//! \name Shift Operation Construction -//! \{ - -//! Constructs a `LSL #value` shift (logical shift left). -static ASMJIT_INLINE_CONSTEXPR Shift lsl(uint32_t value) noexcept { return Shift(ShiftOp::kLSL, value); } -//! Constructs a `LSR #value` shift (logical shift right). -static ASMJIT_INLINE_CONSTEXPR Shift lsr(uint32_t value) noexcept { return Shift(ShiftOp::kLSR, value); } -//! Constructs a `ASR #value` shift (arithmetic shift right). -static ASMJIT_INLINE_CONSTEXPR Shift asr(uint32_t value) noexcept { return Shift(ShiftOp::kASR, value); } -//! Constructs a `ROR #value` shift (rotate right). -static ASMJIT_INLINE_CONSTEXPR Shift ror(uint32_t value) noexcept { return Shift(ShiftOp::kROR, value); } -//! Constructs a `RRX` shift (rotate with carry by 1). -static ASMJIT_INLINE_CONSTEXPR Shift rrx() noexcept { return Shift(ShiftOp::kRRX, 0); } -//! Constructs a `MSL #value` shift (logical shift left filling ones). -static ASMJIT_INLINE_CONSTEXPR Shift msl(uint32_t value) noexcept { return Shift(ShiftOp::kMSL, value); } - -//! \} - #ifndef _DOXYGEN namespace regs { #endif @@ -705,11 +687,11 @@ static ASMJIT_INLINE_CONSTEXPR Vec s(uint32_t id) noexcept { return Vec::make_v3 [[nodiscard]] static ASMJIT_INLINE_CONSTEXPR Vec d(uint32_t id) noexcept { return Vec::make_v64(id); } -//! Creates a 1282-bit V register operand. +//! Creates a 128-bit Q register operand. [[nodiscard]] static ASMJIT_INLINE_CONSTEXPR Vec q(uint32_t id) noexcept { return Vec::make_v128(id); } -//! Creates a 1282-bit V register operand. +//! Creates a 128-bit V register operand. [[nodiscard]] static ASMJIT_INLINE_CONSTEXPR Vec v(uint32_t id) noexcept { return Vec::make_v128(id); } @@ -989,6 +971,30 @@ using namespace regs; //! \name Shift Operation Construction //! \{ +//! Constructs a `LSL #value` shift (logical shift left). +[[nodiscard]] +static ASMJIT_INLINE_CONSTEXPR Shift lsl(uint32_t value) noexcept { return Shift(ShiftOp::kLSL, value); } + +//! Constructs a `LSR #value` shift (logical shift right). +[[nodiscard]] +static ASMJIT_INLINE_CONSTEXPR Shift lsr(uint32_t value) noexcept { return Shift(ShiftOp::kLSR, value); } + +//! Constructs a `ASR #value` shift (arithmetic shift right). +[[nodiscard]] +static ASMJIT_INLINE_CONSTEXPR Shift asr(uint32_t value) noexcept { return Shift(ShiftOp::kASR, value); } + +//! Constructs a `ROR #value` shift (rotate right). +[[nodiscard]] +static ASMJIT_INLINE_CONSTEXPR Shift ror(uint32_t value) noexcept { return Shift(ShiftOp::kROR, value); } + +//! Constructs a `RRX` shift (rotate with carry by 1). +[[nodiscard]] +static ASMJIT_INLINE_CONSTEXPR Shift rrx() noexcept { return Shift(ShiftOp::kRRX, 0); } + +//! Constructs a `MSL #value` shift (logical shift left filling ones). +[[nodiscard]] +static ASMJIT_INLINE_CONSTEXPR Shift msl(uint32_t value) noexcept { return Shift(ShiftOp::kMSL, value); } + //! Constructs a `UXTB #value` extend and shift (unsigned byte extend) (AArch64). [[nodiscard]] static ASMJIT_INLINE_CONSTEXPR Shift uxtb(uint32_t value) noexcept { return Shift(ShiftOp::kUXTB, value); } diff --git a/src/asmjit/arm/a64rapass.cpp b/asmjit/arm/a64rapass.cpp similarity index 98% rename from src/asmjit/arm/a64rapass.cpp rename to asmjit/arm/a64rapass.cpp index 3b68422..9dbd004 100644 --- a/src/asmjit/arm/a64rapass.cpp +++ b/asmjit/arm/a64rapass.cpp @@ -3,19 +3,19 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_AARCH64) && !defined(ASMJIT_NO_COMPILER) -#include "../core/cpuinfo.h" -#include "../core/formatter_p.h" -#include "../core/support.h" -#include "../core/type.h" -#include "../arm/a64assembler.h" -#include "../arm/a64compiler.h" -#include "../arm/a64emithelper_p.h" -#include "../arm/a64instapi_p.h" -#include "../arm/a64instdb_p.h" -#include "../arm/a64rapass_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) @@ -512,10 +512,10 @@ Error RACFGBuilder::on_invoke(InvokeNode* invoke_node, RAInstBuilder& ib) noexce } // Setup clobbered registers. - ib._clobbered[0] = Support::lsb_mask(_pass._phys_reg_count[RegGroup(0)]) & ~fd.preserved_regs(RegGroup(0)); - ib._clobbered[1] = Support::lsb_mask(_pass._phys_reg_count[RegGroup(1)]) & ~fd.preserved_regs(RegGroup(1)); - ib._clobbered[2] = Support::lsb_mask(_pass._phys_reg_count[RegGroup(2)]) & ~fd.preserved_regs(RegGroup(2)); - ib._clobbered[3] = Support::lsb_mask(_pass._phys_reg_count[RegGroup(3)]) & ~fd.preserved_regs(RegGroup(3)); + ib._clobbered[0] = Support::lsb_mask(_pass._phys_reg_count.get(RegGroup(0))) & ~fd.preserved_regs(RegGroup(0)); + ib._clobbered[1] = Support::lsb_mask(_pass._phys_reg_count.get(RegGroup(1))) & ~fd.preserved_regs(RegGroup(1)); + ib._clobbered[2] = Support::lsb_mask(_pass._phys_reg_count.get(RegGroup(2))) & ~fd.preserved_regs(RegGroup(2)); + ib._clobbered[3] = Support::lsb_mask(_pass._phys_reg_count.get(RegGroup(3))) & ~fd.preserved_regs(RegGroup(3)); return Error::kOk; } diff --git a/src/asmjit/arm/a64rapass_p.h b/asmjit/arm/a64rapass_p.h similarity index 88% rename from src/asmjit/arm/a64rapass_p.h rename to asmjit/arm/a64rapass_p.h index 67149ca..dfab0c2 100644 --- a/src/asmjit/arm/a64rapass_p.h +++ b/asmjit/arm/a64rapass_p.h @@ -6,16 +6,16 @@ #ifndef ASMJIT_ARM_A64RAPASS_P_H_INCLUDED #define ASMJIT_ARM_A64RAPASS_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/compiler.h" -#include "../core/racfgblock_p.h" -#include "../core/racfgbuilder_p.h" -#include "../core/rapass_p.h" -#include "../arm/a64assembler.h" -#include "../arm/a64compiler.h" -#include "../arm/a64emithelper_p.h" +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(a64) diff --git a/src/asmjit/arm/armformatter.cpp b/asmjit/arm/armformatter.cpp similarity index 97% rename from src/asmjit/arm/armformatter.cpp rename to asmjit/arm/armformatter.cpp index b6b8a37..5ad83ae 100644 --- a/src/asmjit/arm/armformatter.cpp +++ b/asmjit/arm/armformatter.cpp @@ -3,19 +3,19 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_LOGGING -#include "../core/formatter_p.h" -#include "../core/misc_p.h" -#include "../core/support.h" -#include "../arm/armformatter_p.h" -#include "../arm/a64operand.h" -#include "../arm/a64instapi_p.h" -#include "../arm/a64instdb_p.h" +#include +#include +#include +#include +#include +#include +#include #ifndef ASMJIT_NO_COMPILER - #include "../core/compiler.h" + #include #endif ASMJIT_BEGIN_SUB_NAMESPACE(arm) diff --git a/src/asmjit/arm/armformatter_p.h b/asmjit/arm/armformatter_p.h similarity index 90% rename from src/asmjit/arm/armformatter_p.h rename to asmjit/arm/armformatter_p.h index 1ba671d..ae9adff 100644 --- a/src/asmjit/arm/armformatter_p.h +++ b/asmjit/arm/armformatter_p.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_ARM_ARMFORMATTER_P_H_INCLUDED #define ASMJIT_ARM_ARMFORMATTER_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_LOGGING -#include "../core/formatter.h" -#include "../core/string.h" -#include "../arm/armglobals.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(arm) diff --git a/src/asmjit/arm/armglobals.h b/asmjit/arm/armglobals.h similarity index 85% rename from src/asmjit/arm/armglobals.h rename to asmjit/arm/armglobals.h index e05ee74..864c4f7 100644 --- a/src/asmjit/arm/armglobals.h +++ b/asmjit/arm/armglobals.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_ARM_ARMGLOBALS_H_INCLUDED #define ASMJIT_ARM_ARMGLOBALS_H_INCLUDED -#include "../core/archcommons.h" -#include "../core/inst.h" +#include +#include //! \namespace asmjit::arm //! \ingroup asmjit_arm diff --git a/src/asmjit/arm/armutils.h b/asmjit/arm/armutils.h similarity index 99% rename from src/asmjit/arm/armutils.h rename to asmjit/arm/armutils.h index f23cf45..bf0708d 100644 --- a/src/asmjit/arm/armutils.h +++ b/asmjit/arm/armutils.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_ARM_ARMUTILS_H_INCLUDED #define ASMJIT_ARM_ARMUTILS_H_INCLUDED -#include "../core/support.h" -#include "../arm/armglobals.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(arm) diff --git a/src/asmjit/asmjit-scope-begin.h b/asmjit/asmjit-scope-begin.h similarity index 100% rename from src/asmjit/asmjit-scope-begin.h rename to asmjit/asmjit-scope-begin.h diff --git a/src/asmjit/asmjit-scope-end.h b/asmjit/asmjit-scope-end.h similarity index 100% rename from src/asmjit/asmjit-scope-end.h rename to asmjit/asmjit-scope-end.h diff --git a/src/asmjit/asmjit.h b/asmjit/asmjit.h similarity index 96% rename from src/asmjit/asmjit.h rename to asmjit/asmjit.h index b95350a..235d826 100644 --- a/src/asmjit/asmjit.h +++ b/asmjit/asmjit.h @@ -26,10 +26,10 @@ #pragma message("asmjit/asmjit.h is deprecated! Please use asmjit/[core|x86|a64|host].h instead.") -#include "./core.h" +#include #ifndef ASMJIT_NO_X86 - #include "./x86.h" + #include #endif #endif // ASMJIT_ASMJIT_H_INCLUDED diff --git a/src/asmjit.natvis b/asmjit/asmjit.natvis similarity index 100% rename from src/asmjit.natvis rename to asmjit/asmjit.natvis diff --git a/src/asmjit/core.h b/asmjit/core.h similarity index 98% rename from src/asmjit/core.h rename to asmjit/core.h index b1f5074..b26b45f 100644 --- a/src/asmjit/core.h +++ b/asmjit/core.h @@ -225,10 +225,6 @@ namespace asmjit { //! //! \section build_options Build Options //! -//! - \ref ASMJIT_NO_DEPRECATED - Disables deprecated API at compile time so it won't be available and the -//! compilation will fail if there is attempt to use such API. This includes deprecated classes, namespaces, -//! enumerations, and functions. -//! //! - \ref ASMJIT_NO_SHM_OPEN - Disables functionality that uses `shm_open()`. //! //! - \ref ASMJIT_NO_ABI_NAMESPACE - Disables inline ABI namespace within `asmjit` namespace. This is only provided @@ -238,8 +234,8 @@ namespace asmjit { //! //! \section build_features Build Features //! -//! AsmJit builds by default all supported features, which includes all emitters, logging, instruction validation and -//! introspection, and JIT memory allocation. Features can be disabled at compile time by using `ASMJIT_NO_...` +//! AsmJit builds by default all supported features, which includes all emitters, logging, instruction validation +//! and introspection, and JIT memory allocation. Features can be disabled at compile time by using `ASMJIT_NO_...` //! definitions. //! - \ref ASMJIT_NO_JIT - Disables JIT memory management and \ref JitRuntime. //! @@ -249,11 +245,9 @@ namespace asmjit { //! //! - \ref ASMJIT_NO_LOGGING - Disables \ref Logger and \ref Formatter. //! -//! - \ref ASMJIT_NO_VALIDATION - Disables validation API. -//! -//! - \ref ASMJIT_NO_INTROSPECTION - Disables instruction introspection API, must be used together with \ref -//! ASMJIT_NO_COMPILER as \ref asmjit_compiler requires introspection for its liveness analysis and register -//! allocation. +//! - \ref ASMJIT_NO_INTROSPECTION - Disables instruction introspection and validation API, must be used together +//! with \ref ASMJIT_NO_COMPILER as \ref asmjit_compiler requires introspection for its liveness analysis and +//! register allocation. //! //! - \ref ASMJIT_NO_BUILDER - Disables \ref asmjit_builder functionality completely. This implies \ref //! ASMJIT_NO_COMPILER as \ref asmjit_compiler cannot be used without \ref asmjit_builder. @@ -2281,43 +2275,46 @@ namespace asmjit { } // {asmjit} -#include "asmjit-scope-begin.h" -#include "core/api-config.h" -#include "core/archcommons.h" -#include "core/archtraits.h" -#include "core/arena.h" -#include "core/arenahash.h" -#include "core/arenalist.h" -#include "core/arenapool.h" -#include "core/arenastring.h" -#include "core/arenatree.h" -#include "core/arenavector.h" -#include "core/assembler.h" -#include "core/builder.h" -#include "core/codebuffer.h" -#include "core/codeholder.h" -#include "core/compiler.h" -#include "core/constpool.h" -#include "core/cpuinfo.h" -#include "core/emitter.h" -#include "core/environment.h" -#include "core/errorhandler.h" -#include "core/fixup.h" -#include "core/formatter.h" -#include "core/func.h" -#include "core/globals.h" -#include "core/inst.h" -#include "core/jitallocator.h" -#include "core/jitruntime.h" -#include "core/logger.h" -#include "core/operand.h" -#include "core/osutils.h" -#include "core/span.h" -#include "core/string.h" -#include "core/support.h" -#include "core/target.h" -#include "core/type.h" -#include "core/virtmem.h" -#include "asmjit-scope-end.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #endif // ASMJIT_CORE_H_INCLUDED diff --git a/src/asmjit/core/api-build_p.h b/asmjit/core/api-build_p.h similarity index 96% rename from src/asmjit/core/api-build_p.h rename to asmjit/core/api-build_p.h index af56b64..2de68d2 100644 --- a/src/asmjit/core/api-build_p.h +++ b/asmjit/core/api-build_p.h @@ -48,7 +48,7 @@ #endif -#include "../core/api-config.h" +#include #if !defined(ASMJIT_BUILD_DEBUG) && defined(__GNUC__) && !defined(__clang__) #define ASMJIT_FAVOR_SIZE __attribute__((__optimize__("Os"))) @@ -68,7 +68,7 @@ // Include a unit testing package if this is a `asmjit_test_unit` build. #if defined(ASMJIT_TEST) - #include "../../../testing/tests/broken.h" + #include #endif #endif // ASMJIT_CORE_API_BUILD_P_H_INCLUDED diff --git a/src/asmjit/core/api-config.h b/asmjit/core/api-config.h similarity index 98% rename from src/asmjit/core/api-config.h rename to asmjit/core/api-config.h index 203f9f8..3444cb0 100644 --- a/src/asmjit/core/api-config.h +++ b/asmjit/core/api-config.h @@ -16,7 +16,7 @@ #define ASMJIT_LIBRARY_MAKE_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) //! AsmJit library version, see \ref ASMJIT_LIBRARY_MAKE_VERSION for a version format reference. -#define ASMJIT_LIBRARY_VERSION ASMJIT_LIBRARY_MAKE_VERSION(1, 20, 0) +#define ASMJIT_LIBRARY_VERSION ASMJIT_LIBRARY_MAKE_VERSION(1, 21, 0) //! \def ASMJIT_ABI_NAMESPACE //! @@ -27,7 +27,7 @@ //! AsmJit default, which makes it possible to use multiple AsmJit libraries within a single project, totally //! controlled by users. This is useful especially in cases in which some of such library comes from third party. #if !defined(ASMJIT_ABI_NAMESPACE) - #define ASMJIT_ABI_NAMESPACE v1_20 + #define ASMJIT_ABI_NAMESPACE v1_21 #endif // !ASMJIT_ABI_NAMESPACE //! \} @@ -90,12 +90,6 @@ #define ASMJIT_BUILD_RELEASE #undef ASMJIT_BUILD_RELEASE -//! \def ASMJIT_NO_DEPRECATED -//! -//! Disables deprecated API at compile time (deprecated API won't be available). -#define ASMJIT_NO_DEPRECATED -#undef ASMJIT_NO_DEPRECATED - //! \def ASMJIT_NO_ABI_NAMESPACE //! //! Disables the use of an inline ABI namespace within asmjit namespace (the inline namespace is used as an ABI tag). @@ -138,12 +132,6 @@ #define ASMJIT_NO_TEXT #undef ASMJIT_NO_TEXT -//! \def ASMJIT_NO_VALIDATION -//! -//! Disables instruction validation API. -#define ASMJIT_NO_VALIDATION -#undef ASMJIT_NO_VALIDATION - //! \def ASMJIT_NO_INTROSPECTION //! //! Disables instruction introspection API. diff --git a/src/asmjit/core/archcommons.h b/asmjit/core/archcommons.h similarity index 99% rename from src/asmjit/core/archcommons.h rename to asmjit/core/archcommons.h index 8171eee..2ab5ca9 100644 --- a/src/asmjit/core/archcommons.h +++ b/asmjit/core/archcommons.h @@ -10,7 +10,7 @@ // allows to be created from arm::Shift in a const-expr way, so the arm::Shift must be provided. So this header file // provides everything architecture-specific that is used by the Core API. -#include "../core/globals.h" +#include ASMJIT_BEGIN_SUB_NAMESPACE(arm) diff --git a/src/asmjit/core/archtraits.cpp b/asmjit/core/archtraits.cpp similarity index 94% rename from src/asmjit/core/archtraits.cpp rename to asmjit/core/archtraits.cpp index 51bf12c..d4b3ec7 100644 --- a/src/asmjit/core/archtraits.cpp +++ b/asmjit/core/archtraits.cpp @@ -3,17 +3,17 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/archtraits.h" -#include "../core/environment.h" -#include "../core/misc_p.h" +#include +#include +#include +#include #if !defined(ASMJIT_NO_X86) - #include "../x86/x86archtraits_p.h" + #include #endif #if !defined(ASMJIT_NO_AARCH64) - #include "../arm/a64archtraits_p.h" + #include #endif ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/archtraits.h b/asmjit/core/archtraits.h similarity index 99% rename from src/asmjit/core/archtraits.h rename to asmjit/core/archtraits.h index 877f32f..fc99975 100644 --- a/src/asmjit/core/archtraits.h +++ b/asmjit/core/archtraits.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_ARCHTRAITS_H_INCLUDED #define ASMJIT_CORE_ARCHTRAITS_H_INCLUDED -#include "../core/operand.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/assembler.cpp b/asmjit/core/assembler.cpp similarity index 97% rename from src/asmjit/core/assembler.cpp rename to asmjit/core/assembler.cpp index 3c90945..0349960 100644 --- a/src/asmjit/core/assembler.cpp +++ b/asmjit/core/assembler.cpp @@ -3,14 +3,14 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/assembler.h" -#include "../core/codewriter_p.h" -#include "../core/constpool.h" -#include "../core/emitterutils_p.h" -#include "../core/formatter.h" -#include "../core/logger.h" -#include "../core/support.h" +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/assembler.h b/asmjit/core/assembler.h similarity index 97% rename from src/asmjit/core/assembler.h rename to asmjit/core/assembler.h index 25cd9b3..021b325 100644 --- a/src/asmjit/core/assembler.h +++ b/asmjit/core/assembler.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_ASSEMBLER_H_INCLUDED #define ASMJIT_CORE_ASSEMBLER_H_INCLUDED -#include "../core/codeholder.h" -#include "../core/emitter.h" -#include "../core/operand.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/builder.cpp b/asmjit/core/builder.cpp similarity index 96% rename from src/asmjit/core/builder.cpp rename to asmjit/core/builder.cpp index acdc0b6..8fba8a5 100644 --- a/src/asmjit/core/builder.cpp +++ b/asmjit/core/builder.cpp @@ -3,15 +3,15 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_BUILDER -#include "../core/builder.h" -#include "../core/emitterutils_p.h" -#include "../core/errorhandler.h" -#include "../core/formatter.h" -#include "../core/logger.h" -#include "../core/support.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -34,7 +34,7 @@ public: // BaseBuilder - Utilities // ======================= -static void BaseBuilder_deletePasses(BaseBuilder* self) noexcept { +static void BaseBuilder_delete_passes(BaseBuilder* self) noexcept { for (Pass* pass : self->_passes) { pass->~Pass(); } @@ -50,7 +50,7 @@ BaseBuilder::BaseBuilder() noexcept _pass_arena(64u * 1024u) {} BaseBuilder::~BaseBuilder() noexcept { - BaseBuilder_deletePasses(this); + BaseBuilder_delete_passes(this); } // BaseBuilder - Node Management @@ -612,7 +612,7 @@ Error BaseBuilder::_emit(InstId inst_id, const Operand_& o0, const Operand_& o1, return make_error(Error::kNotInitialized); } -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION // Strict validation. if (has_diagnostic_option(DiagnosticOptions::kValidateIntermediate)) { Operand_ op_array[Globals::kMaxOpCount]; @@ -865,7 +865,7 @@ Error BaseBuilder::serialize_to(BaseEmitter* dst) { // BaseBuilder - Events // ==================== -static ASMJIT_INLINE void BaseBuilder_clearAll(BaseBuilder* self) noexcept { +static ASMJIT_INLINE void BaseBuilder_clear_all(BaseBuilder* self) noexcept { self->_section_nodes.reset(); self->_label_nodes.reset(); @@ -876,7 +876,7 @@ static ASMJIT_INLINE void BaseBuilder_clearAll(BaseBuilder* self) noexcept { self->_node_list.reset(); } -static ASMJIT_INLINE Error BaseBuilder_initSection(BaseBuilder* self) noexcept { +static ASMJIT_INLINE Error BaseBuilder_init_section(BaseBuilder* self) noexcept { SectionNode* initial_section; ASMJIT_PROPAGATE(self->section_node_of(Out(initial_section), 0)); @@ -893,7 +893,7 @@ static ASMJIT_INLINE Error BaseBuilder_initSection(BaseBuilder* self) noexcept { Error BaseBuilder::on_attach(CodeHolder& code) noexcept { ASMJIT_PROPAGATE(Base::on_attach(code)); - Error err = BaseBuilder_initSection(this); + Error err = BaseBuilder_init_section(this); if (ASMJIT_UNLIKELY(err != Error::kOk)) { on_detach(code); } @@ -901,8 +901,8 @@ Error BaseBuilder::on_attach(CodeHolder& code) noexcept { } Error BaseBuilder::on_detach(CodeHolder& code) noexcept { - BaseBuilder_deletePasses(this); - BaseBuilder_clearAll(this); + BaseBuilder_delete_passes(this); + BaseBuilder_clear_all(this); return Base::on_detach(code); } @@ -911,9 +911,9 @@ Error BaseBuilder::on_reinit(CodeHolder& code) noexcept { // BaseEmitter::on_reinit() never fails. (void)Base::on_reinit(code); - BaseBuilder_deletePasses(this); - BaseBuilder_clearAll(this); - return BaseBuilder_initSection(this); + BaseBuilder_delete_passes(this); + BaseBuilder_clear_all(this); + return BaseBuilder_init_section(this); } // Pass - Construction & Destruction diff --git a/src/asmjit/core/builder.h b/asmjit/core/builder.h similarity index 99% rename from src/asmjit/core/builder.h rename to asmjit/core/builder.h index 2e52edd..d65929d 100644 --- a/src/asmjit/core/builder.h +++ b/asmjit/core/builder.h @@ -6,20 +6,20 @@ #ifndef ASMJIT_CORE_BUILDER_H_INCLUDED #define ASMJIT_CORE_BUILDER_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_BUILDER -#include "../core/arena.h" -#include "../core/arenavector.h" -#include "../core/assembler.h" -#include "../core/codeholder.h" -#include "../core/constpool.h" -#include "../core/formatter.h" -#include "../core/inst.h" -#include "../core/operand.h" -#include "../core/string.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -1088,7 +1088,7 @@ public: //! Returns the index of the given operand type `op_type`. //! //! \note If the operand type wa found, the value returned represents its index in \ref operands() - //! array, otherwise \ref Globals::kNPos is returned to signalize that the operand was not found. + //! array, otherwise `SIZE_MAX` is returned to signalize that the operand was not found. [[nodiscard]] inline size_t index_of_op_type(OperandType op_type) const noexcept { Span ops = operands(); @@ -1097,7 +1097,7 @@ public: return i; } - return Globals::kNPos; + return SIZE_MAX; } //! A shortcut that calls `index_of_op_type(OperandType::kMem)`. diff --git a/src/asmjit/core/builder_p.h b/asmjit/core/builder_p.h similarity index 93% rename from src/asmjit/core/builder_p.h rename to asmjit/core/builder_p.h index cb42e7b..131dadb 100644 --- a/src/asmjit/core/builder_p.h +++ b/asmjit/core/builder_p.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_CORE_BUILDER_P_H_INCLUDED #define ASMJIT_CORE_BUILDER_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_BUILDER -#include "../core/builder.h" +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/codebuffer.h b/asmjit/core/codebuffer.h similarity index 98% rename from src/asmjit/core/codebuffer.h rename to asmjit/core/codebuffer.h index eedd06b..347bfa1 100644 --- a/src/asmjit/core/codebuffer.h +++ b/asmjit/core/codebuffer.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_CORE_CODEBUFFER_H_INCLUDED #define ASMJIT_CORE_CODEBUFFER_H_INCLUDED -#include "../core/globals.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/codeholder.cpp b/asmjit/core/codeholder.cpp similarity index 99% rename from src/asmjit/core/codeholder.cpp rename to asmjit/core/codeholder.cpp index 723cc4a..66dae29 100644 --- a/src/asmjit/core/codeholder.cpp +++ b/asmjit/core/codeholder.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/assembler.h" -#include "../core/codewriter_p.h" -#include "../core/logger.h" -#include "../core/support.h" +#include +#include +#include +#include +#include #include #include @@ -32,7 +32,7 @@ static constexpr LabelEntry::ExtraData CodeHolder_make_shared_label_extra_data() return extra_data; } -static constexpr LabelEntry::ExtraData CodeHolder_sharedLabelExtraData = CodeHolder_make_shared_label_extra_data(); +static constexpr LabelEntry::ExtraData CodeHolder_shared_label_extra_data = CodeHolder_make_shared_label_extra_data(); class ResolveFixupIterator { public: @@ -692,7 +692,7 @@ Error CodeHolder::new_label_id(Out label_id_out) noexcept { } else { label_id_out = label_id; - _label_entries.append_unchecked(LabelEntry{const_cast(&CodeHolder_sharedLabelExtraData), uint64_t(0)}); + _label_entries.append_unchecked(LabelEntry{const_cast(&CodeHolder_shared_label_extra_data), uint64_t(0)}); return Error::kOk; } } @@ -710,7 +710,7 @@ Error CodeHolder::new_named_label_id(Out label_id_out, const char* nam } label_id_out = label_id; - _label_entries.append_unchecked(LabelEntry{const_cast(&CodeHolder_sharedLabelExtraData), uint64_t(0)}); + _label_entries.append_unchecked(LabelEntry{const_cast(&CodeHolder_shared_label_extra_data), uint64_t(0)}); return Error::kOk; } diff --git a/src/asmjit/core/codeholder.h b/asmjit/core/codeholder.h similarity index 98% rename from src/asmjit/core/codeholder.h rename to asmjit/core/codeholder.h index 4e4605d..499e815 100644 --- a/src/asmjit/core/codeholder.h +++ b/asmjit/core/codeholder.h @@ -6,21 +6,21 @@ #ifndef ASMJIT_CORE_CODEHOLDER_H_INCLUDED #define ASMJIT_CORE_CODEHOLDER_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/arena.h" -#include "../core/arenahash.h" -#include "../core/arenapool.h" -#include "../core/arenastring.h" -#include "../core/arenatree.h" -#include "../core/arenavector.h" -#include "../core/codebuffer.h" -#include "../core/errorhandler.h" -#include "../core/fixup.h" -#include "../core/operand.h" -#include "../core/span.h" -#include "../core/string.h" -#include "../core/support.h" -#include "../core/target.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/codewriter.cpp b/asmjit/core/codewriter.cpp similarity index 96% rename from src/asmjit/core/codewriter.cpp rename to asmjit/core/codewriter.cpp index 8190252..7befce2 100644 --- a/src/asmjit/core/codewriter.cpp +++ b/asmjit/core/codewriter.cpp @@ -3,11 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/codeholder.h" -#include "../core/codewriter_p.h" +#include +#include +#include +#include -#include "../arm/armutils.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -65,7 +66,7 @@ bool CodeWriterUtils::encode_offset32(uint32_t* dst, int64_t offset64, const Off } value = uint32_t(int32_t(offset64)); - if (!Support::is_encodable_offset_32(int32_t(value), bit_count)) { + if (!EmitterUtils::is_encodable_offset_32(int32_t(value), bit_count)) { return false; } } @@ -228,7 +229,7 @@ bool CodeWriterUtils::encode_offset64(uint64_t* dst, int64_t offset64, const Off offset64 >>= discard_lsb; } - if (!Support::is_encodable_offset_64(offset64, bit_count)) { + if (!EmitterUtils::is_encodable_offset_64(offset64, bit_count)) { return false; } diff --git a/src/asmjit/core/codewriter_p.h b/asmjit/core/codewriter_p.h similarity index 97% rename from src/asmjit/core/codewriter_p.h rename to asmjit/core/codewriter_p.h index 392aea1..f05154e 100644 --- a/src/asmjit/core/codewriter_p.h +++ b/asmjit/core/codewriter_p.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_CODEBUFFERWRITER_P_H_INCLUDED #define ASMJIT_CORE_CODEBUFFERWRITER_P_H_INCLUDED -#include "../core/assembler.h" -#include "../core/codebuffer.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/compiler.cpp b/asmjit/core/compiler.cpp similarity index 98% rename from src/asmjit/core/compiler.cpp rename to asmjit/core/compiler.cpp index 62f79b4..eb12a03 100644 --- a/src/asmjit/core/compiler.cpp +++ b/asmjit/core/compiler.cpp @@ -3,18 +3,18 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/assembler.h" -#include "../core/builder_p.h" -#include "../core/compiler.h" -#include "../core/cpuinfo.h" -#include "../core/logger.h" -#include "../core/rapass_p.h" -#include "../core/rastack_p.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/compiler.h b/asmjit/core/compiler.h similarity index 98% rename from src/asmjit/core/compiler.h rename to asmjit/core/compiler.h index 6d18bd5..6e8a424 100644 --- a/src/asmjit/core/compiler.h +++ b/asmjit/core/compiler.h @@ -6,19 +6,19 @@ #ifndef ASMJIT_CORE_COMPILER_H_INCLUDED #define ASMJIT_CORE_COMPILER_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/arena.h" -#include "../core/arenavector.h" -#include "../core/assembler.h" -#include "../core/builder.h" -#include "../core/constpool.h" -#include "../core/compilerdefs.h" -#include "../core/func.h" -#include "../core/inst.h" -#include "../core/operand.h" -#include "../core/support.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/compilerdefs.h b/asmjit/core/compilerdefs.h similarity index 98% rename from src/asmjit/core/compilerdefs.h rename to asmjit/core/compilerdefs.h index e8e0d0b..5c41c89 100644 --- a/src/asmjit/core/compilerdefs.h +++ b/asmjit/core/compilerdefs.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_COMPILERDEFS_H_INCLUDED #define ASMJIT_CORE_COMPILERDEFS_H_INCLUDED -#include "../core/api-config.h" -#include "../core/arenastring.h" -#include "../core/operand.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/constpool.cpp b/asmjit/core/constpool.cpp similarity index 98% rename from src/asmjit/core/constpool.cpp rename to asmjit/core/constpool.cpp index d83cfec..c3fe994 100644 --- a/src/asmjit/core/constpool.cpp +++ b/asmjit/core/constpool.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/constpool.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/constpool.h b/asmjit/core/constpool.h similarity index 98% rename from src/asmjit/core/constpool.h rename to asmjit/core/constpool.h index 36f6e58..3b90941 100644 --- a/src/asmjit/core/constpool.h +++ b/asmjit/core/constpool.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_CONSTPOOL_H_INCLUDED #define ASMJIT_CORE_CONSTPOOL_H_INCLUDED -#include "../core/arena.h" -#include "../core/arenatree.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/cpuinfo.cpp b/asmjit/core/cpuinfo.cpp similarity index 99% rename from src/asmjit/core/cpuinfo.cpp rename to asmjit/core/cpuinfo.cpp index 2133a7d..5a9d839 100644 --- a/src/asmjit/core/cpuinfo.cpp +++ b/asmjit/core/cpuinfo.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/cpuinfo.h" -#include "../core/support.h" +#include +#include +#include #include diff --git a/src/asmjit/core/cpuinfo.h b/asmjit/core/cpuinfo.h similarity index 99% rename from src/asmjit/core/cpuinfo.h rename to asmjit/core/cpuinfo.h index 6225a8c..921f351 100644 --- a/src/asmjit/core/cpuinfo.h +++ b/asmjit/core/cpuinfo.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_CPUINFO_H_INCLUDED #define ASMJIT_CORE_CPUINFO_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/environment.h" -#include "../core/globals.h" -#include "../core/string.h" -#include "../core/support.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/emithelper.cpp b/asmjit/core/emithelper.cpp similarity index 98% rename from src/asmjit/core/emithelper.cpp rename to asmjit/core/emithelper.cpp index 1805b71..8765484 100644 --- a/src/asmjit/core/emithelper.cpp +++ b/asmjit/core/emithelper.cpp @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/archtraits.h" -#include "../core/emithelper_p.h" -#include "../core/formatter.h" -#include "../core/funcargscontext_p.h" -#include "../core/radefs_p.h" +#include +#include +#include +#include +#include +#include // Can be used for debugging... // #define ASMJIT_DUMP_ARGS_ASSIGNMENT diff --git a/src/asmjit/core/emithelper_p.h b/asmjit/core/emithelper_p.h similarity index 95% rename from src/asmjit/core/emithelper_p.h rename to asmjit/core/emithelper_p.h index 8e41566..2ebaea8 100644 --- a/src/asmjit/core/emithelper_p.h +++ b/asmjit/core/emithelper_p.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_EMITHELPER_P_H_INCLUDED #define ASMJIT_CORE_EMITHELPER_P_H_INCLUDED -#include "../core/emitter.h" -#include "../core/operand.h" -#include "../core/type.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/emitter.cpp b/asmjit/core/emitter.cpp similarity index 98% rename from src/asmjit/core/emitter.cpp rename to asmjit/core/emitter.cpp index 3a8ea04..9c708cd 100644 --- a/src/asmjit/core/emitter.cpp +++ b/asmjit/core/emitter.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/emitterutils_p.h" -#include "../core/errorhandler.h" -#include "../core/logger.h" -#include "../core/support.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/emitter.h b/asmjit/core/emitter.h similarity index 99% rename from src/asmjit/core/emitter.h rename to asmjit/core/emitter.h index e6bc2b3..2c82912 100644 --- a/src/asmjit/core/emitter.h +++ b/asmjit/core/emitter.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_CORE_EMITTER_H_INCLUDED #define ASMJIT_CORE_EMITTER_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/codeholder.h" -#include "../core/formatter.h" -#include "../core/inst.h" -#include "../core/operand.h" -#include "../core/type.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/emitterutils.cpp b/asmjit/core/emitterutils.cpp similarity index 94% rename from src/asmjit/core/emitterutils.cpp rename to asmjit/core/emitterutils.cpp index ef9db4d..85e6945 100644 --- a/src/asmjit/core/emitterutils.cpp +++ b/asmjit/core/emitterutils.cpp @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/assembler.h" -#include "../core/emitterutils_p.h" -#include "../core/formatter_p.h" -#include "../core/logger.h" -#include "../core/support.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/emitterutils_p.h b/asmjit/core/emitterutils_p.h similarity index 81% rename from src/asmjit/core/emitterutils_p.h rename to asmjit/core/emitterutils_p.h index 27513a1..922e413 100644 --- a/src/asmjit/core/emitterutils_p.h +++ b/asmjit/core/emitterutils_p.h @@ -6,8 +6,9 @@ #ifndef ASMJIT_CORE_EMITTERUTILS_P_H_INCLUDED #define ASMJIT_CORE_EMITTERUTILS_P_H_INCLUDED -#include "../core/emitter.h" -#include "../core/operand.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -59,6 +60,18 @@ static ASMJIT_INLINE void op_array_from_emit_args(Operand_ dst[Globals::kMaxOpCo dst[5].copy_from(op_ext[kOp5]); } +[[nodiscard]] +static bool ASMJIT_INLINE_NODEBUG is_encodable_offset_32(int32_t offset, uint32_t num_bits) noexcept { + uint32_t n_rev = 32 - num_bits; + return Support::sar(Support::shl(offset, n_rev), n_rev) == offset; +} + +[[nodiscard]] +static bool ASMJIT_INLINE_NODEBUG is_encodable_offset_64(int64_t offset, uint32_t num_bits) noexcept { + uint32_t n_rev = 64 - num_bits; + return Support::sar(Support::shl(offset, n_rev), n_rev) == offset; +} + #ifndef ASMJIT_NO_LOGGING Error finish_formatted_line(String& sb, const FormatOptions& format_options, const uint8_t* bin_data, size_t bin_size, size_t offset_size, size_t imm_size, const char* comment) noexcept; diff --git a/src/asmjit/core/environment.cpp b/asmjit/core/environment.cpp similarity index 94% rename from src/asmjit/core/environment.cpp rename to asmjit/core/environment.cpp index d5d3d38..fcc67f4 100644 --- a/src/asmjit/core/environment.cpp +++ b/asmjit/core/environment.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/environment.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/environment.h b/asmjit/core/environment.h similarity index 99% rename from src/asmjit/core/environment.h rename to asmjit/core/environment.h index 4b87222..84d45f6 100644 --- a/src/asmjit/core/environment.h +++ b/asmjit/core/environment.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_CORE_ENVIRONMENT_H_INCLUDED #define ASMJIT_CORE_ENVIRONMENT_H_INCLUDED -#include "../core/archtraits.h" +#include #if defined(__APPLE__) #include diff --git a/src/asmjit/core/errorhandler.cpp b/asmjit/core/errorhandler.cpp similarity index 79% rename from src/asmjit/core/errorhandler.cpp rename to asmjit/core/errorhandler.cpp index c1f795f..1034212 100644 --- a/src/asmjit/core/errorhandler.cpp +++ b/asmjit/core/errorhandler.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/errorhandler.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/errorhandler.h b/asmjit/core/errorhandler.h similarity index 99% rename from src/asmjit/core/errorhandler.h rename to asmjit/core/errorhandler.h index 081bab7..085aa32 100644 --- a/src/asmjit/core/errorhandler.h +++ b/asmjit/core/errorhandler.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_CORE_ERRORHANDLER_H_INCLUDED #define ASMJIT_CORE_ERRORHANDLER_H_INCLUDED -#include "../core/globals.h" +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/fixup.h b/asmjit/core/fixup.h similarity index 99% rename from src/asmjit/core/fixup.h rename to asmjit/core/fixup.h index 6dcfcf2..5533f2a 100644 --- a/src/asmjit/core/fixup.h +++ b/asmjit/core/fixup.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_CORE_FIXUP_H_INCLUDED #define ASMJIT_CORE_FIXUP_H_INCLUDED -#include "../core/globals.h" +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/formatter.cpp b/asmjit/core/formatter.cpp similarity index 97% rename from src/asmjit/core/formatter.cpp rename to asmjit/core/formatter.cpp index c7168fe..8ad10a2 100644 --- a/src/asmjit/core/formatter.cpp +++ b/asmjit/core/formatter.cpp @@ -3,25 +3,25 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_LOGGING -#include "../core/archtraits.h" -#include "../core/builder.h" -#include "../core/codeholder.h" -#include "../core/compiler.h" -#include "../core/emitter.h" -#include "../core/formatter_p.h" -#include "../core/string.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #if !defined(ASMJIT_NO_X86) - #include "../x86/x86formatter_p.h" + #include #endif #if !defined(ASMJIT_NO_AARCH64) - #include "../arm/a64formatter_p.h" + #include #endif ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/formatter.h b/asmjit/core/formatter.h similarity index 98% rename from src/asmjit/core/formatter.h rename to asmjit/core/formatter.h index f9a6120..3d0dcca 100644 --- a/src/asmjit/core/formatter.h +++ b/asmjit/core/formatter.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_FORMATTER_H_INCLUDED #define ASMJIT_CORE_FORMATTER_H_INCLUDED -#include "../core/globals.h" -#include "../core/inst.h" -#include "../core/span.h" -#include "../core/string.h" -#include "../core/support.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/formatter_p.h b/asmjit/core/formatter_p.h similarity index 91% rename from src/asmjit/core/formatter_p.h rename to asmjit/core/formatter_p.h index 77fc0ea..495e8f9 100644 --- a/src/asmjit/core/formatter_p.h +++ b/asmjit/core/formatter_p.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_FORMATTER_P_H_INCLUDED #define ASMJIT_CORE_FORMATTER_P_H_INCLUDED -#include "../core/compilerdefs.h" -#include "../core/formatter.h" -#include "../core/operand.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/func.cpp b/asmjit/core/func.cpp similarity index 97% rename from src/asmjit/core/func.cpp rename to asmjit/core/func.cpp index 07dc8de..78c0eeb 100644 --- a/src/asmjit/core/func.cpp +++ b/asmjit/core/func.cpp @@ -3,19 +3,19 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/archtraits.h" -#include "../core/func.h" -#include "../core/operand.h" -#include "../core/type.h" -#include "../core/funcargscontext_p.h" +#include +#include +#include +#include +#include +#include #if !defined(ASMJIT_NO_X86) - #include "../x86/x86func_p.h" + #include #endif #if !defined(ASMJIT_NO_AARCH64) - #include "../arm/a64func_p.h" + #include #endif ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/func.h b/asmjit/core/func.h similarity index 99% rename from src/asmjit/core/func.h rename to asmjit/core/func.h index 51d07fc..8a95417 100644 --- a/src/asmjit/core/func.h +++ b/asmjit/core/func.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_FUNC_H_INCLUDED #define ASMJIT_CORE_FUNC_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/environment.h" -#include "../core/operand.h" -#include "../core/type.h" -#include "../core/support.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/funcargscontext.cpp b/asmjit/core/funcargscontext.cpp similarity index 99% rename from src/asmjit/core/funcargscontext.cpp rename to asmjit/core/funcargscontext.cpp index d7d42f3..c9948bc 100644 --- a/src/asmjit/core/funcargscontext.cpp +++ b/asmjit/core/funcargscontext.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/funcargscontext_p.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/funcargscontext_p.h b/asmjit/core/funcargscontext_p.h similarity index 97% rename from src/asmjit/core/funcargscontext_p.h rename to asmjit/core/funcargscontext_p.h index e83ebf0..33c35e5 100644 --- a/src/asmjit/core/funcargscontext_p.h +++ b/asmjit/core/funcargscontext_p.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_CORE_FUNCARGSCONTEXT_P_H_INCLUDED #define ASMJIT_CORE_FUNCARGSCONTEXT_P_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/environment.h" -#include "../core/func.h" -#include "../core/operand.h" -#include "../core/support.h" -#include "../core/raconstraints_p.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/globals.cpp b/asmjit/core/globals.cpp similarity index 97% rename from src/asmjit/core/globals.cpp rename to asmjit/core/globals.cpp index 7ab1453..ab7a4a5 100644 --- a/src/asmjit/core/globals.cpp +++ b/asmjit/core/globals.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/globals.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/globals.h b/asmjit/core/globals.h similarity index 98% rename from src/asmjit/core/globals.h rename to asmjit/core/globals.h index 45d5c99..49dadc3 100644 --- a/src/asmjit/core/globals.h +++ b/asmjit/core/globals.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_CORE_GLOBALS_H_INCLUDED #define ASMJIT_CORE_GLOBALS_H_INCLUDED -#include "../core/api-config.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -122,9 +122,6 @@ static const constexpr Init_ Init {}; //! A decorator used to not initialize. static const constexpr NoInit_ NoInit {}; -//! Invalid index, which means not in a string. Used by API that can match items in spans, vectors, etc... -static constexpr size_t kNPos = ~size_t(0); - template static ASMJIT_INLINE_NODEBUG bool is_npos(const T& index) noexcept { return index == T(~T(0)); } diff --git a/src/asmjit/core/inst.cpp b/asmjit/core/inst.cpp similarity index 93% rename from src/asmjit/core/inst.cpp rename to asmjit/core/inst.cpp index b538c51..3ed202b 100644 --- a/src/asmjit/core/inst.cpp +++ b/asmjit/core/inst.cpp @@ -3,16 +3,16 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/archtraits.h" -#include "../core/inst.h" +#include +#include +#include #if !defined(ASMJIT_NO_X86) - #include "../x86/x86instapi_p.h" + #include #endif #if !defined(ASMJIT_NO_AARCH64) - #include "../arm/a64instapi_p.h" + #include #endif ASMJIT_BEGIN_NAMESPACE @@ -57,7 +57,7 @@ InstId InstAPI::string_to_inst_id(Arch arch, const char* s, size_t len) noexcept // InstAPI - Validate // ================== -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION Error InstAPI::validate(Arch arch, const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags) noexcept { #if !defined(ASMJIT_NO_X86) if (Environment::is_family_x86(arch)) { @@ -78,7 +78,7 @@ Error InstAPI::validate(Arch arch, const BaseInst& inst, const Operand_* operand return make_error(Error::kInvalidArch); } -#endif // !ASMJIT_NO_VALIDATION +#endif // !ASMJIT_NO_INTROSPECTION // InstAPI - QueryRWInfo // ===================== diff --git a/src/asmjit/core/inst.h b/asmjit/core/inst.h similarity index 99% rename from src/asmjit/core/inst.h rename to asmjit/core/inst.h index 200fceb..3968b24 100644 --- a/src/asmjit/core/inst.h +++ b/asmjit/core/inst.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_CORE_INST_H_INCLUDED #define ASMJIT_CORE_INST_H_INCLUDED -#include "../core/cpuinfo.h" -#include "../core/operand.h" -#include "../core/string.h" -#include "../core/support.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -903,13 +903,11 @@ ASMJIT_API Error inst_id_to_string(Arch arch, InstId inst_id, InstStringifyOptio ASMJIT_API InstId string_to_inst_id(Arch arch, const char* s, size_t len) noexcept; #endif // !ASMJIT_NO_TEXT -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION //! Validates the given instruction considering the given `validation_flags`. [[nodiscard]] ASMJIT_API Error validate(Arch arch, const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags = ValidationFlags::kNone) noexcept; -#endif // !ASMJIT_NO_VALIDATION -#ifndef ASMJIT_NO_INTROSPECTION //! Gets Read/Write information of the given instruction. ASMJIT_API Error query_rw_info(Arch arch, const BaseInst& inst, const Operand_* operands, size_t op_count, InstRWInfo* out) noexcept; diff --git a/src/asmjit/core/instdb.cpp b/asmjit/core/instdb.cpp similarity index 98% rename from src/asmjit/core/instdb.cpp rename to asmjit/core/instdb.cpp index b16b65c..d085bce 100644 --- a/src/asmjit/core/instdb.cpp +++ b/asmjit/core/instdb.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/instdb_p.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/instdb_p.h b/asmjit/core/instdb_p.h similarity index 94% rename from src/asmjit/core/instdb_p.h rename to asmjit/core/instdb_p.h index 49b9af1..326758f 100644 --- a/src/asmjit/core/instdb_p.h +++ b/asmjit/core/instdb_p.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_CORE_INSTDB_P_H_INCLUDED #define ASMJIT_CORE_INSTDB_P_H_INCLUDED -#include "../core/inst.h" -#include "../core/string.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/jitallocator.cpp b/asmjit/core/jitallocator.cpp similarity index 99% rename from src/asmjit/core/jitallocator.cpp rename to asmjit/core/jitallocator.cpp index c7f8e98..ad75ffd 100644 --- a/src/asmjit/core/jitallocator.cpp +++ b/asmjit/core/jitallocator.cpp @@ -3,21 +3,21 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_JIT -#include "../core/archtraits.h" -#include "../core/arena.h" -#include "../core/arenalist.h" -#include "../core/arenapool.h" -#include "../core/arenatree.h" -#include "../core/jitallocator.h" -#include "../core/osutils_p.h" -#include "../core/support.h" -#include "../core/virtmem.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #if defined(ASMJIT_TEST) -#include "../../../testing/commons/random.h" +#include #endif // ASMJIT_TEST ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/jitallocator.h b/asmjit/core/jitallocator.h similarity index 99% rename from src/asmjit/core/jitallocator.h rename to asmjit/core/jitallocator.h index d68f0af..d1eb8f6 100644 --- a/src/asmjit/core/jitallocator.h +++ b/asmjit/core/jitallocator.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_CORE_JITALLOCATOR_H_INCLUDED #define ASMJIT_CORE_JITALLOCATOR_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_JIT -#include "../core/globals.h" -#include "../core/support.h" -#include "../core/virtmem.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/jitruntime.cpp b/asmjit/core/jitruntime.cpp similarity index 95% rename from src/asmjit/core/jitruntime.cpp rename to asmjit/core/jitruntime.cpp index b4ef077..66b3579 100644 --- a/src/asmjit/core/jitruntime.cpp +++ b/asmjit/core/jitruntime.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_JIT -#include "../core/cpuinfo.h" -#include "../core/jitruntime.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/jitruntime.h b/asmjit/core/jitruntime.h similarity index 95% rename from src/asmjit/core/jitruntime.h rename to asmjit/core/jitruntime.h index b21d940..cf401db 100644 --- a/src/asmjit/core/jitruntime.h +++ b/asmjit/core/jitruntime.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_CORE_JITRUNTIME_H_INCLUDED #define ASMJIT_CORE_JITRUNTIME_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_JIT -#include "../core/codeholder.h" -#include "../core/jitallocator.h" -#include "../core/target.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/logger.cpp b/asmjit/core/logger.cpp similarity index 91% rename from src/asmjit/core/logger.cpp rename to asmjit/core/logger.cpp index 705d951..df0b435 100644 --- a/src/asmjit/core/logger.cpp +++ b/asmjit/core/logger.cpp @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_LOGGING -#include "../core/logger.h" -#include "../core/string.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/logger.h b/asmjit/core/logger.h similarity index 98% rename from src/asmjit/core/logger.h rename to asmjit/core/logger.h index e2ef4a5..0f0e733 100644 --- a/src/asmjit/core/logger.h +++ b/asmjit/core/logger.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_LOGGING_H_INCLUDED #define ASMJIT_CORE_LOGGING_H_INCLUDED -#include "../core/inst.h" -#include "../core/string.h" -#include "../core/formatter.h" +#include +#include +#include #ifndef ASMJIT_NO_LOGGING diff --git a/src/asmjit/core/misc_p.h b/asmjit/core/misc_p.h similarity index 97% rename from src/asmjit/core/misc_p.h rename to asmjit/core/misc_p.h index 284b9eb..3c27e35 100644 --- a/src/asmjit/core/misc_p.h +++ b/asmjit/core/misc_p.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_CORE_MISC_P_H_INCLUDED #define ASMJIT_CORE_MISC_P_H_INCLUDED -#include "../core/api-config.h" +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/operand.cpp b/asmjit/core/operand.cpp similarity index 98% rename from src/asmjit/core/operand.cpp rename to asmjit/core/operand.cpp index a3d0eae..3773f37 100644 --- a/src/asmjit/core/operand.cpp +++ b/asmjit/core/operand.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/operand.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/operand.h b/asmjit/core/operand.h similarity index 99% rename from src/asmjit/core/operand.h rename to asmjit/core/operand.h index 43d2337..f7e5e2a 100644 --- a/src/asmjit/core/operand.h +++ b/asmjit/core/operand.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_OPERAND_H_INCLUDED #define ASMJIT_CORE_OPERAND_H_INCLUDED -#include "../core/archcommons.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/osutils.cpp b/asmjit/core/osutils.cpp similarity index 88% rename from src/asmjit/core/osutils.cpp rename to asmjit/core/osutils.cpp index 74d2675..68b5891 100644 --- a/src/asmjit/core/osutils.cpp +++ b/asmjit/core/osutils.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/osutils_p.h" -#include "../core/support.h" +#include +#include +#include #if !defined(_WIN32) #include diff --git a/src/asmjit/core/osutils.h b/asmjit/core/osutils.h similarity index 97% rename from src/asmjit/core/osutils.h rename to asmjit/core/osutils.h index 8e4fdeb..304e6c2 100644 --- a/src/asmjit/core/osutils.h +++ b/asmjit/core/osutils.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_CORE_OSUTILS_H_INCLUDED #define ASMJIT_CORE_OSUTILS_H_INCLUDED -#include "../core/globals.h" +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/osutils_p.h b/asmjit/core/osutils_p.h similarity index 97% rename from src/asmjit/core/osutils_p.h rename to asmjit/core/osutils_p.h index a752a95..3501b7a 100644 --- a/src/asmjit/core/osutils_p.h +++ b/asmjit/core/osutils_p.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_CORE_OSUTILS_P_H_INCLUDED #define ASMJIT_CORE_OSUTILS_P_H_INCLUDED -#include "../core/osutils.h" -#include "../core/string.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/raassignment_p.h b/asmjit/core/raassignment_p.h similarity index 97% rename from src/asmjit/core/raassignment_p.h rename to asmjit/core/raassignment_p.h index 125d11e..04e330d 100644 --- a/src/asmjit/core/raassignment_p.h +++ b/asmjit/core/raassignment_p.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_RAASSIGNMENT_P_H_INCLUDED #define ASMJIT_CORE_RAASSIGNMENT_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/radefs_p.h" -#include "../core/rareg_p.h" +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -142,8 +142,7 @@ public: _layout.phys_index.build_indexes(phys_count); _layout.phys_count = phys_count; - _layout.phys_total = uint32_t(_layout.phys_index[RegGroup::kMaxVirt]) + - uint32_t(_layout.phys_count[RegGroup::kMaxVirt]) ; + _layout.phys_total = _layout.phys_index.get(RegGroup::kMaxVirt) + _layout.phys_count.get(RegGroup::kMaxVirt); _layout.work_count = uint32_t(work_regs.size()); _layout.work_regs = &work_regs; } @@ -337,7 +336,7 @@ public: memset(_work_to_phys_map, uint8_t(Reg::kIdBad), WorkToPhysMap::size_of(_layout.work_count)); for (RegGroup group : Support::enumerate(RegGroup::kMaxVirt)) { - uint32_t phys_base_index = _layout.phys_index[group]; + uint32_t phys_base_index = _layout.phys_index.get(group); Support::BitWordIterator it(_phys_to_work_map->assigned[group]); while (it.has_next()) { @@ -421,7 +420,7 @@ public: // Verify PhysToWorkMap. { for (RegGroup group : Support::enumerate(RegGroup::kMaxVirt)) { - uint32_t phys_count = _layout.phys_count[group]; + uint32_t phys_count = _layout.phys_count.get(group); for (uint32_t phys_id = 0; phys_id < phys_count; phys_id++) { RAWorkId work_id = _phys_to_work_ids[group][phys_id]; if (work_id != kBadWorkId) { diff --git a/src/asmjit/core/racfgblock_p.h b/asmjit/core/racfgblock_p.h similarity index 98% rename from src/asmjit/core/racfgblock_p.h rename to asmjit/core/racfgblock_p.h index 3a0ecfe..a66ace2 100644 --- a/src/asmjit/core/racfgblock_p.h +++ b/asmjit/core/racfgblock_p.h @@ -6,14 +6,14 @@ #ifndef ASMJIT_CORE_RACFGBLOCK_P_H_INCLUDED #define ASMJIT_CORE_RACFGBLOCK_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/arenabitset_p.h" -#include "../core/arenavector.h" -#include "../core/compilerdefs.h" -#include "../core/raassignment_p.h" -#include "../core/support_p.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/racfgbuilder_p.h b/asmjit/core/racfgbuilder_p.h similarity index 99% rename from src/asmjit/core/racfgbuilder_p.h rename to asmjit/core/racfgbuilder_p.h index 54c5738..ab6524c 100644 --- a/src/asmjit/core/racfgbuilder_p.h +++ b/asmjit/core/racfgbuilder_p.h @@ -6,13 +6,13 @@ #ifndef ASMJIT_CORE_RACFGBUILDER_P_H_INCLUDED #define ASMJIT_CORE_RACFGBUILDER_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/formatter.h" -#include "../core/racfgblock_p.h" -#include "../core/rainst_p.h" -#include "../core/rapass_p.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/raconstraints_p.h b/asmjit/core/raconstraints_p.h similarity index 92% rename from src/asmjit/core/raconstraints_p.h rename to asmjit/core/raconstraints_p.h index 3959646..67fd878 100644 --- a/src/asmjit/core/raconstraints_p.h +++ b/asmjit/core/raconstraints_p.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_CORE_RACONSTRAINTS_P_H_INCLUDED #define ASMJIT_CORE_RACONSTRAINTS_P_H_INCLUDED -#include "../core/api-config.h" -#include "../core/archtraits.h" -#include "../core/operand.h" -#include "../core/support.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/radefs_p.h b/asmjit/core/radefs_p.h similarity index 94% rename from src/asmjit/core/radefs_p.h rename to asmjit/core/radefs_p.h index 67a14ac..bcf232b 100644 --- a/src/asmjit/core/radefs_p.h +++ b/asmjit/core/radefs_p.h @@ -6,19 +6,19 @@ #ifndef ASMJIT_CORE_RADEFS_P_H_INCLUDED #define ASMJIT_CORE_RADEFS_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/archtraits.h" -#include "../core/arena.h" -#include "../core/arenabitset_p.h" -#include "../core/arenavector.h" -#include "../core/builder.h" -#include "../core/compilerdefs.h" -#include "../core/logger.h" -#include "../core/operand.h" -#include "../core/support.h" -#include "../core/type.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -133,10 +133,7 @@ struct RARegCount { //! \name Members //! \{ - union { - uint8_t _regs[4]; - uint32_t _packed; - }; + uint32_t _counters; //! \} @@ -144,7 +141,7 @@ struct RARegCount { //! \{ //! Resets all counters to zero. - ASMJIT_INLINE_NODEBUG void reset() noexcept { _packed = 0; } + ASMJIT_INLINE_NODEBUG void reset() noexcept { _counters = 0; } //! \} @@ -152,22 +149,10 @@ struct RARegCount { //! \{ [[nodiscard]] - inline uint8_t& operator[](RegGroup group) noexcept { - ASMJIT_ASSERT(group <= RegGroup::kMaxVirt); - return _regs[size_t(group)]; - } + ASMJIT_INLINE_NODEBUG bool operator==(const RARegCount& other) const noexcept { return _counters == other._counters; } [[nodiscard]] - inline const uint8_t& operator[](RegGroup group) const noexcept { - ASMJIT_ASSERT(group <= RegGroup::kMaxVirt); - return _regs[size_t(group)]; - } - - [[nodiscard]] - ASMJIT_INLINE_NODEBUG bool operator==(const RARegCount& other) const noexcept { return _packed == other._packed; } - - [[nodiscard]] - ASMJIT_INLINE_NODEBUG bool operator!=(const RARegCount& other) const noexcept { return _packed != other._packed; } + ASMJIT_INLINE_NODEBUG bool operator!=(const RARegCount& other) const noexcept { return _counters != other._counters; } //! \} @@ -176,29 +161,29 @@ struct RARegCount { //! Returns the count of registers by the given register `group`. [[nodiscard]] - inline uint32_t get(RegGroup group) const noexcept { + ASMJIT_INLINE uint32_t get(RegGroup group) const noexcept { ASMJIT_ASSERT(group <= RegGroup::kMaxVirt); - uint32_t shift = Support::byte_shift_in_struct(uint32_t(group)); - return (_packed >> shift) & uint32_t(0xFF); + uint32_t shift = uint32_t(group) * 8u; + return (_counters >> shift) & 0xFFu; } //! Sets the register count by a register `group`. - inline void set(RegGroup group, uint32_t n) noexcept { + ASMJIT_INLINE void set(RegGroup group, uint32_t n) noexcept { ASMJIT_ASSERT(group <= RegGroup::kMaxVirt); - ASMJIT_ASSERT(n <= 0xFF); + ASMJIT_ASSERT(n <= 0xFFu); - uint32_t shift = Support::byte_shift_in_struct(uint32_t(group)); - _packed = (_packed & ~uint32_t(0xFF << shift)) + (n << shift); + uint32_t shift = uint32_t(group) * 8u; + _counters = (_counters & ~uint32_t(0xFFu << shift)) + (n << shift); } //! Adds the register count by a register `group`. - inline void add(RegGroup group, uint32_t n = 1) noexcept { + ASMJIT_INLINE void add(RegGroup group, uint32_t n = 1) noexcept { ASMJIT_ASSERT(group <= RegGroup::kMaxVirt); - ASMJIT_ASSERT(0xFF - uint32_t(_regs[size_t(group)]) >= n); + ASMJIT_ASSERT(get(group) + n <= 0xFFu); - uint32_t shift = Support::byte_shift_in_struct(uint32_t(group)); - _packed += n << shift; + uint32_t shift = uint32_t(group) * 8u; + _counters += n << shift; } //! \} @@ -208,13 +193,11 @@ struct RARegCount { struct RARegIndex : public RARegCount { //! Build register indexes based on the given `count` of registers. ASMJIT_INLINE void build_indexes(const RARegCount& count) noexcept { - uint32_t x = uint32_t(count._regs[0]); - uint32_t y = uint32_t(count._regs[1]) + x; - uint32_t z = uint32_t(count._regs[2]) + y; + ASMJIT_ASSERT(count.get(RegGroup(0)) + count.get(RegGroup(1)) <= 0xFFu); + ASMJIT_ASSERT(count.get(RegGroup(0)) + count.get(RegGroup(1)) + count.get(RegGroup(2)) <= 0xFFu); - ASMJIT_ASSERT(y <= 0xFF); - ASMJIT_ASSERT(z <= 0xFF); - _packed = Support::bytepack32_4x8(0, x, y, z); + uint32_t i = count._counters; + _counters = (i + (i << 8u) + (i << 16)) << 8u; } }; diff --git a/src/asmjit/core/rainst_p.h b/asmjit/core/rainst_p.h similarity index 98% rename from src/asmjit/core/rainst_p.h rename to asmjit/core/rainst_p.h index 8ea1cd9..b6f08fd 100644 --- a/src/asmjit/core/rainst_p.h +++ b/asmjit/core/rainst_p.h @@ -6,14 +6,14 @@ #ifndef ASMJIT_CORE_RAINST_P_H_INCLUDED #define ASMJIT_CORE_RAINST_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/arena.h" -#include "../core/compilerdefs.h" -#include "../core/radefs_p.h" -#include "../core/rareg_p.h" -#include "../core/support_p.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -123,7 +123,7 @@ public: //! Returns count of tied registers of a given `group`. [[nodiscard]] - ASMJIT_INLINE_NODEBUG uint32_t tied_count(RegGroup group) const noexcept { return _tied_count[group]; } + ASMJIT_INLINE_NODEBUG uint32_t tied_count(RegGroup group) const noexcept { return _tied_count.get(group); } //! Returns `RATiedReg` at the given `index`. [[nodiscard]] diff --git a/src/asmjit/core/ralocal.cpp b/asmjit/core/ralocal.cpp similarity index 99% rename from src/asmjit/core/ralocal.cpp rename to asmjit/core/ralocal.cpp index 7c395c4..180aa55 100644 --- a/src/asmjit/core/ralocal.cpp +++ b/asmjit/core/ralocal.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/ralocal_p.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/ralocal_p.h b/asmjit/core/ralocal_p.h similarity index 97% rename from src/asmjit/core/ralocal_p.h rename to asmjit/core/ralocal_p.h index c9405db..3a8da4d 100644 --- a/src/asmjit/core/ralocal_p.h +++ b/asmjit/core/ralocal_p.h @@ -6,14 +6,14 @@ #ifndef ASMJIT_CORE_RALOCAL_P_H_INCLUDED #define ASMJIT_CORE_RALOCAL_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/raassignment_p.h" -#include "../core/radefs_p.h" -#include "../core/rainst_p.h" -#include "../core/rapass_p.h" -#include "../core/support.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -122,7 +122,7 @@ public: ASMJIT_INLINE_NODEBUG uint32_t tied_count(RegGroup group) const noexcept { return _tied_count.get(group); } [[nodiscard]] - ASMJIT_INLINE_NODEBUG bool is_group_used(RegGroup group) const noexcept { return _tied_count[group] != 0; } + ASMJIT_INLINE_NODEBUG bool is_group_used(RegGroup group) const noexcept { return _tied_count.get(group) != 0; } //! \} diff --git a/src/asmjit/core/rapass.cpp b/asmjit/core/rapass.cpp similarity index 99% rename from src/asmjit/core/rapass.cpp rename to asmjit/core/rapass.cpp index d7cec90..fda14d8 100644 --- a/src/asmjit/core/rapass.cpp +++ b/asmjit/core/rapass.cpp @@ -3,15 +3,15 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/arenavector.h" -#include "../core/formatter_p.h" -#include "../core/ralocal_p.h" -#include "../core/rapass_p.h" -#include "../core/support_p.h" -#include "../core/type.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -1408,7 +1408,7 @@ Error BaseRAPass::run_global_allocator() noexcept { ASMJIT_FAVOR_SPEED Error BaseRAPass::init_global_live_spans() noexcept { for (RegGroup group : Support::enumerate(RegGroup::kMaxVirt)) { - size_t phys_count = _phys_reg_count[group]; + size_t phys_count = _phys_reg_count.get(group); RALiveSpans* live_spans = nullptr; if (phys_count) { @@ -1448,7 +1448,7 @@ ASMJIT_FAVOR_SPEED Error BaseRAPass::bin_pack(RegGroup group) noexcept { uint32_t(group)); #endif - uint32_t phys_count = _phys_reg_count[group]; + uint32_t phys_count = _phys_reg_count.get(group); ArenaVector work_regs; ArenaVector consecutive_regs; @@ -1957,7 +1957,7 @@ Error BaseRAPass::block_entry_assigned(const PhysToWorkMap* phys_to_work_map) no continue; } - uint32_t phys_base_index = _phys_reg_index[group]; + uint32_t phys_base_index = _phys_reg_index.get(group); Support::BitWordIterator it(phys_to_work_map->assigned[group]); while (it.has_next()) { diff --git a/src/asmjit/core/rapass_p.h b/asmjit/core/rapass_p.h similarity index 97% rename from src/asmjit/core/rapass_p.h rename to asmjit/core/rapass_p.h index 5d28275..3e9e65c 100644 --- a/src/asmjit/core/rapass_p.h +++ b/asmjit/core/rapass_p.h @@ -6,17 +6,17 @@ #ifndef ASMJIT_CORE_RAPASS_P_H_INCLUDED #define ASMJIT_CORE_RAPASS_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/compiler.h" -#include "../core/emithelper_p.h" -#include "../core/raassignment_p.h" -#include "../core/racfgblock_p.h" -#include "../core/radefs_p.h" -#include "../core/rainst_p.h" -#include "../core/rastack_p.h" -#include "../core/support_p.h" +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -350,13 +350,16 @@ public: block->add_flags(RABlockFlags::kHasFixedRegs); } - RATiedReg& dst = ra_inst->_tied_regs[index[group]++]; + RATiedReg& dst = ra_inst->_tied_regs[index.get(group)]; + index.add(group); + dst = *tied_reg; dst._flags &= flags_filter; if (!tied_reg->is_duplicate()) { dst._use_reg_mask &= ~ib._used[group]; } + } node->set_pass_data(ra_inst); @@ -486,12 +489,11 @@ public: inline void _build_phys_index() noexcept { _phys_reg_index.build_indexes(_phys_reg_count); - _phys_reg_total = uint32_t(_phys_reg_index[RegGroup::kMaxVirt]) + - uint32_t(_phys_reg_count[RegGroup::kMaxVirt]) ; + _phys_reg_total = _phys_reg_index.get(RegGroup::kMaxVirt) + _phys_reg_count.get(RegGroup::kMaxVirt); } [[nodiscard]] - ASMJIT_INLINE_NODEBUG uint32_t phys_reg_index(RegGroup group) const noexcept { return _phys_reg_index[group]; } + ASMJIT_INLINE_NODEBUG uint32_t phys_reg_index(RegGroup group) const noexcept { return _phys_reg_index.get(group); } [[nodiscard]] ASMJIT_INLINE_NODEBUG uint32_t phys_reg_total() const noexcept { return _phys_reg_total; } diff --git a/src/asmjit/core/rareg_p.h b/asmjit/core/rareg_p.h similarity index 99% rename from src/asmjit/core/rareg_p.h rename to asmjit/core/rareg_p.h index 0f72edc..1ca95ae 100644 --- a/src/asmjit/core/rareg_p.h +++ b/asmjit/core/rareg_p.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_RAREG_P_H_INCLUDED #define ASMJIT_CORE_RAREG_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/arenavector.h" -#include "../core/radefs_p.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/rastack.cpp b/asmjit/core/rastack.cpp similarity index 98% rename from src/asmjit/core/rastack.cpp rename to asmjit/core/rastack.cpp index 85a49f9..da24e70 100644 --- a/src/asmjit/core/rastack.cpp +++ b/asmjit/core/rastack.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/rastack_p.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/rastack_p.h b/asmjit/core/rastack_p.h similarity index 98% rename from src/asmjit/core/rastack_p.h rename to asmjit/core/rastack_p.h index 8619a8d..0e69588 100644 --- a/src/asmjit/core/rastack_p.h +++ b/asmjit/core/rastack_p.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_CORE_RASTACK_P_H_INCLUDED #define ASMJIT_CORE_RASTACK_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/radefs_p.h" +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/string.cpp b/asmjit/core/string.cpp similarity index 99% rename from src/asmjit/core/string.cpp rename to asmjit/core/string.cpp index d6c47b9..f5eaaf4 100644 --- a/src/asmjit/core/string.cpp +++ b/asmjit/core/string.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/string.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/string.h b/asmjit/core/string.h similarity index 99% rename from src/asmjit/core/string.h rename to asmjit/core/string.h index a6ab533..135869a 100644 --- a/src/asmjit/core/string.h +++ b/asmjit/core/string.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_CORE_STRING_H_INCLUDED #define ASMJIT_CORE_STRING_H_INCLUDED -#include "../core/span.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/target.cpp b/asmjit/core/target.cpp similarity index 82% rename from src/asmjit/core/target.cpp rename to asmjit/core/target.cpp index 59c6fc7..d54401c 100644 --- a/src/asmjit/core/target.cpp +++ b/asmjit/core/target.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/target.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/target.h b/asmjit/core/target.h similarity index 94% rename from src/asmjit/core/target.h rename to asmjit/core/target.h index 36cbef1..bb5cbe2 100644 --- a/src/asmjit/core/target.h +++ b/asmjit/core/target.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_CORE_TARGET_H_INCLUDED #define ASMJIT_CORE_TARGET_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/cpuinfo.h" -#include "../core/func.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/type.cpp b/asmjit/core/type.cpp similarity index 96% rename from src/asmjit/core/type.cpp rename to asmjit/core/type.cpp index 4db15a7..6a0b8a4 100644 --- a/src/asmjit/core/type.cpp +++ b/asmjit/core/type.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/misc_p.h" -#include "../core/type.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/type.h b/asmjit/core/type.h similarity index 99% rename from src/asmjit/core/type.h rename to asmjit/core/type.h index 9224e29..518d9f6 100644 --- a/src/asmjit/core/type.h +++ b/asmjit/core/type.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_CORE_TYPE_H_INCLUDED #define ASMJIT_CORE_TYPE_H_INCLUDED -#include "../core/globals.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/virtmem.cpp b/asmjit/core/virtmem.cpp similarity index 99% rename from src/asmjit/core/virtmem.cpp rename to asmjit/core/virtmem.cpp index 3d6ef5b..37c7824 100644 --- a/src/asmjit/core/virtmem.cpp +++ b/asmjit/core/virtmem.cpp @@ -3,13 +3,13 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #ifndef ASMJIT_NO_JIT -#include "../core/osutils_p.h" -#include "../core/string.h" -#include "../core/support.h" -#include "../core/virtmem.h" +#include +#include +#include +#include #if !defined(_WIN32) #include diff --git a/src/asmjit/core/virtmem.h b/asmjit/core/virtmem.h similarity index 99% rename from src/asmjit/core/virtmem.h rename to asmjit/core/virtmem.h index 846448a..c872bf8 100644 --- a/src/asmjit/core/virtmem.h +++ b/asmjit/core/virtmem.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_CORE_VIRTMEM_H_INCLUDED #define ASMJIT_CORE_VIRTMEM_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_JIT -#include "../core/globals.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/host.h b/asmjit/host.h similarity index 89% rename from src/asmjit/host.h rename to asmjit/host.h index 87fd71a..3601979 100644 --- a/src/asmjit/host.h +++ b/asmjit/host.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_HOST_H_INCLUDED #define ASMJIT_HOST_H_INCLUDED -#include "core.h" +#include // Detect 'X86' or 'X86_64' host architectures. #if ASMJIT_ARCH_X86 != 0 && !defined(ASMJIT_NO_X86) -#include "x86.h" +#include ASMJIT_BEGIN_NAMESPACE namespace host { using namespace x86; } @@ -22,7 +22,7 @@ ASMJIT_END_NAMESPACE // Detect 'AArch64' host architecture. #if ASMJIT_ARCH_ARM == 64 && !defined(ASMJIT_NO_AARCH64) -#include "a64.h" +#include ASMJIT_BEGIN_NAMESPACE namespace host { using namespace a64; } diff --git a/src/asmjit/core/arena.cpp b/asmjit/support/arena.cpp similarity index 99% rename from src/asmjit/core/arena.cpp rename to asmjit/support/arena.cpp index 12810d7..c9329cc 100644 --- a/src/asmjit/core/arena.cpp +++ b/asmjit/support/arena.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/support.h" -#include "../core/arena.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/arena.h b/asmjit/support/arena.h similarity index 99% rename from src/asmjit/core/arena.h rename to asmjit/support/arena.h index 08e1ce7..ec4a63a 100644 --- a/src/asmjit/core/arena.h +++ b/asmjit/support/arena.h @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENA_H_INCLUDED -#define ASMJIT_CORE_ARENA_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENA_H_INCLUDED +#define ASMJIT_SUPPORT_ARENA_H_INCLUDED -#include "../core/support.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -495,4 +495,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENA_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENA_H_INCLUDED diff --git a/src/asmjit/core/arenabitset.cpp b/asmjit/support/arenabitset.cpp similarity index 98% rename from src/asmjit/core/arenabitset.cpp rename to asmjit/support/arenabitset.cpp index 8aaa230..5bc11c8 100644 --- a/src/asmjit/core/arenabitset.cpp +++ b/asmjit/support/arenabitset.cpp @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/support.h" -#include "../core/arena.h" -#include "../core/arenabitset_p.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/arenabitset_p.h b/asmjit/support/arenabitset_p.h similarity index 98% rename from src/asmjit/core/arenabitset_p.h rename to asmjit/support/arenabitset_p.h index 1061194..9b3dcd7 100644 --- a/src/asmjit/core/arenabitset_p.h +++ b/asmjit/support/arenabitset_p.h @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENABITSET_P_H_INCLUDED -#define ASMJIT_CORE_ARENABITSET_P_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENABITSET_P_H_INCLUDED +#define ASMJIT_SUPPORT_ARENABITSET_P_H_INCLUDED -#include "../core/arena.h" -#include "../core/span.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -433,4 +433,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENABITSET_P_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENABITSET_P_H_INCLUDED diff --git a/src/asmjit/core/arenahash.cpp b/asmjit/support/arenahash.cpp similarity index 99% rename from src/asmjit/core/arenahash.cpp rename to asmjit/support/arenahash.cpp index be32149..e9c3736 100644 --- a/src/asmjit/core/arenahash.cpp +++ b/asmjit/support/arenahash.cpp @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/support.h" -#include "../core/arena.h" -#include "../core/arenahash.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/arenahash.h b/asmjit/support/arenahash.h similarity index 96% rename from src/asmjit/core/arenahash.h rename to asmjit/support/arenahash.h index 436123a..c6481ab 100644 --- a/src/asmjit/core/arenahash.h +++ b/asmjit/support/arenahash.h @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENAHASH_H_INCLUDED -#define ASMJIT_CORE_ARENAHASH_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENAHASH_H_INCLUDED +#define ASMJIT_SUPPORT_ARENAHASH_H_INCLUDED -#include "../core/arena.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -195,4 +195,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENAHASH_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENAHASH_H_INCLUDED diff --git a/src/asmjit/core/arenalist.cpp b/asmjit/support/arenalist.cpp similarity index 97% rename from src/asmjit/core/arenalist.cpp rename to asmjit/support/arenalist.cpp index 97cd892..2fbed36 100644 --- a/src/asmjit/core/arenalist.cpp +++ b/asmjit/support/arenalist.cpp @@ -3,9 +3,9 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/arena.h" -#include "../core/arenalist.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/arenalist.h b/asmjit/support/arenalist.h similarity index 96% rename from src/asmjit/core/arenalist.h rename to asmjit/support/arenalist.h index efe1946..84d6107 100644 --- a/src/asmjit/core/arenalist.h +++ b/asmjit/support/arenalist.h @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENALIST_H_INCLUDED -#define ASMJIT_CORE_ARENALIST_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENALIST_H_INCLUDED +#define ASMJIT_SUPPORT_ARENALIST_H_INCLUDED -#include "../core/support.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -218,4 +218,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENALIST_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENALIST_H_INCLUDED diff --git a/src/asmjit/core/arenapool.h b/asmjit/support/arenapool.h similarity index 89% rename from src/asmjit/core/arenapool.h rename to asmjit/support/arenapool.h index cb179c3..398d3f0 100644 --- a/src/asmjit/core/arenapool.h +++ b/asmjit/support/arenapool.h @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENAPOOL_H_INCLUDED -#define ASMJIT_CORE_ARENAPOOL_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENAPOOL_H_INCLUDED +#define ASMJIT_SUPPORT_ARENAPOOL_H_INCLUDED -#include "../core/support.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -63,4 +63,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENAPOOL_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENAPOOL_H_INCLUDED diff --git a/src/asmjit/core/arenastring.h b/asmjit/support/arenastring.h similarity index 93% rename from src/asmjit/core/arenastring.h rename to asmjit/support/arenastring.h index bc90d6d..d424eb8 100644 --- a/src/asmjit/core/arenastring.h +++ b/asmjit/support/arenastring.h @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENASTRING_H_INCLUDED -#define ASMJIT_CORE_ARENASTRING_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENASTRING_H_INCLUDED +#define ASMJIT_SUPPORT_ARENASTRING_H_INCLUDED -#include "../core/globals.h" -#include "../core/arena.h" +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -120,4 +120,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENASTRING_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENASTRING_H_INCLUDED diff --git a/src/asmjit/core/arenatree.cpp b/asmjit/support/arenatree.cpp similarity index 94% rename from src/asmjit/core/arenatree.cpp rename to asmjit/support/arenatree.cpp index b37d182..90f24ff 100644 --- a/src/asmjit/core/arenatree.cpp +++ b/asmjit/support/arenatree.cpp @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/arena.h" -#include "../core/arenatree.h" -#include "../core/support.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE diff --git a/src/asmjit/core/arenatree.h b/asmjit/support/arenatree.h similarity index 98% rename from src/asmjit/core/arenatree.h rename to asmjit/support/arenatree.h index a9a4d1f..6cd5dba 100644 --- a/src/asmjit/core/arenatree.h +++ b/asmjit/support/arenatree.h @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENATREE_H_INCLUDED -#define ASMJIT_CORE_ARENATREE_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENATREE_H_INCLUDED +#define ASMJIT_SUPPORT_ARENATREE_H_INCLUDED -#include "../core/support.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -404,4 +404,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENATREE_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENATREE_H_INCLUDED diff --git a/src/asmjit/core/arenavector.cpp b/asmjit/support/arenavector.cpp similarity index 67% rename from src/asmjit/core/arenavector.cpp rename to asmjit/support/arenavector.cpp index 4eb1a19..70d0222 100644 --- a/src/asmjit/core/arenavector.cpp +++ b/asmjit/support/arenavector.cpp @@ -3,13 +3,36 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/support.h" -#include "../core/arena.h" -#include "../core/arenavector.h" +#include +#include +#include +#include ASMJIT_BEGIN_NAMESPACE +// ArenaVector - Item Size Helpers +// =============================== + +template +static ASMJIT_INLINE_NODEBUG ResultType byte_size_from_item_count(size_t item_count, ArenaVectorBase::ItemSize item_size) noexcept { + if constexpr (IsPowerOf2) { + return ResultType(item_count) << item_size.n; + } + else { + return ResultType(item_count) * item_size.n; + } +} + +template +static ASMJIT_INLINE_NODEBUG size_t item_count_from_byte_size(size_t byte_size, ArenaVectorBase::ItemSize item_size) noexcept { + if constexpr (IsPowerOf2) { + return byte_size >> item_size.n; + } + else { + return byte_size / item_size.n; + } +} + // ArenaVector - Memory Management // =============================== @@ -49,8 +72,8 @@ static ASMJIT_INLINE size_t ArenaVector_expand_byte_size(size_t byte_size) noexc } } -template -static ASMJIT_NOINLINE Error ArenaVector_reserve_with_byte_size(ArenaVectorBase& self, Arena& arena, size_t byte_size, ItemSize item_size) noexcept { +template +static ASMJIT_NOINLINE Error ArenaVector_reserve_with_byte_size(ArenaVectorBase& self, Arena& arena, size_t byte_size, ArenaVectorBase::ItemSize item_size) noexcept { size_t allocated_size; uint8_t* new_data = static_cast(arena.alloc_reusable(byte_size, Out(allocated_size))); @@ -58,14 +81,14 @@ static ASMJIT_NOINLINE Error ArenaVector_reserve_with_byte_size(ArenaVectorBase& return make_error(Error::kOutOfMemory); } - size_t allocated_capacity = Support::item_count_from_byte_size(allocated_size, item_size); + size_t allocated_capacity = item_count_from_byte_size(allocated_size, item_size); void* old_data = self._data; uint32_t size = self._size; if (old_data) { - memcpy(new_data, old_data, Support::byte_size_from_item_count(size, item_size)); - arena.free_reusable(old_data, Support::byte_size_from_item_count(self._capacity, item_size)); + memcpy(new_data, old_data, byte_size_from_item_count(size, item_size)); + arena.free_reusable(old_data, byte_size_from_item_count(self._capacity, item_size)); } self._data = new_data; @@ -97,11 +120,11 @@ static ASMJIT_INLINE bool ArenaVector_check_byte_size(uint64_t byte_size) noexce } } -template -static ASMJIT_INLINE Error ArenaVector_reserve_fit(ArenaVectorBase& self, Arena& arena, size_t item_count, ItemSize item_size) noexcept { +template +static ASMJIT_INLINE Error ArenaVector_reserve_fit(ArenaVectorBase& self, Arena& arena, size_t item_count, ArenaVectorBase::ItemSize item_size) noexcept { size_t capacity = self._capacity; size_t capacity_masked = capacity | Support::bool_as_mask(!ArenaVector_is_valid_size(item_count)); - uint64_t byte_size = Support::byte_size_from_item_count(item_count, item_size); + uint64_t byte_size = byte_size_from_item_count(item_count, item_size); if (ASMJIT_UNLIKELY(Support::bool_or(capacity_masked >= item_count, !ArenaVector_check_byte_size(byte_size)))) { return capacity >= item_count ? Error::kOk : make_error(Error::kOutOfMemory); @@ -110,11 +133,11 @@ static ASMJIT_INLINE Error ArenaVector_reserve_fit(ArenaVectorBase& self, Arena& return ArenaVector_reserve_with_byte_size(self, arena, size_t(byte_size), item_size); } -template -static ASMJIT_INLINE Error ArenaVector_reserve_grow(ArenaVectorBase& self, Arena& arena, size_t item_count, ItemSize item_size) noexcept { +template +static ASMJIT_INLINE Error ArenaVector_reserve_grow(ArenaVectorBase& self, Arena& arena, size_t item_count, ArenaVectorBase::ItemSize item_size) noexcept { size_t capacity = self._capacity; size_t capacity_masked = capacity | Support::bool_as_mask(!ArenaVector_is_valid_size(item_count)); - uint64_t byte_size = Support::byte_size_from_item_count(item_count, item_size); + uint64_t byte_size = byte_size_from_item_count(item_count, item_size); if (ASMJIT_UNLIKELY(Support::bool_or(capacity_masked >= item_count, !ArenaVector_check_byte_size(byte_size)))) { return capacity >= item_count ? Error::kOk : make_error(Error::kOutOfMemory); @@ -124,8 +147,8 @@ static ASMJIT_INLINE Error ArenaVector_reserve_grow(ArenaVectorBase& self, Arena return ArenaVector_reserve_with_byte_size(self, arena, expanded_byte_size, item_size); } -template -static ASMJIT_INLINE Error ArenaVector_grow(ArenaVectorBase& self, Arena& arena, size_t n, ItemSize item_size) noexcept { +template +static ASMJIT_INLINE Error ArenaVector_grow(ArenaVectorBase& self, Arena& arena, size_t n, ArenaVectorBase::ItemSize item_size) noexcept { Support::FastUInt8 of {}; size_t after = Support::add_overflow(self._size, n, &of); @@ -136,8 +159,8 @@ static ASMJIT_INLINE Error ArenaVector_grow(ArenaVectorBase& self, Arena& arena, return ArenaVector_reserve_grow(self, arena, after, item_size); } -template -static ASMJIT_INLINE Error ArenaVector_resize_fit(ArenaVectorBase& self, Arena& arena, size_t n, ItemSize item_size) noexcept { +template +static ASMJIT_INLINE Error ArenaVector_resize_fit(ArenaVectorBase& self, Arena& arena, size_t n, ArenaVectorBase::ItemSize item_size) noexcept { size_t size = self._size; size_t capacity = self._capacity; @@ -146,15 +169,15 @@ static ASMJIT_INLINE Error ArenaVector_resize_fit(ArenaVectorBase& self, Arena& } if (size < n) { - memset(static_cast(self._data) + Support::byte_size_from_item_count(size, item_size), 0, Support::byte_size_from_item_count(n - size, item_size)); + memset(static_cast(self._data) + byte_size_from_item_count(size, item_size), 0, byte_size_from_item_count(n - size, item_size)); } self._size = uint32_t(n); return Error::kOk; } -template -static ASMJIT_INLINE Error ArenaVector_resize_grow(ArenaVectorBase& self, Arena& arena, size_t n, ItemSize item_size) noexcept { +template +static ASMJIT_INLINE Error ArenaVector_resize_grow(ArenaVectorBase& self, Arena& arena, size_t n, ArenaVectorBase::ItemSize item_size) noexcept { size_t size = self._size; size_t capacity = self._capacity; @@ -163,7 +186,7 @@ static ASMJIT_INLINE Error ArenaVector_resize_grow(ArenaVectorBase& self, Arena& } if (size < n) { - memset(static_cast(self._data) + Support::byte_size_from_item_count(size, item_size), 0, Support::byte_size_from_item_count(n - size, item_size)); + memset(static_cast(self._data) + byte_size_from_item_count(size, item_size), 0, byte_size_from_item_count(n - size, item_size)); } self._size = uint32_t(n); @@ -171,44 +194,44 @@ static ASMJIT_INLINE Error ArenaVector_resize_grow(ArenaVectorBase& self, Arena& } // Public API wrappers: -Error ArenaVectorBase::_reserve_fit(Arena& arena, size_t n, Support::ByteSize item_size) noexcept { - return ArenaVector_reserve_fit(*this, arena, n, item_size); +Error ArenaVectorBase::_reserve_fit(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_reserve_fit(*this, arena, n, item_size); } -Error ArenaVectorBase::_reserve_fit(Arena& arena, size_t n, Support::Log2Size item_size) noexcept { - return ArenaVector_reserve_fit(*this, arena, n, item_size); +Error ArenaVectorBase::_reserve_fit(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_reserve_fit(*this, arena, n, item_size); } -Error ArenaVectorBase::_reserve_grow(Arena& arena, size_t n, Support::ByteSize item_size) noexcept { - return ArenaVector_reserve_grow(*this, arena, n, item_size); +Error ArenaVectorBase::_reserve_grow(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_reserve_grow(*this, arena, n, item_size); } -Error ArenaVectorBase::_reserve_grow(Arena& arena, size_t n, Support::Log2Size item_size) noexcept { - return ArenaVector_reserve_grow(*this, arena, n, item_size); +Error ArenaVectorBase::_reserve_grow(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_reserve_grow(*this, arena, n, item_size); } -Error ArenaVectorBase::_reserve_additional(Arena& arena, size_t n, Support::ByteSize item_size) noexcept { - return ArenaVector_grow(*this, arena, n, item_size); +Error ArenaVectorBase::_reserve_additional(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_grow(*this, arena, n, item_size); } -Error ArenaVectorBase::_reserve_additional(Arena& arena, size_t n, Support::Log2Size item_size) noexcept { - return ArenaVector_grow(*this, arena, n, item_size); +Error ArenaVectorBase::_reserve_additional(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_grow(*this, arena, n, item_size); } -Error ArenaVectorBase::_resize_fit(Arena& arena, size_t n, Support::ByteSize item_size) noexcept { - return ArenaVector_resize_fit(*this, arena, n, item_size); +Error ArenaVectorBase::_resize_fit(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_resize_fit(*this, arena, n, item_size); } -Error ArenaVectorBase::_resize_fit(Arena& arena, size_t n, Support::Log2Size item_size) noexcept { - return ArenaVector_resize_fit(*this, arena, n, item_size); +Error ArenaVectorBase::_resize_fit(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_resize_fit(*this, arena, n, item_size); } -Error ArenaVectorBase::_resize_grow(Arena& arena, size_t n, Support::ByteSize item_size) noexcept { - return ArenaVector_resize_grow(*this, arena, n, item_size); +Error ArenaVectorBase::_resize_grow(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_resize_grow(*this, arena, n, item_size); } -Error ArenaVectorBase::_resize_grow(Arena& arena, size_t n, Support::Log2Size item_size) noexcept { - return ArenaVector_resize_grow(*this, arena, n, item_size); +Error ArenaVectorBase::_resize_grow(Arena& arena, size_t n, ItemSize item_size) noexcept { + return ArenaVector_resize_grow(*this, arena, n, item_size); } // ArenaVector - Tests diff --git a/src/asmjit/core/arenavector.h b/asmjit/support/arenavector.h similarity index 87% rename from src/asmjit/core/arenavector.h rename to asmjit/support/arenavector.h index 114274d..f542698 100644 --- a/src/asmjit/core/arenavector.h +++ b/asmjit/support/arenavector.h @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_ARENAVECTOR_H_INCLUDED -#define ASMJIT_CORE_ARENAVECTOR_H_INCLUDED +#ifndef ASMJIT_SUPPORT_ARENAVECTOR_H_INCLUDED +#define ASMJIT_SUPPORT_ARENAVECTOR_H_INCLUDED -#include "../core/arena.h" -#include "../core/span.h" -#include "../core/support.h" +#include +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -20,6 +20,14 @@ class ArenaVectorBase { public: ASMJIT_NONCOPYABLE(ArenaVectorBase) + //! \name Item Size Detail + //! \{ + + template + struct ItemSize { uint32_t n; }; + + //! \} + //! \name Types (C++ compatibility) //! \{ @@ -58,7 +66,7 @@ protected: //! \name Internal //! \{ - inline void _release(Arena& arena, uint32_t item_byte_size) noexcept { + ASMJIT_INLINE void _release(Arena& arena, uint32_t item_byte_size) noexcept { if (_data != nullptr) { arena.free_reusable(_data, _capacity * item_byte_size); reset(); @@ -79,20 +87,20 @@ protected: _capacity = capacity; } - ASMJIT_API Error _reserve_fit(Arena& arena, size_t n, Support::ByteSize byte_size) noexcept; - ASMJIT_API Error _reserve_fit(Arena& arena, size_t n, Support::Log2Size log2_size) noexcept; + ASMJIT_API Error _reserve_fit(Arena& arena, size_t n, ItemSize byte_size) noexcept; + ASMJIT_API Error _reserve_fit(Arena& arena, size_t n, ItemSize log2_size) noexcept; - ASMJIT_API Error _reserve_grow(Arena& arena, size_t n, Support::ByteSize byte_size) noexcept; - ASMJIT_API Error _reserve_grow(Arena& arena, size_t n, Support::Log2Size log2_size) noexcept; + ASMJIT_API Error _reserve_grow(Arena& arena, size_t n, ItemSize byte_size) noexcept; + ASMJIT_API Error _reserve_grow(Arena& arena, size_t n, ItemSize log2_size) noexcept; - ASMJIT_API Error _reserve_additional(Arena& arena, size_t n, Support::ByteSize byte_size) noexcept; - ASMJIT_API Error _reserve_additional(Arena& arena, size_t n, Support::Log2Size log2_size) noexcept; + ASMJIT_API Error _reserve_additional(Arena& arena, size_t n, ItemSize byte_size) noexcept; + ASMJIT_API Error _reserve_additional(Arena& arena, size_t n, ItemSize log2_size) noexcept; - ASMJIT_API Error _resize_fit(Arena& arena, size_t n, Support::ByteSize byte_size) noexcept; - ASMJIT_API Error _resize_fit(Arena& arena, size_t n, Support::Log2Size log2_size) noexcept; + ASMJIT_API Error _resize_fit(Arena& arena, size_t n, ItemSize byte_size) noexcept; + ASMJIT_API Error _resize_fit(Arena& arena, size_t n, ItemSize log2_size) noexcept; - ASMJIT_API Error _resize_grow(Arena& arena, size_t n, Support::ByteSize byte_size) noexcept; - ASMJIT_API Error _resize_grow(Arena& arena, size_t n, Support::Log2Size log2_size) noexcept; + ASMJIT_API Error _resize_grow(Arena& arena, size_t n, ItemSize byte_size) noexcept; + ASMJIT_API Error _resize_grow(Arena& arena, size_t n, ItemSize log2_size) noexcept; ASMJIT_INLINE_NODEBUG void _swap(ArenaVectorBase& other) noexcept { std::swap(_data, other._data); @@ -140,7 +148,7 @@ public: } //! Sets size of the vector to `n`. Used internally by some algorithms. - inline void _set_size(size_t n) noexcept { + ASMJIT_INLINE void _set_size(size_t n) noexcept { ASMJIT_ASSERT(n <= _capacity); _size = uint32_t(n); } @@ -159,6 +167,14 @@ class ArenaVector : public ArenaVectorBase { public: ASMJIT_NONCOPYABLE(ArenaVector) + //! \name Item Size Detail + //! \{ + + static inline constexpr bool ItemSizeIsPowerOf2 = Support::is_power_of_2(sizeof(T)); + static inline constexpr ItemSize item_size_ { ItemSizeIsPowerOf2 ? uint32_t(Support::ctz_t(sizeof(T))) : uint32_t(sizeof(T)) }; + + //! \} + //! \name Types (C++ compatibility) //! \{ @@ -243,12 +259,12 @@ public: //! Returns item at the given index `i` (const). [[nodiscard]] - inline const T& at(size_t i) const noexcept { + ASMJIT_INLINE const T& at(size_t i) const noexcept { ASMJIT_ASSERT(i < _size); return data()[i]; } - inline void _set_end(T* p) noexcept { + ASMJIT_INLINE void _set_end(T* p) noexcept { ASMJIT_ASSERT(p >= data() && p <= data() + _capacity); _set_size(size_t(p - data())); } @@ -498,13 +514,13 @@ public: return as_span().contains(std::forward(value)); } - //! Returns the first index of the given `value` or `Globals::kNPos` if it wasn't found. + //! Returns the first index of the given `value` or `SIZE_MAX` if it wasn't found. template ASMJIT_INLINE size_t index_of(Value&& value) const noexcept { return as_span().index_of(std::forward(value)); } - //! Returns the last index of the given `value` or `Globals::kNPos` if it wasn't found. + //! Returns the last index of the given `value` or `SIZE_MAX` if it wasn't found. template ASMJIT_INLINE size_t last_index_of(Value&& value) const noexcept { return as_span().index_of(std::forward(value)); @@ -517,23 +533,23 @@ public: //! \{ ASMJIT_INLINE Error _reserve_fit(Arena& arena, size_t n) noexcept { - return ArenaVectorBase::_reserve_fit(arena, n, Support::as_item_size()); + return ArenaVectorBase::_reserve_fit(arena, n, item_size_); } ASMJIT_INLINE Error _reserve_grow(Arena& arena, size_t n) noexcept { - return ArenaVectorBase::_reserve_grow(arena, n, Support::as_item_size()); + return ArenaVectorBase::_reserve_grow(arena, n, item_size_); } ASMJIT_INLINE Error _resize_fit(Arena& arena, size_t n) noexcept { - return ArenaVectorBase::_resize_fit(arena, n, Support::as_item_size()); + return ArenaVectorBase::_resize_fit(arena, n, item_size_); } ASMJIT_INLINE Error _resize_grow(Arena& arena, size_t n) noexcept { - return ArenaVectorBase::_resize_grow(arena, n, Support::as_item_size()); + return ArenaVectorBase::_resize_grow(arena, n, item_size_); } ASMJIT_INLINE Error _reserve_additional(Arena& arena, size_t n) noexcept { - return ArenaVectorBase::_reserve_additional(arena, n, Support::as_item_size()); + return ArenaVectorBase::_reserve_additional(arena, n, item_size_); } //! \} @@ -557,7 +573,7 @@ public: return _reserve_fit(arena, n); } else { - return Error(Error::kOk); + return Error::kOk; } } @@ -566,12 +582,12 @@ public: //! If the vector is smaller than `n` the same growing calculations will be used as if `n` items were appended //! to an empty vector, which means reserving additional space for more append operations that could follow. [[nodiscard]] - inline Error reserve_grow(Arena& arena, size_t n) noexcept { + ASMJIT_INLINE Error reserve_grow(Arena& arena, size_t n) noexcept { if (ASMJIT_UNLIKELY(n > _capacity)) { return _reserve_grow(arena, n); } else { - return Error(Error::kOk); + return Error::kOk; } } @@ -622,4 +638,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_ARENAVECTOR_H_INCLUDED +#endif // ASMJIT_SUPPORT_ARENAVECTOR_H_INCLUDED diff --git a/src/asmjit/core/span.h b/asmjit/support/span.h similarity index 57% rename from src/asmjit/core/span.h rename to asmjit/support/span.h index d384794..140738a 100644 --- a/src/asmjit/core/span.h +++ b/asmjit/support/span.h @@ -3,10 +3,10 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_SPAN_H_INCLUDED -#define ASMJIT_CORE_SPAN_H_INCLUDED +#ifndef ASMJIT_SUPPORT_SPAN_H_INCLUDED +#define ASMJIT_SUPPORT_SPAN_H_INCLUDED -#include "../core/globals.h" +#include ASMJIT_BEGIN_NAMESPACE @@ -27,37 +27,19 @@ public: //! \name Overloaded Operators //! \{ - ASMJIT_INLINE_NODEBUG bool operator==(const T* other) const noexcept { return ptr == other; } - ASMJIT_INLINE_NODEBUG bool operator==(const SpanForwardIterator& other) const noexcept { return ptr == other.ptr; } + ASMJIT_INLINE_CONSTEXPR bool operator==(const T* other) const noexcept { return ptr == other; } + ASMJIT_INLINE_CONSTEXPR bool operator==(const SpanForwardIterator& other) const noexcept { return ptr == other.ptr; } - ASMJIT_INLINE_NODEBUG bool operator!=(const T* other) const noexcept { return ptr != other; } - ASMJIT_INLINE_NODEBUG bool operator!=(const SpanForwardIterator& other) const noexcept { return ptr != other.ptr; } + ASMJIT_INLINE_CONSTEXPR bool operator!=(const T* other) const noexcept { return ptr != other; } + ASMJIT_INLINE_CONSTEXPR bool operator!=(const SpanForwardIterator& other) const noexcept { return ptr != other.ptr; } - ASMJIT_INLINE_NODEBUG SpanForwardIterator& operator++() noexcept { ptr++; return *this; } - ASMJIT_INLINE_NODEBUG SpanForwardIterator& operator--() noexcept { ptr--; return *this; } + ASMJIT_INLINE_CONSTEXPR SpanForwardIterator& operator++() noexcept { ptr++; return *this; } + ASMJIT_INLINE_CONSTEXPR SpanForwardIterator operator++(int) noexcept { SpanForwardIterator prev(*this); ptr++; return prev; } - ASMJIT_INLINE_NODEBUG SpanForwardIterator operator++(int) noexcept { SpanForwardIterator prev(*this); ptr++; return prev; } - ASMJIT_INLINE_NODEBUG SpanForwardIterator operator--(int) noexcept { SpanForwardIterator prev(*this); ptr--; return prev; } + ASMJIT_INLINE_CONSTEXPR T& operator*() const noexcept { return *ptr; } + ASMJIT_INLINE_CONSTEXPR T* operator->() const noexcept { return ptr; } - template - ASMJIT_INLINE_NODEBUG SpanForwardIterator operator+(const N& n) noexcept { return SpanForwardIterator(ptr += n); } - - template - ASMJIT_INLINE_NODEBUG SpanForwardIterator operator-(const N& n) noexcept { return SpanForwardIterator(ptr -= n); } - - template - ASMJIT_INLINE_NODEBUG SpanForwardIterator& operator+=(const N& n) noexcept { ptr += n; return *this; } - - template - ASMJIT_INLINE_NODEBUG SpanForwardIterator& operator-=(const N& n) noexcept { ptr -= n; return *this; } - - ASMJIT_INLINE_CONSTEXPR T& operator*() const noexcept { return ptr[0]; } - ASMJIT_INLINE_CONSTEXPR T* operator->() const noexcept { return &ptr[0]; } - - template - ASMJIT_INLINE_NODEBUG T& operator[](const Index& n) noexcept { return *(ptr - n - 1); } - - ASMJIT_INLINE_NODEBUG operator T*() const noexcept { return ptr; } + ASMJIT_INLINE_CONSTEXPR operator T*() const noexcept { return ptr; } //! \} }; @@ -76,49 +58,19 @@ public: //! \name Overloaded Operators //! \{ - ASMJIT_INLINE_NODEBUG bool operator==(const T* other) const noexcept { return ptr == other; } - ASMJIT_INLINE_NODEBUG bool operator==(const SpanReverseIterator& other) const noexcept { return ptr == other.ptr; } + ASMJIT_INLINE_CONSTEXPR bool operator==(const T* other) const noexcept { return ptr == other; } + ASMJIT_INLINE_CONSTEXPR bool operator==(const SpanReverseIterator& other) const noexcept { return ptr == other.ptr; } - ASMJIT_INLINE_NODEBUG bool operator!=(const T* other) const noexcept { return ptr != other; } - ASMJIT_INLINE_NODEBUG bool operator!=(const SpanReverseIterator& other) const noexcept { return ptr != other.ptr; } + ASMJIT_INLINE_CONSTEXPR bool operator!=(const T* other) const noexcept { return ptr != other; } + ASMJIT_INLINE_CONSTEXPR bool operator!=(const SpanReverseIterator& other) const noexcept { return ptr != other.ptr; } - ASMJIT_INLINE_NODEBUG bool operator<(const T* other) const noexcept { return ptr < other; } - ASMJIT_INLINE_NODEBUG bool operator<(const SpanReverseIterator& other) const noexcept { return ptr < other.ptr; } - - ASMJIT_INLINE_NODEBUG bool operator<=(const T* other) const noexcept { return ptr <= other; } - ASMJIT_INLINE_NODEBUG bool operator<=(const SpanReverseIterator& other) const noexcept { return ptr <= other.ptr; } - - ASMJIT_INLINE_NODEBUG bool operator>(const T* other) const noexcept { return ptr > other; } - ASMJIT_INLINE_NODEBUG bool operator>(const SpanReverseIterator& other) const noexcept { return ptr > other.ptr; } - - ASMJIT_INLINE_NODEBUG bool operator>=(const T* other) const noexcept { return ptr >= other; } - ASMJIT_INLINE_NODEBUG bool operator>=(const SpanReverseIterator& other) const noexcept { return ptr >= other.ptr; } - - ASMJIT_INLINE_NODEBUG SpanReverseIterator& operator++() noexcept { ptr--; return *this; } - ASMJIT_INLINE_NODEBUG SpanReverseIterator& operator--() noexcept { ptr++; return *this; } - - ASMJIT_INLINE_NODEBUG SpanReverseIterator operator++(int) noexcept { SpanReverseIterator prev(*this); ptr--; return prev; } - ASMJIT_INLINE_NODEBUG SpanReverseIterator operator--(int) noexcept { SpanReverseIterator prev(*this); ptr++; return prev; } - - template - ASMJIT_INLINE_NODEBUG SpanReverseIterator operator+(const N& n) noexcept { return SpanReverseIterator(ptr -= n); } - - template - ASMJIT_INLINE_NODEBUG SpanReverseIterator operator-(const N& n) noexcept { return SpanReverseIterator(ptr += n); } - - template - ASMJIT_INLINE_NODEBUG SpanReverseIterator& operator+=(const N& n) noexcept { ptr -= n; return *this; } - - template - ASMJIT_INLINE_NODEBUG SpanReverseIterator& operator-=(const N& n) noexcept { ptr += n; return *this; } + ASMJIT_INLINE_CONSTEXPR SpanReverseIterator& operator++() noexcept { ptr--; return *this; } + ASMJIT_INLINE_CONSTEXPR SpanReverseIterator operator++(int) noexcept { SpanReverseIterator prev(*this); ptr--; return prev; } ASMJIT_INLINE_CONSTEXPR T& operator*() const noexcept { return ptr[-1]; } ASMJIT_INLINE_CONSTEXPR T* operator->() const noexcept { return &ptr[-1]; } - template - ASMJIT_INLINE_NODEBUG T& operator[](const Index& n) noexcept { return *(ptr - n - 1); } - - ASMJIT_INLINE_NODEBUG operator T*() const noexcept { return &ptr[-1]; } + ASMJIT_INLINE_CONSTEXPR operator T*() const noexcept { return &ptr[-1]; } //! \} }; @@ -145,10 +97,10 @@ public: //! \{ [[nodiscard]] - ASMJIT_INLINE_NODEBUG iterator begin() const noexcept { return iterator{_begin}; }; + ASMJIT_INLINE_CONSTEXPR iterator begin() const noexcept { return iterator{_begin}; }; [[nodiscard]] - ASMJIT_INLINE_NODEBUG iterator end() const noexcept { return iterator{_end}; }; + ASMJIT_INLINE_CONSTEXPR iterator end() const noexcept { return iterator{_end}; }; //! \} }; @@ -175,10 +127,10 @@ public: //! \{ [[nodiscard]] - ASMJIT_INLINE_NODEBUG iterator begin() const noexcept { return iterator{_end}; }; + ASMJIT_INLINE_CONSTEXPR iterator begin() const noexcept { return iterator{_end}; }; [[nodiscard]] - ASMJIT_INLINE_NODEBUG iterator end() const noexcept { return iterator{_begin}; }; + ASMJIT_INLINE_CONSTEXPR iterator end() const noexcept { return iterator{_begin}; }; //! \} }; @@ -334,7 +286,7 @@ struct Span { return false; } - //! Returns the first index of the given `value` or `Globals::kNPos` if it wasn't found'. + //! Returns the first index of the given `value` or `SIZE_MAX` if it wasn't found'. template [[nodiscard]] ASMJIT_INLINE size_t index_of(Value&& value) const noexcept { @@ -346,16 +298,16 @@ struct Span { } } - return Globals::kNPos; + return SIZE_MAX; } - //! Returns the last index of the given `value` or `Globals::kNPos` if it wasn't found. + //! Returns the last index of the given `value` or `SIZE_MAX` if it wasn't found. template [[nodiscard]] ASMJIT_INLINE size_t last_index_of(Value&& value) const noexcept { size_t i = _size; - while (--i != Globals::kNPos) { + while (--i != SIZE_MAX) { if (_data[i] == value) { break; } @@ -382,4 +334,4 @@ struct Span { ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_SPAN_H_INCLUDED +#endif // ASMJIT_SUPPORT_SPAN_H_INCLUDED diff --git a/src/asmjit/core/support.cpp b/asmjit/support/support.cpp similarity index 90% rename from src/asmjit/core/support.cpp rename to asmjit/support/support.cpp index fb734e6..07ed1e0 100644 --- a/src/asmjit/core/support.cpp +++ b/asmjit/support/support.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -121,6 +121,40 @@ static void test_bit_utils() noexcept { EXPECT_EQ(Support::lsb_mask(i), expected_bits); } + INFO("Support::fill_trailing_bits()"); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(0u)), uint8_t(0u)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(1u)), uint8_t(1u)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(2u)), uint8_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(3u)), uint8_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(4u)), uint8_t(7u)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(0x80u)), uint8_t(0xFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(0xFEu)), uint8_t(0xFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint8_t(0xFFu)), uint8_t(0xFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(0u)), uint16_t(0u)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(1u)), uint16_t(1u)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(2u)), uint16_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(3u)), uint16_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(4u)), uint16_t(7u)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(0x8000u)), uint16_t(0xFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(0xFFFEu)), uint16_t(0xFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint16_t(0xFFFFu)), uint16_t(0xFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(0u)), uint32_t(0u)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(1u)), uint32_t(1u)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(2u)), uint32_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(3u)), uint32_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(4u)), uint32_t(7u)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(0x80000000u)), uint32_t(0xFFFFFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(0xFFFFFFFEu)), uint32_t(0xFFFFFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint32_t(0xFFFFFFFFu)), uint32_t(0xFFFFFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(0u)), uint64_t(0u)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(1u)), uint64_t(1u)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(2u)), uint64_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(3u)), uint64_t(3u)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(4u)), uint64_t(7u)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(0x8000000000000000u)), uint64_t(0xFFFFFFFFFFFFFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(0xFFFFFFFFFFFFFFFEu)), uint64_t(0xFFFFFFFFFFFFFFFFu)); + EXPECT_EQ(Support::fill_trailing_bits(uint64_t(0xFFFFFFFFFFFFFFFFu)), uint64_t(0xFFFFFFFFFFFFFFFFu)); + INFO("Support::is_power_of_2()"); EXPECT_FALSE(Support::is_power_of_2(uint8_t(0))); EXPECT_FALSE(Support::is_power_of_2(uint16_t(0))); diff --git a/src/asmjit/core/support.h b/asmjit/support/support.h similarity index 90% rename from src/asmjit/core/support.h rename to asmjit/support/support.h index 3149ae1..1fc1711 100644 --- a/src/asmjit/core/support.h +++ b/asmjit/support/support.h @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_SUPPORT_H_INCLUDED -#define ASMJIT_CORE_SUPPORT_H_INCLUDED +#ifndef ASMJIT_SUPPORT_SUPPORT_H_INCLUDED +#define ASMJIT_SUPPORT_SUPPORT_H_INCLUDED -#include "../core/globals.h" -#include "../core/span.h" +#include +#include #if defined(_MSC_VER) #include @@ -32,6 +32,13 @@ ASMJIT_BEGIN_NAMESPACE //! here is considered internal and should not be used outside of AsmJit and related projects like AsmTK. namespace Support { +// Support - Maybe Unused +// ====================== + +//! Silences warnings about unused arguments or variables - more variables can be passed to `maybe_unused()` at once. +template +static SUPPORT_INLINE_NODEBUG void maybe_unused(Args&&...) noexcept {} + // Support - Byte Order // ==================== @@ -94,13 +101,6 @@ using FastUInt8 = uint8_t; using FastUInt8 = uint32_t; #endif -// Support - Maybe Unused -// ====================== - -//! Silences warnings about unused arguments or variables - more variables can be passed to `maybe_unused()` at once. -template -static SUPPORT_INLINE_NODEBUG void maybe_unused(Args&&...) noexcept {} - // Support - Min & Max // =================== @@ -254,12 +254,15 @@ SUPPORT_INLINE constexpr bool bool_and(Args&&... args) noexcept { return bool((. template SUPPORT_INLINE constexpr bool bool_or(Args&&... args) noexcept { return bool((... | bool_as(args))); } -// Support - Bit Constants -// ======================= +// Support - Bit Size +// ================== template inline constexpr uint32_t bit_size_of = uint32_t(sizeof(T) * 8u); +// Support - Bit Ones +// ================== + template inline constexpr T bit_ones = T(~T(0)); @@ -665,18 +668,11 @@ SUPPORT_INLINE constexpr T bit_mask(const Index& idx, Args... args) noexcept { r // Fills all trailing bits right of the given `value` from the first most significant bit set. template [[nodiscard]] -SUPPORT_INLINE constexpr T fill_trailing_bits(const T& value) noexcept { - T v = as_basic_uint(value); +SUPPORT_INLINE_NODEBUG T fill_trailing_bits(const T& value) noexcept { + auto v = as_basic_uint(value); - v = v | (v >> 1); - v = v | (v >> 2); - v = v | (v >> 4); - - if constexpr (sizeof(T) > 1u) { v = v | (v >> 8); } - if constexpr (sizeof(T) > 2u) { v = v | (v >> 16); } - if constexpr (sizeof(T) > 4u) { v = v | (v >> 32); } - - return T(v); + uint32_t leading_count = clz(v | 1u); + return T(((bit_ones >> 1u) >> leading_count) | v); } // Support - Is LSB & Consecutive Mask @@ -983,14 +979,14 @@ struct unaligned_uint; template<> struct unaligned_uint<1> { typedef uint8_t type; }; -#if !defined(_MSC_VER) -template<> struct unaligned_uint<2> { typedef uint16_t __attribute__((__may_alias__, __aligned__(1))) type; }; -template<> struct unaligned_uint<4> { typedef uint32_t __attribute__((__may_alias__, __aligned__(1))) type; }; -template<> struct unaligned_uint<8> { typedef uint64_t __attribute__((__may_alias__, __aligned__(1))) type; }; -#else +#if defined(_MSC_VER) template<> struct unaligned_uint<2> { typedef uint16_t __declspec(align(1)) type; }; template<> struct unaligned_uint<4> { typedef uint32_t __declspec(align(1)) type; }; template<> struct unaligned_uint<8> { typedef uint64_t __declspec(align(1)) type; }; +#elif defined(__GNUC__) +template<> struct unaligned_uint<2> { typedef uint16_t __attribute__((__may_alias__, __aligned__(1))) type; }; +template<> struct unaligned_uint<4> { typedef uint32_t __attribute__((__may_alias__, __aligned__(1))) type; }; +template<> struct unaligned_uint<8> { typedef uint64_t __attribute__((__may_alias__, __aligned__(1))) type; }; #endif template @@ -1176,45 +1172,6 @@ SUPPORT_INLINE_NODEBUG void storeu_u64_be(void* p, uint64_t x) noexcept { storeu } // {anonymous} -// Support - Is Encodable Offset -// ============================= - -[[nodiscard]] -static bool SUPPORT_INLINE_NODEBUG is_encodable_offset_32(int32_t offset, uint32_t num_bits) noexcept { - uint32_t n_rev = 32 - num_bits; - return sar(shl(offset, n_rev), n_rev) == offset; -} - -[[nodiscard]] -static bool SUPPORT_INLINE_NODEBUG is_encodable_offset_64(int64_t offset, uint32_t num_bits) noexcept { - uint32_t n_rev = 64 - num_bits; - return sar(shl(offset, n_rev), n_rev) == offset; -} - -// Support - BytePack & Unpack -// =========================== - -//! Pack four 8-bit integer into a 32-bit integer as it is an array of `{b0,b1,b2,b3}`. -[[nodiscard]] -static SUPPORT_INLINE constexpr uint32_t bytepack32_4x8(uint32_t a, uint32_t b, uint32_t c, uint32_t d) noexcept { - return (ByteOrder::kNative == ByteOrder::kLE) - ? (a | (b << 8) | (c << 16) | (d << 24)) - : (d | (c << 8) | (b << 16) | (a << 24)); -} - -template -[[nodiscard]] -static SUPPORT_INLINE constexpr uint32_t unpack_u32_at_0(T x) noexcept { return (ByteOrder::kNative == ByteOrder::kLE) ? uint32_t(uint64_t(x) & 0xFFFFFFFFu) : uint32_t(uint64_t(x) >> 32); } - -template -[[nodiscard]] -static SUPPORT_INLINE constexpr uint32_t unpack_u32_at_1(T x) noexcept { return (ByteOrder::kNative == ByteOrder::kBE) ? uint32_t(uint64_t(x) & 0xFFFFFFFFu) : uint32_t(uint64_t(x) >> 32); } - -[[nodiscard]] -static SUPPORT_INLINE_NODEBUG uint32_t byte_shift_in_struct(uint32_t index) noexcept { - return (ByteOrder::kNative == ByteOrder::kLE) ? index * 8 : (uint32_t(sizeof(uint32_t)) - 1u - index) * 8; -} - // Support - Enumerate // =================== @@ -1330,40 +1287,6 @@ static SUPPORT_INLINE int compare_string_views(const char* a_data, size_t a_size return int(a_size) - int(b_size); } -// Support - Vector Helpers -// ======================== - -struct ByteSize { uint32_t n; }; -struct Log2Size { uint32_t n; }; - -template -struct ByteSizeOrLog2Size { - using Size = ByteSize; - - static SUPPORT_INLINE constexpr Size get() noexcept { return ByteSize{kSize}; } -}; - -template -struct ByteSizeOrLog2Size { - using Size = Log2Size; - - static SUPPORT_INLINE constexpr Size get() noexcept { return Log2Size{ctz_const}; } -}; - -template -static SUPPORT_INLINE constexpr typename ByteSizeOrLog2Size::Size as_item_size() noexcept { - return ByteSizeOrLog2Size::get(); -} - -template -static SUPPORT_INLINE_NODEBUG ResultType byte_size_from_item_count(size_t item_count, ByteSize item_size) noexcept { return ResultType(item_count) * item_size.n; } - -template -static SUPPORT_INLINE_NODEBUG ResultType byte_size_from_item_count(size_t item_count, Log2Size item_size) noexcept { return ResultType(item_count) << item_size.n; } - -static SUPPORT_INLINE_NODEBUG size_t item_count_from_byte_size(size_t byte_size, ByteSize item_size) noexcept { return byte_size / item_size.n; } -static SUPPORT_INLINE_NODEBUG size_t item_count_from_byte_size(size_t byte_size, Log2Size item_size) noexcept { return byte_size >> item_size.n; } - // Support - Operators // =================== @@ -1386,6 +1309,31 @@ struct Or { }; //! \endcond +// Support - BytePack & Unpack +// =========================== + +//! Pack four 8-bit integer into a 32-bit integer as it is an array of `{b0,b1,b2,b3}`. +[[nodiscard]] +static SUPPORT_INLINE constexpr uint32_t bytepack32_4x8(uint32_t a, uint32_t b, uint32_t c, uint32_t d) noexcept { + return (ByteOrder::kNative == ByteOrder::kLE) + ? (a | (b << 8) | (c << 16) | (d << 24)) + : (d | (c << 8) | (b << 16) | (a << 24)); +} + +template +[[nodiscard]] +static SUPPORT_INLINE constexpr uint32_t unpack_u32_at_0(T x) noexcept { + constexpr uint32_t kShift = ByteOrder::kNative == ByteOrder::kLE ? 0 : 32; + return uint32_t((uint64_t(x) >> kShift) & 0xFFFFFFFFu); +} + +template +[[nodiscard]] +static SUPPORT_INLINE constexpr uint32_t unpack_u32_at_1(T x) noexcept { + constexpr uint32_t kShift = ByteOrder::kNative == ByteOrder::kLE ? 32 : 0; + return uint32_t((uint64_t(x) >> kShift) & 0xFFFFFFFFu); +} + // Support - BitWordIterator // ========================= @@ -1686,7 +1634,7 @@ struct Compare { //! Insertion sort. template> -static inline void insertion_sort(T* base, size_t size, const CompareT& cmp = CompareT()) noexcept { +static SUPPORT_INLINE void insertion_sort(T* base, size_t size, const CompareT& cmp = CompareT()) noexcept { for (T* pm = base + 1; pm < base + size; pm++) { for (T* pl = pm; pl > base && cmp(pl[-1], pl[0]) > 0; pl--) { std::swap(pl[-1], pl[0]); @@ -1776,75 +1724,6 @@ static SUPPORT_INLINE_NODEBUG void sort(T* base, size_t size, const CompareT& cm Internal::QSortImpl::sort(base, size, cmp); } -// Support - ReverseIterator -// ========================= - -//! Reverse iterator to avoid including `` header for iteration over arrays, specialized for -//! AsmJit use (noexcept by design). -template -class ArrayReverseIterator { -public: - //! \name Members - //! \{ - - T* _ptr {}; - - //! \} - - //! \name Construction & Destruction - //! \{ - - SUPPORT_INLINE constexpr ArrayReverseIterator() noexcept = default; - SUPPORT_INLINE constexpr ArrayReverseIterator(const ArrayReverseIterator& other) noexcept = default; - SUPPORT_INLINE constexpr ArrayReverseIterator(T* ptr) noexcept : _ptr(ptr) {} - - //! \} - - //! \name Overloaded Operators - //! \{ - - SUPPORT_INLINE_NODEBUG ArrayReverseIterator& operator=(const ArrayReverseIterator& other) noexcept = default; - - SUPPORT_INLINE_NODEBUG bool operator==(const T* other) const noexcept { return _ptr == other; } - SUPPORT_INLINE_NODEBUG bool operator==(const ArrayReverseIterator& other) const noexcept { return _ptr == other._ptr; } - - SUPPORT_INLINE_NODEBUG bool operator!=(const T* other) const noexcept { return _ptr != other; } - SUPPORT_INLINE_NODEBUG bool operator!=(const ArrayReverseIterator& other) const noexcept { return _ptr != other._ptr; } - - SUPPORT_INLINE_NODEBUG bool operator<(const T* other) const noexcept { return _ptr < other; } - SUPPORT_INLINE_NODEBUG bool operator<(const ArrayReverseIterator& other) const noexcept { return _ptr < other._ptr; } - - SUPPORT_INLINE_NODEBUG bool operator<=(const T* other) const noexcept { return _ptr <= other; } - SUPPORT_INLINE_NODEBUG bool operator<=(const ArrayReverseIterator& other) const noexcept { return _ptr <= other._ptr; } - - SUPPORT_INLINE_NODEBUG bool operator>(const T* other) const noexcept { return _ptr > other; } - SUPPORT_INLINE_NODEBUG bool operator>(const ArrayReverseIterator& other) const noexcept { return _ptr > other._ptr; } - - SUPPORT_INLINE_NODEBUG bool operator>=(const T* other) const noexcept { return _ptr >= other; } - SUPPORT_INLINE_NODEBUG bool operator>=(const ArrayReverseIterator& other) const noexcept { return _ptr >= other._ptr; } - - SUPPORT_INLINE_NODEBUG ArrayReverseIterator& operator++() noexcept { _ptr--; return *this; } - SUPPORT_INLINE_NODEBUG ArrayReverseIterator& operator--() noexcept { _ptr++; return *this; } - - SUPPORT_INLINE_NODEBUG ArrayReverseIterator operator++(int) noexcept { ArrayReverseIterator prev(*this); _ptr--; return prev; } - SUPPORT_INLINE_NODEBUG ArrayReverseIterator operator--(int) noexcept { ArrayReverseIterator prev(*this); _ptr++; return prev; } - - template SUPPORT_INLINE_NODEBUG ArrayReverseIterator operator+(const Diff& n) noexcept { return ArrayReverseIterator(_ptr -= n); } - template SUPPORT_INLINE_NODEBUG ArrayReverseIterator operator-(const Diff& n) noexcept { return ArrayReverseIterator(_ptr += n); } - - template SUPPORT_INLINE_NODEBUG ArrayReverseIterator& operator+=(const Diff& n) noexcept { _ptr -= n; return *this; } - template SUPPORT_INLINE_NODEBUG ArrayReverseIterator& operator-=(const Diff& n) noexcept { _ptr += n; return *this; } - - SUPPORT_INLINE constexpr T& operator*() const noexcept { return _ptr[-1]; } - SUPPORT_INLINE constexpr T* operator->() const noexcept { return &_ptr[-1]; } - - template SUPPORT_INLINE_NODEBUG T& operator[](const Diff& n) noexcept { return *(_ptr - n - 1); } - - SUPPORT_INLINE_NODEBUG operator T*() const noexcept { return _ptr; } - - //! \} -}; - // Support - Array // =============== @@ -1881,18 +1760,18 @@ struct Array { //! \{ template - inline T& operator[](const Index& index) noexcept { + SUPPORT_INLINE T& operator[](const Index& index) noexcept { SUPPORT_ASSERT(as_std_uint(index) < N); return _data[as_std_uint(index)]; } template - inline const T& operator[](const Index& index) const noexcept { + SUPPORT_INLINE const T& operator[](const Index& index) const noexcept { SUPPORT_ASSERT(as_std_uint(index) < N); return _data[as_std_uint(index)]; } - constexpr inline bool operator==(const Array& other) const noexcept { + SUPPORT_INLINE constexpr bool operator==(const Array& other) const noexcept { for (size_t i = 0; i < N; i++) { if (_data[i] != other._data[i]) { return false; @@ -1960,33 +1839,33 @@ struct Array { SUPPORT_INLINE Span as_span() noexcept { return Span(_data, N); } SUPPORT_INLINE Span as_span() const noexcept { return Span(_data, N); } - inline void swap(Array& other) noexcept { + SUPPORT_INLINE void swap(Array& other) noexcept { for (size_t i = 0; i < N; i++) { std::swap(_data[i], other._data[i]); } } - inline void fill(const T& value) noexcept { + SUPPORT_INLINE void fill(const T& value) noexcept { for (size_t i = 0; i < N; i++) { _data[i] = value; } } - inline void copy_from(const Array& other) noexcept { + SUPPORT_INLINE void copy_from(const Array& other) noexcept { for (size_t i = 0; i < N; i++) { _data[i] = other._data[i]; } } template - inline void combine(const Array& other) noexcept { + SUPPORT_INLINE void combine(const Array& other) noexcept { for (size_t i = 0; i < N; i++) { _data[i] = Operator::op(_data[i], other._data[i]); } } template - inline T aggregate(T initial_value = T()) const noexcept { + SUPPORT_INLINE T aggregate(T initial_value = T()) const noexcept { T value = initial_value; for (size_t i = 0; i < N; i++) { value = Operator::op(value, _data[i]); @@ -1995,7 +1874,7 @@ struct Array { } template - inline void for_each(Fn&& fn) noexcept { + SUPPORT_INLINE void for_each(Fn&& fn) noexcept { for (size_t i = 0; i < N; i++) { fn(_data[i]); } @@ -2016,4 +1895,4 @@ struct Array { ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_SUPPORT_H_INCLUDED +#endif // ASMJIT_SUPPORT_SUPPORT_H_INCLUDED diff --git a/src/asmjit/core/support_p.h b/asmjit/support/support_p.h similarity index 96% rename from src/asmjit/core/support_p.h rename to asmjit/support/support_p.h index 54087cf..6e196d4 100644 --- a/src/asmjit/core/support_p.h +++ b/asmjit/support/support_p.h @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#ifndef ASMJIT_CORE_SUPPORT_P_H_INCLUDED -#define ASMJIT_CORE_SUPPORT_P_H_INCLUDED +#ifndef ASMJIT_SUPPORT_SUPPORT_P_H_INCLUDED +#define ASMJIT_SUPPORT_SUPPORT_P_H_INCLUDED -#include "../core/arenabitset_p.h" -#include "../core/support.h" +#include +#include ASMJIT_BEGIN_NAMESPACE @@ -252,4 +252,4 @@ public: ASMJIT_END_NAMESPACE -#endif // ASMJIT_CORE_SUPPORT_P_H_INCLUDED +#endif // ASMJIT_SUPPORT_SUPPORT_P_H_INCLUDED diff --git a/src/asmjit/ujit.h b/asmjit/ujit.h similarity index 51% rename from src/asmjit/ujit.h rename to asmjit/ujit.h index 78c1082..4e97298 100644 --- a/src/asmjit/ujit.h +++ b/asmjit/ujit.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_UJIT_H_INCLUDED #define ASMJIT_UJIT_H_INCLUDED -#include "asmjit-scope-begin.h" -#include "ujit/ujitbase.h" -#include "ujit/unicompiler.h" -#include "ujit/unicondition.h" -#include "ujit/uniop.h" -#include "ujit/vecconsttable.h" -#include "asmjit-scope-end.h" +#include +#include +#include +#include +#include +#include +#include #endif // ASMJIT_UJIT_H_INCLUDED diff --git a/src/asmjit/ujit/ujitbase.h b/asmjit/ujit/ujitbase.h similarity index 99% rename from src/asmjit/ujit/ujitbase.h rename to asmjit/ujit/ujitbase.h index ecc72cb..2bbef3c 100644 --- a/src/asmjit/ujit/ujitbase.h +++ b/asmjit/ujit/ujitbase.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_UJIT_JITBASE_P_H_INCLUDED #define ASMJIT_UJIT_JITBASE_P_H_INCLUDED -#include "../host.h" +#include #if !defined(ASMJIT_NO_UJIT) && !defined(ASMJIT_HAS_HOST_BACKEND) #pragma message("ASMJIT_NO_UJIT wasn't defined, however, no backends were found! (ASMJIT_HAS_HOST_BACKEND not defined)") diff --git a/src/asmjit/ujit/unicompiler.h b/asmjit/ujit/unicompiler.h similarity index 99% rename from src/asmjit/ujit/unicompiler.h rename to asmjit/ujit/unicompiler.h index 3c9b52b..79b7d7c 100644 --- a/src/asmjit/ujit/unicompiler.h +++ b/asmjit/ujit/unicompiler.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_UJIT_UNICOMPILER_H_INCLUDED #define ASMJIT_UJIT_UNICOMPILER_H_INCLUDED -#include "ujitbase.h" -#include "uniop.h" -#include "vecconsttable.h" +#include +#include +#include #if !defined(ASMJIT_NO_UJIT) diff --git a/src/asmjit/ujit/unicompiler_a64.cpp b/asmjit/ujit/unicompiler_a64.cpp similarity index 99% rename from src/asmjit/ujit/unicompiler_a64.cpp rename to asmjit/ujit/unicompiler_a64.cpp index 42c39ad..8411119 100644 --- a/src/asmjit/ujit/unicompiler_a64.cpp +++ b/asmjit/ujit/unicompiler_a64.cpp @@ -3,14 +3,14 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "ujitbase.h" +#include +#include #if defined(ASMJIT_UJIT_AARCH64) -#include "unicompiler.h" -#include "unicompiler_utils_p.h" -#include "unicondition.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(ujit) diff --git a/src/asmjit/ujit/unicompiler_utils_p.h b/asmjit/ujit/unicompiler_utils_p.h similarity index 92% rename from src/asmjit/ujit/unicompiler_utils_p.h rename to asmjit/ujit/unicompiler_utils_p.h index b01cc1c..01fe3cb 100644 --- a/src/asmjit/ujit/unicompiler_utils_p.h +++ b/asmjit/ujit/unicompiler_utils_p.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_UJIT_UNICOMPILER_UTILS_P_H_INCLUDED #define ASMJIT_UJIT_UNICOMPILER_UTILS_P_H_INCLUDED -#include "ujitbase.h" +#include #if !defined(ASMJIT_NO_UJIT) -#include "uniop.h" +#include ASMJIT_BEGIN_SUB_NAMESPACE(ujit) diff --git a/src/asmjit/ujit/unicompiler_x86.cpp b/asmjit/ujit/unicompiler_x86.cpp similarity index 99% rename from src/asmjit/ujit/unicompiler_x86.cpp rename to asmjit/ujit/unicompiler_x86.cpp index ae4412e..1855606 100644 --- a/src/asmjit/ujit/unicompiler_x86.cpp +++ b/asmjit/ujit/unicompiler_x86.cpp @@ -3,14 +3,14 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "ujitbase.h" +#include +#include #if defined(ASMJIT_UJIT_X86) -#include "unicompiler.h" -#include "unicompiler_utils_p.h" -#include "unicondition.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(ujit) diff --git a/src/asmjit/ujit/unicondition.h b/asmjit/ujit/unicondition.h similarity index 99% rename from src/asmjit/ujit/unicondition.h rename to asmjit/ujit/unicondition.h index 3e6ee81..f110b3a 100644 --- a/src/asmjit/ujit/unicondition.h +++ b/asmjit/ujit/unicondition.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_UJIT_UNICONDITION_H_INCLUDED #define ASMJIT_UJIT_UNICONDITION_H_INCLUDED -#include "ujitbase.h" -#include "uniop.h" +#include +#include #if !defined(ASMJIT_NO_UJIT) diff --git a/src/asmjit/ujit/uniop.h b/asmjit/ujit/uniop.h similarity index 99% rename from src/asmjit/ujit/uniop.h rename to asmjit/ujit/uniop.h index 63935bf..af27583 100644 --- a/src/asmjit/ujit/uniop.h +++ b/asmjit/ujit/uniop.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_UJIT_UNIOP_H_INCLUDED #define ASMJIT_UJIT_UNIOP_H_INCLUDED -#include "ujitbase.h" +#include #if !defined(ASMJIT_NO_UJIT) diff --git a/src/asmjit/ujit/vecconsttable.cpp b/asmjit/ujit/vecconsttable.cpp similarity index 86% rename from src/asmjit/ujit/vecconsttable.cpp rename to asmjit/ujit/vecconsttable.cpp index 1e3fc5e..1bfe508 100644 --- a/src/asmjit/ujit/vecconsttable.cpp +++ b/asmjit/ujit/vecconsttable.cpp @@ -3,8 +3,8 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" -#include "vecconsttable.h" +#include +#include #if !defined(ASMJIT_NO_UJIT) diff --git a/src/asmjit/ujit/vecconsttable.h b/asmjit/ujit/vecconsttable.h similarity index 99% rename from src/asmjit/ujit/vecconsttable.h rename to asmjit/ujit/vecconsttable.h index b0779ff..7668276 100644 --- a/src/asmjit/ujit/vecconsttable.h +++ b/asmjit/ujit/vecconsttable.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_UJIT_VECCONSTTABLE_H_INCLUDED #define ASMJIT_UJIT_VECCONSTTABLE_H_INCLUDED -#include "../core/globals.h" +#include #if !defined(ASMJIT_NO_UJIT) diff --git a/src/asmjit/x86.h b/asmjit/x86.h similarity index 90% rename from src/asmjit/x86.h rename to asmjit/x86.h index 9a8ceb8..db6c46b 100644 --- a/src/asmjit/x86.h +++ b/asmjit/x86.h @@ -69,16 +69,16 @@ //! - \ref x86::VReduceImm - `REDUCE[PD|PS|SD|SS]` predicate (AVX512+). //! - \ref x86::TLogImm - `VPTERNLOG[D|Q]` predicate and operations (AVX512+). -#include "core.h" +#include -#include "asmjit-scope-begin.h" -#include "x86/x86assembler.h" -#include "x86/x86builder.h" -#include "x86/x86compiler.h" -#include "x86/x86emitter.h" -#include "x86/x86globals.h" -#include "x86/x86instdb.h" -#include "x86/x86operand.h" -#include "asmjit-scope-end.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // ASMJIT_X86_H_INCLUDED diff --git a/src/asmjit/x86/x86archtraits_p.h b/asmjit/x86/x86archtraits_p.h similarity index 98% rename from src/asmjit/x86/x86archtraits_p.h rename to asmjit/x86/x86archtraits_p.h index dee87e4..80d00c2 100644 --- a/src/asmjit/x86/x86archtraits_p.h +++ b/asmjit/x86/x86archtraits_p.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_X86_X86ARCHTRAITS_P_H_INCLUDED #define ASMJIT_X86_X86ARCHTRAITS_P_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/misc_p.h" -#include "../x86/x86operand.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86assembler.cpp b/asmjit/x86/x86assembler.cpp similarity index 99% rename from src/asmjit/x86/x86assembler.cpp rename to asmjit/x86/x86assembler.cpp index e651628..66af7a3 100644 --- a/src/asmjit/x86/x86assembler.cpp +++ b/asmjit/x86/x86assembler.cpp @@ -3,23 +3,23 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) -#include "../core/assembler.h" -#include "../core/codewriter_p.h" -#include "../core/cpuinfo.h" -#include "../core/emitterutils_p.h" -#include "../core/formatter.h" -#include "../core/logger.h" -#include "../core/misc_p.h" -#include "../core/support.h" -#include "../x86/x86assembler.h" -#include "../x86/x86emithelper_p.h" -#include "../x86/x86instapi_p.h" -#include "../x86/x86instdb_p.h" -#include "../x86/x86formatter_p.h" -#include "../x86/x86opcode_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) @@ -620,7 +620,7 @@ ASMJIT_FAVOR_SPEED Error Assembler::_emit(InstId inst_id, const Operand_& o0, co goto Failed; } -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION // Strict validation. if (has_diagnostic_option(DiagnosticOptions::kValidateAssembler)) { Operand_ op_array[Globals::kMaxOpCount]; diff --git a/src/asmjit/x86/x86assembler.h b/asmjit/x86/x86assembler.h similarity index 99% rename from src/asmjit/x86/x86assembler.h rename to asmjit/x86/x86assembler.h index e53b676..98e0862 100644 --- a/src/asmjit/x86/x86assembler.h +++ b/asmjit/x86/x86assembler.h @@ -6,9 +6,9 @@ #ifndef ASMJIT_X86_X86ASSEMBLER_H_INCLUDED #define ASMJIT_X86_X86ASSEMBLER_H_INCLUDED -#include "../core/assembler.h" -#include "../x86/x86emitter.h" -#include "../x86/x86operand.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86builder.cpp b/asmjit/x86/x86builder.cpp similarity index 89% rename from src/asmjit/x86/x86builder.cpp rename to asmjit/x86/x86builder.cpp index b5023fb..d7df465 100644 --- a/src/asmjit/x86/x86builder.cpp +++ b/asmjit/x86/x86builder.cpp @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_BUILDER) -#include "../x86/x86assembler.h" -#include "../x86/x86builder.h" -#include "../x86/x86emithelper_p.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86builder.h b/asmjit/x86/x86builder.h similarity index 99% rename from src/asmjit/x86/x86builder.h rename to asmjit/x86/x86builder.h index 71fae5a..985e3a1 100644 --- a/src/asmjit/x86/x86builder.h +++ b/asmjit/x86/x86builder.h @@ -6,11 +6,11 @@ #ifndef ASMJIT_X86_X86BUILDER_H_INCLUDED #define ASMJIT_X86_X86BUILDER_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_BUILDER -#include "../core/builder.h" -#include "../x86/x86emitter.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86compiler.cpp b/asmjit/x86/x86compiler.cpp similarity index 89% rename from src/asmjit/x86/x86compiler.cpp rename to asmjit/x86/x86compiler.cpp index 0bf4190..bf8fb54 100644 --- a/src/asmjit/x86/x86compiler.cpp +++ b/asmjit/x86/x86compiler.cpp @@ -3,13 +3,13 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_COMPILER) -#include "../x86/x86assembler.h" -#include "../x86/x86compiler.h" -#include "../x86/x86instapi_p.h" -#include "../x86/x86rapass_p.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86compiler.h b/asmjit/x86/x86compiler.h similarity index 99% rename from src/asmjit/x86/x86compiler.h rename to asmjit/x86/x86compiler.h index 245dfef..c65f785 100644 --- a/src/asmjit/x86/x86compiler.h +++ b/asmjit/x86/x86compiler.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_X86_X86COMPILER_H_INCLUDED #define ASMJIT_X86_X86COMPILER_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/compiler.h" -#include "../core/type.h" -#include "../x86/x86emitter.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86emithelper.cpp b/asmjit/x86/x86emithelper.cpp similarity index 98% rename from src/asmjit/x86/x86emithelper.cpp rename to asmjit/x86/x86emithelper.cpp index e1b8ba3..bb22fa4 100644 --- a/src/asmjit/x86/x86emithelper.cpp +++ b/asmjit/x86/x86emithelper.cpp @@ -3,19 +3,19 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) -#include "../core/formatter.h" -#include "../core/funcargscontext_p.h" -#include "../core/string.h" -#include "../core/support.h" -#include "../core/type.h" -#include "../core/radefs_p.h" -#include "../x86/x86emithelper_p.h" -#include "../x86/x86emitter.h" -#include "../x86/x86formatter_p.h" -#include "../x86/x86instapi_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86emithelper_p.h b/asmjit/x86/x86emithelper_p.h similarity index 95% rename from src/asmjit/x86/x86emithelper_p.h rename to asmjit/x86/x86emithelper_p.h index fb70858..ac3f1b7 100644 --- a/src/asmjit/x86/x86emithelper_p.h +++ b/asmjit/x86/x86emithelper_p.h @@ -6,13 +6,13 @@ #ifndef ASMJIT_X86_X86EMITHELPER_P_H_INCLUDED #define ASMJIT_X86_X86EMITHELPER_P_H_INCLUDED -#include "../core/api-config.h" +#include -#include "../core/emithelper_p.h" -#include "../core/func.h" -#include "../x86/x86emitter.h" -#include "../x86/x86instapi_p.h" -#include "../x86/x86operand.h" +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) @@ -106,7 +106,7 @@ public: void init_emitter_funcs(BaseEmitter* emitter) noexcept; static ASMJIT_INLINE void update_emitter_funcs(BaseEmitter* emitter) noexcept { -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION emitter->_funcs.validate = emitter->is_32bit() ? InstInternal::validate_x86 : InstInternal::validate_x64; #else Support::maybe_unused(emitter); diff --git a/src/asmjit/x86/x86emitter.h b/asmjit/x86/x86emitter.h similarity index 99% rename from src/asmjit/x86/x86emitter.h rename to asmjit/x86/x86emitter.h index 1c018af..dafc961 100644 --- a/src/asmjit/x86/x86emitter.h +++ b/asmjit/x86/x86emitter.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_X86_X86EMITTER_H_INCLUDED #define ASMJIT_X86_X86EMITTER_H_INCLUDED -#include "../core/emitter.h" -#include "../core/support.h" -#include "../x86/x86globals.h" -#include "../x86/x86operand.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86formatter.cpp b/asmjit/x86/x86formatter.cpp similarity index 98% rename from src/asmjit/x86/x86formatter.cpp rename to asmjit/x86/x86formatter.cpp index 39c554c..eeb13f8 100644 --- a/src/asmjit/x86/x86formatter.cpp +++ b/asmjit/x86/x86formatter.cpp @@ -3,20 +3,20 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_LOGGING) -#include "../core/cpuinfo.h" -#include "../core/formatter_p.h" -#include "../core/misc_p.h" -#include "../core/support.h" -#include "../x86/x86formatter_p.h" -#include "../x86/x86instapi_p.h" -#include "../x86/x86instdb_p.h" -#include "../x86/x86operand.h" +#include +#include +#include +#include +#include +#include +#include +#include #ifndef ASMJIT_NO_COMPILER - #include "../core/compiler.h" + #include #endif ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86formatter_p.h b/asmjit/x86/x86formatter_p.h similarity index 89% rename from src/asmjit/x86/x86formatter_p.h rename to asmjit/x86/x86formatter_p.h index 360a9b6..b014ea3 100644 --- a/src/asmjit/x86/x86formatter_p.h +++ b/asmjit/x86/x86formatter_p.h @@ -6,12 +6,12 @@ #ifndef ASMJIT_X86_X86FORMATTER_P_H_INCLUDED #define ASMJIT_X86_X86FORMATTER_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_LOGGING -#include "../core/formatter.h" -#include "../core/string.h" -#include "../x86/x86globals.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86func.cpp b/asmjit/x86/x86func.cpp similarity index 99% rename from src/asmjit/x86/x86func.cpp rename to asmjit/x86/x86func.cpp index d8893a3..8de3f86 100644 --- a/src/asmjit/x86/x86func.cpp +++ b/asmjit/x86/x86func.cpp @@ -3,12 +3,12 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) -#include "../x86/x86func_p.h" -#include "../x86/x86emithelper_p.h" -#include "../x86/x86operand.h" +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86func_p.h b/asmjit/x86/x86func_p.h similarity index 96% rename from src/asmjit/x86/x86func_p.h rename to asmjit/x86/x86func_p.h index c3e7985..1249daf 100644 --- a/src/asmjit/x86/x86func_p.h +++ b/asmjit/x86/x86func_p.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_X86_X86FUNC_P_H_INCLUDED #define ASMJIT_X86_X86FUNC_P_H_INCLUDED -#include "../core/func.h" +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86globals.h b/asmjit/x86/x86globals.h similarity index 99% rename from src/asmjit/x86/x86globals.h rename to asmjit/x86/x86globals.h index 8de5620..07c459f 100644 --- a/src/asmjit/x86/x86globals.h +++ b/asmjit/x86/x86globals.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_X86_X86GLOBALS_H_INCLUDED #define ASMJIT_X86_X86GLOBALS_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/inst.h" +#include +#include //! \namespace asmjit::x86 //! \ingroup asmjit_x86 diff --git a/src/asmjit/x86/x86instapi.cpp b/asmjit/x86/x86instapi.cpp similarity index 99% rename from src/asmjit/x86/x86instapi.cpp rename to asmjit/x86/x86instapi.cpp index 8642e53..29757bc 100644 --- a/src/asmjit/x86/x86instapi.cpp +++ b/asmjit/x86/x86instapi.cpp @@ -3,16 +3,16 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) -#include "../core/cpuinfo.h" -#include "../core/instdb_p.h" -#include "../core/misc_p.h" -#include "../x86/x86instapi_p.h" -#include "../x86/x86instdb_p.h" -#include "../x86/x86opcode_p.h" -#include "../x86/x86operand.h" +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) @@ -59,7 +59,7 @@ InstId string_to_inst_id(const char* s, size_t len) noexcept { // x86::InstInternal - Validate // ============================ -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION struct X86ValidationData { //! Allowed registers by \ref RegType. RegMask allowed_reg_mask[uint32_t(RegType::kMaxValue) + 1]; @@ -738,7 +738,7 @@ Error validate_x64(const BaseInst& inst, const Operand_* operands, size_t op_cou return validate(InstDB::Mode::kX64, inst, operands, op_count, validation_flags); } -#endif // !ASMJIT_NO_VALIDATION +#endif // !ASMJIT_NO_INTROSPECTION // x86::InstInternal - QueryRWInfo // =============================== diff --git a/src/asmjit/x86/x86instapi_p.h b/asmjit/x86/x86instapi_p.h similarity index 91% rename from src/asmjit/x86/x86instapi_p.h rename to asmjit/x86/x86instapi_p.h index cda4000..6c1d072 100644 --- a/src/asmjit/x86/x86instapi_p.h +++ b/asmjit/x86/x86instapi_p.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_X86_X86INSTAPI_P_H_INCLUDED #define ASMJIT_X86_X86INSTAPI_P_H_INCLUDED -#include "../core/inst.h" -#include "../core/operand.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) @@ -22,12 +22,9 @@ Error ASMJIT_CDECL inst_id_to_string(InstId inst_id, InstStringifyOptions option InstId ASMJIT_CDECL string_to_inst_id(const char* s, size_t len) noexcept; #endif // !ASMJIT_NO_TEXT -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION Error ASMJIT_CDECL validate_x86(const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags) noexcept; Error ASMJIT_CDECL validate_x64(const BaseInst& inst, const Operand_* operands, size_t op_count, ValidationFlags validation_flags) noexcept; -#endif // !ASMJIT_NO_VALIDATION - -#ifndef ASMJIT_NO_INTROSPECTION Error ASMJIT_CDECL query_rw_info(Arch arch, const BaseInst& inst, const Operand_* operands, size_t op_count, InstRWInfo* out) noexcept; Error ASMJIT_CDECL query_features(Arch arch, const BaseInst& inst, const Operand_* operands, size_t op_count, CpuFeatures* out) noexcept; #endif // !ASMJIT_NO_INTROSPECTION diff --git a/src/asmjit/x86/x86instdb.cpp b/asmjit/x86/x86instdb.cpp similarity index 99% rename from src/asmjit/x86/x86instdb.cpp rename to asmjit/x86/x86instdb.cpp index d48b77e..238d6f6 100644 --- a/src/asmjit/x86/x86instdb.cpp +++ b/asmjit/x86/x86instdb.cpp @@ -3,15 +3,15 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) -#include "../core/cpuinfo.h" -#include "../core/misc_p.h" -#include "../core/support.h" -#include "../x86/x86instdb_p.h" -#include "../x86/x86opcode_p.h" -#include "../x86/x86operand.h" +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) @@ -4696,7 +4696,7 @@ const uint32_t InstDB::alias_index_to_inst_id_table[] = { // x86::InstDB - InstSignature & OpSignature // ========================================= -#ifndef ASMJIT_NO_VALIDATION +#ifndef ASMJIT_NO_INTROSPECTION // ${InstSignatureTable:Begin} // ------------------- Automatically generated, do not edit ------------------- #define ROW(count, x86, x64, implicit, o0, o1, o2, o3, o4, o5) \ @@ -5496,7 +5496,7 @@ const InstDB::OpSignature InstDB::_op_signature_table[] = { #undef ROW // ---------------------------------------------------------------------------- // ${InstSignatureTable:End} -#endif // !ASMJIT_NO_VALIDATION +#endif // !ASMJIT_NO_INTROSPECTION // x86::InstInternal - QueryRWInfo // =============================== diff --git a/src/asmjit/x86/x86instdb.h b/asmjit/x86/x86instdb.h similarity index 99% rename from src/asmjit/x86/x86instdb.h rename to asmjit/x86/x86instdb.h index ff92046..34f51a1 100644 --- a/src/asmjit/x86/x86instdb.h +++ b/asmjit/x86/x86instdb.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_X86_X86INSTDB_H_INCLUDED #define ASMJIT_X86_X86INSTDB_H_INCLUDED -#include "../core/span.h" -#include "../x86/x86globals.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86instdb_p.h b/asmjit/x86/x86instdb_p.h similarity index 99% rename from src/asmjit/x86/x86instdb_p.h rename to asmjit/x86/x86instdb_p.h index e9536ce..43aa452 100644 --- a/src/asmjit/x86/x86instdb_p.h +++ b/asmjit/x86/x86instdb_p.h @@ -6,8 +6,8 @@ #ifndef ASMJIT_X86_X86INSTDB_P_H_INCLUDED #define ASMJIT_X86_X86INSTDB_P_H_INCLUDED -#include "../core/instdb_p.h" -#include "../x86/x86instdb.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86opcode_p.h b/asmjit/x86/x86opcode_p.h similarity index 99% rename from src/asmjit/x86/x86opcode_p.h rename to asmjit/x86/x86opcode_p.h index 80cb3a1..511f702 100644 --- a/src/asmjit/x86/x86opcode_p.h +++ b/asmjit/x86/x86opcode_p.h @@ -6,7 +6,7 @@ #ifndef ASMJIT_X86_X86OPCODE_P_H_INCLUDED #define ASMJIT_X86_X86OPCODE_P_H_INCLUDED -#include "../x86/x86globals.h" +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86operand.cpp b/asmjit/x86/x86operand.cpp similarity index 98% rename from src/asmjit/x86/x86operand.cpp rename to asmjit/x86/x86operand.cpp index 1d5f276..8477dcf 100644 --- a/src/asmjit/x86/x86operand.cpp +++ b/asmjit/x86/x86operand.cpp @@ -3,11 +3,11 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) -#include "../core/misc_p.h" -#include "../x86/x86operand.h" +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86operand.h b/asmjit/x86/x86operand.h similarity index 99% rename from src/asmjit/x86/x86operand.h rename to asmjit/x86/x86operand.h index 52f4703..2f5357f 100644 --- a/src/asmjit/x86/x86operand.h +++ b/asmjit/x86/x86operand.h @@ -6,10 +6,10 @@ #ifndef ASMJIT_X86_X86OPERAND_H_INCLUDED #define ASMJIT_X86_X86OPERAND_H_INCLUDED -#include "../core/archtraits.h" -#include "../core/operand.h" -#include "../core/type.h" -#include "../x86/x86globals.h" +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/src/asmjit/x86/x86rapass.cpp b/asmjit/x86/x86rapass.cpp similarity index 99% rename from src/asmjit/x86/x86rapass.cpp rename to asmjit/x86/x86rapass.cpp index 151b1f0..7110b45 100644 --- a/src/asmjit/x86/x86rapass.cpp +++ b/asmjit/x86/x86rapass.cpp @@ -3,19 +3,19 @@ // See or LICENSE.md for license and copyright information // SPDX-License-Identifier: Zlib -#include "../core/api-build_p.h" +#include #if !defined(ASMJIT_NO_X86) && !defined(ASMJIT_NO_COMPILER) -#include "../core/cpuinfo.h" -#include "../core/formatter_p.h" -#include "../core/support.h" -#include "../core/type.h" -#include "../x86/x86assembler.h" -#include "../x86/x86compiler.h" -#include "../x86/x86instapi_p.h" -#include "../x86/x86instdb_p.h" -#include "../x86/x86emithelper_p.h" -#include "../x86/x86rapass_p.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) @@ -785,7 +785,7 @@ Error RACFGBuilder::on_invoke(InvokeNode* invoke_node, RAInstBuilder& ib) noexce // Setup clobbered registers. for (RegGroup group : Support::enumerate(RegGroup::kMaxVirt)) { - ib._clobbered[group] = Support::lsb_mask(_pass._phys_reg_count[group]) & ~fd.preserved_regs(group); + ib._clobbered[group] = Support::lsb_mask(_pass._phys_reg_count.get(group)) & ~fd.preserved_regs(group); } return Error::kOk; diff --git a/src/asmjit/x86/x86rapass_p.h b/asmjit/x86/x86rapass_p.h similarity index 88% rename from src/asmjit/x86/x86rapass_p.h rename to asmjit/x86/x86rapass_p.h index 610f0a1..4dd1d5f 100644 --- a/src/asmjit/x86/x86rapass_p.h +++ b/asmjit/x86/x86rapass_p.h @@ -6,16 +6,16 @@ #ifndef ASMJIT_X86_X86RAPASS_P_H_INCLUDED #define ASMJIT_X86_X86RAPASS_P_H_INCLUDED -#include "../core/api-config.h" +#include #ifndef ASMJIT_NO_COMPILER -#include "../core/compiler.h" -#include "../core/racfgblock_p.h" -#include "../core/racfgbuilder_p.h" -#include "../core/rapass_p.h" -#include "../x86/x86assembler.h" -#include "../x86/x86compiler.h" -#include "../x86/x86emithelper_p.h" +#include +#include +#include +#include +#include +#include +#include ASMJIT_BEGIN_SUB_NAMESPACE(x86) diff --git a/configure.sh b/configure.sh index 659d6dc..3f9b1d6 100755 --- a/configure.sh +++ b/configure.sh @@ -1,11 +1,9 @@ -#!/bin/sh +#!/bin/bash -BUILD_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DASMJIT_TEST=1" - -echo "== [Configuring Build - Debug] ==" -eval cmake . -B build/Debug -DCMAKE_BUILD_TYPE=Debug ${BUILD_OPTIONS} "$@" +echo "== [configure debug] ==" +cmake --preset debug "$@" echo "" -echo "== [Configuring Build - Release] ==" -eval cmake . -B build/Release -DCMAKE_BUILD_TYPE=Release ${BUILD_OPTIONS} "$@" +echo "== [configure release] ==" +cmake --preset release "$@" echo "" diff --git a/configure_sanitizers.sh b/configure_sanitizers.sh index 2634bcd..defd80f 100755 --- a/configure_sanitizers.sh +++ b/configure_sanitizers.sh @@ -1,15 +1,13 @@ -#!/bin/sh +#!/bin/bash -BUILD_OPTIONS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DASMJIT_TEST=1" - -echo "== [Configuring Build - Release_ASAN] ==" -eval cmake . -B build/Release_ASAN ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release -DASMJIT_SANITIZE=address "$@" +echo "== [configure release-asan] ==" +cmake --preset release-asan "$@" echo "" -echo "== [Configuring Build - Release_MSAN] ==" -eval cmake . -B build/Release_MSAN ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release -DASMJIT_SANITIZE=memory "$@" +echo "== [configure release-msan] ==" +cmake --preset release-msan "$@" echo "" -echo "== [Configuring Build - Release_UBSAN] ==" -eval cmake . -B build/Release_UBSAN ${BUILD_OPTIONS} -DCMAKE_BUILD_TYPE=Release -DASMJIT_SANITIZE=undefined "$@" +echo "== [configure release-ubsan] ==" +cmake --preset release-ubsan "$@" echo "" diff --git a/db/isa_x86.json b/db/isa_x86.json index b4bdaa8..d6be812 100644 --- a/db/isa_x86.json +++ b/db/isa_x86.json @@ -3551,45 +3551,6 @@ {"x64": "tmmultf32ps X:tmm, tmm, tmm" , "op": "[RMV] VEX.128.66.0F38.W0 48 11:rrr:bbb"} ]}, - {"category": "AMX", "ext": "AMX_TRANSPOSE", "instructions": [ - {"x64": "t2rpntlvwz0 W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.NP.0F38.W0 6E !(11):rrr:100"}, - {"apx": "t2rpntlvwz0 W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.NP.0F38.W0 6E !(11):rrr:100"}, - {"x64": "t2rpntlvwz0t1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.NP.0F38.W0 6F !(11):rrr:100"}, - {"apx": "t2rpntlvwz0t1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.NP.0F38.W0 6F !(11):rrr:100"}, - {"x64": "t2rpntlvwz1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.66.0F38.W0 6E !(11):rrr:100"}, - {"apx": "t2rpntlvwz1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.66.0F38.W0 6E !(11):rrr:100"}, - {"x64": "t2rpntlvwz1t1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.66.0F38.W0 6F !(11):rrr:100"}, - {"apx": "t2rpntlvwz1t1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.66.0F38.W0 6F !(11):rrr:100"}, - {"x64": "ttransposed W:tmm, tmm" , "op": "[RMV] VEX.128.F3.0F38.W0 5F 11:rrr:bbb"} - ]}, - - {"category": "AMX", "ext": "AMX_TRANSPOSE AMX_COMPLEX", "instructions": [ - {"x64": "tconjtcmmimfp16ps W:tmm, tmm, tmm" , "op": "[RMV] VEX.128.NP.0F38.W0 6B 11:rrr:bbb"}, - {"x64": "tconjtfp16 W:tmm, tmm" , "op": "[RM ] VEX.128.66.0F38.W0 6B 11:rrr:bbb"}, - {"x64": "ttcmmimfp16ps X:tmm, tmm, tmm" , "op": "[RMV] VEX.128.F2.0F38.W0 6B 11:rrr:bbb"}, - {"x64": "ttcmmrlfp16ps X:tmm, tmm, tmm" , "op": "[RMV] VEX.128.F3.0F38.W0 6B 11:rrr:bbb"} - ]}, - - {"category": "AMX", "ext": "AMX_TRANSPOSE AMX_MOVRS", "instructions": [ - {"x64": "t2rpntlvwz0rs W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.NP.MAP5.W0 F8 !(11):rrr:100"}, - {"apx": "t2rpntlvwz0rs W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.NP.MAP5.W0 F8 !(11):rrr:100"}, - {"x64": "t2rpntlvwz0rst1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.NP.MAP5.W0 F9 !(11):rrr:100"}, - {"apx": "t2rpntlvwz0rst1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.NP.MAP5.W0 F9 !(11):rrr:100"}, - {"x64": "t2rpntlvwz1rs W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.66.MAP5.W0 F8 !(11):rrr:100"}, - {"apx": "t2rpntlvwz1rs W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.66.MAP5.W0 F8 !(11):rrr:100"}, - {"x64": "t2rpntlvwz1rst1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] VEX.128.66.MAP5.W0 F9 !(11):rrr:100"}, - {"apx": "t2rpntlvwz1rst1 W:tmm, W:tmm+1, tmem" , "op": "[RM ] EVEX.128.66.MAP5.W0 F9 !(11):rrr:100"} - ]}, - - {"category": "AMX", "ext": "AMX_TRANSPOSE AMX_BF16", "instructions": [ - {"x64": "ttdpbf16ps X:tmm, tmm, tmm" , "op": "[RMV] VEX.128.F3.0F38.W0 6C 11:rrr:bbb"}, - {"x64": "ttdpfp16ps X:tmm, tmm, tmm" , "op": "[RMV] VEX.128.F2.0F38.W0 6C 11:rrr:bbb"} - ]}, - - {"category": "AMX", "ext": "AMX_TRANSPOSE AMX_TF32", "instructions": [ - {"x64": "ttmmultf32ps X:tmm, tmm, tmm" , "op": "[RMV] VEX.128.NP.0F38.W0 48 11:rrr:bbb"} - ]}, - {"category": "GP GP_EXT", "ext": "APX_F", "instructions": [ {"apx": "adc x:r8/m8, R:r8" , "op": "[MR ] EVEX.ND=0.LLZ.NP.MAP4.WIG 10 /r" , "io": "OF=W SF=W ZF=W AF=W PF=W CF=X"}, {"apx": "adc x:rv/mv, R:rv" , "op": "[MR ] EVEX.ND=0.LLZ.Pv.MAP4.Wv 11 /r" , "io": "OF=W SF=W ZF=W AF=W PF=W CF=X"}, diff --git a/tools/enumgen.js b/tools/enumgen.js index d02c34d..3823b80 100644 --- a/tools/enumgen.js +++ b/tools/enumgen.js @@ -405,7 +405,7 @@ class Generator { } const generator = new Generator({ - baseDir : path.resolve(__dirname, "../src"), + baseDir : path.resolve(__dirname, ".."), verify : process.argv.indexOf("--verify") !== -1, noBackup: process.argv.indexOf("--no-backup") !== -1 }); diff --git a/tools/tablegen-a64.js b/tools/tablegen-a64.js index c0c416a..363a47d 100644 --- a/tools/tablegen-a64.js +++ b/tools/tablegen-a64.js @@ -83,7 +83,7 @@ class ArmTableGen extends core.TableGen { // -------------------------------------------------------------------------- parse() { - const rawData = this.dataOfFile("src/asmjit/arm/a64instdb.cpp"); + const rawData = this.dataOfFile("asmjit/arm/a64instdb.cpp"); const stringData = StringUtils.extract(rawData, "// ${InstInfo:Begin}", "// ${InstInfo:End"); const re = new RegExp( @@ -186,11 +186,11 @@ class ArmTableGen extends core.TableGen { onBeforeRun() { this.load([ - "src/asmjit/arm/a64emitter.h", - "src/asmjit/arm/a64globals.h", - "src/asmjit/arm/a64instdb.cpp", - "src/asmjit/arm/a64instdb.h", - "src/asmjit/arm/a64instdb_p.h" + "asmjit/arm/a64emitter.h", + "asmjit/arm/a64globals.h", + "asmjit/arm/a64instdb.cpp", + "asmjit/arm/a64instdb.h", + "asmjit/arm/a64instdb_p.h" ]); this.parse(); } diff --git a/tools/tablegen-x86.js b/tools/tablegen-x86.js index 91d9754..e58328e 100644 --- a/tools/tablegen-x86.js +++ b/tools/tablegen-x86.js @@ -469,7 +469,7 @@ class X86TableGen extends core.TableGen { // -------------------------------------------------------------------------- parse() { - const data = this.dataOfFile("src/asmjit/x86/x86instdb.cpp"); + const data = this.dataOfFile("asmjit/x86/x86instdb.cpp"); const re = new RegExp( "INST\\(" + "([A-Za-z0-9_]+)\\s*" + "," + // [01] Instruction. @@ -777,10 +777,10 @@ class X86TableGen extends core.TableGen { onBeforeRun() { this.load([ - "src/asmjit/x86/x86globals.h", - "src/asmjit/x86/x86instdb.cpp", - "src/asmjit/x86/x86instdb.h", - "src/asmjit/x86/x86instdb_p.h" + "asmjit/x86/x86globals.h", + "asmjit/x86/x86instdb.cpp", + "asmjit/x86/x86instdb.h", + "asmjit/x86/x86instdb_p.h" ]); this.parse(); }