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
790790 r = get_reg(rc);
791791 #ifdef TCC_TARGET_X86_64
792792 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;
793794 #else
794795 if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
796+ int addr_type = VT_INT, load_size = 4, load_type = VT_INT;
795797 #endif
796− int r2;
798+ int r2, original_type;
797799 unsigned long long ll;
800+ original_type = vtop->type.t;
798801 /* two register type load : expand to two words
799802 temporarily */
800803 #ifndef TCC_TARGET_X86_64
@@ -809,11 +812,6 @@ ST_FUNC int gv(int rc) · 8 unmodified lines
809812 #endif
810813 if (r >= VT_CONST || /* XXX: test to VT_CONST incorrect ? */
811814 (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
817815 /* We do not want to modifier the long long
818816 pointer here, so the safest (and less
819817 efficient) is to save all the other registers
@@ -845,6 +843,7 @@ ST_FUNC int gv(int rc) · 25 unmodified lines
845843 vpop();
846844 /* write second register */
847845 vtop->r2 = r2;
846+ vtop->type.t = original_type;
848847 } else if ((vtop->r & VT_LVAL) && !is_float(vtop->type.t)) {
849848 int t1, t;
850849 /* 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
3838 return result;
3939 }
4040
41−#define RET_PRIMITIVE_TEST(name, type) \
41+#define RET_PRIMITIVE_TEST(name, type, val) \
4242 static int ret_ ## name ## _test_callback(void *ptr) { \
4343 type (*callback) (type) = (type(*)(type))ptr; \
44− type x = 29; \
44+ type x = val; \
4545 type y = callback(x); \
4646 return (y == x+x) ? 0 : -1; \
4747 } \
@@ -51,11 +51,11 @@ static int run_callback(const char *src, callback_type callback) { · 3 unmodified lines
5151 return run_callback(src, ret_ ## name ## _test_callback); \
5252 }
5353
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)
5959
6060 /*
6161 * 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