Commit Graph
62 Commits
Author SHA1 Message Date
Ryan Houdek 157f66bfc0 Fixes MOVSS op bug found by unit tests
It had failed to zext to 128bits when loading from memory
2020-03-06 07:56:19 +02:00
Ryan Houdek 9c363fb317 Various fixes that unit tests have found
- Need to distinguish between unsigned and signed saturating ops
- Fixes vector splat
- Fixes VUMULL/VSMULL num element calculation
- Fixes undefined behaviour in a couple of vector shift ops
- Implements VSSHR
- Fixes VExtr calculating offset correctly
- Fixes VInsGPR calculating offset correctly
- Fixes PSRA (not immediate) x86 ops
- Fixes scalar vector unary ops to correctly insert lower bits
- Fixes conversion instructions correctly inserting lower bits
- Fixes PINSRW using the wrong element size
2020-03-06 07:56:19 +02:00
Ryan Houdek 9b21caa647 Adds support for CMPPD's NEQ comparison 2020-03-06 07:56:19 +02:00
Ryan Houdek 1a7eddb49d Fixes a bug in MOVLPD 2020-03-06 07:56:19 +02:00
Ryan Houdek d2a1c41563 Fixes the missed BTC op instruction from the previous BT* changes 2020-03-06 07:56:19 +02:00
Ryan Houdek cd5e34e8cc Fixes a bunch of various bugs in the x86 translation
Removes a bunch of MMX instructions accidently exposed in the
opdispatcher tables.
2020-03-06 07:56:19 +02:00
Ryan Houdek ba6c542a56 Adds support for MOVMSKPS/MOVMSKPD 2020-03-06 07:56:18 +02:00
Ryan Houdek 7909b1f277 Adds UNPCKHPS instruction 2020-03-06 07:56:18 +02:00
Ryan Houdek e67f141c29 Adds packed float comparison x86 instructions CMPPS/CMPPD 2020-03-06 07:56:18 +02:00
Ryan Houdek 9870547d50 Fixes 32bit element selection for SHUFP 2020-03-06 07:56:18 +02:00
Ryan Houdek f645bd7901 Adds a few new IR ops
Fixes REP CMPS. It needs to also break when ZF == 0
Fixes REPNE SCAS. It shouldn't set ZF to 0 on entry. Could result in erroneous flag setting.
Implements a few new x86 ops
2020-03-06 07:56:18 +02:00
Ryan Houdek ec5f3a6854 Fixes LEA instruction
LEA changes behaviour based on the ordering of the prefixes on the
instruction

eg:
66 48 8d 3d ffffffff: lea rdi, [rip - 1]
48 66 8d 3d ffffffff: lea di, [rip - 1]

So we need to know the order of a few of the prefixes.
In the future this should probably be switched to a three deep stack to
have the ordering but for now this'll do
2020-03-06 07:56:17 +02:00
Ryan Houdek 64e863a5a0 Adds a few more instructions to the OpcodeDispatcher 2020-03-06 07:56:17 +02:00
Ryan Houdek d8b3e3bd84 Adds Popcount x86 instruction to dispatcher 2020-03-06 07:56:16 +02:00
Ryan Houdek ed12a8a242 Fixes x86 instruction decoding.
In the case of modrm + immediate then the immediate would end up
overwriting Src1 due to the the order of the decoding.
Changes Src1 and Src2 to an array and use a variable to index the array.
Causes a bit of code churn but fixes instruction decoding and allows
easier expansion in the future for instructions that have more sources
like AVX
2020-03-06 07:56:15 +02:00
Ryan Houdek 8a2bf00fb6 Enforces register classes on loadstores
Register class for loadstores must be declared upfront.
This was causing a pain point when we were trying to load <16byte in to
FPRs, which was requiring a GPR<->FPR dance.
2020-03-06 07:56:15 +02:00
Ryan Houdek 472ec5f5cf Adds 11 new emulated syscalls 2020-03-06 07:56:15 +02:00
Ryan Houdek 7ade645af2 Adds vector compare ops to OpDispatcher 2020-03-06 07:56:14 +02:00
Ryan Houdek 39802cc464 Adds a couple nop implementation of ops in OpDispatcher 2020-03-06 07:56:14 +02:00
Ryan Houdek 67ac4f015f Adds ANDN to OpDispatcher 2020-03-06 07:56:14 +02:00
Ryan Houdek 1f4418b463 Adds missing move to OpDispatcher 2020-03-06 07:56:14 +02:00
Ryan Houdek 134fa50f8b Adds fsqrt and frsqrt to OpDispatcher 2020-03-06 07:56:14 +02:00
Ryan Houdek 9bc899aba0 Changes CMPS to not break RA
RA isn't happy with how this is arranged, so it needs to be changed
until RA is good enough to support it
2020-03-06 07:56:14 +02:00
Scott Mansell 26141e426a Fix unsigned/signed compare conditions
Also, rename to match the LLVM naming style, which is less confusing.
2020-03-06 07:56:07 +02:00
Scott Mansell 7f840aa3e9 Basic FADD implementation
Only handles addition of two positive numbers
2020-03-06 07:56:07 +02:00
Scott Mansell f5bf8eaeb2 Add FST/FSTP m80 2020-03-06 07:56:07 +02:00
Scott Mansell bbd951603f Add FLD m32/m64
Currently produces incorrect results on infinities/denormals.
2020-03-06 07:56:06 +02:00
Scott Mansell 4051d529df Fix size of movesd xmm <-- m64 2020-03-06 07:56:06 +02:00
Ryan Houdek 8cd865a91e Removes debug log 2020-03-06 07:56:06 +02:00
Ryan Houdek f4a5770f1e Implements lock prefix on some commonly used ops 2020-03-06 07:56:06 +02:00
Ryan Houdek e1d2a934e2 Fixes the scalar SSE ops and MOVD 2020-03-06 07:56:05 +02:00
Ryan Houdek 6fb2d1aa1f Implements XADD x86 instruction 2020-03-06 07:56:05 +02:00
Ryan Houdek 2858adc0d3 Fixes MOVSD x86 instruction 2020-03-06 07:56:04 +02:00
Ryan Houdek 28142703ee Fixes BTR/BTS op when destination is GPR 2020-03-06 07:56:04 +02:00
Ryan Houdek 77e7a453d3 Adds BTC x86 instruction 2020-03-06 07:56:04 +02:00
Ryan Houdek 255138dcc4 Adds a bunch of new instructions to the OpcodeDispatcher 2020-03-06 07:56:03 +02:00
Scott Mansell 2babc1292c GdbServer: Breakpoint intergation 2020-03-06 07:56:01 +02:00
Ryan Houdek e0e708a9c0 Fixes three instructions necessary for shared apps to run
Fixes MOVHPD which was failing.
Fixes FXSTOR and FXSAVE which was accidently loading the memory location
rather than doing an LEA of the address.
2020-03-06 07:56:01 +02:00
Ryan Houdek af5a562508 Fixes bug in STOS and CMPS
We were storing one too many elements. So even if the counter register
was zero it would do a store or comparison
2020-03-06 07:56:00 +02:00
Scott Mansell 8a6efad301 Stub FNSTCW/FLDCW so libc.so.6 can be loaded
Apparently doesn't need any other x86 instructions.
Or anything more than noped out state save/restore.
2020-03-06 07:56:00 +02:00
Ryan Houdek 3f06f3e87d Fixes bug in PUSH op with RSP source.
We were modifying RSP to adjust the stack first.
Then if the source used RSP then it was offset by the store size.

`push [rsp]` was broken before this
2020-03-06 07:56:00 +02:00
Ryan Houdek 2df55d303a Fixes bug in SHR op
Smaller ops could have been shifting data from the larger source in to
the smaller op space when it should have been zero'd
2020-03-06 07:55:59 +02:00
Ryan Houdek afdbd9ebdc Fixes issues with PSLLDQ and PSRLDQ
These are whole vector shift instructions and they shift by bytes rather
than bits.
You only get an immediate offset for the instruction.
Implements two new IR ops to account for these instructions

This also doesn't match AArch64 behaviour 100%, requires two
instructions to emulate rather than the single one on the x86-side
2020-03-06 07:55:59 +02:00
Scott Mansell 20fc6a489e Fix STOS to not load SSA regs across blocks 2020-03-06 07:55:45 +02:00
Ryan Houdek 9e132e107a Adds alignment information to the mem loadstore IR ops
Allows us to not always emit unaligned loadstore ops for these
2020-03-06 07:55:45 +02:00
Ryan Houdek 435357e06e Fixes a bug in STOS 2020-03-06 07:55:44 +02:00
Ryan Houdek 3a041c3b1c Fixes bug in block creation for any block containing RET.
Would have a redundant StoreContext after the RET which broke IR
analysis
2020-03-06 07:55:44 +02:00
Ryan Houdek e1cecbcfe3 Changes to the new multiblock frontend decoder
Simple linear scan forward of instruction decoding isn't viable to do.
We need to break up the decoding at the block boundaries.
Otherwise our decoding gets in to the weeds and decodes trash.
2020-03-06 07:55:37 +02:00
Ryan Houdek b7c7a34cf6 Changes (aggressively) how branching is handled in the frontend.
This changes over CondJump to have a defined True and False branch path.
Additionally needing to change over everything to handle this.
This now means that a false branch condition will no longer assume
fallthrough past this instruction.
Currently the x86-64 JIT generates an additional jmp instruction on
fallthrough that isn't optimized away.

This is working towards improvements in our IR branching model and
improving IRValidation in doing so.
This is working towards the model that IRBlocks can only have 0-2
successors.
Ret/Exit - 0 successors
Jump - 2 successors
CondJump - 2 successors

TBD:
Syscall/CPUID - Breaking block?
2020-03-06 07:55:37 +02:00
Scott Mansell d1f2d85d0c Fix up usage tracking of Args.
Make sure we keep them up to date when removing
nodes.
2020-03-06 07:55:36 +02:00