aboutsummaryrefslogtreecommitdiff
path: root/x86_64-gen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2016-10-19 19:21:27 +0200
committergrischka <grischka>2016-10-19 19:21:27 +0200
commitbfd1c08d6c579445fe75dd633fbd9b0757cea5d0 (patch)
tree299e8c05200731561bd7f6bbe3d733fd9c3a4e94 /x86_64-gen.c
parent02919cd27506e25dacdbe72dad1ae2718eb75991 (diff)
downloadtinycc-bfd1c08d6c579445fe75dd633fbd9b0757cea5d0.tar.gz
tinycc-bfd1c08d6c579445fe75dd633fbd9b0757cea5d0.tar.bz2
tccrun/win64: cleanup runtime function table
- call RtlDeleteFunctionTable (important for multiple compilations) - the RUNTIME_FUNCTION* is now at the beginning of the runtime memory. Therefor when tcc_relocate is called with user memory, this should be done manually before it is free'd: RtlDeleteFunctionTable(*(void**)user_mem); [ free(user_mem); ] - x86_64-gen.c: expand char/short return values to int
Diffstat (limited to 'x86_64-gen.c')
-rw-r--r--x86_64-gen.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/x86_64-gen.c b/x86_64-gen.c
index fa2460c..dd52e4a 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -893,6 +893,22 @@ void gfunc_call(int nb_args)
}
gcall_or_jmp(0);
+ /* other compilers don't clear the upper bits when returning char/short */
+ bt = vtop->type.ref->type.t & (VT_BTYPE | VT_UNSIGNED);
+ if (bt == (VT_BYTE | VT_UNSIGNED))
+ o(0xc0b60f); /* movzbl %al, %eax */
+ else if (bt == VT_BYTE)
+ o(0xc0be0f); /* movsbl %al, %eax */
+ else if (bt == VT_SHORT)
+ o(0x98); /* cwtl */
+ else if (bt == (VT_SHORT | VT_UNSIGNED))
+ o(0xc0b70f); /* movzbl %al, %eax */
+#if 0 /* handled in gen_cast() */
+ else if (bt == VT_INT)
+ o(0x9848); /* cltq */
+ else if (bt == (VT_INT | VT_UNSIGNED))
+ o(0xc089); /* mov %eax,%eax */
+#endif
vtop--;
}