Commit graph

362 commits

Author SHA1 Message Date
Lioncash
1395baefa9 interface: Return register files by const reference
Prevents unnecessary copies where they aren't particularly required.
2016-08-25 12:51:41 +01:00
Lioncash
37755cbfec translate: Simplify function pointer calls
They can just be called like regular functions
2016-08-24 23:19:50 +01:00
Lioncash
9b874c2e23 CMakeLists: Add FPSCR.h to the list of headers
Whoops, that one's on me
2016-08-24 23:19:49 +01:00
MerryMage
22cca5ff72 emit_x64: Actually advance RSB pointer 2016-08-24 23:19:47 +01:00
Lioncash
eba3a06d80 frontend: Introduce FPSCR register helper class
Encapsulates all of the FPSCR state.
2016-08-24 20:51:14 +01:00
MerryMage
b5a86889cd Implement VCVT 2016-08-23 22:20:04 +01:00
MerryMage
445aad0639 x64/emitter: Add opBits argument to CVTSI2SS and CVTSI2SD 2016-08-23 21:58:34 +01:00
MerryMage
78464a8f01 translate_arm/vfp2: Implement VSTM (A1, A2) 2016-08-23 20:54:38 +01:00
MerryMage
a96704eb0f arm_types: new_reg >= 0 is always true since new_reg is unsigned 2016-08-23 20:11:41 +01:00
MerryMage
7a01dba3c4 arm_types: Change type signature of operator+ to size_t instead of int 2016-08-23 20:07:53 +01:00
MerryMage
af9a68f0d1 translate_arm/vfp2: Implement VLDM (A1, A2) 2016-08-23 20:07:06 +01:00
Lioncash
d5805cc6eb intrusive_list: Add size querying
Since we store pointers and have an interface for iterators
set up, the count is just the distance from the beginning
to the end of the list.

Nice thing is that because of this, basic blocks also get
the ability to have a size count without needing to do anything
directly.
2016-08-23 19:52:09 +01:00
Lioncash
2180a4be7a basic_block: Use a range-based for loop for iteration 2016-08-23 19:51:01 +01:00
Lioncash
897b776250 string_util: Use C++ attribute specifier for format strings
This is also compatible with both clang and GCC
2016-08-23 19:38:48 +01:00
Lioncash
867d345fdc disassembler: Deduplicate SignStr
Also just makes it return a character, rather than a pointer to a
string.
2016-08-23 16:40:33 +01:00
Lioncash
8bed891011 x64 emitter: Fix swapped parameter names 2016-08-23 16:39:38 +01:00
MerryMage
c8b2f63c93 get_set_elimination_pass: Eliminate unnecessary gets/sets of extended registers 2016-08-23 15:57:20 +01:00
MerryMage
e0f9dead5d microinstruction: Identity's type depends on the type of its argument 2016-08-23 15:48:30 +01:00
Lioncash
67706c208b assert: Use false in asserts rather than 0
Quiets extended warnings.
2016-08-23 14:31:54 +01:00
MerryMage
8c7a81a308 VPOP and VPUSH are floating-point load-store instructions 2016-08-23 14:26:50 +01:00
MerryMage
34cffa86a4 dead_code_elimination_pass: Update to use IR::Inst::MayHaveSideEffects 2016-08-23 13:12:14 +01:00
Lioncash
46573eb538 intrusive_list: Add insert_before() and insert_after() helper functions
Small helpers for inserting nodes before and after an existing one.
insert() is the same as insert_before(), so insert() is just made
to be an alias of this.
2016-08-23 12:38:57 +01:00
MerryMage
8d1b9f32ca Standardize indentation of switch statments 2016-08-23 12:19:27 +01:00
MerryMage
2471be317e arm_types: Implement LocationDescription::FPSCR_RMode 2016-08-23 02:22:04 +01:00
Lioncash
47f285249b microinstruction: Introduce convenience informational functions
Whenever more rigorous optimizations are attempted (or even basic ones),
it's usually helpful to know what overall kind of instruction is being
dealt with, in the event certain classes of instructions may be eligible
for optimization.
2016-08-22 21:36:48 +01:00
Lioncash
06ec4b5977 microinstruction: Make constructor explicit 2016-08-22 16:01:18 +01:00
Lioncash
1bedd3bd7f CMakeLists: Clean up
Moves functions out of the main CMakeLists file into module files that
can just be included whenever necessary. This also uses the CMake
provided variables for enforcing compiler requirements.
2016-08-22 15:55:39 +01:00
MerryMage
72250b119f backend_x64/block_of_code: Add more floating point constants
* MFloatPositiveZero32
* MFloatPositiveZero64
* MFloatMinS32
* MFloatMaxS32
* MFloatMinU32
* MFloatMaxU32
2016-08-22 15:54:19 +01:00
MerryMage
a32689c832 x64/emitter: Implement CMPxxSD instructions 2016-08-22 15:54:18 +01:00
MerryMage
843d29b5a9 translate_arm/branch: Read-after-write in arm_BLX_reg
When BLX LR is translated, BXWritePC(GetRegister(Reg::LR)) was executed
after the SetRegister(Reg::LR, _) update was done.
2016-08-22 15:53:56 +01:00
MerryMage
d8bee60947 translate_thumb: Read-after-write in thumb16_BLX_reg
When the instruction BLX LR is translated, BXWritePC(GetRegister(Reg::LR))
was executed after the SetRegister(Reg::LR, _) update was performed.
2016-08-22 14:28:51 +01:00
Lioncash
1abe881921 basic_block: Add proxy member functions for the instruction list
Currently basic block kind of acts like a 'dumb struct' which makes things
a little more verbose to write (as opposed to keeping it all in one place,
I guess). It's also a little wonky conceptually, considering a block is
composed of instructions (i.e. 'contains' them).

So providing accessors that make it act more like a container can make working
with algorithms a little nicer. It also makes the API a little more
defined.

Ideally, the list would be only available through a function, but
currently, the pool allocator is exposed, which seems somewhat odd,
considering the block itself should manage its overall allocations
(with placement new, and regular new), rather than putting that
sanitizing directly on the IR emitter (it should just care about emission,
not block state). However, recontaining that can be followed up with,
as it's very trivial to do.
2016-08-22 13:44:56 +01:00
Lioncash
226d66dd5b intrusive_list: satisfy the Swappable concept 2016-08-22 12:38:16 +01:00
Lioncash
2a9fdacc60 intrusive_list: move iterator implementation above list
Will make keeping non-member list functions easier to keep together with
the class.
2016-08-22 12:38:16 +01:00
Lioncash
669ffb5f3a intrusive_list: Add pop_back(), pop_front(), front(), and back() member functions 2016-08-20 21:26:16 +01:00
Lioncash
86f803da04 reg_alloc: Use Inst's HasUses() function where applicable 2016-08-20 21:26:09 +01:00
Lioncash
a8ba15f0d5 intrusive_list: Make Remove and IsEmpty stdlib compatible
Makes the name match the standard library equivalents.

C++17 introduces non-member empty() which allows for nicer handling
in generic contexts. May as well make the data structure compatible with
it.
2016-08-19 20:25:18 +01:00
Lioncash
23d190f7b0 intrusive_list: Support inserters
Allows std::inserter, std::back_inserter, and std::front_inserter to work
with intrusive lists.
2016-08-19 20:25:17 +01:00
Lioncash
36a0ad5bc2 reg_alloc: const correctness for ValueLocation() 2016-08-19 19:33:57 +01:00
MerryMage
2d6a86e43c Remove <cassert> 2016-08-19 01:53:24 +01:00
MerryMage
192a0029be ir/opcodes: Implement IR::AreTypesCompatible
Type-checking is now occuring in more than one place.
2016-08-19 01:34:14 +01:00
Tillmann Karras
9782e7da3f verification_pass: show type errors 2016-08-19 01:17:30 +01:00
Tillmann Karras
dad7724b86 TranlateArm: implement remaining multiplies
SMLALxy, SMLAxy, SMULxy SMLAWy, SMULWy, SMLAD, SMLALD, SMLSD, SMLSLD,
SMUAD, SMUSD
2016-08-19 01:08:38 +01:00
MerryMage
fe15cbd50e translate_arm/parallel: Detect UNPREDICTABLE instructions 2016-08-19 00:59:07 +01:00
MerryMage
2119dfc926 translate_arm/multiply: MLA is UNPREDICTABLE when Ra == R15 2016-08-19 00:59:05 +01:00
MerryMage
0d0f4b1b4f translate_arm/load_store: Correct implementation for LDM* 2016-08-19 00:59:04 +01:00
MerryMage
4acc481463 translate_arm/load_store: Handle unpredictable instructions
This necessated handling literal versions of the instructions separately
as they had different requirements. The rationale for detecting
unpredictable instructions is because:

a. they are unlikely to be outputted by a well-behaved compiler
b. their behaviour may change between different processors

I would rather unpredictable instructions fail loudly than silently do
approximately the right thing.
2016-08-19 00:59:02 +01:00
MerryMage
5869e79b9c translate_arm: Simplify EmitImmShift and EmitRegShift 2016-08-19 00:21:31 +01:00
Lioncash
fe9329ef3e intrusive_list: Add list class type definitions; extend iterator interface
Adds type definitions, and extends the list interface to support all
standard library forms of iterator creation.
2016-08-18 23:47:26 +01:00
Lioncash
95a83543f2 intrusive_list: Get rid of unnecessary static_casts
The only valid objects to add to the list are those that inherit from
IntrusiveListNode. Therefore anything being added to the list that isn't
inheriting from it will cause compilation to fail.
2016-08-18 23:47:26 +01:00
Lioncash
67509935f6 intrusive_list: Eliminate need for separate const iterator construct
This generalizes the regular iterator to be compatible with both use
cases. Passing in the list instance directly isn't needed, because the
only way you'd ever get a valid instantiation of an iterator is from a
list instance itself.
2016-08-18 23:47:26 +01:00
MerryMage
b8cf43c43e translate_arm/data_processing: Rd == R15 is unpredictable for rsr instructions 2016-08-18 18:23:05 +01:00
MerryMage
efc8d2f772 arm_translator: NV conditional is obsolete 2016-08-18 18:21:48 +01:00
MerryMage
5f7d940fde disassemble_arm: Partially implement coprocessor and hint instructions 2016-08-18 18:21:16 +01:00
MerryMage
36a916a766 decoder/arm: Correct NOP decoder 2016-08-18 18:20:29 +01:00
MerryMage
e9e7ac6e65 decoder/arm: Correct PLD decoder for v6K 2016-08-18 18:19:34 +01:00
MerryMage
269160ef0d emit_x64: Clear RSB-related caches when ClearCache() is called 2016-08-18 18:18:44 +01:00
MerryMage
1a3f3ac435 emit_x64: Correct behaviour of PackedOperation for immediate argument
x64 MOVD_xmm does not support an immediate oparg
2016-08-18 18:17:17 +01:00
MerryMage
b2de47954b EmitX64: Emit correct cycle count on cond failure 2016-08-18 18:16:18 +01:00
Lioncash
841098a0bc ir: separate components out a little more 2016-08-17 20:46:21 +01:00
Lioncash
9690d1423d intrusive_list: explicitly default relevant constructors 2016-08-17 20:46:11 +01:00
Lioncash
cbd99e4367 jitstate: Use std::array's fill() in ResetRSB
Performs the equivalent behavior
2016-08-17 10:10:43 +01:00
Lioncash
74ee92ee38 jitstate: const correctness
GetReturnFromRunCodeAddress is const qualified, so this can accept a const
pointer. This also allows for making the constructor accept a const
pointer as well.
2016-08-17 10:10:43 +01:00
Lioncash
9ed9f4c565 mp: Generalize function information retrieval
Generalizes MemFnInfo to be compatible with all function types.
Also adds type introspection for arguments, as well as helper templates for the common types supported by all partial specializations.
2016-08-17 10:08:40 +01:00
Lioncash
439619c827 reg_alloc: Make GetRegLoc return by const reference
Considering a HostLocInfo instance houses a std::vector, every time this
function is called can cause a potential heap allocation.

This can be somewhat unnecessary because this function is only used to query
for information we already have.

Considering this is used by several other internal query functions such as
IsRegisterOccupied, IsRegisterAllocated, and IsLastUse, this will result
in better codegen (returning an address is just 3 instructions excluding
the ret instruction for returning, meanwhile heap alloc can be 60+).

This also renames the function to have the same name as its non-const
counterpart, since overloading will just select the correct function
instead of putting that onus on the developer.
2016-08-17 10:08:08 +01:00
MerryMage
0ebb572e2d Optimization: Make RSB a ring buffer instead of a stack 2016-08-15 15:48:22 +01:00
MerryMage
7d7ac0af71 Optimization: Make SVC use RSB 2016-08-15 15:02:08 +01:00
MerryMage
6c45619aa1 Optimization: Implement terminal LinkBlockFast 2016-08-15 14:33:17 +01:00
MerryMage
624e84fa09 Optimization: Tweak RSB 2016-08-15 14:08:06 +01:00
MerryMage
070298b948 Optimization: bugfix! Return Stack Buffer location hash calculation was incorrect 2016-08-15 13:21:58 +01:00
MerryMage
e164ede4dc TranslateArm: Implement MRS, MSR (imm), MSR (reg) 2016-08-15 11:50:49 +01:00
bunnei
30f3d869cc TranslateArm: Implement VPUSH and VPOP. 2016-08-13 19:37:03 +01:00
MerryMage
9c82a12f8f ir_opt: Update VerificationPass to current IR 2016-08-13 18:39:49 +01:00
MerryMage
8fc21f481a RegAlloc: Handle case when def is unused 2016-08-13 01:55:03 +01:00
MerryMage
d43d97b990 EmitX64/EmitPushRSB: Assert that patch location is of correct size 2016-08-13 00:52:31 +01:00
MerryMage
960d14d18e Optimization: Implement Return Stack Buffer 2016-08-13 00:10:23 +01:00
bunnei
8e68e6fdd9 TranslateArm: Implement QADD16/QSUB16/UQADD16/UQSUB16. 2016-08-12 19:00:44 +01:00
bunnei
4b09c0d032 TranslateArm: Implement QADD8 and UQADD8. 2016-08-12 19:00:44 +01:00
bunnei
127fbe99cb TranslateArm: Implement QSUB8. 2016-08-12 19:00:44 +01:00
bunnei
86fe29c6d2 TranslateArm: Implement UQSUB8. 2016-08-12 19:00:44 +01:00
MerryMage
1029fd27ce Update documentation (2016-08-12) 2016-08-12 18:17:31 +01:00
MerryMage
3808938c98 Fix SETEND 2016-08-11 19:15:58 +01:00
bunnei
218980cf69 load_store: Implement LDRSB and LDRSH. 2016-08-11 17:18:20 +01:00
MerryMage
0e5593ba62 TranslateArm: Implement SETEND 2016-08-11 17:15:33 +01:00
MerryMage
8964b38cf9 IR/DumpBlock: Print references to ExtRegs 2016-08-11 17:15:02 +01:00
MerryMage
b4c586d5ef TranslateArm: VSTR: Correct behaviour in big-endian mode 2016-08-10 16:43:37 +01:00
MerryMage
945498a16a DisassemblerArm: Disassemble SETEND 2016-08-10 16:15:07 +01:00
bunnei
8e8db6e137 TranslateArm: Implement VSTR. 2016-08-10 15:01:23 +01:00
MerryMage
df39308e03 TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB 2016-08-09 22:57:20 +01:00
MerryMage
d921390928 TranslateArm: Add santity check to see if we've emitted a terminal instruction 2016-08-09 22:47:41 +01:00
MerryMage
2eec43178a IR: Opaque can be of any type 2016-08-09 22:46:44 +01:00
MerryMage
29d30bf931 Interface: Added Jit::Reset to reset CPU state 2016-08-09 22:45:54 +01:00
MerryMage
82f42d065f DisassemblerArm: Implemented disassembly of STR*/LDR* instructions 2016-08-09 22:44:42 +01:00
MerryMage
d0d51ba346 TranslateArm: Implement STM, STMDA, STMDB, STMIB 2016-08-08 22:49:11 +01:00
Tillmann Karras
5d26899ac9 Add simplified LogicalShiftRight64 IR opcode 2016-08-08 22:27:05 +01:00
Tillmann Karras
ccb2aa96a5 Add support for the APSR.Q flag 2016-08-08 22:27:04 +01:00
Tillmann Karras
11e0688e5f Fix build on case-sensitive file systems 2016-08-08 22:27:03 +01:00
MerryMage
85549d7ae2 TranslateArm: Implement LDM, LDMDA, LDMDB, LDMIB 2016-08-08 22:26:06 +01:00
MerryMage
46e4864707 ArmTypes: Add RegListToString and reorganise 2016-08-08 22:20:28 +01:00
MerryMage
975f011fc0 BackendX64/RegAlloc: Do not allocate RSP for guest use 2016-08-08 16:01:07 +01:00
MerryMage
abd113f160 EmitX64: Renamed patch_jmp_locations to patch_jg_locations 2016-08-08 15:56:07 +01:00
MerryMage
52fa998e6b EmitX64: EmitTerminalLinkBlock: Fix behaviour when setting T and E flags 2016-08-07 22:47:43 +01:00
MerryMage
04c1a0d2de EmitX64: Switch MXCSR when switching to interpreter 2016-08-07 22:47:17 +01:00
MerryMage
edb236ab07 Correct implementation of thumb16_SVC and arm_SVC 2016-08-07 22:19:39 +01:00
MerryMage
a32063fa60 EmitX64: Implement block linking 2016-08-07 22:11:39 +01:00
MerryMage
328422b740 RegAlloc: HostCall flushes all XMM regsiters 2016-08-07 21:02:16 +01:00
MerryMage
4dcd1d1859 Arm: BLX is UNPREDICTABLE when Rm is PC 2016-08-07 20:50:33 +01:00
MerryMage
1af5bef32c TranslateArm: Implement BLX (imm), BLX (reg) and BXJ 2016-08-07 20:40:31 +01:00
MerryMage
939bb5c0cb TranslateArm: Implement NOP 2016-08-07 20:08:31 +01:00
MerryMage
e48df9d8fd TranslateArm: Implement Hint instructions as NOPs 2016-08-07 20:04:48 +01:00
MerryMage
3a465ba4a8 VFP: Implement VLDR 2016-08-07 19:59:35 +01:00
MerryMage
a2c2db277b VFP: Implement VMOV (all variants) 2016-08-07 19:25:12 +01:00
MerryMage
aba705f6b9 BackendX64: Merge Routines into BlockOfCode 2016-08-07 18:08:48 +01:00
MerryMage
0f412247ed VFP: Implement VSQRT 2016-08-07 12:19:07 +01:00
MerryMage
cd8e7c0504 VFP: Implement VNEG 2016-08-07 12:04:21 +01:00
MerryMage
da33af5abe VFP: Implement VMLA, VMLS, VNMLA, VNMLS 2016-08-07 11:49:06 +01:00
MerryMage
3f1345a1a5 VFP: Implement VNMUL, VDIV 2016-08-07 10:56:12 +01:00
MerryMage
12e7f2c359 VFP: Implement VMUL 2016-08-07 10:21:14 +01:00
MerryMage
97b5fa173f VFP: Implement VSUB 2016-08-07 01:45:52 +01:00
MerryMage
ce6b5f8210 VFP: Implement VABS 2016-08-07 01:27:18 +01:00
MerryMage
f88b1b4c2e FPSCR: Save and restore MSCSR across supervisor call, fix MXCSR exception mask 2016-08-07 01:10:19 +01:00
MerryMage
c35f06470f VFP: Interpret VFP instructions when FPSCR.Len or FPSCR.Stride != 1 2016-08-06 23:01:18 +01:00
MerryMage
94b99f5949 Common: Add an intrusive list implementation; remove use of boost::intrusive::list. 2016-08-06 22:23:01 +01:00
Tillmann Karras
9264e2e04c Use XOR when loading a zero immediate 2016-08-06 21:17:11 +01:00
Tillmann Karras
55204a80d0 Implement SMMLA, SMMLS, SMMUL 2016-08-06 21:17:11 +01:00
Tillmann Karras
846d07d7b5 Add Sub64 opcode 2016-08-06 21:17:11 +01:00
Tillmann Karras
b9f4f1ed0f Add carry support to MostSignificantWord 2016-08-06 21:17:11 +01:00
Tillmann Karras
01aebcb385 Remove *MulHi wrappers 2016-08-06 21:17:11 +01:00
Tillmann Karras
5e047107a0 Disassemble more instructions
CLZ, SEL, USAD8, USADA8, SSAT, SSAT16, USAT, USAT16, SMLAL*, SMLA*,
SMUL*, SMLAW*, SMULW*, SMLAD, SMLALD, SMLSD, SMLSLD, SMUAD, SMUSD
2016-08-06 21:17:11 +01:00
Tillmann Karras
f99cb613cf Disassemble packs and more multiplies 2016-08-06 21:17:11 +01:00
MerryMage
7915f97d98 TranslateArm/LoadStore: Add default case to switches for arm_LDRD_imm and arm_LDRD_reg (fixes GCC warning) 2016-08-06 20:42:06 +01:00
MerryMage
4d127c19dd Common: Add a memory pool implementation, remove use of boost::pool 2016-08-06 20:41:00 +01:00
MerryMage
411e804b0d Interface: Forward declare Arm::LocationDescriptor 2016-08-06 20:11:35 +01:00
MerryMage
4b31ea25a7 VFP: Implement VADD.{F32,F64} 2016-08-06 20:03:15 +01:00
MerryMage
8ff414ee0e Frontend/Decoder: 1. Remove member pointer as a template argument. 2. Sort ARM table such that unconditional instructions are on top. 2016-08-06 20:03:15 +01:00
MerryMage
94d5738f62 BackendX64/Routines: Add floating-point constants 2016-08-06 20:01:47 +01:00
MerryMage
8754728a82 BackendX64/RegAlloc: Corrected code emitted by EmitMove for XMM->Spill case 2016-08-06 20:01:47 +01:00
MerryMage
8cc4fe8a10 BackendX64/RegAlloc: HostLocToX64 now handles XMM registers properly 2016-08-06 20:01:47 +01:00
bunnei
2448d52394 load_store: Use correct types for LDR/STR. 2016-08-05 20:51:32 -04:00
bunnei
8c2300d477 arm: Implement LDRD reg/imm instructions. 2016-08-05 20:05:02 -04:00
bunnei
72608b7af6 arm: Handle Cond::NV (some 3DS games use this despite being obsolete). 2016-08-05 20:05:02 -04:00
bunnei
ec3a98cf95 arm: Implement LDRH reg/imm instructions. 2016-08-05 20:05:01 -04:00
bunnei
192a0fba7a arm: Implement LDRB reg/imm instructions. 2016-08-05 20:05:00 -04:00
bunnei
dfb318f208 arm: Implement STRD reg/imm instructions. 2016-08-05 20:04:59 -04:00
bunnei
e931dc2496 arm: Implement STRH reg/imm instructions. 2016-08-05 20:04:58 -04:00
bunnei
9f77662b24 arm: Implement STRB reg/imm instructions. 2016-08-05 20:04:57 -04:00
bunnei
caab1bbc7c arm: Implement STR reg/imm instructions. 2016-08-05 20:04:56 -04:00
bunnei
b09ecb4532 arm: Implement LDR reg/imm instructions. 2016-08-05 20:04:55 -04:00
MerryMage
856298577d EmitX64: Don't give MOVSX or MOVZX an immediate oparg 2016-08-06 01:03:39 +01:00
MerryMage
640ce48baa VFP: Implement {Get,Set}ExtendedRegister{32,64} 2016-08-05 19:06:10 +01:00