Commit Graph
68 Commits
Author SHA1 Message Date
Ryan Houdek 7f4836b982 Fixes 32bit x87 usage
All of the ops that were relying on a 64bit memory offset were being
downgraded to 32bit.

Abuses the XMM_FLAGS option a bit to indicate that it shouldn't
downgrade the 64bit size flag. Which isn't an issue since all these
operations can't encode a register since modrm_r is used for table
decoding
2020-10-25 11:17:00 -07:00
Stefanos Kornilios Mitsis Poiitidis 93e372c7a4 IR/JITs: Inline Constants Implementation
Based on @phire's idea, Inline constants are constants that can be used as imms in instructions.

This
- Adds OP_INLINECONSTANT to represent them in the IR
- Modifies the ConstProp pass to transform OP_CONSTANT to OP_INLINECONSTANT based on per-platform heuristics
- Modifies the backends to use imms
- Supported opcodes: Add, Sub, Lsl, Lsr, Asr, Ror, Rol
2020-10-22 18:49:17 +03:00
Ryan Houdek dd49a04809 Fixes RIP literal sign extending on 32bit
RIP Literal isn't actually RIP literal on 32bit, it is RIP absolute.
64bit treats the 32bit as a signed offset, while 32bit treats it as a
32bit unsigned offset
2020-10-17 20:19:50 -07:00
Ryan Houdek a8175ca891 Moves away from std::is_pod
This is deprecated in C++20 and will spam warnings all over the place
2020-10-17 16:02:55 -07:00
Ryan Houdek 02d029877c Adds segment register flags mask 2020-10-09 23:33:07 -07:00
Ryan Houdek 83ac23be21 Implements new VTBL1 IR op
This perfectly matches the AArch64 variant and almost perfectly matches
x86's pshufb instruction
2020-09-26 12:59:34 -07:00
Ryan Houdek ddd7b8f406 Adds a mixxing VXor op to the IREmitter helper 2020-09-26 12:52:26 -07:00
Stefanos Kornilios Mitsis Poiitidis 83db01f505 Merge pull request #429 from Sonicadvance1/psign
Implements support for SSSE3 PSIGN{B,W,D}
2020-09-26 20:20:06 +03:00
Ryan Houdek b68832f31b Adds the IR ops to the IREmitter helper 2020-09-24 19:45:17 -07:00
Ryan Houdek 09ee71b8c3 Adds missing VFSub IREmitter function 2020-09-23 18:07:53 -07:00
Ryan Houdek de2a165a7d Adds ability for the frontend to register a signal handler
This will come to be useful for our host code execution and wine in the
future
2020-09-22 13:19:41 -07:00
Scott Mansell b0cfc19267 Fast replacement path for constants 2020-09-17 11:29:57 +12:00
Ryan Houdek d424cf0eee Merge pull request #365 from phire/IR_iterators
Refactor the IR Interface to prevent "foot-shooting"
2020-09-16 11:24:44 -07:00
Stefanos Kornilios Mitsis Poiitidis df3bdf361f SMC: Add --smc-full-checks, implement frontend, irint, irjit, unit test 2020-09-16 01:15:21 +03:00
Ryan Houdek e9b74b0230 Initial Callback support
This interface is for native host code to be able to call back in to JIT
to execute guest code.
This is mainly for thunks but could be used for other purposes.
This can cross a couple ABI boundaries so one must be careful when
calling in to this
2020-09-11 15:48:51 -07:00
Scott Mansell d515753b38 Remove remaing traces of NodeWrapperIterator 2020-09-11 21:50:30 +12:00
Scott Mansell e756b46189 Allow AllNodes to iterate in reverse
We replace Dummy with the old unused BeginBlock
and pointing it at block header like EndBlock
2020-09-11 21:50:30 +12:00
Scott Mansell 3c6dbd0ade Change iterator type of IR.at
And switch over more passes to use the new interfaces.
2020-09-11 21:50:30 +12:00
Scott Mansell df6618a4d2 New replace node functions
Probally doesn't build
2020-09-11 21:48:03 +12:00
Scott Mansell 4ad4f28a75 Add Code and All Code iterators 2020-09-11 21:48:03 +12:00
Scott Mansell 599231c180 IRListView: Add GetOp<T> 2020-09-11 21:48:03 +12:00
Scott Mansell 36afd5b1c6 Block Iterator: Use structured bindings 2020-09-11 21:48:03 +12:00
Scott Mansell 446b261f24 Iterator for blocks 2020-09-11 21:48:03 +12:00
Ryan Houdek 4b17521ab9 Merge pull request #343 from Sonicadvance1/cpuid_improvements
Has /proc/cpuinfo generated from CPUID
2020-09-06 12:40:03 -07:00
Ryan Houdek e177bb3ebc Adds a git_version generated header
Allows us to get the short git hash at runtime
2020-09-05 16:59:10 -07:00
Ryan Houdek 0819a40c57 Adds option to disable TSO
This is a knowingly wrong option for anything running in a threaded
environment
2020-09-05 16:58:03 -07:00
Ryan Houdek 50349db4c6 Moves our entire execution model over to signal execution
This requires implementing custom ASM dispatchers for the interpreter
side of things so it works correctly.
Allows all of our CPU backends to safely support signaling.
This is a bit of a nightmare change and requires rethinking logic about
debugging in some instances.
2020-09-02 16:00:17 -07:00
Scott Mansell 3989772a4f Remove OP_Zext
Zext has confusing sematics and does excatly the same thing as BFE

 * Repace with other ops (mostly BFE)
 * Allow specifying BFE size
2020-08-26 00:47:01 +12:00
Ryan Houdek 5efab55ea9 Removes LLVM from FEX
LLVM has too many problems with it to use it as a tiered level of JIT.
We won't be able to use it
2020-08-19 18:02:28 -07:00
Ryan Houdek b38983df35 Implements new TSO loadstore IR ops.
These need to end up being specially handled on non-x86 platforms
2020-08-12 15:24:00 -07:00
Stefanos Kornilios Mitsis Poiitidis 8c8e6294b6 Thunks: ALTINST, OP_THUNK, basic infrastructure 2020-07-20 13:52:28 +03: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
Stefanos Kornilios Mitsis Poiitidis c19e8b3d2f Implement PAVGB/PAVGW 2020-07-04 19:30:53 +03: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
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 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
Ryan Houdek 7302ad1996 Adds new FEX config for telling the guest how many CPU cores it can have
This is just a virtual number that the guest can query through the
various means. Will affect mesa with how many helper threads it
generates at the very least
2020-06-04 00:03:41 -07:00
Ryan Houdek 2f1d7f70a2 Adds new IR ops that PSADBW will need 2020-05-30 18:49:09 -07:00
Ryan Houdek 3759cbdb65 Interpreter based x87 support!
This implements support for 130 of the 132 x87 ops as interpreter
fallbacks.

The two missing ops are the BCD load and BCD store instructions and can
be implemented another time.

This allows us to no longer have to rely on a libstdc++ modification to
handle their usage of long double. This instead works entirely through
using `long double` directly in the interpreter. Which will either use
real x87 on an x86 host. Or in the case of ARM devices, fall down
glibc's long double soft float path.

This doesn't necessarily need to be quick right now. It's more important
to have the compatibility improvement from this.
2020-05-28 14:47:43 -07:00
Ryan Houdek fd857e4966 Makes threaded compilation not rely on a global mutex
As we run more threaded applications it is becoming apparent that this
needs to be fixed now.
This duplicates the FrontendDecoder and Passmanager per thread so they
no longer block each other while compiling.
Increases a bit of memory usage but completely worth it.
2020-05-27 10:18:02 -07:00
Stefanos Kornilios Mitsis Poiitidis 2fd8e617ff Merge pull request #207 from Sonicadvance1/interpreter_fallback
Adds support for interpreter fallback
2020-05-27 14:20:58 +03:00
Ryan Houdek 38ff936c81 Adds support for interpreter fallback
The IRHeader itself contains a flag for if a block should fallback to
the interpreter.
This is necessary for the case that an IR is loaded and the Frontend
object no longer has the data necessary to know if it should do an
interpreter fallback.
This is super useful for bisecting JIT versus Intepreter failures, and
also cases where falling back to intepreter for compatibility is a lot
more simple than wiring things through the JIT (ala x87)

This isn't currently utilized, but will be once x87 work lands
2020-05-26 19:08:18 -07:00
Ryan Houdek 5569894d81 Implements fence ops
These map directly to x86 fence instructions, which have equivalent ARM
versions as well.
2020-05-26 19:04:35 -07:00
Ryan Houdek 7c8f7c732f Fixes some missing includes 2020-05-25 20:04:17 -07:00
Ryan Houdek 667e514262 Adds 32bit GDT state to CoreState
32bit x86 memory accesses require going through the GDT and has syscalls
that support setting these.
The GDT isn't a flat address space like in x86-64, so we actually need
to support this.
2020-05-15 03:01:17 -07:00
Ryan Houdek d2cf07a4fd Passes the running mode through from FEX to FEXCore 2020-05-14 00:56:31 -07:00
Ryan Houdek c171fbb71e Add 64bit config option
Not currently wired up to anything
2020-05-14 00:55:52 -07:00
Ryan Houdek 718b3e6b4c Refactors PassManager to ingest IREmitter class instead of OpDispatcher
The Passmanager passes need very little or zero x86 knowledge to do
their work. They don't need the x86 OpDispatcher handling code at all.
Convert this entirely over to using the IREmitter class so it can
actually optimize IR code from the IRLoader frontend
2020-05-09 12:14:59 -07:00
Ryan Houdek 1b720479c4 Adds a self contained IREmitter class
This class does IR emitting and some basic handling of IR specific
tasks.

This is going to be used to split the x86 OpDispatcher from the IR
emission so the IR emitter can be passed around without caring about x86
dependencies.
2020-05-08 19:03:22 -07:00
Ryan Houdek 6e4b29d760 Implements a TypeDefition type for IR handling
Will be useful when parsing later
2020-05-07 17:40:29 -07:00