Commit Graph
327 Commits
Author SHA1 Message Date
Stefanos Kornilios Mitsis Poiitidis 8c8e6294b6 Thunks: ALTINST, OP_THUNK, basic infrastructure 2020-07-20 13:52:28 +03:00
Ryan Houdek 9b78876862 Fixes LLVM not clearing code cache on ARM platforms
Surprised this hasn't caused issues before but was picked up on the
SolidRun Honeycomb LX2K
2020-07-19 12:08:27 +11:00
Ryan Houdek 2536bfe42c Correctly fixes prefix ordering in the frontend
This was sort of partially worked around.
The issue comes down to REX.W and Operand size prefix ordering on an
instruction.
When an instruction has both prefixes, then the one that has occured
later will overwrite the previous one.
Additionally in the case of 66h being reused as an escape prefix, we
needed to ignore it in this case.

The previous workaround was that if an instruction happened to have both
widening and narrowing, then widening would win(for MODRM args),
but then later on in the instruction decoding the literal constant
decoding would properly check which order the flags came in.
This resulted in literal constants working, but not modrm bytes

Instead replace the "last" flag handling with a two deep stack that we
can push and pop the flags correctly on to it, this ensures that the
flags stay around in the 66h ignoring mode (so widening doesn't get
obliterated).

This effects every instruction that supports REX.W and 66h Operand size
prefix, so it could be fixing some unknown bugs elsewhere.
Very specifically this one was found in OpenSSL, because it looks like
GCC is padding a mov instruction with 66h.

Instruction Examples:
Only difference is the prefix order being swapped
0x00000000   4                 66488b1f  mov rbx, qword [rdi]
0x00000004   4                 48668b1f  mov bx, word [rdi]
2020-07-15 00:10:20 -07:00
Ryan Houdek ac68dc40e5 Fixes INC and DEC flag setting
These two instructions explicitly don't set the CF flag.
Otherwise they behave the same as ADD/SUB flag setting
Fixes part of curl
2020-07-15 00:09:16 -07:00
Ryan Houdek 2dd7a8d16d Disables CLMUL in CPUID
This would be a pain to support in NEON since it requires a 128bit
resulting multiply
2020-07-13 10:27:48 -07:00
Stefanos Kornilios Mitsis Poiitidis f3014e43b8 Merge pull request #268 from Sonicadvance1/minor_fixes
Minor fixes
2020-07-13 12:31:09 +03:00
Ryan Houdek 383b8b7bb5 Fixes VADDV assert and implementation detail
AArch64's ADDV instruction doesn't support 8byte elements, it instead
needs to use ADDP(scalar) for the operation.

Fixes an assert and minor behaviour difference there
2020-07-12 03:41:02 +01:00
Ryan Houdek 43a8915074 Works around some vixl asserts
These don't change behaviour, but in debug mode were causing asserts
2020-07-12 03:39:55 +01:00
Ryan Houdek 80b9b45b3e Cleans up a couple warnings 2020-07-11 06:21:28 +01:00
Ryan Houdek f593906c9a Fixes LORegion feature detection problem
LORegion is a requirement of ARMv8.1, but the hypervisor of the c630
isn't exposing the identification register correctly.
If the host supports atomics, just assume it supports LORegions as well

Fixes an assert when building vixl in debug
2020-07-11 06:21:08 +01:00
Ryan Houdek 1f727c5826 Fixes Vector_FToF op on AArch64 JIT
Only fixes asserts, no code emission changes
2020-07-11 06:20:57 +01:00
Ryan Houdek cb74beadb4 Fixes Zext on FPR->GPR conversion for AArch64
The 32bit and lower sizes were making vixl asserts fire.
Wouldn't actually change emitted code
2020-07-11 06:20:50 +01:00
Ryan Houdek d281e9f7ff Fixes LDIV bug in aarch64 JIT
vixl asserts were firing for the 16bit variant, and we needed to sext
the divisor for the 32bit variant
2020-07-11 06:20:40 +01:00
Ryan Houdek a1db6a0dec Adds new signal delegator class
Allows us to register host and guest signal delegators.
Currently only host signals are handled, guest signal delegation will
take a bit of work still.
2020-07-11 06:12:06 +01:00
Stefanos Kornilios Mitsis Poiitidis 951ff40904 Frontend: Fix 15-byte long opcode assert 2020-07-08 14:00:14 +03:00
Stefanos Kornilios Mitsis Poiitidis 560d467058 VURAvg: Fix arm64 jit 2020-07-04 21:52:15 +03:00
Stefanos Kornilios Mitsis Poiitidis 8eaa11f4f2 VURAvg: Fix llvm implementation 2020-07-04 20:51:13 +03:00
Stefanos Kornilios Mitsis Poiitidis c19e8b3d2f Implement PAVGB/PAVGW 2020-07-04 19:30:53 +03:00
Ryan Houdek 9c99dbfbdc Fixes AtomicSwap IR op on x86
lock prefix needed to go before the xchg, not before the move that was
there
2020-07-02 22:18:44 -07:00
Ryan Houdek 03e084c7f0 Merge pull request #248 from FEX-Emu/fork_syscall
clone: Some support for fork, Flag validation
2020-07-02 14:39:23 -07:00
Ryan Houdek 4612fb5a67 Implements support for cache clearing in the ARM64 JIT
Previously the ARM64 JIT didn't support cache clearing at all.
This adds support for clearing the JIT cache while keeping dispatcher
helpers around and the ASM dispatcher alive.
2020-07-01 23:07:09 -07:00
Ryan Houdek bb60044e12 Splits JitArm64 IR handlers to a jump table
Improves compilation time by multiple minutes
Clang was taking multiple minutes to compile JIT.cpp for ARM.
This drops it down to a handful of seconds instead.

No functional behaviour change, only movement.
JIT compile times might deviate slightly moving from a switch to a jump
table, but will be negligible in either direction.
2020-07-02 02:46:14 +01:00
Ryan Houdek ce15a1bdcd Corrects MM register alignment in CoreState
This was misaligned by 8 bytes, which worked fine on x86, but crashed
when loaded on ARM.

Now it is correctly aligned to 128bit
2020-07-01 06:08:39 +01:00
Stefanos Kornilios Mitsis Poiitidis 2ccaea7d66 clone: Validate flags, cleanup 2020-06-30 16:23:43 +03:00
Ryan Houdek 8a5813e4d0 [WIP] Fork syscall support
Bit buggy
2020-06-30 16:22:47 +03:00
Ryan Houdek bd26d15879 Fixes LLVM multiblock
The break ir op is actually a block ender and it happened that in
regular code paths they were already ending the blocks correctly.

This enforces block ending in the Unimplemented op so multiblock still
generates the invalid code path correctly and it compiles.
We hit these a few times in multiblock for times in the code where it is
checking for CPU features and choosing a code path depending on CPUID
results.

Potentially these could be made in to no-ops since we'll never hit these
codepaths in practice, but it is nicer to break in case we actually do
hit one of these paths.
2020-06-26 12:31:15 -07:00
Ryan Houdek 2bcc46c9e5 Implements FFREEP support in the OpDispatcher
There's some history for this instruction. It is not in the official
instruction documentations from AMD or Intel but it is supported on
almost every x87 supporting CPU (I think there was some Cyrix that
missed it?)

This was originally implemented by accident on the Intel 80287 CPU.
It was then periodically documented in random documentation.

The instruction behaves exactly like FFREE but then pops the stack after
the operation.
For our current implementation of FFREE, which is a NOP, we just need to
pop the stack.
2020-06-20 08:11:26 -07:00
Stefanos Kornilios Mitsis Poiitidis 0e19763045 Merge pull request #236 from Sonicadvance1/32bit_move_segments
Supports segment register moving
2020-06-16 10:47:17 +03:00
Stefanos Kornilios Mitsis Poiitidis 88d78e6664 Merge pull request #233 from Sonicadvance1/armv8_0_atomics
Implements atomic ops for ARMv8.0 devices
2020-06-16 10:46:12 +03:00
Stefanos Kornilios Mitsis Poiitidis cc2f994956 Merge pull request #237 from Sonicadvance1/32bit_opdispatcher
Supports 32bit operating mode in the OpDispatcher
2020-06-16 10:45:13 +03:00
Stefanos Kornilios Mitsis Poiitidis 06ece0402b Merge pull request #238 from Sonicadvance1/remove_debug_log
Remove a debug log from the AArch64 JIT
2020-06-16 10:43:08 +03:00
Ryan Houdek 2acf22f15b Fixes cvtps2dq instruction
This must of have been a copy and paste error, I didn't even have this
instruction on my list of implemented instructions.
It definitely isn't converting to a GPR
2020-06-15 20:25:13 -07:00
Ryan Houdek ea85c70daf Remove a debug log from the AArch64 JIT
These keep sneaking back in when I'm testing
2020-06-14 14:35:53 -07:00
Stefanos Kornilios Mitsis Poiitidis 77b63760be Merge pull request #235 from Sonicadvance1/32bit_remove_64bit_size
Removes 64bit size from frontend when in 32bit mode
2020-06-14 03:15:48 +03:00
Ryan Houdek fc777887f4 Supports 32bit operating mode in the OpDispatcher
Pretty basic for the most part, just changes default operating mode for
most everything from 64bit to 32bit.
2020-06-12 19:27:43 -07:00
Ryan Houdek c2bd346297 Supports segment register moving
32bit apps are setting GS register that I saw.
64Bit applications can also technically use these instructions but it
has some major limitation that causes applications to never use them
2020-06-12 18:49:29 -07:00
Ryan Houdek 5b9de1675f Removes 64bit size from frontend when in 32bit mode
64bit mode doesn't exist when we are operating in 32bit mode, so this
needs to be disabled.
This forces a fallback to a 32bit size for those ops
2020-06-12 15:19:40 -07:00
Ryan Houdek 7bfe127fcb Ensures the core saves the entry cache to the correct folder
We should store this in XDG_CACHE_HOME, not DATA_HOME.
Also fallback the HOME and PWD directories correctly
2020-06-12 15:08:16 -07:00
Ryan Houdek 53c46312ff Implements atomic ops for ARMv8.0 devices
These can only be implemented as acquire/release exclusive loops on
ARMv8.0 so they end up looking pretty disgusting.
This is more for compatibility for testing than anything. I'm not
expecting ANY ARMv8.0 device to get decent performance
2020-06-12 15:06:36 -07:00
Ryan Houdek b262b59916 Fixes up prefix handling for 32bit
Moves REX to a 64bit only table entry. This allows the missing INC/DEC
instructions to exist in 32bit space
2020-06-10 16:49:06 -07:00
Stefanos Kornilios Mitsis Poiitidis 8ca73a63cc Merge pull request #174 from Sonicadvance1/enter_inst
Enter inst
2020-06-11 00:41:18 +03:00
Ryan Houdek 97070ea548 Implements ENTER instruction 2020-06-06 11:52:51 -07:00
Ryan Houdek b25f1c4e3b Fixes a case of the BT ops failing to test the correct bit
When the `BT mem` operation was accessing memory where the bit offset
wasn't a multiple of the access size, then we were dividing the offset
by bytes and accessing bits at `mem[byteOffset] &= (BitOffset)`.
BitOffset wasn't adjusted to compensate for the access size being added
to the address.
Causing a mismatch of testing the wrong bits. Unit tests didn't capture
this.
Trying to run glxgears on i965/iris showed extensive corruption because
of it though.
2020-06-03 23:48:28 -07:00
Stefanos Kornilios Mitsis Poiitidis f1173a3bca Merge pull request #218 from Sonicadvance1/implements_lods
Implements LODS instruction
2020-05-31 12:02:11 +03:00
Stefanos Kornilios Mitsis Poiitidis a659024547 Merge pull request #220 from Sonicadvance1/psadbw
Implements psadbw for MMX and SSE2
2020-05-31 12:00:36 +03:00
Ryan Houdek a147e5eca1 Implements psadbw for MMX and SSE2
Saw this when running Freedreno on x86-64
2020-05-31 03:22:11 +01:00
Ryan Houdek 3dae3f4b84 Fixes bug that cropped up in cvtpi2ps from previous changes 2020-05-31 03:22:11 +01:00
Ryan Houdek 2ba797a992 Implements new IR ops in the CPU backends 2020-05-31 03:22:11 +01:00
Ryan Houdek 111b0624ca Implements LODS instruction
Theoretically the REP case can be optimized if it is known not to fault,
but that is one legitimate use case of this instruction.
This is just to ensure that we have this instruction covered, it hasn't
been encountered in a real program yet.
2020-05-29 23:35:36 -07:00
Ryan Houdek c0711404e9 Forces LLVM backend to use the native CPU architecture
Better than relying on a hardcoded CPU target
Should fix a crash on x86 host cpus that don't support BMI1
2020-05-29 17:51:37 -07:00