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