Commit Graph
56 Commits
Author SHA1 Message Date
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 6669bcfffd Merge pull request #209 from Sonicadvance1/minor_opts
Minor memory allocation optimizations in the IR passes.
2020-05-27 14:27:08 +03: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 b3b6727a8e Minor optimization in IRCompaction pass
Codeblock array was constantly being reallocated.
Changes the remap array over to a allocate in multiples of the alignment
size.
Was hitting a pedantic case where the compaction would hit slightly
increasing function sizes so large numbers of reallocations occured
quickly.
2020-05-26 22:25:15 -07:00
Ryan Houdek f8579d5458 Minor optimization in the RCLSE pass
We already have an unmodified classification struct. Just memcpy it to
reset the state. Reduces a bunch of temporary allocations.
Also disables the CFG calculation since we aren't using it currently
2020-05-26 22:23:10 -07: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
Stefanos Kornilios Mitsis Poiitidis 7799cd43a4 Merge pull request #199 from Sonicadvance1/ir_has_sideeffects
Implements HasSideEffects IR option
2020-05-26 09:36:02 +03:00
Ryan Houdek f41700cd58 Lets DCE pass use the new HasSideEffects IR attribute
This will be less prone to breaking since you should have the sideeffect
described in the IR
2020-05-25 17:55:26 -07:00
Ryan Houdek 98d6feabae Marks IR ops that have side effects in the IR file 2020-05-25 17:53:57 -07:00
Ryan Houdek 277d0c6e22 Adds JSON IR option HasSideEffects
This will be useful for making sure our DCE pass isn't so fragile
2020-05-25 17:50:07 -07:00
Ryan Houdek 6cdbab9846 Fixes RCLSE CPUState classification
We were missing the newly added GDT classifications.
Wouldn't have caused any issues in any 64bit applications, but threw an
assert in debug builds
2020-05-25 00:34:19 -07:00
Ryan Houdek 0a1a52860d Works around a spill bug in the RA
Spilling is a mess in this version of the RA and there was a significant
bug that effectively made spilling either infinite loop or crash.

This adds a bunch of new comments about the logic of the spilling and
ipmroves it so it shouldn't break as easily.

There are still some edge cases that can be hit that break spilling but
a lot of this code is going to be scrapped for the new RA coming up
anyway.
This is temporary until the new RA merges in.
2020-05-11 16:19:08 -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 bb7e58b3f1 Adds more IR documentation 2020-05-08 18:40:21 -07:00
Ryan Houdek 4269cef98f Adds the ability for the IR printer to dump TypeDefinition
No IR uses this currently directly but it could definitely happen.
2020-05-07 17:40:29 -07:00
Ryan Houdek 54ee9cbe86 Adds predefined TypeDefinition types for common sizes 2020-05-07 17:40:29 -07:00
Ryan Houdek 00028d41db Updates IR dumping to be easier to parse
This will allow us to lex the text
2020-05-07 17:25:44 -07:00
Ryan Houdek 0e4bd4e7b7 Significantly improves IR documentation in the JSON file
Doesn't cover 100% of the IR ops but it hits about half
2020-05-07 17:24:44 -07:00
Ryan Houdek ad467c5b30 Adds new vector float negate and float add horizontal IR ops 2020-04-25 17:55:37 -07:00
Ryan Houdek 3bf641dd14 Adds RA printing to the IR dumping function
If a backend has RA then this'll pass through the RAPass and will dump
the RA alongside the IR. Very useful for debugging.
2020-04-18 13:42:44 -07:00
Ryan Houdek 36a9388481 Lets the IR validation pass validate RA
Adds some additional validation that an IR op is generating RA for ops
that set a destination.
Ensuring correct register class and that there is a physical register
assigned
2020-04-17 18:09:46 -07:00
Ryan Houdek 37e2a2bb6f Adds validation passes after regular passes
This is required for the forthcoming IRValidation pass change that
validates RA is working
2020-04-17 18:09:46 -07:00
Ryan Houdek 8d7a512b16 Move vector op RegisterSize and ElementSize values in to the header struct
Sadly this is a fairly substantial change that can't be broken in to
something smaller.
The gist of the problem is that most of the vector ops declared their
own uint8_t RegisterSize and ElementSize variables in their structs.
This was initially done because there were assumptions elsewhere in the
source that sometimes mixed up the IROp member `Size` and `Elements` as
sometimes meaning `Size` elements and `Elements` number of elements.
Other times there was an assumption that `Size` was the full register
size and `Elements` was the number of elements inside that size.
ex: `Size`: 16, `Elements` 8 would sometimes be interpreted as i8v16 OR i128v8

These assumptions are now removed and we also save on average 16bits per
vector operation. This is a necessary evil first step for upcoming IR
considerations.
This should have zero change on runtime behaviour and unit tests confirm
that.
2020-04-11 22:17:48 -07:00
Ryan Houdek 2267bc0949 Minor IR cleanup
Changes the IR register class definition to exist in the JSON file.
Removes a couple of IR ops that were unused and weren't necessary.

Changes the CPUID IR op to the new paired op which improves perf ever so
slightly.
Changes RA class handling in the RA pass to pull directly from the new
generated helper routine until it hits a complex op

Still need RA constraints to remove extraneous moves that would crop up
2020-04-10 19:16:47 -07:00
Ryan Houdek 30bce2468d Remove magic numbers for invalid register class definition
Consolidates usage of register class to the one that is defined in the
IR Json file.
Every magic number is replaced with InvalidClass and instead uses the
enums directly

Another bug fix is that the GetHostFlags IR ops was being declared as
using the flags register class, which isn't a real thing yet.
This would most likely have ended up with host flag usage being
scheduled to a GPR that was already scheduled and overwrite it.

Once this IR op ends up in host flags this will be changed as well
2020-04-10 01:02:29 -07:00
Ryan Houdek 74f61a00bc Adds invalid class definition through the IR definitions file 2020-04-10 01:02:11 -07:00
Ryan Houdek 4ed0f61ccc Makes sure FCMP IR op destination size is set to 4
Adds a description about its operation
2020-04-10 01:02:07 -07:00
Ryan Houdek 0766de70dd Merge pull request #89 from Sonicadvance1/wip_pair
CMPXCHG8B and CMPXCHG16B support
2020-04-10 00:56:26 -07:00
Ryan Houdek 70a3557925 Make sure the DCE pass doesn't remove pair context store ops 2020-04-10 00:50:35 -07:00
Ryan Houdek 24eb25bc89 Make sure the RCLSE pass can't optimize through paired context loadstore ops 2020-04-10 00:50:35 -07:00
Ryan Houdek 3bb0d06a36 Adds new paired reg IR ops 2020-04-08 00:17:12 -07:00
Ryan Houdek 27df596218 Adds support for register class conflicts to the RA
On average adds <1% performance overhead to RA
2020-04-08 00:14:52 -07:00
Ryan Houdek f46870a2fb Fix a bug in the const prop pass
When a Zext is going 64bit->128bit this involves a register class change.
This is special cased in the CPU cores and the const prop class doesn't
really have a way to handle this case in the IR level
2020-04-06 12:25:58 -07:00
Ryan Houdek 211b9b625b Makes the RCLSE pass more strict about what it optimizes 2020-04-06 12:25:58 -07:00
Ryan Houdek 4ebfd7b9dc Removes the, buggy and redundant, redundant flag calculation elimination pass
The RCLSE pass already handles this
2020-04-06 12:25:58 -07:00
Stefanos Kornilios Mitsis Poiitidis 4049b30e57 Merge pull request #76 from Sonicadvance1/syscall_cleanup
Syscall cleanup
2020-04-06 18:10:05 +03:00
Ryan Houdek 52aae9b3e6 Optimize the syscall IR op argument loading based on syscall definition
When we have function calls we can call the handler directly instead of
a thunk step in between
2020-04-05 14:00:22 -07:00
Stefanos Kornilios Mitsis Poiitidis 227d6dc8c1 Merge pull request #83 from Sonicadvance1/unordered_ordered_compare
Implements unordered and ordered compare IR op
2020-04-05 13:02:44 +03:00
Ryan Houdek 840fee77b4 Implements unordered and ordered compare IR op
Implements the remaining missed comparisons for x86's compare ops
2020-04-04 23:19:22 -07:00
Ryan Houdek 3e398a1b9b Pass Context to the OpDispatcher 2020-04-04 23:05:03 -07:00
Ryan Houdek 33a4ff061d Allow IRValidation pass to ignore invalid SSA nodes 2020-04-04 23:04:56 -07:00
Ryan Houdek f1d928d468 Allow RA pass to work with invalid SSA nodes 2020-04-04 23:04:49 -07:00
Ryan Houdek a7079e5bec Allow the value domination pass to work with invalid SSA values 2020-04-04 23:04:42 -07:00
Ryan Houdek fd4fb37056 Adds a new VMOV IR op
Both AArch64 and x86 don't have optimal paths to move <64bit FPRs to
another with ZEXT.
So this is optimal for 128bit and 64bit while smaller ops have have the
expected overhead when using it
2020-04-01 20:04:05 -07:00
Ryan Houdek a8d4d0d3c3 Adds new IR ops
vector pairwise add
vector unsigned shift right with narrowing
vector unsigned and signed extend with lengthening from upper bits
vector unsigned and signed multiply with lengthening from upper bits
2020-03-27 20:56:56 -07:00
Ryan Houdek f89ef01578 Implements the COMISS instructions
These are fairly popular so not having them around is causing headaches.
We will really want these in the future to use the host register, btu
that is more time consuming than I want to dedicate to at the moment.

So the FCMP instruction must be told which flags to generate up front,
then it generates the flags in to a GPR which are then tracked and
pulled out with a specific IR op.

This can be augmented in the future to more easily RA the host flag
register
2020-03-21 22:52:46 -07:00
Ryan Houdek 9c24a92f73 Makes sure DCE pass doesn't remove print IR op
This is useful for debugging, don't want the DCE pass to remove it
2020-03-20 12:04:23 -07:00
Ryan Houdek 4692a761b6 Implements two new IR Op codes
Extracts a vector element to a scalar value
Inserts a scalar element in to a vector
2020-03-17 13:49:47 -07:00