Commit Graph

562 Commits

Author SHA1 Message Date
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
Tzvetan Mikov
67847228e7 Const correctness of ZoneStackBase::Block::data()
The C-style cast was discarding const and casting to `(uint8_t *)` at
the same time, causing a warning. Add const and non-const versions of
the method.
2024-08-26 07:36:25 +02:00
kobalicek
9b28f627a5 [ci] Updated macos configuration (GCC bumbed to 14) 2024-08-26 07:24:01 +02:00
kobalicek
b4a2976458 [db] Removed a duplicate entry vmmcall from x86 database 2024-08-25 20:52:24 +02:00
kobalicek
330aa64386 Avoid unused function warnings when building for Windows/ARM64 2024-07-08 11:53:33 +02:00
kobalicek
ffac9f36fb [bug] Deprecate BaseMem::setSize()
BaseMem::setSize() should not be used anymore as the only memory
operand that understands size is x86::Mem, which makes it x86
specific.

The reason is that other architectures require more bits, so for
example arm::Mem uses the storage used by x86 size for storing
other information such as offset mode, and possibly more information
will be needed in the future to support AArch64 SVE or SME, etc...

At the moment BaseMem::setSize() has been deprecated, so code using
it would still compile, but with a warning. It will be removed in
the future though.
2024-06-28 22:07:13 +02:00
kobalicek
062e69ca81 [Bug] Fixed a string buffer growing strategy
For some reason the growing strategy of asmjit::String was too
aggressive, basically reaching the maximum doubling capacity too
fast (after the first reallocation). This code adapts the current
vector growing strategy to be used also by asmjit::String, which
doubles the capacity until a threshold is reached and then grows
linearly.
2024-06-22 10:39:33 +02:00
kobalicek
f5df7a2b1b Improved the performance of bin-packing (Compiler) (fixes #440)
During bin-packing, a single function nonOverlappingUnionOf() is
called many times to calculate a union of one live ranges with
another. Before this change it used ZoneVector::reserve() to make
sure that there is enough space for the union, however, in some
cases this is not ideal in case that the union grows every time
the function is called. In that case it's reallocating the vector
many times, which affects performance.

Instead of calling reserve(), a new function growingReserve() was
added to tell the vector to grow when it needs to reallocate.

In addition, this change fixes some documentation regarding the
use of JitAllocator (Explicit Code Relocation section in core.h).
2024-06-13 13:18:05 +02:00
kobalicek
4a61c23ab6 Enable try mode in RA local's switchToAssignment()
This feature has been disabled for a long time so
it could be tested properly, but production didn't
reveal any issues.

When try mode is enabled the RA will try to allocate
the reassignment first to avoid possibly having to
emit code in a separate block (try mode basically
"tries" to emit code before a branch and not as a
consequence of it).
2024-06-05 07:36:13 +02:00
kobalicek
63e7d060ac Support C++20 without warnings
C++20 deprecates mixing enums of different types (comparisons, etc...),
however, we use enums instea of "static constexpr" in classes to define
constants, because otherwise we would have to give such constants
storage - this is required for up to C++14 and since we still support
C++11 we have to keep using enums...
2024-06-05 00:33:15 +02:00
kobalicek
d6c5be2212 Don't leave a trailing white-space in cpu brand name 2024-05-31 18:48:26 +02:00
kobalicek
55c5d6cef5 [Bug] Fixed pblendvb in x86 instruction DB (#436) 2024-05-21 09:24:09 +02:00
kobalicek
b9c8b5399f [Bug] Fixed MOV reg->mem instruction rewriting (Compiler)
The problem is that the rewriter must also rewrite an instruction
ID in case that it's a [K|V]MOV[B|W|D|Q] instruction that moves
from either K or SIMD register to GP register. when such instruction
is rewritten in a way that it ends up as "xMOVx GP, [MEM]" it would
be invalid if it's not changed to a general purpose MOV.

The problem can only happen in case that the compiler spills a
virtual register, which is then moved to a scalar register.

In addition, checks were added to MOVD|MOVQ to ensure that when an
invalid instruction is emitted it's not ignored as it used to be.
2024-05-19 17:51:16 +02:00
kobalicek
594576485b [Bug] Fixed a reverse iterator (not used anywhere atm) 2024-05-16 22:11:28 +02:00
kobalicek
2110882ef2 [CI] Updated workflow to run on AArch64 runners 2024-05-16 22:11:18 +02:00
kobalicek
d401bdb580 Added gpz() and gpSignature() to all emitters 2024-05-16 22:11:10 +02:00
kobalicek
e5d7c0bd5d Avoid using memcpy(this) to prevent possible warnings 2024-03-24 23:55:38 +01:00