History

Fixed 64-bit integer bug introduced by x86-64 ABI work.

Now I need to check that the x86-64 stuff still works.

James Lyon committed 13 years ago

Commit 23f73e91 parent cbce6d22 files · +12 −13Browse files

Unified · Split

2 files
  1. tccgen.c +5 −6
  2. tests/abitest.c +7 −7
tccgen.c+5−6
@@ -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_64791#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#else794#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#endif797#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 words801 /* two register type load : expand to two words
799 temporarily */802 temporarily */
800#ifndef TCC_TARGET_X86_64803#ifndef TCC_TARGET_X86_64
@@ -809,11 +812,6 @@ ST_FUNC int gv(int rc) · 8 unmodified lines
809#endif812#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 long815 /* We do not want to modifier the long long
818 pointer here, so the safest (and less816 pointer here, so the safest (and less
819 efficient) is to save all the other registers817 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 type849 /* lvalue of scalar type : need to use lvalue type
tests/abitest.c+7−7
@@ -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
54RET_PRIMITIVE_TEST(int, int)54RET_PRIMITIVE_TEST(int, int, 70000)
55RET_PRIMITIVE_TEST(longlong, long long)55RET_PRIMITIVE_TEST(longlong, long long, 4333369356528LL)
56RET_PRIMITIVE_TEST(float, float)56RET_PRIMITIVE_TEST(float, float, 63.0)
57RET_PRIMITIVE_TEST(double, double)57RET_PRIMITIVE_TEST(double, double, 14789798.0)
58RET_PRIMITIVE_TEST(longdouble, long double)58RET_PRIMITIVE_TEST(longdouble, long double, 378943892.0)
59 59
60/*60/*
61 * ret_2float_test:61 * ret_2float_test:

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t