Unified · Split
| @@ -349,9 +349,8 @@ static void gadd_sp(int val) · 348 unmodified lines | |||
| 349 | } | 349 | } |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | /* generate function call with address in (vtop->t, vtop->c) and free function | 352 | /* 'is_jmp' is '1' if it is a jump */ |
| 353 | context. Stack entry is popped */ | 353 | static void gcall_or_jmp(int is_jmp) |
| 354 | void gfunc_call(GFuncContext *c) | ||
| 355 | { | 354 | { |
| 356 | int r; | 355 | int r; |
| 357 | if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { | 356 | if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) { |
| @@ -365,13 +364,20 @@ void gfunc_call(GFuncContext *c) · 7 unmodified lines | |||
| 365 | put_elf_reloc(symtab_section, cur_text_section, | 364 | put_elf_reloc(symtab_section, cur_text_section, |
| 366 | ind + 1, R_386_PC32, 0); | 365 | ind + 1, R_386_PC32, 0); |
| 367 | } | 366 | } |
| 368 | oad(0xe8, vtop->c.ul - 4); | 367 | oad(0xe8 + is_jmp, vtop->c.ul - 4); /* call/jmp im */ |
| 369 | } else { | 368 | } else { |
| 370 | /* otherwise, indirect call */ | 369 | /* otherwise, indirect call */ |
| 371 | r = gv(RC_INT); | 370 | r = gv(RC_INT); |
| 372 | o(0xff); /* call *r */ | 371 | o(0xff); /* call/jmp *r */ |
| 373 | o(0xd0 + r); | 372 | o(0xd0 + r + (is_jmp << 4)); |
| 374 | } | 373 | } |
| 374 | } | ||
| 375 | |||
| 376 | /* generate function call with address in (vtop->t, vtop->c) and free function | ||
| 377 | context. Stack entry is popped */ | ||
| 378 | void gfunc_call(GFuncContext *c) | ||
| 379 | { | ||
| 380 | gcall_or_jmp(0); | ||
| 375 | if (c->args_size && c->func_call == FUNC_CDECL) | 381 | if (c->args_size && c->func_call == FUNC_CDECL) |
| 376 | gadd_sp(c->args_size); | 382 | gadd_sp(c->args_size); |
| 377 | vtop--; | 383 | vtop--; |
| @@ -862,6 +868,13 @@ void gen_cvt_ftof(int t) · 484 unmodified lines | |||
| 862 | gv(RC_FLOAT); | 868 | gv(RC_FLOAT); |
| 863 | } | 869 | } |
| 864 | 870 | ||
| 871 | /* computed goto support */ | ||
| 872 | void ggoto(void) | ||
| 873 | { | ||
| 874 | gcall_or_jmp(1); | ||
| 875 | vtop--; | ||
| 876 | } | ||
| 877 | |||
| 865 | /* bound check support functions */ | 878 | /* bound check support functions */ |
| 866 | #ifdef CONFIG_TCC_BCHECK | 879 | #ifdef CONFIG_TCC_BCHECK |
| 867 | 880 | ||