Now I need to check that the x86-64 stuff still works.
Unified · Split
| @@ -790,11 +790,14 @@ ST_FUNC int gv(int rc) · 789 unmodified lines | |||
| 790 | r = get_reg(rc); | 790 | r = get_reg(rc); |
| 791 | #ifdef TCC_TARGET_X86_64 | 791 | #ifdef TCC_TARGET_X86_64 |
| 792 | if (((vtop->type.t & VT_BTYPE) == VT_QLONG) || ((vtop->type.t & VT_BTYPE) == VT_QFLOAT)) { | 792 | if (((vtop->type.t & VT_BTYPE) == VT_QLONG) || ((vtop->type.t & VT_BTYPE) == VT_QFLOAT)) { |
| 793 | int addr_type = VT_LLONG, load_size = 8, load_type = ((vtop->type.t & VT_BTYPE) == VT_QLONG) ? VT_LLONG : VT_DOUBLE; | ||
| 793 | #else | 794 | #else |
| 794 | if ((vtop->type.t & VT_BTYPE) == VT_LLONG) { | 795 | if ((vtop->type.t & VT_BTYPE) == VT_LLONG) { |
| 796 | int addr_type = VT_INT, load_size = 4, load_type = VT_INT; | ||
| 795 | #endif | 797 | #endif |
| 796 | int r2; | 798 | int r2, original_type; |
| 797 | unsigned long long ll; | 799 | unsigned long long ll; |
| 800 | original_type = vtop->type.t; | ||
| 798 | /* two register type load : expand to two words | 801 | /* two register type load : expand to two words |
| 799 | temporarily */ | 802 | temporarily */ |
| 800 | #ifndef TCC_TARGET_X86_64 | 803 | #ifndef TCC_TARGET_X86_64 |
| @@ -809,11 +812,6 @@ ST_FUNC int gv(int rc) · 8 unmodified lines | |||
| 809 | #endif | 812 | #endif |
| 810 | if (r >= VT_CONST || /* XXX: test to VT_CONST incorrect ? */ | 813 | if (r >= VT_CONST || /* XXX: test to VT_CONST incorrect ? */ |
| 811 | (vtop->r & VT_LVAL)) { | 814 | (vtop->r & VT_LVAL)) { |
| 812 | #ifdef TCC_TARGET_X86_64 | ||
| 813 | int addr_type = VT_LLONG, load_size = 8, load_type = ((vtop->type.t & VT_BTYPE) == VT_QLONG) ? VT_LLONG : VT_DOUBLE; | ||
| 814 | #else | ||
| 815 | int addr_type = VT_INT, load_size = 4, load_type = VT_INT; | ||
| 816 | #endif | ||
| 817 | /* We do not want to modifier the long long | 815 | /* We do not want to modifier the long long |
| 818 | pointer here, so the safest (and less | 816 | pointer here, so the safest (and less |
| 819 | efficient) is to save all the other registers | 817 | efficient) is to save all the other registers |
| @@ -845,6 +843,7 @@ ST_FUNC int gv(int rc) · 25 unmodified lines | |||
| 845 | vpop(); | 843 | vpop(); |
| 846 | /* write second register */ | 844 | /* write second register */ |
| 847 | vtop->r2 = r2; | 845 | vtop->r2 = r2; |
| 846 | vtop->type.t = original_type; | ||
| 848 | } else if ((vtop->r & VT_LVAL) && !is_float(vtop->type.t)) { | 847 | } else if ((vtop->r & VT_LVAL) && !is_float(vtop->type.t)) { |
| 849 | int t1, t; | 848 | int t1, t; |
| 850 | /* lvalue of scalar type : need to use lvalue type | 849 | /* lvalue of scalar type : need to use lvalue type |
| @@ -38,10 +38,10 @@ static int run_callback(const char *src, callback_type callback) { · 37 unmodified lines | |||
| 38 | return result; | 38 | return result; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | #define RET_PRIMITIVE_TEST(name, type) \ | 41 | #define RET_PRIMITIVE_TEST(name, type, val) \ |
| 42 | static int ret_ ## name ## _test_callback(void *ptr) { \ | 42 | static int ret_ ## name ## _test_callback(void *ptr) { \ |
| 43 | type (*callback) (type) = (type(*)(type))ptr; \ | 43 | type (*callback) (type) = (type(*)(type))ptr; \ |
| 44 | type x = 29; \ | 44 | type x = val; \ |
| 45 | type y = callback(x); \ | 45 | type y = callback(x); \ |
| 46 | return (y == x+x) ? 0 : -1; \ | 46 | return (y == x+x) ? 0 : -1; \ |
| 47 | } \ | 47 | } \ |
| @@ -51,11 +51,11 @@ static int run_callback(const char *src, callback_type callback) { · 3 unmodified lines | |||
| 51 | return run_callback(src, ret_ ## name ## _test_callback); \ | 51 | return run_callback(src, ret_ ## name ## _test_callback); \ |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | RET_PRIMITIVE_TEST(int, int) | 54 | RET_PRIMITIVE_TEST(int, int, 70000) |
| 55 | RET_PRIMITIVE_TEST(longlong, long long) | 55 | RET_PRIMITIVE_TEST(longlong, long long, 4333369356528LL) |
| 56 | RET_PRIMITIVE_TEST(float, float) | 56 | RET_PRIMITIVE_TEST(float, float, 63.0) |
| 57 | RET_PRIMITIVE_TEST(double, double) | 57 | RET_PRIMITIVE_TEST(double, double, 14789798.0) |
| 58 | RET_PRIMITIVE_TEST(longdouble, long double) | 58 | RET_PRIMITIVE_TEST(longdouble, long double, 378943892.0) |
| 59 | 59 | ||
| 60 | /* | 60 | /* |
| 61 | * ret_2float_test: | 61 | * ret_2float_test: |