Commit Graph

422 Commits

Author SHA1 Message Date
Reality
3906ff11ef [A64/Vector] Scope VMX FPCR in vector helpers
Save and restore FPCR around each VMX FP operation so vector code
doesn't leak FPCR state into scalar paths. Drop the DN bit so NaN
propagation fixup can inspect original payloads.
2026-03-23 10:39:50 +09:00
Reality
5b0b15676c [CPU/A64] Avoid static init order in A64 sequences
The A64 sequence table is populated by registration statics spread across
multiple translation units. Keeping the backing map as a global object makes
registration depend on cross-TU initialization order and can hit the table
before it has been constructed.

Move the sequence table behind a function-local static so sequence
registration is safe regardless of which unit initializes first.
2026-03-23 00:42:59 +09:00
Herman S.
883c2030d0 [ARM64] Initial commit for arm64 backend
Based entirely off existing xbyak x86 implementation and available
tests. Still needs a lot of optimization and testing on non-Windows
platforms.

So far passes all tests and boots at least some games on Windows.
2026-03-22 15:57:37 +09:00
Herman S.
bc37068f90 [x64] Fix AVX-512 VECTOR_DENORMFLUSH merge-masking & FpRangeSign values
Copy src1 into dest before the masked vrangeps so that unmasked lanes
(normal/inf/NaN values) are preserved via merge-masking. Previously,
when the register allocator assigned different physical registers for
dest and src1, unmasked lanes would retain stale values from dest.

Tested with Intel SDE and AVX-512 cpu to verify.

Also shift unused FpRangeSign constants into bits [3:2] of the vrangeps
immediate, matching the Intel encoding. Only one used in the code was 0
so it was already correct by accident but using the others in the future
would produce incorrect results.
2026-03-21 15:16:59 +09:00
Wunkolo
7801d53842 [x64] Add AVX512 optimization for VECTOR_DENORMFLUSH
Use the `vptestnmd`-instruction to quickly test if the exponent bits of
each element is zero and put these results into a mask register. This
mask register can then be used to write `+0.0` or `-0.0` values
depending on the original value's sign-bit.

A masked `vrangeps` instruction is used to move zero-values into the effected
elements while preserving the sign-bit without having to touch memory.
2026-03-20 22:26:17 +01:00
Wunkolo
b1983bab68 [x64] Add GFNI optimization for single-byte vector splats
Use the `vgf2p8affineqb` instruction to splat byte-values across a whole
register without having to touch memory.
2026-03-20 21:34:35 +01:00
Herman S.
2713e85042 [Memory/x64] Add optional inline MMIO range checks for I32 loads/stores
When emit_inline_mmio_checks is enabled, the x64 backend emits
explicit address range checks (0x7FC00000–0x7FFFFFFF) before I32 memory
ops and routes hits through MMIOAwareLoad/Store directly, avoiding the
cost of trapping access violations for MMIO regions. The MMIO page
commit in AddVirtualMappedRange is skipped in this mode since accesses
are handled inline rather than via exception.
2026-03-21 01:30:31 +09:00
Herman S.
b8912a4c79 [CPU/Backend] Refactor shared backend logic into CRTP base 2026-03-17 13:31:15 +09:00
Herman S.
5e636ac335 [x64] Implement missing byte-swap store/load paths
Fill in all unimplemented LOAD_STORE_BYTE_SWAP code paths in the x64
backend that previously hit assert_false or assert_always and add
tests
2026-03-16 02:52:26 +09:00
Gliniak
10f66a47f6 Revert "place locals on backend pages"
This reverts commit fe7dc26e3f.

Reason:
- It gives no real performance impact, but introduces issues
2026-03-11 19:50:32 +01:00
Herman S.
b24ea8ef99 [CPU/XThread] Add DWARF .eh_frame unwind info for JIT code on Linux
Generate per-function CIE+FDE records and register them via
__register_frame so the C++ exception unwinder can propagate through
JIT frames. Replace setjmp/longjmp fiber reentry with throw/catch
on Linux to ensure destructors and RAII guards run during fiber
stack switches.
2026-03-11 00:02:34 +09:00
Herman S.
341a735142 [x64] Fix vector mask issue and add missing tests 2026-03-09 14:15:14 +09:00
Herman S.
f41ea1296b [x64/Debug] Fix TrapDebugPrint to properly terminate string 2026-03-09 14:15:14 +09:00
Herman S.
bf6e1a81eb [Posix] Fix DeallocFixed crashes / memory leaks
BaseHeap::Dispose() walks the page table and calls
DeallocFixed(addr, 0, kRelease) for every allocated page region.
These addresses are within file-backed view mappings (i.e. guest memory).
On Windows, VirtualFree on file-mapped pages silently returns FALSE.
On POSIX, the code hit assert_always() and crashed. Changed to return false
to match Windows behavior.

Memory leaks from munmap(addr, 0):

Callers passed length=0 to DeallocFixed(kRelease). On Windows this works because
VirtualFree(addr, 0, MEM_RELEASE) means "release the entire region" — Windows
ignores the length parameter for MEM_RELEASE and always frees the whole
allocation. On POSIX, munmap(addr, 0) fails with EINVAL, so the memory was
silently leaked every time.
2026-03-09 13:43:56 +09:00
Herman S.
71c5702ee8 [Build] Convert build system to raw cmake and remove premake layer 2026-03-04 17:37:36 +09:00
Herman S.
f2b9b57e18 Reapply "[x64] Zero extend on mov to 8bit register"
This reverts commit 3a6f63f34f.

(The issue wasn't xbyak but rather cherrypick order wrt to
other commits, xbyak upgrade was a red herring)
2026-02-14 02:23:58 +09:00
Herman S.
f5afafaec0 Ensure stack allocations maintain 16-byte alignment for AVX instructions 2026-02-14 02:02:40 +09:00
Herman S.
7e66a85f43 [x64/Linux] More return __m128i by value in xmm0 rather than pointer 2026-02-14 01:38:53 +09:00
Herman S.
0921a4fb04 [x64/Linux] Return __m128i by value in xmm0 rather than a pointer 2026-02-14 01:35:12 +09:00
Herman S.
2abf91603e [x64/Linux] Ensure EmitHostToGuestThunk saves rsi 2026-02-14 01:34:59 +09:00
Herman S.
11815400cd [CPU] Fix f16 pack rounding and SHORT_2 test input
Add round-to-nearest-even to the fast float16 pack path by folding a
0xFFF rounding bias into XMMF16PackLCPI0 and extracting bit 13 of the
source as the tie-breaker, matching the software fallback behavior.

Fix PACK_SHORT_2 test to use pre-biased float input (0x40400000 = 3.0)
as the hardware expects, rather than raw 0.0f which is out of range.
2026-02-14 00:48:16 +09:00
Herman S.
bb70e5c651 [CPU] Fix incorrect all_same detection in constant vector shift paths
The loop conditions `n < 8 - n` and `n < 4 - n` terminated early,
only checking the first half of elements. This caused EmitInt16 and
EmitInt32 to incorrectly take the uniform shift path when trailing
elements had different shift amounts.

Resolves potential issues in SHL, SHR, and SHA.
2026-02-14 00:35:09 +09:00
Herman S.
10e8224a63 [CPU] Use RAII lock_guard in GuestTrampolineGroup 2026-02-14 00:17:45 +09:00
Herman S.
dad5f327bf [CPU] Fix off by one in bsearch 2026-02-13 23:33:40 +09:00
Herman S.
3a6f63f34f Revert "[x64] Zero extend on mov to 8bit register"
This reverts commit 88b0aea272.

(It needs to be applied after xbyak update)
2026-02-13 23:13:07 +09:00
Herman S.
1182f9d73d [x64] Add software fallback for PACK_FLOAT16_4
Current implementation has an off by 1 in rounding, should
round up to even but doesn't. Need to figure out how to implement
it properly so just leaving the software version here for later
verification.
2026-02-13 21:48:42 +09:00
Herman S.
374ec3634e [x64] Implement f32 arithmetic and tests
Probably not needed but doesn't hurt to be complete
2026-02-13 21:48:01 +09:00
Herman S.
fdb32b909f [x64] Remove AVX512 optimization for vrefp
The precision is too low so it's more trouble than it's worth.
2026-02-13 21:13:39 +09:00
Herman S.
77e320f79a [x64] Fix AVX2 optimization path for VECTOR_SHL_V128
Ensure the optimized path matches the fallback behavior
2026-02-13 20:40:48 +09:00
Herman S.
b3a131698c [x64] Fix AVX512 optimization path for vadduws 2026-02-13 19:57:44 +09:00
Herman S.
70c1092195 [x64] Fix AVX-512 vctuxs NaN handling
(using ordered comparison predicate)
2026-02-13 19:31:08 +09:00
Herman S.
f95ebb9c55 [x64] Fix mismatched operand sizes in CNTLZ fallback 2026-02-13 19:29:21 +09:00
Herman S.
88b0aea272 [x64] Zero extend on mov to 8bit register 2026-02-13 17:20:31 +09:00
Herman S.
15f61a1a10 [x64] Fix vector mask issue and add missing tests 2026-02-13 17:07:03 +09:00
Herman S.
09a15fbedc [Testing] Get tests running (dirty hack for linux) 2026-02-13 13:32:39 +09:00
Gliniak
14c2814654 [CPU] Fixed bug in VECTOR_SHL_V128 implementation
- For EmitInt8 there was missing check for & 7 which was causing graphical glitches in movies

- There is probably similar bug in 16/32 version, but that's for another commit
2026-02-11 22:41:36 +01:00
Gliniak
702fbc8adb [CPU/X64] Fixed random on boot crashes related to rsp not being aligned
vmovaps returns failure if it encounters unaligned memory.
Alignemnt must be done on 16 bytes, but sometimes rsp ends with 8
2025-11-09 21:59:46 +01:00
Gliniak
f1d444dd99 [CPU/X64] Added const path for indirect call
This prevents having false-positive logs about invalid handling

This case should only happen on deadend paths of code like calling 0
2025-11-01 19:18:45 +01:00
Gliniak
1ad35e4d61 [CPU/X64] Added missing const path to Emit8_IN_16 2025-11-01 17:39:10 +01:00
Gliniak
906c0b8fa6 [CPU] Fixed issue with const path in AVX512 vector left rotate.
- Added logging in case of similar issues
2025-10-28 17:43:21 +01:00
Margen67
25d6f8269a [premake] Cleanup 2025-07-27 02:46:43 -07:00
Margen67
3eef564ff8 [format] Require EOF newline 2025-07-19 14:42:21 -07:00
Margen67
4cb783bf22 Header cleanup 2025-07-19 14:42:21 -07:00
Xphalnos
47f327e848 [Misc] Replaced const with constexpr where possible 2025-04-08 19:32:17 +02:00
Xphalnos
7479ccc292 [Misc] Fix Some Warnings on Clang Build with Windows + Adding constexpr 2025-03-27 17:52:18 +01:00
Xphalnos
5f918ef28d [Misc] Replaced const with constexpr where possible 2025-03-25 19:50:37 +01:00
nikolay-kyosev
9a0ed48168 A fix for the release build crash on linux. 2025-01-27 18:21:14 +01:00
Marco Rodolfi
8d841693ff [cpu] Fix System-V ABI guest to host and host to guest thunk emitters for Linux
Upstream changes made from xenia-project#1339 and xenia-project#2228 back to canary builds. This fixes various emulation crashes caused from different calling conventions on System-V ABI platforms compared to Windows standard.
2025-01-19 16:36:52 +01:00
The-Little-Wolf
b9be601fad [CPU/x64_sequences] - MAX_V128 fixs
- change e.vandps to e.vorps in MAX_V128 to ensure NaN instructions matches real hardware
2025-01-18 20:00:56 +01:00
Gliniak
3ac98ebfba [Static Analysis] Resolved some issues mentioned in Alexandr-u report 2024-11-02 19:08:34 +01:00