Mercurial > repos > blastem
comparison cpu_dsl.py @ 2723:4f88822e6a5d default tip
Fix regression in CPU DSL implementation impacting new 68K core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 17 Jul 2025 07:38:33 -0700 |
parents | 033d8d4308e3 |
children |
comparison
equal
deleted
inserted
replaced
2722:0fc9de2b9741 | 2723:4f88822e6a5d |
---|---|
2244 if self.dispatch == 'call': | 2244 if self.dispatch == 'call': |
2245 if self.body in self.subroutines: | 2245 if self.body in self.subroutines: |
2246 pieces.append('\nvoid {pre}execute({type} *context, uint32_t target_cycle)'.format(pre = self.prefix, type = self.context_type)) | 2246 pieces.append('\nvoid {pre}execute({type} *context, uint32_t target_cycle)'.format(pre = self.prefix, type = self.context_type)) |
2247 pieces.append('\n{') | 2247 pieces.append('\n{') |
2248 bodyPieces = [] | 2248 bodyPieces = [] |
2249 self.temp = {} | |
2249 self.declaredLocals.clear() | 2250 self.declaredLocals.clear() |
2250 if self.sync_cycle: | 2251 if self.sync_cycle: |
2251 bodyPieces.append('\n\t{sync}(context, target_cycle);'.format(sync=self.sync_cycle)) | 2252 bodyPieces.append('\n\t{sync}(context, target_cycle);'.format(sync=self.sync_cycle)) |
2252 if self.pc_reg: | 2253 if self.pc_reg: |
2253 bodyPieces.append('\n\tif (context->breakpoints) {') | 2254 bodyPieces.append('\n\tif (context->breakpoints) {') |
2256 if self.interrupt in self.subroutines: | 2257 if self.interrupt in self.subroutines: |
2257 bodyPieces.append('\n\t\t\tif (context->cycles >= context->sync_cycle) {') | 2258 bodyPieces.append('\n\t\t\tif (context->cycles >= context->sync_cycle) {') |
2258 bodyPieces.append(f'\n\t\t\t\t{self.sync_cycle}(context, target_cycle);') | 2259 bodyPieces.append(f'\n\t\t\t\t{self.sync_cycle}(context, target_cycle);') |
2259 bodyPieces.append('\n\t\t\t}') | 2260 bodyPieces.append('\n\t\t\t}') |
2260 self.meta = {} | 2261 self.meta = {} |
2261 self.temp = {} | |
2262 self.subroutines[self.interrupt].inline(self, [], bodyPieces, otype, None) | 2262 self.subroutines[self.interrupt].inline(self, [], bodyPieces, otype, None) |
2263 for size in self.temp: | |
2264 bodyPieces.append('\n\t\t\tuint{sz}_t gen_tmp{sz}__;'.format(sz=size)) | |
2265 if self.pc_offset: | 2263 if self.pc_offset: |
2266 bodyPieces.append(f'\n\t\t\tuint32_t debug_pc = context->{self.pc_reg} - {self.pc_offset};') | 2264 bodyPieces.append(f'\n\t\t\tuint32_t debug_pc = context->{self.pc_reg} - {self.pc_offset};') |
2267 pc_reg = 'debug_pc' | 2265 pc_reg = 'debug_pc' |
2268 else: | 2266 else: |
2269 pc_reg = 'context->' + self.pc_reg | 2267 pc_reg = 'context->' + self.pc_reg |
2271 bodyPieces.append(f'\n\t\t\tdebug_handler handler = tern_find_ptr(context->breakpoints, tern_int_key({pc_reg}, key_buf));') | 2269 bodyPieces.append(f'\n\t\t\tdebug_handler handler = tern_find_ptr(context->breakpoints, tern_int_key({pc_reg}, key_buf));') |
2272 bodyPieces.append('\n\t\t\tif (handler) {') | 2270 bodyPieces.append('\n\t\t\tif (handler) {') |
2273 bodyPieces.append(f'\n\t\t\t\thandler(context, {pc_reg});') | 2271 bodyPieces.append(f'\n\t\t\t\thandler(context, {pc_reg});') |
2274 bodyPieces.append('\n\t\t\t}') | 2272 bodyPieces.append('\n\t\t\t}') |
2275 self.meta = {} | 2273 self.meta = {} |
2276 self.temp = {} | |
2277 self.subroutines[self.body].inline(self, [], bodyPieces, otype, None) | 2274 self.subroutines[self.body].inline(self, [], bodyPieces, otype, None) |
2278 bodyPieces.append('\n\t}') | 2275 bodyPieces.append('\n\t}') |
2279 bodyPieces.append('\n\t} else {') | 2276 bodyPieces.append('\n\t} else {') |
2280 bodyPieces.append('\n\twhile (context->cycles < target_cycle)') | 2277 bodyPieces.append('\n\twhile (context->cycles < target_cycle)') |
2281 bodyPieces.append('\n\t{') | 2278 bodyPieces.append('\n\t{') |
2282 if self.interrupt in self.subroutines: | 2279 if self.interrupt in self.subroutines: |
2283 bodyPieces.append('\n\t\tif (context->cycles >= context->sync_cycle) {') | 2280 bodyPieces.append('\n\t\tif (context->cycles >= context->sync_cycle) {') |
2284 bodyPieces.append(f'\n\t\t\t{self.sync_cycle}(context, target_cycle);') | 2281 bodyPieces.append(f'\n\t\t\t{self.sync_cycle}(context, target_cycle);') |
2285 bodyPieces.append('\n\t\t}') | 2282 bodyPieces.append('\n\t\t}') |
2286 self.meta = {} | 2283 self.meta = {} |
2287 self.temp = {} | |
2288 self.subroutines[self.interrupt].inline(self, [], bodyPieces, otype, None) | 2284 self.subroutines[self.interrupt].inline(self, [], bodyPieces, otype, None) |
2289 for size in self.temp: | |
2290 bodyPieces.append('\n\tuint{sz}_t gen_tmp{sz}__;'.format(sz=size)) | |
2291 self.meta = {} | 2285 self.meta = {} |
2292 self.temp = {} | |
2293 self.subroutines[self.body].inline(self, [], bodyPieces, otype, None) | 2286 self.subroutines[self.body].inline(self, [], bodyPieces, otype, None) |
2294 for name in self.declaredLocals: | 2287 for name in self.declaredLocals: |
2295 pieces.append(f'\n\tuint{self.declaredLocals[name]}_t {name};') | 2288 pieces.append(f'\n\tuint{self.declaredLocals[name]}_t {name};') |
2289 for size in self.temp: | |
2290 pieces.append('\n\t\t\tuint{sz}_t gen_tmp{sz}__;'.format(sz=size)) | |
2296 pieces += bodyPieces | 2291 pieces += bodyPieces |
2297 pieces.append('\n\t}') | 2292 pieces.append('\n\t}') |
2298 if self.pc_reg: | 2293 if self.pc_reg: |
2299 pieces.append('\n\t}') | 2294 pieces.append('\n\t}') |
2300 pieces.append('\n}') | 2295 pieces.append('\n}') |