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