filename | src/sh4/ia32abi.h |
changeset | 905:4c17ebd9ef5e |
prev | 901:32c5cf5e206f |
next | 906:268ea359f884 |
author | nkeynes |
date | Wed Oct 29 23:51:58 2008 +0000 (14 years ago) |
permissions | -rw-r--r-- |
last change | Use regparam calling conventions for all functions called from translated code, along with a few other high-use functions. Can probably extend this to all functions, but as it is this is a nice performance boost |
file | annotate | diff | log | raw |
1.1 --- a/src/sh4/ia32abi.h Sun Oct 26 02:28:29 2008 +00001.2 +++ b/src/sh4/ia32abi.h Wed Oct 29 23:51:58 2008 +00001.3 @@ -26,14 +26,68 @@1.4 * Note: clobbers EAX to make the indirect call - this isn't usually1.5 * a problem since the callee will usually clobber it anyway.1.6 */1.7 -#define CALL_FUNC0_SIZE 71.8 static inline void call_func0( void *ptr )1.9 {1.10 load_imm32(R_EAX, (uint32_t)ptr);1.11 CALL_r32(R_EAX);1.12 }1.14 -#define CALL_FUNC1_SIZE 111.15 +#ifdef HAVE_FASTCALL1.16 +static inline void call_func1( void *ptr, int arg1 )1.17 +{1.18 + if( arg1 != R_EAX ) {1.19 + MOV_r32_r32( arg1, R_EAX );1.20 + }1.21 + load_imm32(R_ECX, (uint32_t)ptr);1.22 + CALL_r32(R_ECX);1.23 +}1.24 +1.25 +static inline void call_func2( void *ptr, int arg1, int arg2 )1.26 +{1.27 + if( arg2 != R_EDX ) {1.28 + MOV_r32_r32( arg2, R_EDX );1.29 + }1.30 + if( arg1 != R_EAX ) {1.31 + MOV_r32_r32( arg1, R_EAX );1.32 + }1.33 + load_imm32(R_ECX, (uint32_t)ptr);1.34 + CALL_r32(R_ECX);1.35 +}1.36 +1.37 +/**1.38 + * Write a double (64-bit) value into memory, with the first word in arg2a, and1.39 + * the second in arg2b1.40 + */1.41 +static inline void MEM_WRITE_DOUBLE( int addr, int arg2a, int arg2b )1.42 +{1.43 + PUSH_r32(arg2b);1.44 + PUSH_r32(addr);1.45 + call_func2(sh4_write_long, addr, arg2a);1.46 + POP_r32(R_EAX);1.47 + POP_r32(R_EDX);1.48 + ADD_imm8s_r32(4, R_EAX);1.49 + call_func0(sh4_write_long);1.50 +}1.51 +1.52 +/**1.53 + * Read a double (64-bit) value from memory, writing the first word into arg2a1.54 + * and the second into arg2b. The addr must not be in EAX1.55 + */1.56 +static inline void MEM_READ_DOUBLE( int addr, int arg2a, int arg2b )1.57 +{1.58 + PUSH_r32(addr);1.59 + call_func1(sh4_read_long, addr);1.60 + POP_r32(R_ECX);1.61 + PUSH_r32(R_EAX);1.62 + MOV_r32_r32(R_ECX, R_EAX);1.63 + ADD_imm8s_r32(4, R_EAX);1.64 + call_func0(sh4_read_long);1.65 + if( arg2b != R_EAX ) {1.66 + MOV_r32_r32(R_EAX, arg2b);1.67 + }1.68 + POP_r32(arg2a);1.69 +}1.70 +#else1.71 static inline void call_func1( void *ptr, int arg1 )1.72 {1.73 PUSH_r32(arg1);1.74 @@ -41,7 +95,6 @@1.75 ADD_imm8s_r32( 4, R_ESP );1.76 }1.78 -#define CALL_FUNC2_SIZE 121.79 static inline void call_func2( void *ptr, int arg1, int arg2 )1.80 {1.81 PUSH_r32(arg2);1.82 @@ -53,9 +106,7 @@1.83 /**1.84 * Write a double (64-bit) value into memory, with the first word in arg2a, and1.85 * the second in arg2b1.86 - * NB: 30 bytes1.87 */1.88 -#define MEM_WRITE_DOUBLE_SIZE 301.89 static inline void MEM_WRITE_DOUBLE( int addr, int arg2a, int arg2b )1.90 {1.91 ADD_imm8s_r32( 4, addr );1.92 @@ -73,9 +124,7 @@1.93 /**1.94 * Read a double (64-bit) value from memory, writing the first word into arg2a1.95 * and the second into arg2b. The addr must not be in EAX1.96 - * NB: 27 bytes1.97 */1.98 -#define MEM_READ_DOUBLE_SIZE 271.99 static inline void MEM_READ_DOUBLE( int addr, int arg2a, int arg2b )1.100 {1.101 PUSH_r32(addr);1.102 @@ -89,6 +138,7 @@1.103 MOV_r32_r32( R_EAX, arg2b );1.104 POP_r32(arg2a);1.105 }1.106 +#endif1.108 /**1.109 * Emit the 'start of block' assembly. Sets up the stack frame and save
.