Commit Graph

1074 Commits

Author SHA1 Message Date
TranzRail
1d51b574ec [Kernel] Add PVR opcode (includes cvars support) 2022-01-29 02:44:55 -06:00
Wunkolo
24205ee860 [x64] Fix VECTOR_SH{L,R,A}_V128(Int8) masking
[AltiVec](https://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf)
doc says that it just uses the lower `log2(n)` bits of the shift-amount
rather than the whole element-sized value. So there is no need to handle
an overflow. Also adjusts 64-bit literals to utilize the explicit
`UINT64_C` type.
2022-01-29 02:39:34 -06:00
Wunkolo
f8350b5536 [x64] Add VECTOR_SH{R,L}_I8_SAME_CONSTANT unit test
This is to target the new GFNI-based optimization for the Int8 case.
2022-01-29 02:39:34 -06:00
Wunkolo
bd9a290b30 [x64] Add GFNI-based optimization for VECTOR_SH{R,L}_V128(Int8)
In the `Int8` case of `VECTOR_SH{R,L}_V128`, when all the values are the
same, then a single-instruction `gf2p8affineqb` can be emitted that does
an int8-based arithmetic-shift, utilizing GF(8) arithmetic.

More info here:
https://wunkolo.github.io/post/2020/11/gf2p8affineqb-int8-shifting/

Also fixes the iteration-type for when detecting if all of the simd
lanes are the same value(was iterating `u16` and not `u8`)
2022-01-29 02:39:34 -06:00
Wunkolo
f7c14a089d [x64] Add host-extension detection preprocessor
Rather than having a huge list of if-statements that all do the same
thing, this preprocessor allows a more concise pattern to detecting if
the emit-flag is enabled as well as the correlated Xbyak flag that it
needs to check for to before allowing the feature-flag to be emitted.

Also moved the AVX-check to the beginning to early-out rather than do a
bunch of wasted work only to find out last that the host doesn't even
support AVX.
2022-01-23 05:04:56 -06:00
Wunkolo
a9a365aa32 [x64] Add GFNI-based optimization for VECTOR_SHA_V128(Int8)
In the `Int8` case of `VECTOR_SHA_V128`, when all the values are the same, then a single-instruction `gf2p8affineqb` can be emitted that does an int8-based arithmetic-shift, utilizing GF(8) arithmetic.

More info here:
https://wunkolo.github.io/post/2020/11/gf2p8affineqb-int8-shifting/

As of now(Dec 2021): Tremont(Lakefield), Jasper Lake, Ice lake, Tigerlake, and Rocket Lake support GNFI.
2022-01-13 15:32:55 -06:00
Wunkolo
fba23e3e75 [x64] Add kX64EmitGFNI emitter feature-flag
This determines support for the `gf2p8affineqb` instruction. Even though `GFNI` is typically found with AVX512-enabled chips, it _is_ possible for there to be a chip with `GFNI` but does not support `AVX` or `AVX2` of any sort. An example of this is Tremont(Lakefield) chips as well as Jasper Lake.

13df339fe7/GenuineIntel/GenuineIntel00806A1_Lakefield_LC_InstLatX64.txt (L1297-L1299)

13df339fe7/GenuineIntel/GenuineIntel00906C0_JasperLake_InstLatX64.txt (L1252-L1254)
2022-01-13 15:32:55 -06:00
Wunkolo
5d1b53cd6f [x64] Add VECTOR_SHA_I8_SAME_CONSTANT unit test
This is to target the new GNFI-based optimization for the Int8 case.
2022-01-13 15:32:55 -06:00
Wunkolo
233ed107fe [CPU] Remove use_haswell_instructions in favor of x64_extension_mask
Rather than having a single bool to conditionally detect haswell-level
instruction features. The granularity is increased with a new
`x64_extension_mask` where individual features within the x64 backend
can be turned on or off in a bit-mask manner. Since we have an ARM
backend on the horizon, I've added this to the new `x64`
configuration-group rather than `CPU`. This new pattern will hopefully
allow for testing to be more targetted to certain processor features and
allows the user to determine if they want certain features to be enabled
or disabled(such as avoiding BMI2 on certain AMD processors due to
pdep/pext being incredibly slow). The default configuration is to detect
and utilize all available features.
2022-01-11 03:57:32 -06:00
Wunkolo
37aa3d129c [x64] Explicitly handle AND_NOT dest == src1
This addresses a JIT-issue in the case that the `src1` and `dest`
register are both the same. This issue only happens in the "generic"
x86 path but not in the BMI1-accelerated path.

Thanks Rick for the extensive debugging help.

When `src1` and `dest` were the same, then the `addc` instruction at
`82099A08` in title `584108FF` might emit the following assembly:
```
.text:82099A08                 andc      r11, r10, r11
  |
  | Jitted
  |
  V
00000000A0011B15  mov         rbx,r10
00000000A0011B18  not         rbx
00000000A0011B1B  and         rbx,rbx
```

This was due to the src1 operand and the destination register being the
same, which used to call the "else" case in the x64 emitter when it
needs to be handled explicitly due to register aliasing/allocation.

Addresses issue #1945
2022-01-10 15:48:49 -06:00
Wunkolo
4303f6b200 [x64] Fix OPCODE_AND_NOT src1-constant case
Fix the the case where src1 is constant and src2 is non-constant causing
an assert due to trying to call `.constant()` on the src2 operand.
Interfaces with an issue Gliniak was encountering where title `4D53082D`
encounters an assert. Also includes a BMI1-acceleration in the 64-bit
case where a temporary register is needed(the `and` x86 instruction only
supports immediate constants up to 32-bits).
2022-01-06 13:00:58 -06:00
Wunkolo
24d4e1e0e5 [x64] Add BMI1-based acceleration for AndNot
In the case of having two register operands for `AndNot`, the `andn` instruction can be used when the host supports `BMI1`. `andn` only supports 32-bit and 64-bit operands, so some register up-casting is needed.
2022-01-04 16:16:49 -06:00
Wunkolo
3ab43d480d [x64] Add kX64EmitBMI1 feature-flag and detection
The `BMI1 feature` fits into the current pattern of `use_haswell_instructions` as BMI1 was only introduced in haswell.

Also moved the aliases to the end of the enum rather than interleave it with the bit definitions.
2022-01-04 16:16:49 -06:00
Wunkolo
0fdb855a11 [JIT, x64] Add and implement OPCODE_AND_NOT
Verified the x64 implementation using `xenia-cpu-ppc-tests`.
2022-01-04 16:16:49 -06:00
Wunkolo
5317907523 [x64] Add kX64EmitAVX512* feature-flags
Implements the detection of some baseline `AVX512` subsets and some common aliases into `X64EmitterFeatureFlags`.

So far, `AVX512{F,VL,BW,DQ}` are the only subsets of `AVX512` that are detected with this PR since I anticipate these are the ones that will actually be used a lot in the x64 backend. Some aliases are also implemented such as `kX64EmitAVX512Ortho` which is `AVX512F` and `AVX512VL` combined which are the two subsets of AVX512 required to allow for `AVX512` operations upon `ymm` and `xmm` registers.

These aliases can possibly be collapsed since we could just always require `AVX512VL` to be supported to allow for _any_ kind of `AVX512` to be used since we will practically always want to use `AVX512` on `xmm` registers at the very least as there is no use-case where we want to use the 512-bit `zmm` registers exclusively.
2022-01-02 11:52:31 -06:00
Wunkolo
1a8068b151 [Base] Add user-literals for several memory sizes
Rather than using `n * 1024 * 1024`, this adds a convenient `_MiB`/`_KiB` user-literal to the new `literals.h` header to concisely describe units of memory in a much more readable way. Any other useful literals can be added to this header. These literals exist in the `xe::literals` namespace so they are opt-in, similar to `std::chrono` literals, and require a `using namespace xe::literals` statement to utilize it within the current scope.

I've done a pass through the codebase to replace trivial instances of `1024 * 1024 * ...` expressions being used but avoided anything that added additional casting complexity from `size_t` to `uint32_t` and such to keep this commit concise.
2022-01-02 11:51:31 -06:00
Wunkolo
b64b4c6761 [x64] IsFeatureEnabled: Allow parallel feature checks
Just checking if the resulting mask is non-zero means we cannot allow this function to check for multiple features in parallel. A hypothetical computer that supports FMA but not AVX2 will return `true` if you try to call `IsFeatureEnabled(kX64EmitFMA | kX64EmitAVX2)`. We should make sure all the masked flags return `true` rather than check for non-zero.

This is ramping up to allow for particular subsets of AVX512 to be checked for in parallel with a single function call.
2021-12-28 20:57:32 -06:00
Triang3l
fdec0ab332 [Code] Make union usage more consistent 2021-11-03 20:45:09 +03:00
Triang3l
e720e0a540 [Code] Remove game names from code comments (most of at least) 2021-09-05 21:27:40 +03:00
Triang3l
6ce5330f5f [UI] Loop thread to main thread WindowedAppContext 2021-08-28 19:38:24 +03:00
Triang3l
f540c188bf [Lint] Revert incorrect clang-format changes 2021-08-26 21:18:18 +03:00
Triang3l
7edfdc2672 Merge branch 'master' into linux_windowing 2021-08-26 22:58:14 +03:00
gibbed
a3535be416 [CPU] Suppress C4065 warning in SyscallHandler. 2021-06-29 02:41:29 -05:00
gibbed
0cf4cab59b [CPU] Add syscall handler. 2021-06-28 20:32:52 -05:00
gibbed
6c0d03fad3 [CPU] Reduce complexity of Value::Round. 2021-06-28 20:32:52 -05:00
Joel Linn
d87bf995e1 Satisfy linter
Apply changes suggested by clang-format-12
2021-06-27 16:33:35 -05:00
emoose
c889a8af3f [CPU] Load alt-title-ids XEX header into XexModule::opt_alternate_title_ids_ 2021-06-25 23:48:25 -05:00
emoose
e3c14419f6 [CPU/XEX] Use correct size for XEXP-patched header buffer 2021-06-06 04:50:21 -05:00
Joel Linn
ceb382f8ec Update Catch2 test framework
- Use their main() method to fix command line options. Fix CLion testing
- Change to correct tag syntax.
2021-06-02 22:28:43 -05:00
Joel Linn
fa7f292432 [CPU] ResolveFunction() Fix declaration mismatch 2021-06-02 22:28:43 -05:00
Joel Linn
5284075cf9 [CPU] Misc GCC build fixes 2021-06-02 22:28:43 -05:00
Joel Linn
86722be9ca [Base] Make Arena alignment aware
- Add align parameter
- Templated Alloc() implicitly aligns type correctly
- Rewind may leak padding that was added due to alignment
2021-06-02 22:28:43 -05:00
Joel Linn
a86d7173e1 Refactor FourCC magic uses
- Use new fourcc_t type
- Improves compiler compatibility by removing multi chars
2021-06-02 22:28:43 -05:00
Triang3l
ff23b1d9f9 [x64] LoadConstantXmm: Don't load -0 as +0 + cleanup 2021-05-16 14:26:57 +03:00
gibbed
38c3db1afb [CPU/Kernel] Transparently byteswap xex2_version. 2021-05-01 17:29:05 -05:00
emoose
bb7c5b8266 [CPU/XEX] Move SecurityInfo conversion code to ReadSecurityInfo & call that during ApplyPatch 2021-01-31 23:18:54 -06:00
Triang3l
e348d6361e [PPC] Disable frsqrte tests in a way not breaking the rest 2020-12-12 14:00:29 +03:00
Triang3l
5c47a3a588 [x64] vcfux single rounding for 0x80000000+ 2020-12-11 21:20:13 +03:00
Triang3l
d0b849aad7 [PPC] vcfsx/vcfux: Only mul if needed 2020-12-10 21:34:37 +03:00
Triang3l
cb93ddf873 [PPC] vcfsx/vcfux optimization/simplification 2020-12-10 21:29:33 +03:00
Triang3l
db1d6b1fef [PPC] Fix test suite name being ignored 2020-12-10 21:27:26 +03:00
gibbed
1513dd235b [Kernel] Code reentrance for guest fibers.
[Kernel] Code reentrance using exceptions for guest fibers.
2020-12-05 14:17:33 -06:00
gibbed
326220309b [x64] Handle constant in LOG2_F32/F64/V128. 2020-11-27 05:34:08 -06:00
Triang3l
a73592c2ef [Memory/CPU] UWP: Support separate code execution and write memory, FromApp functions + other Windows memory fixes 2020-11-24 22:18:50 +03:00
Triang3l
86ae42919d [Memory] Close shared memory FD and properly handle its invalid value 2020-11-22 14:17:37 +03:00
Sandy Carter
49e194009b [memory linux] Properly unlink shared memory
shm_unlink(name) is the proper way to close a shared memory in linux.
Prior to this, xenia was creating and not cleaning up shared memory handle
which would accumulate in /dev/shm. shm_unlink is the proper way of doing
this.
Add filename to CloseFileMappingHandle signature.
Add simple test to open and close.
2020-11-22 13:54:00 +03:00
Sandy Carter
2c7009ca80 [memory] Move "Local\\" prefix to win impl
CreateFileMappingHandle now takes shared memory name without a prefix.
The doc of shm_open recommends not using slashes and prefixing with "/".
The prefixing has been moved to the os implementation layer.
Invocations of CreateFileMappingHandle were all using "Local\\" so these
prefixes were removed.
2020-11-22 13:54:00 +03:00
Joel Linn
06214c544a [CPU] std::sort compare: satisfy comp(a,a)==false 2020-11-14 13:30:06 -06:00
Triang3l
9428af52e4 [CPU] break_on_unimplemented_instructions cvar 2020-08-09 22:01:54 +03:00
gibbed
814728ebbe [x64] Space r/xmm regs in thunk emitter. 2020-04-13 12:57:14 -05:00