Paulo Matos
5267cde60e
Whole-tree reformat with clang-format-19
2025-07-17 08:10:00 +02:00
Ryan Houdek
e36a64ecc0
Merge pull request #4681 from Sonicadvance1/i_dislike_tuple_2
...
FEXCore/OpcodeDispatcher: Removes tuple usage for Dispatch tables
2025-07-16 14:23:18 -07:00
Ryan Houdek
82be09b6a3
FEXCore/OpcodeDispatcher: Removes tuple usage for Dispatch tables
...
NFC
2025-07-16 13:57:16 -07:00
LC
e0ca04bfec
Merge pull request #4684 from Sonicadvance1/spurious_syscall_crash
...
FEXCore/OpcodeDispatcher: Fix a spurious crash that can occur with multiblock
2025-07-15 21:44:51 -04:00
Ryan Houdek
dfe3b4502a
FEXCore/OpcodeDispatcher: Fix a spurious crash that can occur with multiblock
...
If multiblock discovers a codepath with an `int 0x80` then it would
crash the emulator even if it never gets executed. Ensure that this
ERROR_AND_DIE_FMT instead just gets handled as an UnhandledOp to ensure
the Core early terminates the block.
Found by having steamwebhelper spuriously crash when it hit this.
Adds a simple unittest to ensure discovery doesn't break again.
2025-07-15 17:43:16 -07:00
Ryan Houdek
219ab44a82
FEXCore: Implement a mostly NOP implementation of waitpkg
...
Part of waitpkg is the TPAUSE instruction. This instruction gives an
RDTSC deadline to go in to a low power sleep mode with the CPU.
Semantically we can't implement umonitor and umwait with ARM's exclusive
monitor implementation, but a nop implementation is sane. Just need to
make sure to clear the pre-req flags.
This lowers power consumption of UE5 games since their job handler now
goes to a tpause based implementation instead of a `pause` spinloop
implementation.
2025-07-15 16:13:29 -07:00
Ryan Houdek
43bba77840
FEXCore: Implement support for NX bit.
...
Long time coming but thanks to bylaw's changes in #4474 , this is now
trivial to implement.
Fixes #2175
2025-07-15 10:41:24 -07:00
Tony Wasserka
d5b166bdd9
OpcodeDispatcher: Strengthen error message to fatal
2025-07-15 16:55:18 +02:00
Ryan Houdek
0dff992fab
FEXCore: Implement xsaveopt
...
It's the same as xsave because we don't track a hidden "xinuse" hardware
mask. So this is a trivial implementation.
2025-07-14 17:31:47 -07:00
Billy Laws
d41cb3b69d
FEXCore: Support multiple entrypoints into a multiblock
...
If a multiblock contains a call instruction, we know at the point
of compilation that the instruction after that call will likely be
jumped to at some point. Avoid redundant recompilation by tracking
such cases and including an entrypoint for that instruction in the
multiblock aswell.
2025-07-10 16:00:24 +01:00
Alyssa Rosenzweig
02f45854e8
IR: include a fence in CPUID
...
easier for post-RA to chew thru.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-07-02 13:04:49 -04:00
Alyssa Rosenzweig
de4becc26e
OpcodeDispatcher: mask certain divisors
...
needed for fusing.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-30 15:58:33 -04:00
Alyssa Rosenzweig
af23f4325f
OpcodeDispatcher: reorder xor-with-self sequence
...
this lets us peephole fuse things even when there are flags calculated in the
way
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-30 15:58:33 -04:00
Alyssa Rosenzweig
3f3b6ad337
IR: merge regular/long divisions
...
this makes it a lot easier to turn a long division into a non-long division,
just by nulling out a source.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-24 16:10:29 -04:00
Alyssa Rosenzweig
1eb470083c
IR: merge div/rem opcodes
...
it's simpler & faster to calculate both together, matching the x86 semantic.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-10 17:08:20 -04:00
Alyssa Rosenzweig
6864d48dcf
OpcodeDispatcher: optimize cdq
...
prereq to optimizing sign-ext+ldiv in a reasonable way.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-03 15:00:06 -04:00
Alyssa Rosenzweig
06299cca4b
OpcodeDispatcher: optimize out Bfi for storereg
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
af5aaab38b
OpcodeDispatcher: optimize a few ALU-with-constant ops
...
instead of relying on ConstProp for this.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
a9eb1bd4e6
OpcodeDispatcher: don't generate pointless Bfe for moves
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
83ef2da95f
OpcodeDispatcher: avoid zero shift in SHLD
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
ba13ccadb8
OpcodeDispatcher: use ArithRef for 8/16-bit imul
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
4a2dee873d
OpcodeDispatcher: use ArithRef for small rotates
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
0d235d63d0
OpcodeDispatcher: use ArithRef for bit tests
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
820d5c1447
OpcodeDispatcher: use ArithRef for rotates
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
bf3a1839a2
OpcodeDispatcher: transform DF ourselves
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-06-02 14:15:51 -04:00
Alyssa Rosenzweig
0fbe69ebcf
OpcodeDispatcher: optimize xor-with-self flags
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-05-28 13:53:38 -04:00
Alyssa Rosenzweig
3fbc8204b7
OpcodeDispatcher: clean up logical flags
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-05-28 13:28:31 -04:00
Alyssa Rosenzweig
0e67f30103
OpcodeDispatcher: make Push do the right thing and use it
...
this both optimizes and bug-fixes pusha while deleting a snotton of code.
Closes: https://github.com/FEX-Emu/FEX/issues/4589
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-05-26 15:52:23 -04:00
Alyssa Rosenzweig
a01e29ac99
IR: extend the IR header with RA info
...
Beyond the actual registers allocated, there are two pieces of sideband data we
store in the RAData object:
* # of spill slots (explicitly)
* whether RA has run (implicitly by the existence of RAData)
We want to get rid of RAData, so we'll move these to the header.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-05-19 13:42:59 -04:00
Ryan Houdek
00f8181c3a
OpcodeDispatcher: Fix CPUID being a instruction fence
...
It is common practice for games to use CPUID as an instruction barrier
for various reasons. Ensure that we respect this by adding support for
an instruction barrier.
2025-04-15 15:42:43 -07:00
Ryan Houdek
60565cc2ef
OpcodeDispatcher: Implement support for self-synchronizing cycle counter
...
FEAT_ECV added a new synchronizing cycle counter instruction that
restrict speculation across the cycle counter access. Because it
restricts speculation, it effectively acts like an isb and load dsb.
Luckily for us, this actually matches behaviour for what rdtscp does, so
we can take advantage of it if the host supports FEAT_ECV.
2025-04-15 15:42:43 -07:00
Ryan Houdek
0ca34d11ad
Merge pull request #4454 from alyssarosenzweig/silly-nop
...
Fix 66 90 decoding to a nop
2025-03-28 14:50:02 -07:00
Alyssa Rosenzweig
3a2ca41724
OpcodeDispatcher: handle 66 90 as a NOP
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-03-28 13:03:34 -04:00
Lioncache
54dbb9f248
OpcodeDispatcher: Fix potential for uninitialized value use in RCRSmallerOp()
...
If Src isn't a constant, then no value is actually assigned to SrcConst, so this
can result in uninitialized arithmetic being performed
2025-03-28 04:45:40 -04:00
Ryan Houdek
8f9d818368
OpcodeDispathcer: static analysis warnings
2025-03-27 04:26:40 -07:00
Ryan Houdek
d48413cbec
Merge pull request #4426 from alyssarosenzweig/opt/shld-improvements
...
Drop some masking in shld
2025-03-24 19:24:51 -07:00
Alyssa Rosenzweig
b86cbda03d
OpcodeDispatcher: drop useless mask in trivial cmpxchg
...
hit by upcoming opt pass, but we don't want to depend on that pass for that.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-03-24 16:17:04 -04:00
Alyssa Rosenzweig
e26b9b12fa
OpcodeDispatcher: drop useless zext in shld
...
this gets deleted by an upcoming opt pass, but we shouldn't be depending on
the opt pass for it!
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-03-24 16:00:24 -04:00
Ryan Houdek
ab7f6484cf
Merge pull request #4414 from pmatos/AddrMode-DeusEx
...
Fix address modes calculation on 32bit guests
2025-03-20 13:21:53 -07:00
Paulo Matos
b18f148575
Abstract AddressMode into its own header
...
Also refactor usage of utility functions into x87 Stack Optimization Pass.
2025-03-20 11:41:26 +01:00
Alyssa Rosenzweig
61d2a09827
OpcodeDispatcher: fix BT flags
...
ZF needs to be preserved.
the new code is the same instr count on flagm although probably an extra uop.
the inst count regression is on flagm, but we can't tolerate broken behaviour.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2025-03-18 15:26:47 -04:00
Paulo Matos
64020e8828
Simplify by merging FSTF64 with FST
2025-03-18 15:54:54 +01:00
Ryan Houdek
b0b41d00ee
Various: More static analysis warnings cleanup
...
NFC
2025-03-12 17:27:41 -07:00
Ryan Houdek
a37d6a3841
JIT: Optimize CAS
...
Hey kid, want to see a sick trick?
Finally optimal codegen for 64-bit cmpxchg.
2025-03-07 14:24:45 -08:00
Ryan Houdek
2bf87ff40f
Various: Removes warnings about uninitialized variables
...
NFC. These wouldn't even occur in practice.
2025-03-04 19:59:26 -08:00
Billy Laws
cdae654fe4
FEXCore: Somewhat implement LSL
...
Emulate by always returning failure, this deviates from both Linux
and Windows but shouldn't be depended on by anything.
2025-02-27 23:45:14 +00:00
Billy Laws
a506c84bc7
FEXCore: Implement SIDT
2025-02-27 23:45:14 +00:00
Ryan Houdek
5b4fd590d1
OpcodeDispatcher: Use offset for LRCPC2 more frequently
...
We were missing small offset immediate encoded LRCPC2 pretty much
always.
This fixes that. Finishes up what #4216 started.
2025-02-10 10:38:39 -08:00
Billy Laws
40662f947f
OpcodeDispatcher: Only set mark _Break as setting RIP in the non-MB case
...
If we're starting a new block here then the newly started block won't have
set RIP and it is erroneous to set it.
2025-02-06 00:01:40 +00:00
Paulo Matos
0bccb1ece5
Ensure predicate cache is reset when control flow leaves block
...
Whenever the control float leaves the block, it might clobber the
predicate register so we reset the cache whenever that happens.
Fixes #4264
2025-01-27 20:12:43 +01:00