Alyssa Rosenzweig
cec98637c9
OpcodeDispatcher: Avoid extra OR in GetPackedRFLAG
...
We know that bit 0 is CF, so we can do CF first and then avoid setting
Original to 2 (for reserved) with a silly `or xzr, #2` instruction.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 13:18:39 -04:00
Alyssa Rosenzweig
d5026f5815
OpcodeDispatcher: Handle SF/ZF together for GetPackedRFLAG
...
They're together on both x86 and arm64, so this is faster if we're
getting both.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 13:18:39 -04:00
Alyssa Rosenzweig
1e4456ec40
OpcodeDispatcher: Use orlshl in GetPackedRFLAG
...
Saves some moves.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 13:18:39 -04:00
Alyssa Rosenzweig
e285c7c9a0
OpcodeDispatcher: Use TEST when possible
...
Faster sign/negate testing for 32-bit/64-bit inputs. This could maybe be
extended to 8/16-bit if we have FlagM but that's for later.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 13:18:39 -04:00
Alyssa Rosenzweig
8244c7f2a6
OpcodeDispatcher: Use orlshl when possible
...
If we can prove that a flag bit could not possibly be set, we can use
orlshl rather than bfi, which can be more efficient.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 13:18:39 -04:00
Alyssa Rosenzweig
747c5e17f8
OpcodeDispatcher: Add ZeroNZCV helper
...
In some cases we just want to insert in one bit at a time, add a helper
to zero the 4 flags together so we can avoid the extra RMW cycle at the
beginning.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 13:18:39 -04:00
Alyssa Rosenzweig
52ce027e9b
OpcodeDispatcher: Set N flag more efficiently
...
We can set N more efficiently with some bit math, and zero ZCV at the
same time. In the future we'll be able to use TST for this to make it
even faster.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
0fb3903889
OpcodeDispatcher: Pack NZCV flags together
...
Later, this will let us take advantage of the arm64 flags. For
now, this just turns some strb's into bfi's for dubious benefit.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
2832afd0f7
OpcodeDispatcher: Calculate deferred flags more
...
If we read or write NZCV flags we need to call CalculateDeferredFlags on
block boundaries, if only to flush out the cached copy.
Also, when leaving a block we call it to flush out. This is annoyingly
invasive but I don't know of a better way to do this that doesn't
involve rearchitecting the dispatcher.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
4af42477a7
OpcodeDispatcher: Use GetRFLAG more
...
We'll add an extra caching layer in a moment so can't call _LoadFlag
directly and expect correct results.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
4786aa479c
OpcodeDispatcher: Unify SetRFLAG impls
...
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
8a049aa0c3
Context: Make BackendFeatures public
...
So that the OpcodeDispatcher can check the supported features and emit
code accordingly.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
64bac687b5
IR: Add TEST opcode
...
Maps to arm64 tst, except properly SSA. This will need some RA support
to avoid redundant mrs/msr sequences.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
6e05494ad0
IR: Add Orlshr
...
Similar to Orlshl. This will let us save an instruction in
GetPackedRFLAG.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
4d13f5d97d
IR: Add Orlshl op
...
On arm64, orr (with a shifted register) is maybe fewer cycles and
definitely easier on the RA than bfi (=> fewer moves generated). So,
it's preferred when we know the corresponding bit is 0 in the
destination.
It's not useful on other targets, so it's gated behind a backend feature
bit.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Alyssa Rosenzweig
1ad928dc2c
IR: Add special NZCV "flag"
...
Reserve 4 bytes of "flags" to model the 32-bit arm64 NZCV register, so
we can start porting FEX's flag handling code over to using NZCV without
needing the whole compiler to be aware of instructions that might
clobber host flags.
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io >
2023-08-02 12:38:00 -04:00
Ryan Houdek
c235ab883d
OpcodeDispatcher: Optimize phsubsw/phaddsw
...
Goes from 41 instructions down to 20(!) instructions.
The primary optimization here is removing a bunch of dull inserts and
instead using zip logic to get the elements where we want them.
The previous implementation was trying to retain semantics around how
the original instruction is implemented, which makes no sense at all.
Unzip the even and odd elements and just do the saturating operations
directly!
Huge shoutout to @dougallj again, showing that I was thinking about this implementation far too much like an x86 developer.
Before:
```asm
0x0000ffff8f300c50 10ffffe0 adr x0, #-0x4 (addr 0xffff8f300c4c)
0x0000ffff8f300c54 f9005f80 str x0, [x28, #184 ]
0x0000ffff8f300c58 3dc010c4 ldr q4, [x6, #64 ]
0x0000ffff8f300c5c 6e60bae5 neg v5.8h, v23.8h
0x0000ffff8f300c60 6e60b886 neg v6.8h, v4.8h
0x0000ffff8f300c64 4eb71ee0 mov v0.16b, v23.16b
0x0000ffff8f300c68 6e0614a0 mov v0.h[1], v5.h[1]
0x0000ffff8f300c6c 4ea01c07 mov v7.16b, v0.16b
0x0000ffff8f300c70 6e0614c4 mov v4.h[1], v6.h[1]
0x0000ffff8f300c74 6e0e34a7 mov v7.h[3], v5.h[3]
0x0000ffff8f300c78 6e0e34c4 mov v4.h[3], v6.h[3]
0x0000ffff8f300c7c 6e1654a7 mov v7.h[5], v5.h[5]
0x0000ffff8f300c80 6e1654c4 mov v4.h[5], v6.h[5]
0x0000ffff8f300c84 4ea71ce0 mov v0.16b, v7.16b
0x0000ffff8f300c88 6e1e74a0 mov v0.h[7], v5.h[7]
0x0000ffff8f300c8c 4ea01c05 mov v5.16b, v0.16b
0x0000ffff8f300c90 6e1e74c4 mov v4.h[7], v6.h[7]
0x0000ffff8f300c94 0f10a4a6 sxtl v6.4s, v5.4h
0x0000ffff8f300c98 4f10a4a5 sxtl2 v5.4s, v5.8h
0x0000ffff8f300c9c 0f10a487 sxtl v7.4s, v4.4h
0x0000ffff8f300ca0 4f10a484 sxtl2 v4.4s, v4.8h
0x0000ffff8f300ca4 4ea5bcc5 addp v5.4s, v6.4s, v5.4s
0x0000ffff8f300ca8 4ea4bce4 addp v4.4s, v7.4s, v4.4s
0x0000ffff8f300cac 0e6148a5 sqxtn v5.4h, v5.4s
0x0000ffff8f300cb0 4ea51ca0 mov v0.16b, v5.16b
0x0000ffff8f300cb4 4e614880 sqxtn2 v0.8h, v4.4s
0x0000ffff8f300cb8 4ea01c17 mov v23.16b, v0.16b
0x0000ffff8f300cbc 58000040 ldr x0, pc+8 (addr 0xffff8f300cc4)
0x0000ffff8f300cc0 d63f0000 blr x0
0x0000ffff8f300cc4 a4e97128 ldff1h {z8.d}, p4/z, [x9, x9, lsl #1 ]
0x0000ffff8f300cc8 0000ffff udf #0xffff
0x0000ffff8f300ccc 000100dd unallocated (Unallocated)
0x0000ffff8f300cd0 00000000 udf #0x0
[DEBUG] RIP: 0x100d7
[DEBUG] Guest Code instructions: 1
[DEBUG] Host Code instructions: 41
[DEBUG] Blow-up Amt: 41x
```
After:
```asm
0x0000ffffe2500a04 10ffffe0 adr x0, #-0x4 (addr 0xffffe2500a00)
0x0000ffffe2500a08 f9005f80 str x0, [x28, #184 ]
0x0000ffffe2500a0c 3dc010c4 ldr q4, [x6, #64 ]
0x0000ffffe2500a10 4e441ae5 uzp1 v5.8h, v23.8h, v4.8h
0x0000ffffe2500a14 4e445ae4 uzp2 v4.8h, v23.8h, v4.8h
0x0000ffffe2500a18 4e642cb7 sqsub v23.8h, v5.8h, v4.8h
0x0000ffffe2500a1c 58000040 ldr x0, pc+8 (addr 0xffffe2500a24)
0x0000ffffe2500a20 d63f0000 blr x0
0x0000ffffe2500a24 f7fec128 unallocated (Unallocated)
0x0000ffffe2500a28 0000ffff udf #0xffff
0x0000ffffe2500a2c 000100dd unallocated (Unallocated)
0x0000ffffe2500a30 00000000 udf #0x0
[DEBUG] RIP: 0x100d7
[DEBUG] Guest Code instructions: 1
[DEBUG] Host Code instructions: 20
[DEBUG] Blow-up Amt: 20x
```
2023-08-02 00:10:32 -07:00
Ryan Houdek
4bf3a0888b
OpcodeDispatcher: Optimize CMPXCHG{8B,16B} final comparison
...
Optimizes the instruction blow-up from 36x to 34x.
The issue with this instruction is that AArch64 doesn't do something
like x86 where it sets a flag if the CAS was successful. This means we
need to do additional comparisons after the fact to see if it was
actually successful.
Previously this was implemented as eor+eor+orr+cmp+cset, Now it is
cmp+ccmp+cset, Saving two instructions.
Simple optimization but easy to do. This instruction is still mostly
killed by the overhead of moving registers all over.
Before:
```asm
0x0000ffffe25002ec 10ffffe0 adr x0, #-0x4 (addr 0xffffe25002e8)
0x0000ffffe25002f0 f9005f80 str x0, [x28, #184 ]
0x0000ffffe25002f4 aa0403f4 mov x20, x4
0x0000ffffe25002f8 aa0603f5 mov x21, x6
0x0000ffffe25002fc aa0703f6 mov x22, x7
0x0000ffffe2500300 aa0503f7 mov x23, x5
0x0000ffffe2500304 aa1403e2 mov x2, x20
0x0000ffffe2500308 aa1503e3 mov x3, x21
0x0000ffffe250030c 4862ffb6 caspal x2, x3, x22, x23, [x29]
0x0000ffffe2500310 aa0203f4 mov x20, x2
0x0000ffffe2500314 aa0303f5 mov x21, x3
0x0000ffffe2500318 aa1403f6 mov x22, x20
0x0000ffffe250031c aa1503f4 mov x20, x21
; ZF Flag + branch
0x0000ffffe2500320 ca0402d5 eor x21, x22, x4
0x0000ffffe2500324 ca060297 eor x23, x20, x6
0x0000ffffe2500328 aa1702b5 orr x21, x21, x23
0x0000ffffe250032c f10002bf cmp x21, #0x0 (0)
0x0000ffffe2500330 9a9f17f7 cset x23, eq
0x0000ffffe2500334 390b1b97 strb w23, [x28, #710 ]
0x0000ffffe2500338 b4000075 cbz x21, #+0xc (addr 0xffffe2500344)
0x0000ffffe250033c aa1603e4 mov x4, x22
0x0000ffffe2500340 aa1403e6 mov x6, x20
0x0000ffffe2500344 58000040 ldr x0, pc+8 (addr 0xffffe250034c)
0x0000ffffe2500348 d63f0000 blr x0
0x0000ffffe250034c f7fec128 unallocated (Unallocated)
0x0000ffffe2500350 0000ffff udf #0xffff
0x0000ffffe2500354 00010053 unallocated (Unallocated)
0x0000ffffe2500358 00000000 udf #0x0
[DEBUG] RIP: 0x1004f
[DEBUG] Guest Code instructions: 1
[DEBUG] Host Code instructions: 36
[DEBUG] Blow-up Amt: 36x
```
After:
```asm
0x0000ffffe25002ec 10ffffe0 adr x0, #-0x4 (addr 0xffffe25002e8)
0x0000ffffe25002f0 f9005f80 str x0, [x28, #184 ]
0x0000ffffe25002f4 aa0403f4 mov x20, x4
0x0000ffffe25002f8 aa0603f5 mov x21, x6
0x0000ffffe25002fc aa0703f6 mov x22, x7
0x0000ffffe2500300 aa0503f7 mov x23, x5
0x0000ffffe2500304 aa1403e2 mov x2, x20
0x0000ffffe2500308 aa1503e3 mov x3, x21
0x0000ffffe250030c 4862ffb6 caspal x2, x3, x22, x23, [x29]
0x0000ffffe2500310 aa0203f6 mov x22, x2
0x0000ffffe2500314 aa0303f7 mov x23, x3
0x0000ffffe2500318 aa1603f8 mov x24, x22
0x0000ffffe250031c aa1703f9 mov x25, x23
; ZF Flag + branch
0x0000ffffe2500320 eb1402df cmp x22, x20
0x0000ffffe2500324 fa5502e0 ccmp x23, x21, #nzcv, eq
0x0000ffffe2500328 9a9f17f4 cset x20, eq
0x0000ffffe250032c 390b1b94 strb w20, [x28, #710 ]
0x0000ffffe2500330 b5000074 cbnz x20, #+0xc (addr 0xffffe250033c)
0x0000ffffe2500334 aa1803e4 mov x4, x24
0x0000ffffe2500338 aa1903e6 mov x6, x25
0x0000ffffe250033c 58000040 ldr x0, pc+8 (addr 0xffffe2500344)
0x0000ffffe2500340 d63f0000 blr x0
0x0000ffffe2500344 f7fec128 unallocated (Unallocated)
0x0000ffffe2500348 0000ffff udf #0xffff
0x0000ffffe250034c 00010053 unallocated (Unallocated)
0x0000ffffe2500350 00000000 udf #0x0
[DEBUG] RIP: 0x1004f
[DEBUG] Guest Code instructions: 1
[DEBUG] Host Code instructions: 34
[DEBUG] Blow-up Amt: 34x
```
2023-08-01 20:01:02 -07:00
Ryan Houdek
6834fe32e4
IR: Adds support for GPRPair to Select IR op
...
This IR operation was limited to GPR only previously for the values
getting compared.
This adds support for GPRPair (and technically FPR) so that it can be
used directly with GPR pairs. I say technically FPR because the
IREmitter disallowed FPRs for the comparison, but this was already
supported in all of the backends, we just didn't ever use it.
Some minor changes to the constant prop pass to ensure that we don't try
to propagate a select in to a CondJump, otherwise pair comparisons would
be duplicated. This code is expecting to be able to merge a simple
comparison in to a `cbnz`, which doesn't happen with GPR pairs.
2023-08-01 19:50:15 -07:00
Ryan Houdek
d196709162
Merge pull request #2850 from Sonicadvance1/put_the_man_in_its_place
...
FEXCore: Ensure that the man page follows DESTDIR
2023-08-01 14:28:06 -07:00
Ryan Houdek
475a6a38fa
FEXCore: Ensure that the man page follows DESTDIR
...
When cmake's `install` function is invoked with a relative path, then it
is interpreted as being relative to the `CMAKE_INSTALL_PREFIX` variable.
This variable follows both `DESTDIR` and `CMAKE_INSTALL_PREFIX` so it is
best to use relative addresses in the install path.
Thanks for the report Mike!
Fixes #2849
2023-08-01 13:28:21 -07:00
Mai
0f748bd724
Merge pull request #2829 from Sonicadvance1/mingw_runner
...
Github: Adds mingw build test workflow
2023-07-31 21:45:24 -04:00
Ryan Houdek
47bd331239
Github: Adds mingw build test workflow
...
Currently only does a build, doing a CI run means figuring out why
TestHarnessRunner doesn't find libraries correctly.
I want to ensure we don't break building at least while sorting out the
rest of this.
2023-07-31 17:55:24 -07:00
Ryan Houdek
173b70d191
Merge pull request #2817 from Sonicadvance1/psad_you_know
...
OpcodeDispatcher: Optimize PSAD* to use vuabdl{2,}
2023-07-31 14:54:57 -07:00
Ryan Houdek
96aa0a844e
Merge pull request #2845 from Sonicadvance1/thunks_guestlibs
...
Thunks: Set bitness flags for 64-bit guests
2023-07-31 12:43:11 -07:00
Ryan Houdek
48121cd585
Thunks: Set bitness flags for 64-bit guests
...
This will help non-multiarch aware distros
2023-07-31 12:22:33 -07:00
Ryan Houdek
52d7efda10
Merge pull request #2839 from Sonicadvance1/shrdi_of
...
OpcodeDispatcher: Fixes SHRD by immediate OF flag calculation
2023-07-31 10:56:40 -07:00
Ryan Houdek
30ab4d3f58
Merge pull request #2848 from lioncash/aliases
...
ARMEmitter: Add cinc/cinv/csetm aliases
2023-07-30 20:18:29 -07:00
Lioncache
f9fa0f25e2
ARMEmitter: Add cinc/cinv/csetm aliases
...
Also corrects a cneg test using CC_AL. The ARM ARM says this
shouldn't be using both AL and NV
2023-07-30 22:41:03 -04:00
Ryan Houdek
eebcbfda96
Merge pull request #2847 from lioncash/aliases
...
ARMEmitter: Add ngc/ngcs aliases
2023-07-30 19:07:32 -07:00
Lioncache
1483ddb538
ARMEmitter: Add ngc/ngcs aliases
2023-07-30 21:55:54 -04:00
Ryan Houdek
d2bca9b997
Merge pull request #2846 from lioncash/aliases
...
ARMEmitter: Add bfc/bfxil aliases
2023-07-30 18:49:01 -07:00
Lioncache
8f48021a63
ARMEmitter: Add bfxil alias
2023-07-30 21:18:20 -04:00
Lioncache
1da5d7f2e6
ARMEmitter: Add bfc alias
2023-07-30 21:18:17 -04:00
Ryan Houdek
0a5db6c404
Merge pull request #2843 from Sonicadvance1/implement_socketcall_recvsendmmsg
...
Linux: Implement {recv,send}mmsg inside of socketcall
2023-07-30 18:04:44 -07:00
Ryan Houdek
4681061011
Merge pull request #2844 from lioncash/aliases
...
ARMEmitter: Add sbfiz/tst/ubfiz aliases
2023-07-30 18:01:34 -07:00
Lioncache
4e9eeb1a16
ARMEmitter: Add SBFIZ/UBFIZ aliases
2023-07-30 20:19:37 -04:00
Lioncache
95d728b634
ARMEmitter: Add TST aliases
2023-07-30 19:36:56 -04:00
Ryan Houdek
187e551a0c
Linux: Implement {recv,send}mmsg inside of socketcall
...
These are the last two missing socketcall operations. Implementing them
is mostly using the other implementation just in a helper function.
2023-07-30 15:45:01 -07:00
Ryan Houdek
7c4e4c4409
Merge pull request #2842 from Sonicadvance1/syscall_accept4
...
Linux: Implement accept4 inside of socketcall
2023-07-30 15:44:18 -07:00
Ryan Houdek
bdd8df2100
Linux: Implement accept4 inside of socketcall
...
Steam started using this recently. So implement it.
Still missing recvmmsg and sendmmsg here.
2023-07-30 15:11:45 -07:00
Ryan Houdek
1d1bdfb96d
OpcodeDispatcher: Fixes SHRD by immediate OF flag calculation
...
We were calculating this like the regular SHR instruction which isn't
correct.
With this resolved, Denuvo games get slightly farther.
2023-07-28 18:00:50 -07:00
Ryan Houdek
2fc6542d15
Merge pull request #2838 from lioncash/imm
...
ARMEmitter: Finish off remaining SVE Integer Wide Immediate - Unpredicated categories
2023-07-28 17:57:23 -07:00
Lioncache
5e88be3c99
ARMEmitter: Handle SVE MUL immediate (unpredicated)
2023-07-28 19:55:06 -04:00
Lioncache
be52844ce0
ARMEmitter: Handle SVE MIN/MAX immediate (unpredicated)
2023-07-28 19:47:32 -04:00
Lioncache
d629884147
ARMEmitter: Handle SVE ADD/SUB immediate (unpredicated)
2023-07-28 19:23:06 -04:00
Ryan Houdek
64c72430bf
Merge pull request #2837 from lioncash/predicate
...
Arm64/Emitter: Add remaining missing SVE predicate range assertions
2023-07-28 14:44:43 -07:00
Lioncache
1b13e8db7d
Arm64/Emitter: Simplify SVE constructive prefix
...
Moves the assert and op definition into the implementing function.
Also enforces valid use of predicate registers.
2023-07-28 17:17:51 -04:00
Ryan Houdek
1ce0ea8f3b
Merge pull request #2835 from Sonicadvance1/cmn_alias
...
ARMEmitter: Implement cmn alias
2023-07-28 14:15:01 -07:00
Lioncache
8557656259
Arm64/Emitter: Simplify SVE FP unary operations predicated group
...
Moves the asserts into the implementation function and also enforces
valid use of predicates.
2023-07-28 17:07:15 -04:00