aboutsummaryrefslogtreecommitdiff
path: root/sjit_c.c
diff options
context:
space:
mode:
authorCamil Staps2018-12-24 10:57:02 +0100
committerCamil Staps2018-12-24 10:57:02 +0100
commit0923472a035c1045f9f3291f8a0fe8bf8cbf65b1 (patch)
treeca3ede5ed610ac535a9ea899ffc4e97ca40ec379 /sjit_c.c
parentAdd -Wall -Wextra -Werror -Ofast (diff)
Use rcx as scratch register, since it is caller-saved in the System V and Microsoft calling conventions
Diffstat (limited to 'sjit_c.c')
-rw-r--r--sjit_c.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/sjit_c.c b/sjit_c.c
index 54c43dc..50e8f57 100644
--- a/sjit_c.c
+++ b/sjit_c.c
@@ -54,12 +54,12 @@ static inline void gen_instr(char *full_code, char **code_p, uint64_t **pgm_p, u
#ifdef DEBUG_JIT_INSTRUCTIONS
fprintf(stderr,"PushRef %lu\n",arg);
#endif
- code[0]='\x48'; /* mov rbx,[rsp+ARG*8] */
+ code[0]='\x48'; /* mov rcx,[rsp+ARG*8] */
code[1]='\x8b';
- code[2]='\x5c';
+ code[2]='\x4c';
code[3]='\x24';
code[4]=(unsigned char)arg*8;
- code[5]='\x53'; /* push rbx */
+ code[5]='\x51'; /* push rcx */
pgm+=2;
code+=6;
break;
@@ -68,11 +68,11 @@ static inline void gen_instr(char *full_code, char **code_p, uint64_t **pgm_p, u
#ifdef DEBUG_JIT_INSTRUCTIONS
fprintf(stderr,"PushI %lu\n",arg);
#endif
- code[0]='\x48'; /* mov rbx,ARG */
+ code[0]='\x48'; /* mov rcx,ARG */
code[1]='\xc7';
- code[2]='\xc3';
+ code[2]='\xc1';
*(uint32_t*)&code[3]=(uint32_t)arg;
- code[7]='\x53'; /* push rbx */
+ code[7]='\x51'; /* push rcx */
pgm+=2;
code+=8;
break;
@@ -81,10 +81,10 @@ static inline void gen_instr(char *full_code, char **code_p, uint64_t **pgm_p, u
#ifdef DEBUG_JIT_INSTRUCTIONS
fprintf(stderr,"Put %lu\n",arg);
#endif
- code[0]='\x5b'; /* pop rbx */
- code[1]='\x48'; /* mov [rsp+ARG*8],rbx */
+ code[0]='\x59'; /* pop rcx */
+ code[1]='\x48'; /* mov [rsp+ARG*8],rcx */
code[2]='\x89';
- code[3]='\x5c';
+ code[3]='\x4c';
code[4]='\x24';
code[5]=(unsigned char)(arg-1)*8;
pgm+=2;
@@ -140,27 +140,27 @@ static inline void gen_instr(char *full_code, char **code_p, uint64_t **pgm_p, u
#endif
/* mov rax,[rsp+8] */
code[0]='\x48'; code[1]='\x8b'; code[2]='\x44'; code[3]='\x24'; code[4]='\x08';
- /* mov rbx,[rsp+16] */
- code[5]='\x48'; code[6]='\x8b'; code[7]='\x5c'; code[8]='\x24'; code[9]='\x10';
+ /* mov rcx,[rsp+16] */
+ code[5]='\x48'; code[6]='\x8b'; code[7]='\x4c'; code[8]='\x24'; code[9]='\x10';
switch (*pgm) {
case IAddRet:
case ISubRet:
- /* {add,sub} rax,rbx */
+ /* {add,sub} rax,rcx */
code[10]='\x48';
code[11]=*pgm==IAddRet ? '\x01' : '\x29';
- code[12]='\xd8';
+ code[12]='\xc8';
code+=13;
break;
case IMulRet:
- /* imul rax,rbx */
- code[10]='\x48'; code[11]='\x0f'; code[12]='\xaf'; code[13]='\xc3';
+ /* imul rax,rcx */
+ code[10]='\x48'; code[11]='\x0f'; code[12]='\xaf'; code[13]='\xc1';
code+=14;
break;
case IDivRet:
/* xor rdx,rdx */
code[10]='\x48'; code[11]='\x31'; code[12]='\xd2';
- /* idiv rbx */
- code[13]='\x48'; code[14]='\xf7'; code[15]='\xfb';
+ /* idiv rcx */
+ code[13]='\x48'; code[14]='\xf7'; code[15]='\xf9';
code+=16;
break;
}