diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-01-02 13:14:09 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-01-02 13:14:09 -0800 |
commit | af8bf7f7f18861ef1235e85a72ca100e755d9859 (patch) | |
tree | 7f6def8718420b3a11a54b017fdaffe5eb09a223 /gen_x86.c | |
parent | f92dd42cd257aba22ce4076d1cab2876babe3471 (diff) |
Added functions to gen_x86 for saving and restoring callee save registers to better abstract over ABI differences between x86 and x86-64
Diffstat (limited to 'gen_x86.c')
-rw-r--r-- | gen_x86.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -2039,3 +2039,33 @@ void call_args_abi(code_info *code, code_ptr fun, uint32_t num_args, ...) *no_adjust_rsp = code->cur - (no_adjust_rsp+1); #endif } + +void save_callee_save_regs(code_info *code) +{ + push_r(code, RBX); + push_r(code, RBP); +#ifdef X86_64 + push_r(code, R12); + push_r(code, R13); + push_r(code, R14); + push_r(code, R15); +#else + push_r(code, RDI); + push_r(code, RSI); +#endif +} + +void restore_callee_save_regs(code_info *code) +{ +#ifdef X86_64 + pop_r(code, R15); + pop_r(code, R14); + pop_r(code, R13); + pop_r(code, R12); +#else + pop_r(code, RSI); + pop_r(code, RDI); +#endif + pop_r(code, RBP); + pop_r(code, RBX); +} |