Mercurial > repos > blastem
comparison m68k_core_x86.c @ 665:d0943769353b
Added functions to gen_x86 for saving and restoring callee save registers to better abstract over ABI differences between x86 and x86-64
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 02 Jan 2015 13:14:09 -0800 |
parents | 92ce5ea5ffc9 |
children | 30ccf56842d6 |
comparison
equal
deleted
inserted
replaced
664:bca748422bf0 | 665:d0943769353b |
---|---|
2279 mov_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, current_cycle), opts->gen.cycles, SZ_D); | 2279 mov_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, current_cycle), opts->gen.cycles, SZ_D); |
2280 mov_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, target_cycle), opts->gen.limit, SZ_D); | 2280 mov_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, target_cycle), opts->gen.limit, SZ_D); |
2281 retn(code); | 2281 retn(code); |
2282 | 2282 |
2283 opts->start_context = (start_fun)code->cur; | 2283 opts->start_context = (start_fun)code->cur; |
2284 save_callee_save_regs(code); | |
2284 #ifdef X86_64 | 2285 #ifdef X86_64 |
2285 if (opts->gen.scratch2 != RDI) { | 2286 if (opts->gen.scratch2 != RDI) { |
2286 mov_rr(code, RDI, opts->gen.scratch2, SZ_PTR); | 2287 mov_rr(code, RDI, opts->gen.scratch2, SZ_PTR); |
2287 } | 2288 } |
2288 //save callee save registers | |
2289 push_r(code, RBP); | |
2290 push_r(code, R12); | |
2291 push_r(code, R13); | |
2292 push_r(code, R14); | |
2293 push_r(code, R15); | |
2294 #else | 2289 #else |
2295 //save callee save registers | |
2296 push_r(code, RBP); | |
2297 push_r(code, RBX); | |
2298 push_r(code, RSI); | |
2299 push_r(code, RDI); | |
2300 | |
2301 mov_rdispr(code, RSP, 20, opts->gen.scratch2, SZ_D); | 2290 mov_rdispr(code, RSP, 20, opts->gen.scratch2, SZ_D); |
2302 mov_rdispr(code, RSP, 24, opts->gen.context_reg, SZ_D); | 2291 mov_rdispr(code, RSP, 24, opts->gen.context_reg, SZ_D); |
2303 #endif | 2292 #endif |
2304 call(code, opts->gen.load_context); | 2293 call(code, opts->gen.load_context); |
2305 call_r(code, opts->gen.scratch2); | 2294 call_r(code, opts->gen.scratch2); |
2306 call(code, opts->gen.save_context); | 2295 call(code, opts->gen.save_context); |
2307 #ifdef X86_64 | 2296 restore_callee_save_regs(code); |
2308 //restore callee save registers | |
2309 pop_r(code, R15); | |
2310 pop_r(code, R14); | |
2311 pop_r(code, R13); | |
2312 pop_r(code, R12); | |
2313 pop_r(code, RBP); | |
2314 #else | |
2315 pop_r(code, RDI); | |
2316 pop_r(code, RSI); | |
2317 pop_r(code, RBX); | |
2318 pop_r(code, RBP); | |
2319 #endif | |
2320 retn(code); | 2297 retn(code); |
2321 | 2298 |
2322 opts->native_addr = code->cur; | 2299 opts->native_addr = code->cur; |
2323 call(code, opts->gen.save_context); | 2300 call(code, opts->gen.save_context); |
2324 push_r(code, opts->gen.context_reg); | 2301 push_r(code, opts->gen.context_reg); |