Alyssa Rosenzweig
0503c89ff6
OpcodeDispatcher: use NZCV update helpers
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-19 14:12:54 -04:00
Alyssa Rosenzweig
6dd410698a
OpcodeDispatcher: add helpers for updating NZCV metadata
...
to reduce error-prone copypaste
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-19 14:12:54 -04:00
Ryan Houdek
9cab746aa7
Merge pull request #3407 from neobrain/feature_libfwd_arguments_on_guest_stack
...
Library Forwarding: Allocate packed arguments on the guest stack if needed
2024-02-12 16:31:34 -08:00
Alyssa Rosenzweig
68232366e4
OpcodeDispatcher: don't mask add/sub sources
...
not needed in the new approach
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-12 12:36:28 -04:00
Alyssa Rosenzweig
d7ff1b78fb
IR: handle 8/16-bit AddNZCV/SubNZCV
...
we can do it more effectively than the current s/w lowering.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-12 12:36:09 -04:00
Ryan Houdek
df3d6938ae
Merge pull request #3410 from alyssarosenzweig/opt/nzcv-pass-2
...
Add NZCV+PF/AF optimization pass
2024-02-10 05:03:12 -08:00
Ryan Houdek
ba41da7da0
Merge pull request #3414 from Sonicadvance1/fix_one_mutex_hang
...
Fixes one mutex hang
2024-02-09 05:54:40 -08:00
Ryan Houdek
2480bab409
Fixes one mutex hang
...
When code invalidation is happening we currently have the issue that a
thread can acquire the code invalidation mutex in the middle of
invalidation. This is due to us acquiring and releasing the mutex
between each thread's code invalidation.
We need to hold the mutex for the entire duration for all thread's code
invalidation.
This fixes a rare hang on proton startup and resolves a consistent hang
on Proton application shutdown.
This now puts us on par with FEX-2312.1 with hanging.
This does not fix a relatively rare hang on fork (which also existed with FEX-2312.1).
This also does not fix the issue that the intersection of our mutexes
between frontend and backend are very convoluted. In part of the work
that is going to fix the rare fork mutex hang will change more of this.
2024-02-08 18:18:00 -08:00
Alyssa Rosenzweig
ad7202e7d7
OpcodeDispatcher: optimize test -1
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-08 14:10:13 -04:00
Alyssa Rosenzweig
175a57dd27
OpcodeDispatcher: emit AndWithFlags directly for primary alu
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 14:22:28 -04:00
Alyssa Rosenzweig
e2ce60148c
OpcodeDispatcher: emit AndWithFlags directly for 2ndary alu
...
rely on opt pass to drop the flags.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 14:22:28 -04:00
Alyssa Rosenzweig
99660129f3
IR: implement AndWithFlags for 8/16-bit
...
easier to deal with in the JIT
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 14:22:28 -04:00
Alyssa Rosenzweig
308d9a751c
RedundantFlagCalculationElimination: optimize rmif
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:26 -04:00
Alyssa Rosenzweig
4bd28c0ed8
RedundantFlagCalculationElimination: optimize condaddnzcv
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:26 -04:00
Alyssa Rosenzweig
8397f3ac99
RedundantFlagCalculationElimination: refine AXFLAG
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:26 -04:00
Alyssa Rosenzweig
0452bc7212
RedundantFlagCalculationElimination: optimize condjump
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:26 -04:00
Alyssa Rosenzweig
3d7ed89ffb
RedundantFlagCalculationElimination: optimize NZCVSelect
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:25 -04:00
Alyssa Rosenzweig
23ab0a978e
RedundantFlagCalculationElimination: also handle InvalidateFlags
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:25 -04:00
Alyssa Rosenzweig
7f47a9ef0e
IR: add local dead flag elimination pass
...
RCLSE ignores NZCV and doesn't optimize stores which doesn't help us with PF/AF
either. So, we add a new pass for dead flag elimination (cannibalizing the old
and broken dead flag elimination pass). This is a simple local optimizer that
walks each block backwards, converging in linear time & constant space in a
single iteration.
Right now, it doesn't do a ton (other than a nice reduction in silliness in
the hot Sonic block), but it provides the framework to fuse comparisons.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-06 13:06:25 -04:00
Alyssa Rosenzweig
4331753ca0
Merge pull request #3408 from alyssarosenzweig/opt/tst
...
Optimize TST
2024-02-06 11:28:02 -04:00
Paulo Matos
fa8bcfd67a
Clean up access to possible nullptr
...
Patch suggested by @Sonicadvance1
2024-02-06 12:31:38 +00:00
Alyssa Rosenzweig
235f32ce8c
Merge pull request #3401 from Sonicadvance1/runtime_preserve_all
...
HostFeatures: Supports runtime disabling of preserve_all
2024-02-05 15:34:46 -04:00
Alyssa Rosenzweig
2e0cb2fbd4
OpcodeDispatcher: optimize TST
...
it's just an AndWithFlags setting the PF.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-05 15:32:21 -04:00
Alyssa Rosenzweig
4790a7ba79
IR: add AndWithFlags
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-05 15:32:21 -04:00
Tony Wasserka
df3e51fc8c
Library Forwarding: Allocate packed arguments on the guest stack if needed
...
This is required for host-side calls to guest functions on 32-bit guests.
Since the host stack is allocated before FEX blocks memory inaccessible to
the guest, the guest would otherwise fail to read the packed argument data.
2024-02-05 18:10:34 +01:00
Ryan Houdek
c437129ed8
Revert "Revert "FEXLoader: Moves thread management to the frontend""
...
This reverts commit 5358af7794 .
2024-02-03 00:57:36 -08:00
Alyssa Rosenzweig
8d3f0b6f02
OpcodeDispatcher: reassociate and sink W in sha1
...
We only need each part of W extracted in the corresponding round, so sink the
extract into the round to reduce pressure.
Further, W and E are added and then never used again. So, by reassociating we
can do the add upfront, killing W and E at the start and further reducing
pressure.
Eliminates spilling in sha1rnds4.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
60f7b9bcc4
OpcodeDispatcher: optimze sha1's 2/3 expr
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
a487557173
OpcodeDispatcher: extract BitwiseAtLeastTwo
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
394b4888bb
OpcodeDispatcher: reassociate and remat C0, G0
...
costs 2 moves and eliminates the rest of our spilling
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
142cbdd852
OpcodeDispatcher: expand, reassociate, and interleave sha256 calc
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
2f9102f78d
OpcodeDispatcher: expand & interleave sha256 calc
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
c9824d04cb
OpcodeDispatcher: sink sha256 extracts
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
9c2a569539
OpcodeDispatcher: reexpress Major in sha256
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
515aa4ce3e
OpcodeDispatcher: fuse eor+ror in sha256
...
This reduces instructions a ton.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
f616beb992
OpcodeDispatcher: CSE sha
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
0dcf1e12b8
OpcodeDispatcher: copyprop sha logic
...
prepare for clever
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Alyssa Rosenzweig
2cbf544ef5
OpcodeDispatcher: expand sha logic
...
no functional change, just preparing for cleverness.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-02-02 13:03:07 -04:00
Ryan Houdek
0eed73beeb
HostFeatures: Supports runtime disabling of preserve_all
...
This is used for instcountci to ensure instruction counts don't change
when a compiler supports this feature or not. Always runtime disable
when running in instcountci.
CMake option from #3394 can still be useful so leaving that in place.
2024-02-02 08:59:04 -08:00
Mai
6993f4fd8d
Merge pull request #3400 from Sonicadvance1/revert_runtime_longmode_switch
...
Revert #3303
2024-02-02 11:53:44 -05:00
Paulo Matos
4623544f69
Improve XCHG operations
...
Marking loads as allowing upper garbage simplifies some operations.
Update InstCountCI as well.
2024-02-02 08:16:13 +00:00
Ryan Houdek
ccf1402fe6
Revert "FEXCore: Accurately store segment descriptors"
...
This reverts commit 8648fb1485 .
2024-02-01 18:14:30 -08:00
Ryan Houdek
da0e1b515a
Revert "OpcodeDispatcher: Initial support for runtime long-mode switch"
...
This reverts commit 9e5d7aa5fe .
2024-02-01 18:14:24 -08:00
Ryan Houdek
cec1814a09
Merge pull request #3384 from pmatos/CDQOp-Opt
...
Optimize CDQOp
2024-01-31 17:51:23 -08:00
Mai
4d49ac7c3d
Merge pull request #3387 from alyssarosenzweig/opt/rotates
...
Optimize rotates
2024-01-31 18:20:40 -05:00
Alyssa Rosenzweig
6d13d9fb56
Merge pull request #3395 from pmatos/StaticAnalysis
...
Code cleanup - mainly dead store removal; NFC
2024-01-31 17:24:48 -04:00
Mai
ae7dc250db
Merge pull request #3386 from alyssarosenzweig/opt/shift
...
Optimize shifts a bit
2024-01-31 14:11:58 -05:00
Paulo Matos
e4560ed0c8
Code cleanup - mainly dead store removal; NFC
...
scan-build found a few dead stores that can be easily cleaned-up
2024-01-31 08:35:55 +00:00
Alyssa Rosenzweig
f3eee8f305
OpcodeDispatcher: optimize bextr's length sanitize
...
reordering the operations saves an immediate move.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-01-30 22:28:06 -04:00
Alyssa Rosenzweig
f66085f4a7
OpcodeDispatcher: optimize bextr's (1 << x) - 1
...
little algebraic trick I cribbed from llvm
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2024-01-30 22:28:06 -04:00