1
1
#include "v2_compiler.h"
2
2
3
3
#include "jit_rs.h"
4
+ #include <dynarec/dynarec.h>
4
5
#include <log.h>
5
6
#include <mem/n64bus.h>
6
7
#include <disassemble.h>
@@ -42,10 +43,11 @@ bool should_break(u32 address) {
42
43
static bool v2_idle_loop_detection_enabled = true;
43
44
44
45
int temp_code_len = 0 ;
45
- source_instruction_t temp_code [TEMP_CODE_SIZE ];
46
+ mips_instruction_t temp_code [TEMP_CODE_SIZE ];
47
+ dynarec_instruction_category_t temp_code_category [TEMP_CODE_SIZE ];
46
48
u64 temp_code_vaddr = 0 ;
47
49
48
- #define LAST_INSTR_CATEGORY (temp_code [temp_code_len - 1].category )
50
+ #define LAST_INSTR_CATEGORY (temp_code_category [temp_code_len - 1])
49
51
#define LAST_INSTR_IS_BRANCH ((temp_code_len > 0) && ((LAST_INSTR_CATEGORY == BRANCH) || (LAST_INSTR_CATEGORY == BRANCH_LIKELY)))
50
52
51
53
u64 v2_get_last_compiled_block () {
@@ -69,18 +71,18 @@ void fill_temp_code(u64 virtual_address, u32 physical_address, bool* code_mask)
69
71
70
72
dynarec_instruction_category_t prev_instr_category = NORMAL ;
71
73
if (i > 0 ) {
72
- prev_instr_category = temp_code [i - 1 ]. category ;
74
+ prev_instr_category = temp_code_category [i - 1 ];
73
75
}
74
76
75
77
code_mask [BLOCKCACHE_INNER_INDEX (instr_address )] = true;
76
78
77
- temp_code [i ].instr . raw = n64_read_physical_word (instr_address );
78
- temp_code [i ]. category = instr_category (temp_code [i ]. instr );
79
+ temp_code [i ].raw = n64_read_physical_word (instr_address );
80
+ temp_code_category [i ] = instr_category (temp_code [i ]);
79
81
temp_code_len ++ ;
80
82
instructions_left_in_block -- ;
81
83
82
84
bool instr_ends_block ;
83
- switch (temp_code [i ]. category ) {
85
+ switch (temp_code_category [i ]) {
84
86
// Possible to end block
85
87
case CACHE :
86
88
case STORE :
@@ -134,7 +136,7 @@ void fill_temp_code(u64 virtual_address, u32 physical_address, bool* code_mask)
134
136
#endif
135
137
136
138
// If we filled up the buffer, make sure the last instruction is not a branch
137
- if (temp_code_len == TEMP_CODE_SIZE && is_branch (temp_code [TEMP_CODE_SIZE - 1 ]. category )) {
139
+ if (temp_code_len == TEMP_CODE_SIZE && is_branch (temp_code_category [TEMP_CODE_SIZE - 1 ])) {
138
140
logwarn ("Filled temp_code buffer, but the last instruction was a branch. Stripping it out." );
139
141
temp_code_len -- ;
140
142
}
@@ -167,16 +169,16 @@ bool detect_idle_loop(u64 virtual_address) {
167
169
return false;
168
170
}
169
171
170
- if (temp_code_len == 2 && temp_code [1 ].instr . raw == 0x00000000 ) {
172
+ if (temp_code_len == 2 && temp_code [1 ].raw == 0x00000000 ) {
171
173
// b -1
172
174
// nop
173
- if (temp_code [0 ].instr . raw == 0x1000FFFF ) {
175
+ if (temp_code [0 ].raw == 0x1000FFFF ) {
174
176
return true;
175
177
}
176
178
177
179
// j (self)
178
180
// nop
179
- if (temp_code [0 ].instr . op == OPC_J && temp_code [0 ]. instr .j .target == ((virtual_address >> 2 ) & 0x3FFFFFF )) {
181
+ if (temp_code [0 ].op == OPC_J && temp_code [0 ].j .target == ((virtual_address >> 2 ) & 0x3FFFFFF )) {
180
182
return true;
181
183
}
182
184
}
@@ -234,7 +236,7 @@ void v2_compile_new_block(
234
236
for (int i = 0 ; i < temp_code_len ; i ++ ) {
235
237
u64 instr_virtual_address = virtual_address + (i << 2 );
236
238
u32 instr_physical_address = physical_address + (i << 2 );
237
- emit_instruction_ir (temp_code [i ]. instr , i , instr_virtual_address , instr_physical_address );
239
+ emit_instruction_ir (temp_code [i ], i , instr_virtual_address , instr_physical_address );
238
240
}
239
241
240
242
if (!ir_context .block_end_pc_ir_emitted && temp_code_len > 0 ) {
0 commit comments