tcc.h, tccgen.c: Introduce Sym *external_helper_sym(int v); to create an external reference with no specific type. This avoids type conflicts if the symbol is used from C too. the other files: use it.
Unified · Split
| @@ -785,7 +785,7 @@ static void gcall_or_jmp(int is_jmp) · 784 unmodified lines | |||
| 785 | 785 | ||
| 786 | static void gen_bounds_call(int v) | 786 | static void gen_bounds_call(int v) |
| 787 | { | 787 | { |
| 788 | Sym *sym = external_global_sym(v, &func_old_type); | 788 | Sym *sym = external_helper_sym(v); |
| 789 | 789 | ||
| 790 | greloc(cur_text_section, sym, ind, R_ARM_PC24); | 790 | greloc(cur_text_section, sym, ind, R_ARM_PC24); |
| 791 | o(0xebfffffe); | 791 | o(0xebfffffe); |
| @@ -1717,7 +1717,7 @@ done: · 925 unmodified lines | |||
| 1717 | vtop--; | 1717 | vtop--; |
| 1718 | break; | 1718 | break; |
| 1719 | case 3: | 1719 | case 3: |
| 1720 | vpush_global_sym(&func_old_type, func); | 1720 | vpush_helper_func(func); |
| 1721 | vrott(3); | 1721 | vrott(3); |
| 1722 | gfunc_call(2); | 1722 | gfunc_call(2); |
| 1723 | vpushi(0); | 1723 | vpushi(0); |
| @@ -2137,7 +2137,7 @@ ST_FUNC void gen_cvt_itof(int t) · 413 unmodified lines | |||
| 2137 | func=TOK___floatdidf; | 2137 | func=TOK___floatdidf; |
| 2138 | } | 2138 | } |
| 2139 | if(func_type) { | 2139 | if(func_type) { |
| 2140 | vpush_global_sym(func_type, func); | 2140 | vpushsym(func_type, external_helper_sym(func)); |
| 2141 | vswap(); | 2141 | vswap(); |
| 2142 | gfunc_call(1); | 2142 | gfunc_call(1); |
| 2143 | vpushi(0); | 2143 | vpushi(0); |
| @@ -2196,7 +2196,7 @@ void gen_cvt_ftoi(int t) · 52 unmodified lines | |||
| 2196 | func=TOK___fixdfdi; | 2196 | func=TOK___fixdfdi; |
| 2197 | } | 2197 | } |
| 2198 | if(func) { | 2198 | if(func) { |
| 2199 | vpush_global_sym(&func_old_type, func); | 2199 | vpush_helper_func(func); |
| 2200 | vswap(); | 2200 | vswap(); |
| 2201 | gfunc_call(1); | 2201 | gfunc_call(1); |
| 2202 | vpushi(0); | 2202 | vpushi(0); |
| @@ -2277,7 +2277,7 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) { · 74 unmodified lines | |||
| 2277 | vtop->r = TREG_R0; | 2277 | vtop->r = TREG_R0; |
| 2278 | o(0xe1a0000d | (vtop->r << 12)); // mov r0,sp | 2278 | o(0xe1a0000d | (vtop->r << 12)); // mov r0,sp |
| 2279 | vswap(); | 2279 | vswap(); |
| 2280 | vpush_global_sym(&func_old_type, TOK___bound_new_region); | 2280 | vpush_helper_func(TOK___bound_new_region); |
| 2281 | vrott(3); | 2281 | vrott(3); |
| 2282 | gfunc_call(2); | 2282 | gfunc_call(2); |
| 2283 | func_bound_add_epilog = 1; | 2283 | func_bound_add_epilog = 1; |
| @@ -662,7 +662,7 @@ static void arm64_gen_bl_or_b(int b) · 661 unmodified lines | |||
| 662 | 662 | ||
| 663 | static void gen_bounds_call(int v) | 663 | static void gen_bounds_call(int v) |
| 664 | { | 664 | { |
| 665 | Sym *sym = external_global_sym(v, &func_old_type); | 665 | Sym *sym = external_helper_sym(v); |
| 666 | 666 | ||
| 667 | greloca(cur_text_section, sym, ind, R_AARCH64_CALL26, 0); | 667 | greloca(cur_text_section, sym, ind, R_AARCH64_CALL26, 0); |
| 668 | o(0x94000000); // bl | 668 | o(0x94000000); // bl |
| @@ -1782,7 +1782,7 @@ ST_FUNC void gen_opf(int op) · 1113 unmodified lines | |||
| 1782 | case TOK_GT: func = TOK___gttf2; cond = 13; break; | 1782 | case TOK_GT: func = TOK___gttf2; cond = 13; break; |
| 1783 | default: assert(0); break; | 1783 | default: assert(0); break; |
| 1784 | } | 1784 | } |
| 1785 | vpush_global_sym(&func_old_type, func); | 1785 | vpush_helper_func(func); |
| 1786 | vrott(3); | 1786 | vrott(3); |
| 1787 | gfunc_call(2); | 1787 | gfunc_call(2); |
| 1788 | vpushi(0); | 1788 | vpushi(0); |
| @@ -1885,7 +1885,7 @@ ST_FUNC void gen_cvt_itof(int t) · 96 unmodified lines | |||
| 1885 | int func = (f & VT_BTYPE) == VT_LLONG ? | 1885 | int func = (f & VT_BTYPE) == VT_LLONG ? |
| 1886 | (f & VT_UNSIGNED ? TOK___floatunditf : TOK___floatditf) : | 1886 | (f & VT_UNSIGNED ? TOK___floatunditf : TOK___floatditf) : |
| 1887 | (f & VT_UNSIGNED ? TOK___floatunsitf : TOK___floatsitf); | 1887 | (f & VT_UNSIGNED ? TOK___floatunsitf : TOK___floatsitf); |
| 1888 | vpush_global_sym(&func_old_type, func); | 1888 | vpush_helper_func(func); |
| 1889 | vrott(2); | 1889 | vrott(2); |
| 1890 | gfunc_call(1); | 1890 | gfunc_call(1); |
| 1891 | vpushi(0); | 1891 | vpushi(0); |
| @@ -1913,7 +1913,7 @@ ST_FUNC void gen_cvt_ftoi(int t) · 21 unmodified lines | |||
| 1913 | int func = (t & VT_BTYPE) == VT_LLONG ? | 1913 | int func = (t & VT_BTYPE) == VT_LLONG ? |
| 1914 | (t & VT_UNSIGNED ? TOK___fixunstfdi : TOK___fixtfdi) : | 1914 | (t & VT_UNSIGNED ? TOK___fixunstfdi : TOK___fixtfdi) : |
| 1915 | (t & VT_UNSIGNED ? TOK___fixunstfsi : TOK___fixtfsi); | 1915 | (t & VT_UNSIGNED ? TOK___fixunstfsi : TOK___fixtfsi); |
| 1916 | vpush_global_sym(&func_old_type, func); | 1916 | vpush_helper_func(func); |
| 1917 | vrott(2); | 1917 | vrott(2); |
| 1918 | gfunc_call(1); | 1918 | gfunc_call(1); |
| 1919 | vpushi(0); | 1919 | vpushi(0); |
| @@ -1947,7 +1947,7 @@ ST_FUNC void gen_cvt_ftof(int t) · 27 unmodified lines | |||
| 1947 | int func = (t == VT_LDOUBLE) ? | 1947 | int func = (t == VT_LDOUBLE) ? |
| 1948 | (f == VT_FLOAT ? TOK___extendsftf2 : TOK___extenddftf2) : | 1948 | (f == VT_FLOAT ? TOK___extendsftf2 : TOK___extenddftf2) : |
| 1949 | (t == VT_FLOAT ? TOK___trunctfsf2 : TOK___trunctfdf2); | 1949 | (t == VT_FLOAT ? TOK___trunctfsf2 : TOK___trunctfdf2); |
| 1950 | vpush_global_sym(&func_old_type, func); | 1950 | vpush_helper_func(func); |
| 1951 | vrott(2); | 1951 | vrott(2); |
| 1952 | gfunc_call(1); | 1952 | gfunc_call(1); |
| 1953 | vpushi(0); | 1953 | vpushi(0); |
| @@ -2061,7 +2061,7 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) { · 107 unmodified lines | |||
| 2061 | vtop->r = TREG_R(0); | 2061 | vtop->r = TREG_R(0); |
| 2062 | o(0x910003e0 | vtop->r); // mov r0,sp | 2062 | o(0x910003e0 | vtop->r); // mov r0,sp |
| 2063 | vswap(); | 2063 | vswap(); |
| 2064 | vpush_global_sym(&func_old_type, TOK___bound_new_region); | 2064 | vpush_helper_func(TOK___bound_new_region); |
| 2065 | vrott(3); | 2065 | vrott(3); |
| 2066 | gfunc_call(2); | 2066 | gfunc_call(2); |
| 2067 | func_bound_add_epilog = 1; | 2067 | func_bound_add_epilog = 1; |
| @@ -2254,7 +2254,7 @@ void gen_opi(int op) · 2253 unmodified lines | |||
| 2254 | call_func: | 2254 | call_func: |
| 2255 | vswap(); | 2255 | vswap(); |
| 2256 | /* call generic idiv function */ | 2256 | /* call generic idiv function */ |
| 2257 | vpush_global_sym(&func_old_type, t); | 2257 | vpush_helper_func(t); |
| 2258 | vrott(3); | 2258 | vrott(3); |
| 2259 | gfunc_call(2); | 2259 | gfunc_call(2); |
| 2260 | vpushi(0); | 2260 | vpushi(0); |
| @@ -2385,7 +2385,7 @@ void gen_opf(int op) · 124 unmodified lines | |||
| 2385 | // must call intrinsic DP floating point divide | 2385 | // must call intrinsic DP floating point divide |
| 2386 | vswap(); | 2386 | vswap(); |
| 2387 | /* call generic idiv function */ | 2387 | /* call generic idiv function */ |
| 2388 | vpush_global_sym(&func_old_type, TOK__divd); | 2388 | vpush_helper_func(TOK__divd); |
| 2389 | vrott(3); | 2389 | vrott(3); |
| 2390 | gfunc_call(2); | 2390 | gfunc_call(2); |
| 2391 | vpushi(0); | 2391 | vpushi(0); |
| @@ -2396,7 +2396,7 @@ void gen_opf(int op) · 4 unmodified lines | |||
| 2396 | // must call intrinsic SP floating point divide | 2396 | // must call intrinsic SP floating point divide |
| 2397 | vswap(); | 2397 | vswap(); |
| 2398 | /* call generic idiv function */ | 2398 | /* call generic idiv function */ |
| 2399 | vpush_global_sym(&func_old_type, TOK__divf); | 2399 | vpush_helper_func(TOK__divf); |
| 2400 | vrott(3); | 2400 | vrott(3); |
| 2401 | gfunc_call(2); | 2401 | gfunc_call(2); |
| 2402 | vpushi(0); | 2402 | vpushi(0); |
| @@ -345,7 +345,7 @@ static void gen_static_call(int v) · 344 unmodified lines | |||
| 345 | { | 345 | { |
| 346 | Sym *sym; | 346 | Sym *sym; |
| 347 | 347 | ||
| 348 | sym = external_global_sym(v, &func_old_type); | 348 | sym = external_helper_sym(v); |
| 349 | oad(0xe8, -4); | 349 | oad(0xe8, -4); |
| 350 | greloc(cur_text_section, sym, ind-4, R_386_PC32); | 350 | greloc(cur_text_section, sym, ind-4, R_386_PC32); |
| 351 | } | 351 | } |
| @@ -985,11 +985,11 @@ ST_FUNC void gen_cvt_ftoi(int t) · 633 unmodified lines | |||
| 985 | { | 985 | { |
| 986 | int bt = vtop->type.t & VT_BTYPE; | 986 | int bt = vtop->type.t & VT_BTYPE; |
| 987 | if (bt == VT_FLOAT) | 987 | if (bt == VT_FLOAT) |
| 988 | vpush_global_sym(&func_old_type, TOK___fixsfdi); | 988 | vpush_helper_func(TOK___fixsfdi); |
| 989 | else if (bt == VT_LDOUBLE) | 989 | else if (bt == VT_LDOUBLE) |
| 990 | vpush_global_sym(&func_old_type, TOK___fixxfdi); | 990 | vpush_helper_func(TOK___fixxfdi); |
| 991 | else | 991 | else |
| 992 | vpush_global_sym(&func_old_type, TOK___fixdfdi); | 992 | vpush_helper_func(TOK___fixdfdi); |
| 993 | vswap(); | 993 | vswap(); |
| 994 | gfunc_call(1); | 994 | gfunc_call(1); |
| 995 | vpushi(0); | 995 | vpushi(0); |
| @@ -1099,7 +1099,7 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) { · 103 unmodified lines | |||
| 1099 | #endif | 1099 | #endif |
| 1100 | if (use_call) | 1100 | if (use_call) |
| 1101 | { | 1101 | { |
| 1102 | vpush_global_sym(&func_old_type, TOK_alloca); | 1102 | vpush_helper_func(TOK_alloca); |
| 1103 | vswap(); /* Move alloca ref past allocation size */ | 1103 | vswap(); /* Move alloca ref past allocation size */ |
| 1104 | gfunc_call(1); | 1104 | gfunc_call(1); |
| 1105 | } | 1105 | } |
| @@ -402,7 +402,7 @@ static void gcall_or_jmp(int docall) · 401 unmodified lines | |||
| 402 | 402 | ||
| 403 | static void gen_bounds_call(int v) | 403 | static void gen_bounds_call(int v) |
| 404 | { | 404 | { |
| 405 | Sym *sym = external_global_sym(v, &func_old_type); | 405 | Sym *sym = external_helper_sym(v); |
| 406 | 406 | ||
| 407 | greloca(cur_text_section, sym, ind, R_RISCV_CALL_PLT, 0); | 407 | greloca(cur_text_section, sym, ind, R_RISCV_CALL_PLT, 0); |
| 408 | o(0x17 | (1 << 7)); // auipc TR, 0 %call(func) | 408 | o(0x17 | (1 << 7)); // auipc TR, 0 %call(func) |
| @@ -1125,7 +1125,7 @@ ST_FUNC void gen_opf(int op) · 716 unmodified lines | |||
| 1125 | case TOK_GT: func = TOK___gttf2; cond = 13; break; | 1125 | case TOK_GT: func = TOK___gttf2; cond = 13; break; |
| 1126 | default: assert(0); break; | 1126 | default: assert(0); break; |
| 1127 | } | 1127 | } |
| 1128 | vpush_global_sym(&func_old_type, func); | 1128 | vpush_helper_func(func); |
| 1129 | vrott(3); | 1129 | vrott(3); |
| 1130 | gfunc_call(2); | 1130 | gfunc_call(2); |
| 1131 | vpushi(0); | 1131 | vpushi(0); |
| @@ -1213,7 +1213,7 @@ ST_FUNC void gen_cvt_itof(int t) · 81 unmodified lines | |||
| 1213 | int func = l ? | 1213 | int func = l ? |
| 1214 | (u ? TOK___floatunditf : TOK___floatditf) : | 1214 | (u ? TOK___floatunditf : TOK___floatditf) : |
| 1215 | (u ? TOK___floatunsitf : TOK___floatsitf); | 1215 | (u ? TOK___floatunsitf : TOK___floatsitf); |
| 1216 | vpush_global_sym(&func_old_type, func); | 1216 | vpush_helper_func(func); |
| 1217 | vrott(2); | 1217 | vrott(2); |
| 1218 | gfunc_call(1); | 1218 | gfunc_call(1); |
| 1219 | vpushi(0); | 1219 | vpushi(0); |
| @@ -1239,7 +1239,7 @@ ST_FUNC void gen_cvt_ftoi(int t) · 19 unmodified lines | |||
| 1239 | int func = l ? | 1239 | int func = l ? |
| 1240 | (u ? TOK___fixunstfdi : TOK___fixtfdi) : | 1240 | (u ? TOK___fixunstfdi : TOK___fixtfdi) : |
| 1241 | (u ? TOK___fixunstfsi : TOK___fixtfsi); | 1241 | (u ? TOK___fixunstfsi : TOK___fixtfsi); |
| 1242 | vpush_global_sym(&func_old_type, func); | 1242 | vpush_helper_func(func); |
| 1243 | vrott(2); | 1243 | vrott(2); |
| 1244 | gfunc_call(1); | 1244 | gfunc_call(1); |
| 1245 | vpushi(0); | 1245 | vpushi(0); |
| @@ -1281,7 +1281,7 @@ ST_FUNC void gen_cvt_ftof(int dt) · 35 unmodified lines | |||
| 1281 | vtop->r2 = 1 + vtop->r; | 1281 | vtop->r2 = 1 + vtop->r; |
| 1282 | } | 1282 | } |
| 1283 | } | 1283 | } |
| 1284 | vpush_global_sym(&func_old_type, func); | 1284 | vpush_helper_func(func); |
| 1285 | gcall_or_jmp(1); | 1285 | gcall_or_jmp(1); |
| 1286 | vtop -= 2; | 1286 | vtop -= 2; |
| 1287 | vpushi(0); | 1287 | vpushi(0); |
| @@ -1342,7 +1342,7 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) · 54 unmodified lines | |||
| 1342 | vtop->r = TREG_R(0); | 1342 | vtop->r = TREG_R(0); |
| 1343 | o(0x00010513); /* mv a0,sp */ | 1343 | o(0x00010513); /* mv a0,sp */ |
| 1344 | vswap(); | 1344 | vswap(); |
| 1345 | vpush_global_sym(&func_old_type, TOK___bound_new_region); | 1345 | vpush_helper_func(TOK___bound_new_region); |
| 1346 | vrott(3); | 1346 | vrott(3); |
| 1347 | gfunc_call(2); | 1347 | gfunc_call(2); |
| 1348 | func_bound_add_epilog = 1; | 1348 | func_bound_add_epilog = 1; |
| @@ -1437,10 +1437,11 @@ ST_FUNC void vpushi(int v); · 1436 unmodified lines | |||
| 1437 | ST_FUNC ElfSym *elfsym(Sym *); | 1437 | ST_FUNC ElfSym *elfsym(Sym *); |
| 1438 | ST_FUNC void update_storage(Sym *sym); | 1438 | ST_FUNC void update_storage(Sym *sym); |
| 1439 | ST_FUNC Sym *external_global_sym(int v, CType *type); | 1439 | ST_FUNC Sym *external_global_sym(int v, CType *type); |
| 1440 | ST_FUNC Sym *external_helper_sym(int v); | ||
| 1441 | ST_FUNC void vpush_helper_func(int v); | ||
| 1440 | ST_FUNC void vset(CType *type, int r, int v); | 1442 | ST_FUNC void vset(CType *type, int r, int v); |
| 1441 | ST_FUNC void vset_VT_CMP(int op); | 1443 | ST_FUNC void vset_VT_CMP(int op); |
| 1442 | ST_FUNC void vswap(void); | 1444 | ST_FUNC void vswap(void); |
| 1443 | ST_FUNC void vpush_global_sym(CType *type, int v); | ||
| 1444 | ST_FUNC void vrote(SValue *e, int n); | 1445 | ST_FUNC void vrote(SValue *e, int n); |
| 1445 | ST_FUNC void vrott(int n); | 1446 | ST_FUNC void vrott(int n); |
| 1446 | ST_FUNC void vrotb(int n); | 1447 | ST_FUNC void vrotb(int n); |
| @@ -80,7 +80,7 @@ ST_DATA int func_var; /* true if current function is variadic (used by return in · 79 unmodified lines | |||
| 80 | ST_DATA int func_vc; | 80 | ST_DATA int func_vc; |
| 81 | static int last_line_num, new_file, func_ind; /* debug info control */ | 81 | static int last_line_num, new_file, func_ind; /* debug info control */ |
| 82 | ST_DATA const char *funcname; | 82 | ST_DATA const char *funcname; |
| 83 | ST_DATA CType int_type, func_old_type, char_type, char_pointer_type, func_mem_move, void_type, void_ptr_type; | 83 | ST_DATA CType int_type, func_old_type, char_type, char_pointer_type; |
| 84 | static CString initstr; | 84 | static CString initstr; |
| 85 | 85 | ||
| 86 | #if PTR_SIZE == 4 | 86 | #if PTR_SIZE == 4 |
| @@ -800,14 +800,6 @@ ST_FUNC void tccgen_init(TCCState *s1) · 713 unmodified lines | |||
| 800 | char_pointer_type = char_type; | 800 | char_pointer_type = char_type; |
| 801 | mk_pointer(&char_pointer_type); | 801 | mk_pointer(&char_pointer_type); |
| 802 | 802 | ||
| 803 | void_type.t = VT_VOID; | ||
| 804 | void_ptr_type = void_type; | ||
| 805 | mk_pointer(&void_ptr_type); | ||
| 806 | func_mem_move.t = VT_FUNC; | ||
| 807 | func_mem_move.ref = sym_push(SYM_FIELD, &void_ptr_type, 0, 0); | ||
| 808 | func_mem_move.ref->f.func_call = FUNC_CDECL; | ||
| 809 | func_mem_move.ref->f.func_type = FUNC_OLD; | ||
| 810 | |||
| 811 | func_old_type.t = VT_FUNC; | 803 | func_old_type.t = VT_FUNC; |
| 812 | func_old_type.ref = sym_push(SYM_FIELD, &int_type, 0, 0); | 804 | func_old_type.ref = sym_push(SYM_FIELD, &int_type, 0, 0); |
| 813 | func_old_type.ref->f.func_call = FUNC_CDECL; | 805 | func_old_type.ref->f.func_call = FUNC_CDECL; |
| @@ -1493,6 +1485,20 @@ ST_FUNC Sym *external_global_sym(int v, CType *type) · 679 unmodified lines | |||
| 1493 | return s; | 1485 | return s; |
| 1494 | } | 1486 | } |
| 1495 | 1487 | ||
| 1488 | /* create an external reference with no specific type similar to asm labels. | ||
| 1489 | This avoids type conflicts if the symbol is used from C too */ | ||
| 1490 | ST_FUNC Sym *external_helper_sym(int v) | ||
| 1491 | { | ||
| 1492 | CType ct = { VT_ASM, NULL }; | ||
| 1493 | return external_global_sym(v, &ct); | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | /* push a reference to an helper function (such as memmove) */ | ||
| 1497 | ST_FUNC void vpush_helper_func(int v) | ||
| 1498 | { | ||
| 1499 | vpushsym(&func_old_type, external_helper_sym(v)); | ||
| 1500 | } | ||
| 1501 | |||
| 1496 | /* Merge symbol attributes. */ | 1502 | /* Merge symbol attributes. */ |
| 1497 | static void merge_symattr(struct SymAttr *sa, struct SymAttr *sa1) | 1503 | static void merge_symattr(struct SymAttr *sa, struct SymAttr *sa1) |
| 1498 | { | 1504 | { |
| @@ -1681,12 +1687,6 @@ static Sym *external_sym(int v, CType *type, int r, AttributeDef *ad) · 182 unmodified lines | |||
| 1681 | return s; | 1687 | return s; |
| 1682 | } | 1688 | } |
| 1683 | 1689 | ||
| 1684 | /* push a reference to global symbol v */ | ||
| 1685 | ST_FUNC void vpush_global_sym(CType *type, int v) | ||
| 1686 | { | ||
| 1687 | vpushsym(type, external_global_sym(v, type)); | ||
| 1688 | } | ||
| 1689 | |||
| 1690 | /* save registers up to (vtop - n) stack entry */ | 1690 | /* save registers up to (vtop - n) stack entry */ |
| 1691 | ST_FUNC void save_regs(int n) | 1691 | ST_FUNC void save_regs(int n) |
| 1692 | { | 1692 | { |
| @@ -1904,7 +1904,7 @@ static void gen_bounded_ptr_add(void) · 211 unmodified lines | |||
| 1904 | vpushv(&vtop[-1]); | 1904 | vpushv(&vtop[-1]); |
| 1905 | vrott(3); | 1905 | vrott(3); |
| 1906 | } | 1906 | } |
| 1907 | vpush_global_sym(&func_old_type, TOK___bound_ptr_add); | 1907 | vpush_helper_func(TOK___bound_ptr_add); |
| 1908 | vrott(3); | 1908 | vrott(3); |
| 1909 | gfunc_call(2); | 1909 | gfunc_call(2); |
| 1910 | vtop -= save; | 1910 | vtop -= save; |
| @@ -1941,7 +1941,7 @@ static void gen_bounded_ptr_deref(void) · 30 unmodified lines | |||
| 1941 | /* may happen with struct member access */ | 1941 | /* may happen with struct member access */ |
| 1942 | return; | 1942 | return; |
| 1943 | } | 1943 | } |
| 1944 | sym = external_global_sym(func, &func_old_type); | 1944 | sym = external_helper_sym(func); |
| 1945 | if (!sym->c) | 1945 | if (!sym->c) |
| 1946 | put_extern_sym(sym, NULL, 0, 0); | 1946 | put_extern_sym(sym, NULL, 0, 0); |
| 1947 | /* patch relocation */ | 1947 | /* patch relocation */ |
| @@ -1998,7 +1998,7 @@ ST_FUNC void gbound_args(int nb_args) · 50 unmodified lines | |||
| 1998 | || v == TOK___sigsetjmp | 1998 | || v == TOK___sigsetjmp |
| 1999 | #endif | 1999 | #endif |
| 2000 | ) { | 2000 | ) { |
| 2001 | vpush_global_sym(&func_old_type, TOK___bound_setjmp); | 2001 | vpush_helper_func(TOK___bound_setjmp); |
| 2002 | vpushv(sv + 1); | 2002 | vpushv(sv + 1); |
| 2003 | gfunc_call(1); | 2003 | gfunc_call(1); |
| 2004 | func_bound_add_epilog = 1; | 2004 | func_bound_add_epilog = 1; |
| @@ -2415,7 +2415,7 @@ static void gen_opl(int op) · 410 unmodified lines | |||
| 2415 | #endif | 2415 | #endif |
| 2416 | gen_func: | 2416 | gen_func: |
| 2417 | /* call generic long long function */ | 2417 | /* call generic long long function */ |
| 2418 | vpush_global_sym(&func_old_type, func); | 2418 | vpush_helper_func(func); |
| 2419 | vrott(3); | 2419 | vrott(3); |
| 2420 | gfunc_call(2); | 2420 | gfunc_call(2); |
| 2421 | vpushi(0); | 2421 | vpushi(0); |
| @@ -3379,13 +3379,13 @@ static void gen_cvt_itof1(int t) · 957 unmodified lines | |||
| 3379 | (VT_LLONG | VT_UNSIGNED)) { | 3379 | (VT_LLONG | VT_UNSIGNED)) { |
| 3380 | 3380 | ||
| 3381 | if (t == VT_FLOAT) | 3381 | if (t == VT_FLOAT) |
| 3382 | vpush_global_sym(&func_old_type, TOK___floatundisf); | 3382 | vpush_helper_func(TOK___floatundisf); |
| 3383 | #if LDOUBLE_SIZE != 8 | 3383 | #if LDOUBLE_SIZE != 8 |
| 3384 | else if (t == VT_LDOUBLE) | 3384 | else if (t == VT_LDOUBLE) |
| 3385 | vpush_global_sym(&func_old_type, TOK___floatundixf); | 3385 | vpush_helper_func(TOK___floatundixf); |
| 3386 | #endif | 3386 | #endif |
| 3387 | else | 3387 | else |
| 3388 | vpush_global_sym(&func_old_type, TOK___floatundidf); | 3388 | vpush_helper_func(TOK___floatundidf); |
| 3389 | vrott(2); | 3389 | vrott(2); |
| 3390 | gfunc_call(1); | 3390 | gfunc_call(1); |
| 3391 | vpushi(0); | 3391 | vpushi(0); |
| @@ -3407,13 +3407,13 @@ static void gen_cvt_ftoi1(int t) · 15 unmodified lines | |||
| 3407 | /* not handled natively */ | 3407 | /* not handled natively */ |
| 3408 | st = vtop->type.t & VT_BTYPE; | 3408 | st = vtop->type.t & VT_BTYPE; |
| 3409 | if (st == VT_FLOAT) | 3409 | if (st == VT_FLOAT) |
| 3410 | vpush_global_sym(&func_old_type, TOK___fixunssfdi); | 3410 | vpush_helper_func(TOK___fixunssfdi); |
| 3411 | #if LDOUBLE_SIZE != 8 | 3411 | #if LDOUBLE_SIZE != 8 |
| 3412 | else if (st == VT_LDOUBLE) | 3412 | else if (st == VT_LDOUBLE) |
| 3413 | vpush_global_sym(&func_old_type, TOK___fixunsxfdi); | 3413 | vpush_helper_func(TOK___fixunsxfdi); |
| 3414 | #endif | 3414 | #endif |
| 3415 | else | 3415 | else |
| 3416 | vpush_global_sym(&func_old_type, TOK___fixunsdfdi); | 3416 | vpush_helper_func(TOK___fixunsdfdi); |
| 3417 | vrott(2); | 3417 | vrott(2); |
| 3418 | gfunc_call(1); | 3418 | gfunc_call(1); |
| 3419 | vpushi(0); | 3419 | vpushi(0); |
| @@ -3904,13 +3904,13 @@ ST_FUNC void vstore(void) · 484 unmodified lines | |||
| 3904 | /* address of memcpy() */ | 3904 | /* address of memcpy() */ |
| 3905 | #ifdef TCC_ARM_EABI | 3905 | #ifdef TCC_ARM_EABI |
| 3906 | if(!(align & 7)) | 3906 | if(!(align & 7)) |
| 3907 | vpush_global_sym(&func_old_type, TOK_memmove8); | 3907 | vpush_helper_func(TOK_memmove8); |
| 3908 | else if(!(align & 3)) | 3908 | else if(!(align & 3)) |
| 3909 | vpush_global_sym(&func_old_type, TOK_memmove4); | 3909 | vpush_helper_func(TOK_memmove4); |
| 3910 | else | 3910 | else |
| 3911 | #endif | 3911 | #endif |
| 3912 | /* Use memmove, rather than memcpy, as dest and src may be same: */ | 3912 | /* Use memmove, rather than memcpy, as dest and src may be same: */ |
| 3913 | vpush_global_sym(&func_mem_move, TOK_memmove); | 3913 | vpush_helper_func(TOK_memmove); |
| 3914 | 3914 | ||
| 3915 | vswap(); | 3915 | vswap(); |
| 3916 | /* source */ | 3916 | /* source */ |
| @@ -7363,7 +7363,7 @@ static void init_putz(init_params *p, unsigned long c, int size) · 3446 unmodified lines | |||
| 7363 | if (p->sec) { | 7363 | if (p->sec) { |
| 7364 | /* nothing to do because globals are already set to zero */ | 7364 | /* nothing to do because globals are already set to zero */ |
| 7365 | } else { | 7365 | } else { |
| 7366 | vpush_global_sym(&func_old_type, TOK_memset); | 7366 | vpush_helper_func(TOK_memset); |
| 7367 | vseti(VT_LOCAL, c); | 7367 | vseti(VT_LOCAL, c); |
| 7368 | #ifdef TCC_TARGET_ARM | 7368 | #ifdef TCC_TARGET_ARM |
| 7369 | vpushs(size); | 7369 | vpushs(size); |
| @@ -653,7 +653,7 @@ static void gcall_or_jmp(int is_jmp) · 652 unmodified lines | |||
| 653 | 653 | ||
| 654 | static void gen_bounds_call(int v) | 654 | static void gen_bounds_call(int v) |
| 655 | { | 655 | { |
| 656 | Sym *sym = external_global_sym(v, &func_old_type); | 656 | Sym *sym = external_helper_sym(v); |
| 657 | oad(0xe8, 0); | 657 | oad(0xe8, 0); |
| 658 | #ifdef TCC_TARGET_PE | 658 | #ifdef TCC_TARGET_PE |
| 659 | greloca(cur_text_section, sym, ind-4, R_X86_64_PC32, -4); | 659 | greloca(cur_text_section, sym, ind-4, R_X86_64_PC32, -4); |
| @@ -1022,7 +1022,7 @@ void gfunc_epilog(void) · 362 unmodified lines | |||
| 1022 | v = -loc; | 1022 | v = -loc; |
| 1023 | 1023 | ||
| 1024 | if (v >= 4096) { | 1024 | if (v >= 4096) { |
| 1025 | Sym *sym = external_global_sym(TOK___chkstk, &func_old_type); | 1025 | Sym *sym = external_helper_sym(TOK___chkstk); |
| 1026 | oad(0xb8, v); /* mov stacksize, %eax */ | 1026 | oad(0xb8, v); /* mov stacksize, %eax */ |
| 1027 | oad(0xe8, 0); /* call __chkstk, (does the stackframe too) */ | 1027 | oad(0xe8, 0); /* call __chkstk, (does the stackframe too) */ |
| 1028 | greloca(cur_text_section, sym, ind-4, R_X86_64_PC32, -4); | 1028 | greloca(cur_text_section, sym, ind-4, R_X86_64_PC32, -4); |
| @@ -2209,7 +2209,7 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) { · 1180 unmodified lines | |||
| 2209 | #endif | 2209 | #endif |
| 2210 | if (use_call) | 2210 | if (use_call) |
| 2211 | { | 2211 | { |
| 2212 | vpush_global_sym(&func_old_type, TOK_alloca); | 2212 | vpush_helper_func(TOK_alloca); |
| 2213 | vswap(); /* Move alloca ref past allocation size */ | 2213 | vswap(); /* Move alloca ref past allocation size */ |
| 2214 | gfunc_call(1); | 2214 | gfunc_call(1); |
| 2215 | } | 2215 | } |