Commit Graph

539 Commits

Author SHA1 Message Date
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
kobalicek
268bce7952 Minor change making static analysis happy
* clang-18 on now enabled on CI and used for static analysis
  * return error when X86Internal_setupSaveRestoreInfo() is called
    with invalid register group. Should never happen though.
2024-03-09 11:53:14 +01:00
kobalicek
7ff9c2a545 [CI] Minor changes in CMakeLists.txt, disable arm/v7 because of CI 2024-03-09 08:26:46 +01:00
kobalicek
3ca5c186bf [Bug] Fixed RW info of sub and subs instructions (AArch64) 2024-02-23 22:09:50 +01:00
kobalicek
4e50d8b319 Allocate preserved registers last
Register allocator now tries to allocate preserved registers last,
improving prolog/epilog sequence especially on AArch64, which has
calling conventions that require to preserve both GP and vector
registers.
2024-02-16 21:58:20 +01:00
kobalicek
d82e478fb8 Use atomics in CpuInfo::host()
The code was fine, however, some compilers may be able to optimize
it and in some border cases the features returned would be all zero.
This prevents such behavior.
2024-02-10 22:44:02 +01:00
kobalicek
9e39b1e814 Added basic abstractions to CondCode, Gp, and Vec
* Each architecture now provides r32() and r64() functions for
    register casting
  * Each architecture now provides v128() function for register
    casting, returning just Vec to make writing cross platform
    code easier
  * Added some basic condition code abstractions so it can be used
    interchangeably across architectures
  * Added back unlicense to asmjit database (now it's dual licensed)
2024-02-10 16:43:40 +01:00
kobalicek
a63d41e80b Added support for mach_vm_remap() for dual mapping
mach_vm_remap() allows to create a dual mapping without having to
use a file descriptor, which has to open a file or shm memory. The
problem is that the recent macos version started displaying a popup
message when such file is opened and that annoyed a lot of users.

Thus, the initial code-path is no longer used, and mach_vm_remap()
is used instead.

This change only applies for x86 macs. Apple silicon doesn't allow
dual mapping and instead uses MAP_JIT.
2024-01-25 22:23:13 +01:00
kobalicek
bfa0bf690c Workaround for issue #427
MSVC incorrectly auto-vectorizes a loop that is used in liveness
analysis. Due to this bug the result is wrong, which then affects
how registers are allocated. This workarounds a C++ compiler bug.
2024-01-23 23:46:52 +01:00
kobalicek
03b784c9fe [Doc] Added CONTRIBUTING.md and issue templates; updated docs 2024-01-22 00:25:23 +01:00
kobalicek
b4b2ff3109 Hardened runtime detection enhancements
A new HardenedRuntimeFlags::kDualMapping flag has been introduced to
detect whether dual mapping is provided by the target platform. This
flag can be set even when hardened runtime is not enforced in cases,
in which dual mapping is not available.

This fixes running unit tests on Apple hardware where dual mapping
is not available, but MAP_JIT is (AArch64 hardware).

Additionally, this changeset fixes using -msse2 flag on non-x86
targets, where compiler don't mind "-msse2" flag, but warns about
it. This makes the build 100% clean.
2024-01-20 12:23:11 +01:00
kobalicek
8210620f3e [Bug] Fixed AArch64 calling convention handling on Apple platforms
The standard AArch64 calling convention specifies that the minimum
size of each argument passed via stack is 8 bytes. However, Apple
doesn't follow this convention and only aligns stack to 8 bytes
when an argument has 8 bytes or more. This makes it incompatible
with the standard calling convention as two consecutive 32-bit
integers would occupy only 8 bytes instead of 16 when passed via
stack.
2024-01-20 09:30:00 +01:00
kobalicek
118ae6ced1 [Bug] Fixed sign and zero extension in Function API (x86)
The problem was that the sign/zero extension was not working with
TypeIds, but it was working with register IDs, when emitted. Thus,
even when TypeId was uint8, for example, the register could be
uint32, so the final instruction emitted was 'movzx eax, eax', for
example, which was wrong.
2024-01-13 14:31:35 +01:00
kobalicek
c620b113ad Added API to set BaseMem base+index types 2024-01-07 21:31:56 +01:00
kobalicek
1cf7ee03ed Improved compile times by avoiding <iterator> header 2024-01-06 23:39:33 +01:00
kobalicek
33ef5fded9 [Doc] Mostly documentation update 2024-01-03 17:03:06 +01:00
kobalicek
3772c447ca [ABI] Accumulated API/ABI changes
* Renamed all eq() methods to equals() (consistency) (ABI)
  * Reorganized some X86 instructions in X86 database
  * Properly detect RISC-V CPU at compile time (Environment)
  * Removed CallConvId::kNone in favor of defaulting to kCDecl (ABI)
  * CallConvId::kHost is now alias to CallConvId::kCDecl (ABI)
  * Added FloatABI to Environment to disginguish between softfloat
    and hardfloat
  * Added more AArch64 CPU features and their detection (ABI)
  * Because of CallConvId changes it's now possible to run
    compiler tests on 32-bit ARM (fixes a bug in test cases)
  * Added QEMU to CI build matrix to test different architectures
2024-01-01 20:15:00 +01:00
kobalicek
a465fe71ab [ABI] Reworked FuncSignature 2023-12-27 21:17:45 +01:00
kobalicek
b0638ede77 [Bug] Fixed CpuInfo not reporting hw thread count on non-windows platforms 2023-12-27 18:11:49 +01:00
kobalicek
5ce45e0356 [ABI] Renamed a64::Vec::ElementType to a64::VecElementType 2023-12-27 13:04:27 +01:00
kobalicek
b4ad286890 [Doc] Documentation fixes 2023-12-27 02:43:41 +01:00
kobalicek
f27334eaf8 [ABI] Moved vector operand from arm to a64 namespace
This is unfortunately API/ABI break, which cannot be deprecated
instead of removed as arm::Vec would collide with a64::Vec if present.

This is a preparetion for ARM32 tooling.
2023-12-27 02:26:36 +01:00
kobalicek
b25df5554d [ABI] Updated instruction DB, operands, and minor API changes
This changeset contains an updated instruction database that brings
ARM32 instructions for the first time. It also updates instruction
database tooling especially for ARM64, which will also be used by
ARM32 generator.

Additionally, new operan has been added, which represents a register
list as used by ARM32 instruction set.

Other minor changes are related to ARM - some stuff had to be moved
to a64 namespace from arm namespace as it's incompatible between
32-bit and 64-bit ISA.
2023-12-26 23:28:40 +01:00
kobalicek
13bd440022 [ABI] Added prfm instruction (AArch64) 2023-12-26 19:05:05 +01:00