578 Commits

Author SHA1 Message Date
Alexander Myltsev
c87860217e [bug] Fixed missing header files in install target 2025-12-13 15:32:29 +01:00
Ilya Vinogradov
0cf6eafda2 [bug] Fixed FMOV encoding bug (AArch64) 2025-12-09 14:48:18 +01:00
kobalicek
12f9ca3b32 [doc] Documentation update (chat links) 2025-11-29 09:13:10 +01:00
kobalicek
11f75973ae [bug] Fixed UniCompiler's new_reg to forward to new_reg
It forwarded to new_similar_reg, which would be a compile-time
error.
2025-11-19 22:00:31 +01:00
kobalicek
28295814dd [doc] Documentation and funding update
* Removed github funding links
  * Fixed few documentation links
2025-11-15 10:54:23 +01:00
kobalicek
9888fcf213 [bug] Fixed a bug in Vec::half() that halved to ZMM instead of XMM 2025-11-13 21:50:54 +01:00
kobalicek
b56f4176cb Codebase update and improvements, instruction DB update
* Denested src folder to root, renamed testing to asmjit-testing

  * Refactored how headers are included into <asmjit/...> form. This
    is necessary as compilers would never simplify a path once a ..
    appears in include directory - then paths such as ../core/../core
    appeared in asserts, which was ugly

  * Moved support utilities into asmjit/support/... (still included
    by asmjit/core.h for convenience and compatibility)

  * Added CMakePresets.json for making it easy to develop AsmJit

  * Reworked CMakeLists to be shorter and use CMake option(),
    etc... This simplifies it and makes it using more standard
    features

  * ASMJIT_EMBED now creates asmjit_embed INTERFACE library,
    which is accessible via asmjit::asmjit target - this simplifies
    embedding and makes it the same as library targets from a CMake
    perspective

  * Removed ASMJIT_DEPS - this is now provided by cmake target
    aliases - 'asmjit::asmjit' so users should not need this variable

  * Changed meaning of ASMJIT_LIBS - this now contains only AsmJit
    dependencies without asmjit::asmjit target alias. Don't rely on
    ASMJIT_LIBS anymore as it's only used internally

  * Removed ASMJIT_NO_DEPRECATED option - AsmJit is not going
    to provide controllable deprecations in the future

  * Removed ASMJIT_NO_VALIDATION in favor of ASMJIT_NO_INTROSPECTION,
    which now controls query, features, and validation API presence

  * Removed ASMJIT_DIR option - it was never really needed

  * Removed AMX_TRANSPOSE feature from instruction database (X86).
    Intel has removed it as well, so it's a feature that won't
    be siliconized
2025-11-02 22:31:46 +01:00
kobalicek
5134d396bd [abi] Improved ujit integration
* Do not mark UniCompiler emit functions noexcept to make the
    signatures compatible with BackendCompiler
  * Added more functions that wrap BackendCompiler functionality
  * Simplified the way of creating functions to make it more
    compatible with how BackendCompiler creates and finishes
    functions
2025-10-12 21:50:05 +02:00
kobalicek
212832c329 Updated AsmJit README.md 2025-10-05 17:52:40 +02:00
kobalicek
c0d23a11e5 Removed extra semicolons in x86/aarch64 emitters 2025-10-05 17:41:57 +02:00
kobalicek
cdc4eacbb1 [abi] Added more functionality to ujit
* Renamed round to round_even
  * Added round_half_up intrinsic
  * Added floating-point mod
  * Added a scalar version of floating-point abs and neg
  * Added a behavior enum to specify how float to int conversion
    handles out-of-range and NaN cases
  * Updated some APX stuff in instruction database
2025-10-05 17:31:24 +02:00
kobalicek
32b5f78700 Minor C++17 modernization
* Inspired by the one of the pull requests (#483)
  * Use std::make_unique to make a unique pointer (tests only)
  * Use override instead of virtual to override a virtual member
    function
2025-09-08 09:41:31 +02:00
Golubev Alexander
13eb299dda [bug] Install missing header: core/span.h (cmake)
* The header was added recently, but it was missing in cmake, thus it was not installed.
2025-09-08 09:28:22 +02:00
kobalicek
e14b42a63a [bug] Fixed not rewriting injected code by Compiler
* The bug was introduced by the latest changes. The rewriter
    only interated basic blocks, but not possibly injected code
    that converts one register state into another via a small
    code sequence injected at the end of the function.

  * Resolved some static analysis problems. The reported
    use-after-free was a false positive constructing by
    contradicting conditions - so new asserts guard this.
2025-09-06 23:40:53 +02:00
kobalicek
f0870474a2 [doc] Minor documentation update 2025-09-06 13:50:26 +02:00
kobalicek
7596c6d035 [abi] AsmJit v1.18 - performance and memory footprint improvements
* Refactored the whole codebase to use snake_case convention to
    name functions and variables, including member variables.
    Class naming is unchanged and each starts with upper-case
    character. The intention of this change is to make the source
    code more readable and consistent across multiple projects
    where AsmJit is currently used.

  * Refactored support.h to make it more shareable across projects.

  * x86::Vec now inherits from UniVec

  * minor changes in JitAllocator and WriteScope in order to make
    the size of WriteScope smaller

  * added ZoneStatistics and Zone::statistics() getter

  * improved x86::EmitHelper to use tables instead of choose() and
    other mechanisms to pick between SSE and AVX instructions

  * Refactored the whole codebase to use snake_case convention for
    for functions names, function parameter names, struct members,
    and variables

  * Added a non-owning asmjit::Span<T> type and use into public API
    to hide the usage of ZoneVector in CodeHolder, Builder, and
    Compiler. Users now only get Span (with data and size), which
    doesn't require users to know about ZoneVector

  * Removed RAWorkId from RATiedReg in favor of RAWorkReg*

  * Removed GEN from LiveInfo as it's not needed by CFG construction
    to save memory (GEN was merged with LIVE-IN bits). The remaining
    LIVE-IN, LIVE-OUT, and KILL bits are enough, however KILL bits may
    be removed in the future as KILL bits are not needed after LIVE-IN
    and LIVE-OUT converged

  * Optimized the representation of LIVE-IN, LIVE-OUT, and KILL bits
    per block. Now only registers that live across multiple basic
    blocks are included here, which means that virtual registers that
    only live in a single block are not included and won't be overhead
    during liveness analysis. This optimization alone can make liveness
    analysis 90% faster depending on the code generated (more virtual
    registers that only live in a single basic block -> more gains)

  * Optimized building liveness information bits per block. The new
    code uses an optimized algorithm to prevent too many traversals
    and uses a more optimized code for a case in which not too many
    registers are used (it avoids array operations if the number of
    all virtual registers within the function fits a single BitWord)

  * Optimized code that computes which virtual register is only used
    in a single basic block - this aims to optimize register allocator
    in the future by using a designed code path for allocating regs
    only used in a single basic block

  * Reduced the information required for each live-span, which is used
    by bin-packing. Now the struct is 8 bytes, which is good for a lot
    of optimizations C++ compiler can do

  * Added UniCompiler (ujit) which can be used to share code paths
    between X86, X86_64, and AArch64 code generation (experimental).
2025-09-06 13:44:34 +02:00
kobalicek
a3199e8857 [bug] Fixed missing control flow in some JCCs (x86::Compiler) 2025-06-28 22:43:54 +02:00
kobalicek
964e7c20b5 [abi] API cleanup and documentation fixes
* Added first node to Zone so the reset is simpler
  * Added x86::Xmm/Ymm/Zmm deprecated aliases of x86::Vec
    to make user code not break when using these deprecated
    types
  * Documentation fixes and clarifications
2025-06-16 10:13:04 +02:00
kobalicek
2ff454d415 [abi] AsmJit v1.17 - cumulative & breaking changes
* Reworked register operands - all vector registers are now
    platform::Vec deriving from UniVec (universal vector operand),
    additionally, there is no platform::Reg, instead asmjit::Reg
    provides all necessary features to make it a base register for
    each target architecture
  * Reworked casting between registers - now architecture agnostic
    names are preferred - use Gp32 instead of Gpd or GpW, Gp64
    instead of Gpq and GpX, etc...
  * Reworked vector registers and their names - architecture
    agnostic naming is now preferred Vec32, Vec64, Vec128, etc...
  * Reworked naming conventions used across AsmJit - for clarity
    Identifiers are now prefixed with the type, like sectionId(),
    labelId(), etc...
  * Reworked how Zone and ZoneAllocator are used across AsmJit,
    prefering Zone in most cases and ZoneAllocator only for
    containers - this change alone achieves around 5% better
    performance of Builder and Compiler
  * Reworked LabelEntry - decreased the size of the base entry
    to 16 bytes for anonymous and unnamed labels. Avoided an
    indirection when using labelEntries() - LabelEntry is now
    a value and not a pointer
  * Renamed LabelLink to Fixup
  * Added a new header <asmjit/host.h> which would include
    <asmjit/core.h> + target tools for the host architecture,
    if enabled and supported
  * Added new AArch64 instructions (BTI, CSSC, CHKFEAT)
  * Added a mvn_ alternative of mvn instruction (fix for Windows
    ARM64 SDK)
  * Added more AArch64 CPU features to CpuInfo
  * Added better support for Apple CPU detection (Apple M3, M4)
  * Added a new benchmarking tool asmjit_bench_overhead, which
    benchmarks the overhead of CodeHolder::init()/reset() and
    creating/attaching emitters to it. Thanks to the benchmark the
    most common code-paths were optimized
  * Added a new benchmarking tool asmjit_bench_regalloc, which
    aims to benchmark the cost and complexity of register allocation.
  * Renamed asmjit_test_perf to asmjit_bench_codegen to make it
    clear what is a test and what is a benchmark
2025-06-15 16:45:37 +02:00
qubka
f8e7f67b01 [abi] Add support for marking registers as unavailable in FuncFrame (#477) 2025-06-05 14:49:55 +02:00
kobalicek
8315855c64 [abi] Changed signature of Xmm regs to Vec regs in x86 emitter
The purpose of this change is to minimize casting when using Vec
as a type for all vector registers in user code. In these cases
AsmJit required to cast Vec to Xmm to call emitter methods. After
this change it's no longer necessary to do that, which simplifies
user code.
2025-06-01 09:01:37 +02:00
kobalicek
408476b0b3 [ci] Updated CI to not use a deprecated windows image 2025-05-30 18:50:31 +02:00
kobalicek
7dd20bf239 Improved move semantics of ZoneVector 2025-05-30 16:42:21 +02:00
kobalicek
9f6ef3a2f3 Simplified unavailable register handing in RAPass (Compiler) 2025-05-30 15:30:14 +02:00
kobalicek
c993fd9bfc Reworked asmjit_environment_info 2025-05-30 15:07:32 +02:00
kobalicek
ea9ae96653 Added asmjit_environment_info executable 2025-05-25 18:05:56 +02:00
kobalicek
2e2866d481 Minor update of X86 ISA DB
* Instructions wr[u]ss[d|q] no longer accept register as the first
    operand (that was a bug to accept this form)
  * Moved APX version of legacy instructions closer so they are next
    to each other
2025-05-25 08:19:44 +02:00
kobalicek
356dddbc55 [abi] Switched to C++17 2025-05-24 19:21:17 +02:00
kobalicek
cecc73f297 [doc] Minor documentation update 2025-05-10 15:23:57 +02:00
kobalicek
6c9a6b2454 [abi] Reorganized instruction DB, removed deprecated instructions
* Removed AVX512_ER, AVX512_PF, AVX512_4FMAPS, and AVX512_4VNNIW
    extensions and corresponding instructions (these were never
    advertised by any x86 CPU and were only used by Xeon Phi acc.,
    which AsmJit never supported)
  * Removed CPU extensions HLE, MPX, and TSX
  * Kept extension RTM, which is only for backward compatibility to
    recognize instructions, but it's no longer checked by CpuInfo as
    it's been deprecated together with HLE and MPX
  * The xtest instruction now reports it requires RTM
  * Reorganized x86 extensions a bit - they are now reordered to group
    them by category, preparing for the future where extension IDs will
    be always added after existing records for ABI compatibility
  * Instruction vcvtneps2bf16 no longer accepts form without an explicit
    memory operand size
  * Removed aliased instructions in CMOVcc, Jcc, And SETcc categories,
    now there is only a single instruction id for all aliased instructions.
  * Added a new feature to always show instruction aliases in Logger, which
    includes formatting instructio nodes (Builder, Compiler)

Instruction DB-only updates (not applied to C++ yet):

  * AsmJit DB from now uses the same license as AsmJit (Zlib) and
    no longer applies dual licensing (Zlib and Public Domain)
  * Added support for aggregated instruction definitions in
    x86 instruction database, which should simplify the maintenance
    and reduce bugs (also the syntax is comparable to descriptions
    used by Intel APX instruction manuals)
  * Added support for APX instructions and new features
  * Added support for AVX10.1 and AVX10.2 instructions (both new
    instructions and new encodings of existing instructions)
  * Added support for MOVRS instructions
  * Added support for KL instructions (loadiwkey)
  * Added support for AESKLE instructions
  * Added support for AESKLEWIDE_KL instructions
  * Added support for AMX_[AVX512|MOVRS|FP8|TF32|TRANSPOSE]
  * NOTE: None of the instruction additions is currently used by
    Asmjit, it's a pure database update that needs more work to
    make all the instructions available in future AsmJit
2025-05-10 15:04:11 +02:00
kobalicek
9eb6edbf71 Allow users to specify a home register hint (compiler) 2025-05-08 07:03:09 +02:00
kobalicek
4cd9198a6c Improved register allocation of consecutive register in some cases
* The implementation tries to detect whether a virtual register
    only lives in a single basic block and then uses a move approach
    instead of spill/alloc when reallocating
  * Additionally, the implementation now improves the use of scratch
    registers during function arguments allocation - scratch is only
    reserved when it's actually needed
2025-04-20 18:44:52 +02:00
kobalicek
e8c8e2e48a Prefer reassignment over spill in some cases (Compiler)
Changes the reassognment decision used by local register allocator.
When the virtual register is killed by the instruction (or has a
separate output slot) it would be reassigned instead of spilled.
This should be a minor improvement for certain border cases.
2025-03-30 10:32:01 +02:00
kobalicek
67c7fadba3 [bug] Fixed accessors to out flags in RATiedReg (Compiler) 2025-03-29 13:07:06 +01:00
kobalicek
4111caeca4 [abi] Added support for pushw imm (X86/X64) 2025-03-09 19:27:12 +01:00
kobalicek
04d05cdc2f Added support for NetBSD CPUID detection (AArch64) 2025-03-09 12:10:18 +01:00
kobalicek
342b57f0f6 [abi] Improved Zone to use adaptive size of blocks 2025-03-08 15:37:25 +01:00
kobalicek
029075b84b Minor things
* Added missing noexcept to some helper functions
  * Removed Linux images from workflows that will be out of support
    soon (ubuntu 20.04)
2025-02-12 16:17:09 +01:00
kobalicek
58c585f003 [bug] Don't negate a signed number (UB fix)
* Fixes a potential UB in number to string conversion because of
    a possible undefined behavior caused by -int64_t(a) code. The
    fix replaces the code with Support::neg() function, which was
    designed for exactly this.
2025-02-12 15:55:09 +01:00
kobalicek
e1b20711cc Little maintenance update
* Little documentation fixes
  * Added virtual destructor to emit helpers to silence warnings of
    some compilers (it's totally useless change though as it changes
    nothing in reality - emit helpers are allocated mostly on stack)
2025-01-23 00:05:20 +01:00
kobalicek
cfc9f813cc [bug] Fixed RW information of ldp instruction (aarch64) 2024-12-16 22:17:48 +01:00
kobalicek
976f8ed35a [bug] Properly use vpternlog write-only cases (x86::Compiler) 2024-12-15 18:50:15 +01:00
kobalicek
7bed2b0e14 [bug] Fixed tablegen to properly add implicit zeroing flag
It was ignoring the flag and as a result the instruction such as

  vpcmpeqd k1 {k2}, zmm1, zmm2

would have k1 set as Read/Write, which is incorrect.
2024-11-22 20:26:31 +01:00
kobalicek
0b3aec39d1 [bug] Fixed RW info of VPERMT2B and VPERMI2B instructions (x86)
* The first operand (destination) is read/write and not overwrite

In addition, added the following new AArch64 instructions to DB:

  * CPA extensions (DB-only)
  * FAMINMAX extensions (DB-only)
  * FP8 ASIMD extensions (DB-only)
  * LUT extensions (DB-only)
2024-11-16 00:32:59 +01:00
kobalicek
d28c4be2e7 [bug] Properly validate ADD[S]/SUB[S]/CMP/CMN with extend option
Extend option in ADD, ADDS, SUB, SUBS, CMP, and CMN instructions
doesn't always use the same second register type. For example when
extending from a BYTE the second source register must be W and not
X.

This change makes sure that the assembler accepts the correct
combination and refuses the incorrect one.

IMPORTANT: Although this is not an ABI change, the new behavior
can break AArch64 code that used the incorrect signatures.
2024-11-15 22:02:48 +01:00
kobalicek
439febb13a [bug] Fixed RW information of pre/post indexing on aarch64 2024-11-10 16:44:56 +01:00
kobalicek
f1096428b8 [bug] Fixed JitAllocator::reset() when it's empty 2024-10-25 09:26:00 +02:00
kobalicek
e7239626b8 Updated minimum cmake version to 3.19
* The latest cmake versions started showing warnings about the
    minimum version supported as there are possibly some breaking
    changes not affecting us
  * Reworked some bits in CMakeLists.txt to take advantage of the
    raised version
  * Removed the use of policies that are now enabled by cmake by
    default
  * Removed deprecated build options
2024-10-21 00:20:22 +02:00
Xingyu Xie
514a89f4c4 Changed a64::Inst to a namespace instead of struct (#449) 2024-10-16 18:58:47 +02:00
Xing Guo
2e93826348 Fixed a typo: Threat -> Treat. (#446) 2024-09-16 17:20:11 +02:00