Now, ./tcc -run -DTCC_TARGET_X86_64 tcc.c -run tcctest.c works!
Unified · Split
| @@ -6208,10 +6208,10 @@ static void gen_cast(CType *type) · 6207 unmodified lines | |||
| 6208 | gen_cast(type); | 6208 | gen_cast(type); |
| 6209 | } | 6209 | } |
| 6210 | } | 6210 | } |
| 6211 | #ifndef TCC_TARGET_X86_64 | ||
| 6211 | } else if ((dbt & VT_BTYPE) == VT_LLONG) { | 6212 | } else if ((dbt & VT_BTYPE) == VT_LLONG) { |
| 6212 | if ((sbt & VT_BTYPE) != VT_LLONG) { | 6213 | if ((sbt & VT_BTYPE) != VT_LLONG) { |
| 6213 | /* scalar to long long */ | 6214 | /* scalar to long long */ |
| 6214 | #ifndef TCC_TARGET_X86_64 | ||
| 6215 | /* machine independent conversion */ | 6215 | /* machine independent conversion */ |
| 6216 | gv(RC_INT); | 6216 | gv(RC_INT); |
| 6217 | /* generate high word */ | 6217 | /* generate high word */ |
| @@ -6231,15 +6231,21 @@ static void gen_cast(CType *type) · 13 unmodified lines | |||
| 6231 | /* patch second register */ | 6231 | /* patch second register */ |
| 6232 | vtop[-1].r2 = vtop->r; | 6232 | vtop[-1].r2 = vtop->r; |
| 6233 | vpop(); | 6233 | vpop(); |
| 6234 | } | ||
| 6234 | #else | 6235 | #else |
| 6236 | } else if ((dbt & VT_BTYPE) == VT_LLONG || | ||
| 6237 | (dbt & VT_BTYPE) == VT_PTR) { | ||
| 6238 | /* XXX: not sure if this is perfect... need more tests */ | ||
| 6239 | if ((sbt & VT_BTYPE) != VT_LLONG) { | ||
| 6235 | int r = gv(RC_INT); | 6240 | int r = gv(RC_INT); |
| 6236 | if (sbt != (VT_INT | VT_UNSIGNED) && sbt != VT_PTR) { | 6241 | if (sbt != (VT_INT | VT_UNSIGNED) && |
| 6242 | sbt != VT_PTR && sbt != VT_FUNC) { | ||
| 6237 | /* x86_64 specific: movslq */ | 6243 | /* x86_64 specific: movslq */ |
| 6238 | o(0x6348); | 6244 | o(0x6348); |
| 6239 | o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r)); | 6245 | o(0xc0 + (REG_VALUE(r) << 3) + REG_VALUE(r)); |
| 6240 | } | 6246 | } |
| 6241 | #endif | ||
| 6242 | } | 6247 | } |
| 6248 | #endif | ||
| 6243 | } else if (dbt == VT_BOOL) { | 6249 | } else if (dbt == VT_BOOL) { |
| 6244 | /* scalar to bool */ | 6250 | /* scalar to bool */ |
| 6245 | vpushi(0); | 6251 | vpushi(0); |
| @@ -1158,6 +1158,10 @@ void cast_test() · 1157 unmodified lines | |||
| 1158 | (int)p, (unsigned int)p, | 1158 | (int)p, (unsigned int)p, |
| 1159 | (long)p, (unsigned long)p, | 1159 | (long)p, (unsigned long)p, |
| 1160 | (long long)p, (unsigned long long)p); | 1160 | (long long)p, (unsigned long long)p); |
| 1161 | |||
| 1162 | /* from integers to pointers */ | ||
| 1163 | printf("%p %p %p %p\n", | ||
| 1164 | (void *)a, (void *)b, (void *)c, (void *)d); | ||
| 1161 | } | 1165 | } |
| 1162 | 1166 | ||
| 1163 | /* initializers tests */ | 1167 | /* initializers tests */ |