For some reason there was no point for that anymore.
Unified · Split
| @@ -1363,7 +1363,7 @@ from_stack: · 1362 unmodified lines | |||
| 1363 | addr = (n + nf + sn) * 4; | 1363 | addr = (n + nf + sn) * 4; |
| 1364 | sn += size; | 1364 | sn += size; |
| 1365 | } | 1365 | } |
| 1366 | sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), | 1366 | sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | VT_LVAL, |
| 1367 | addr + 12); | 1367 | addr + 12); |
| 1368 | } | 1368 | } |
| 1369 | last_itod_magic=0; | 1369 | last_itod_magic=0; |
| @@ -446,7 +446,7 @@ static void arm64_load_cmp(int r, SValue *sv); · 445 unmodified lines | |||
| 446 | ST_FUNC void load(int r, SValue *sv) | 446 | ST_FUNC void load(int r, SValue *sv) |
| 447 | { | 447 | { |
| 448 | int svtt = sv->type.t; | 448 | int svtt = sv->type.t; |
| 449 | int svr = sv->r & ~VT_LVAL_TYPE; | 449 | int svr = sv->r; |
| 450 | int svrv = svr & VT_VALMASK; | 450 | int svrv = svr & VT_VALMASK; |
| 451 | uint64_t svcul = (uint32_t)sv->c.i; | 451 | uint64_t svcul = (uint32_t)sv->c.i; |
| 452 | svcul = svcul >> 31 & 1 ? svcul - ((uint64_t)1 << 32) : svcul; | 452 | svcul = svcul >> 31 & 1 ? svcul - ((uint64_t)1 << 32) : svcul; |
| @@ -546,7 +546,7 @@ ST_FUNC void load(int r, SValue *sv) · 93 unmodified lines | |||
| 546 | ST_FUNC void store(int r, SValue *sv) | 546 | ST_FUNC void store(int r, SValue *sv) |
| 547 | { | 547 | { |
| 548 | int svtt = sv->type.t; | 548 | int svtt = sv->type.t; |
| 549 | int svr = sv->r & ~VT_LVAL_TYPE; | 549 | int svr = sv->r; |
| 550 | int svrv = svr & VT_VALMASK; | 550 | int svrv = svr & VT_VALMASK; |
| 551 | uint64_t svcul = (uint32_t)sv->c.i; | 551 | uint64_t svcul = (uint32_t)sv->c.i; |
| 552 | svcul = svcul >> 31 & 1 ? svcul - ((uint64_t)1 << 32) : svcul; | 552 | svcul = svcul >> 31 & 1 ? svcul - ((uint64_t)1 << 32) : svcul; |
| @@ -1039,7 +1039,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 486 unmodified lines | |||
| 1039 | a[i] < 32 ? 16 + (a[i] - 16) / 2 * 16 : | 1039 | a[i] < 32 ? 16 + (a[i] - 16) / 2 * 16 : |
| 1040 | 224 + ((a[i] - 32) >> 1 << 1)); | 1040 | 224 + ((a[i] - 32) >> 1 << 1)); |
| 1041 | sym_push(sym->v & ~SYM_FIELD, &sym->type, | 1041 | sym_push(sym->v & ~SYM_FIELD, &sym->type, |
| 1042 | (a[i] & 1 ? VT_LLOCAL : VT_LOCAL) | lvalue_type(sym->type.t), | 1042 | (a[i] & 1 ? VT_LLOCAL : VT_LOCAL) | VT_LVAL, |
| 1043 | off); | 1043 | off); |
| 1044 | 1044 | ||
| 1045 | if (a[i] < 16) { | 1045 | if (a[i] < 16) { |
| @@ -1126,7 +1126,7 @@ ST_FUNC void gen_va_arg(CType *t) · 80 unmodified lines | |||
| 1126 | gaddrof(); | 1126 | gaddrof(); |
| 1127 | r0 = intr(gv(RC_INT)); | 1127 | r0 = intr(gv(RC_INT)); |
| 1128 | r1 = get_reg(RC_INT); | 1128 | r1 = get_reg(RC_INT); |
| 1129 | vtop[0].r = r1 | lvalue_type(t->t); | 1129 | vtop[0].r = r1 | VT_LVAL; |
| 1130 | r1 = intr(r1); | 1130 | r1 = intr(r1); |
| 1131 | 1131 | ||
| 1132 | if (!hfa) { | 1132 | if (!hfa) { |
| @@ -1964,7 +1964,7 @@ void gfunc_prolog(Sym *func_sym) · 1963 unmodified lines | |||
| 1964 | /* define parameters */ | 1964 | /* define parameters */ |
| 1965 | while ((sym = sym->next) != NULL) { | 1965 | while ((sym = sym->next) != NULL) { |
| 1966 | type = &sym->type; | 1966 | type = &sym->type; |
| 1967 | sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr); | 1967 | sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | VT_LVAL, addr); |
| 1968 | size = type_size(type, &align); | 1968 | size = type_size(type, &align); |
| 1969 | size = (size + 3) & ~3; | 1969 | size = (size + 3) & ~3; |
| 1970 | 1970 | ||
| @@ -587,7 +587,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 586 unmodified lines | |||
| 587 | addr += size; | 587 | addr += size; |
| 588 | } | 588 | } |
| 589 | sym_push(sym->v & ~SYM_FIELD, type, | 589 | sym_push(sym->v & ~SYM_FIELD, type, |
| 590 | VT_LOCAL | lvalue_type(type->t), param_addr); | 590 | VT_LOCAL | VT_LVAL, param_addr); |
| 591 | param_index++; | 591 | param_index++; |
| 592 | } | 592 | } |
| 593 | func_ret_sub = 0; | 593 | func_ret_sub = 0; |
| @@ -1084,16 +1084,7 @@ ST_FUNC void gen_bounded_ptr_deref(void) · 490 unmodified lines | |||
| 1084 | if (nocode_wanted) | 1084 | if (nocode_wanted) |
| 1085 | return; | 1085 | return; |
| 1086 | 1086 | ||
| 1087 | size = 0; | 1087 | size = type_size(&vtop->type, &align); |
| 1088 | /* XXX: put that code in generic part of tcc */ | ||
| 1089 | if (!is_float(vtop->type.t)) { | ||
| 1090 | if (vtop->r & VT_LVAL_BYTE) | ||
| 1091 | size = 1; | ||
| 1092 | else if (vtop->r & VT_LVAL_SHORT) | ||
| 1093 | size = 2; | ||
| 1094 | } | ||
| 1095 | if (!size) | ||
| 1096 | size = type_size(&vtop->type, &align); | ||
| 1097 | switch(size) { | 1088 | switch(size) { |
| 1098 | case 1: func = TOK___bound_ptr_indir1; break; | 1089 | case 1: func = TOK___bound_ptr_indir1; break; |
| 1099 | case 2: func = TOK___bound_ptr_indir2; break; | 1090 | case 2: func = TOK___bound_ptr_indir2; break; |
| @@ -681,7 +681,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 680 unmodified lines | |||
| 681 | } | 681 | } |
| 682 | } | 682 | } |
| 683 | sym_push(sym->v & ~SYM_FIELD, &sym->type, | 683 | sym_push(sym->v & ~SYM_FIELD, &sym->type, |
| 684 | (byref ? VT_LLOCAL : VT_LOCAL) | lvalue_type(sym->type.t), | 684 | (byref ? VT_LLOCAL : VT_LOCAL) | VT_LVAL, |
| 685 | param_addr); | 685 | param_addr); |
| 686 | } | 686 | } |
| 687 | func_va_list_ofs = addr; | 687 | func_va_list_ofs = addr; |
| @@ -932,11 +932,6 @@ struct filespec { · 931 unmodified lines | |||
| 932 | dereferencing value */ | 932 | dereferencing value */ |
| 933 | #define VT_BOUNDED 0x8000 /* value is bounded. The address of the | 933 | #define VT_BOUNDED 0x8000 /* value is bounded. The address of the |
| 934 | bounding function call point is in vc */ | 934 | bounding function call point is in vc */ |
| 935 | #define VT_LVAL_BYTE 0x1000 /* lvalue is a byte */ | ||
| 936 | #define VT_LVAL_SHORT 0x2000 /* lvalue is a short */ | ||
| 937 | #define VT_LVAL_UNSIGNED 0x4000 /* lvalue is unsigned */ | ||
| 938 | #define VT_LVAL_TYPE (VT_LVAL_BYTE | VT_LVAL_SHORT | VT_LVAL_UNSIGNED) | ||
| 939 | |||
| 940 | /* types */ | 935 | /* types */ |
| 941 | #define VT_BTYPE 0x000f /* mask for basic type */ | 936 | #define VT_BTYPE 0x000f /* mask for basic type */ |
| 942 | #define VT_VOID 0 /* void type */ | 937 | #define VT_VOID 0 /* void type */ |
| @@ -1426,7 +1421,6 @@ ST_FUNC void vstore(void); · 483 unmodified lines | |||
| 1426 | ST_FUNC void inc(int post, int c); | 1421 | ST_FUNC void inc(int post, int c); |
| 1427 | ST_FUNC void parse_mult_str (CString *astr, const char *msg); | 1422 | ST_FUNC void parse_mult_str (CString *astr, const char *msg); |
| 1428 | ST_FUNC void parse_asm_str(CString *astr); | 1423 | ST_FUNC void parse_asm_str(CString *astr); |
| 1429 | ST_FUNC int lvalue_type(int t); | ||
| 1430 | ST_FUNC void indir(void); | 1424 | ST_FUNC void indir(void); |
| 1431 | ST_FUNC void unary(void); | 1425 | ST_FUNC void unary(void); |
| 1432 | ST_FUNC void expr_prod(void); | 1426 | ST_FUNC void expr_prod(void); |
| @@ -1408,7 +1408,7 @@ ST_FUNC void save_reg_upstack(int r, int n) · 1407 unmodified lines | |||
| 1408 | p->c.i */ | 1408 | p->c.i */ |
| 1409 | p->r = (p->r & ~(VT_VALMASK | VT_BOUNDED)) | VT_LLOCAL; | 1409 | p->r = (p->r & ~(VT_VALMASK | VT_BOUNDED)) | VT_LLOCAL; |
| 1410 | } else { | 1410 | } else { |
| 1411 | p->r = lvalue_type(p->type.t) | VT_LOCAL; | 1411 | p->r = VT_LVAL | VT_LOCAL; |
| 1412 | } | 1412 | } |
| 1413 | p->r2 = VT_CONST; | 1413 | p->r2 = VT_CONST; |
| 1414 | p->c.i = l; | 1414 | p->c.i = l; |
| @@ -1430,7 +1430,7 @@ ST_FUNC int get_reg_ex(int rc, int rc2) · 15 unmodified lines | |||
| 1430 | n=0; | 1430 | n=0; |
| 1431 | for(p = vstack; p <= vtop; p++) { | 1431 | for(p = vstack; p <= vtop; p++) { |
| 1432 | if ((p->r & VT_VALMASK) == r || | 1432 | if ((p->r & VT_VALMASK) == r || |
| 1433 | (p->r2 & VT_VALMASK) == r) | 1433 | p->r2 == r) |
| 1434 | n++; | 1434 | n++; |
| 1435 | } | 1435 | } |
| 1436 | if (n <= 1) | 1436 | if (n <= 1) |
| @@ -1454,7 +1454,7 @@ ST_FUNC int get_reg(int rc) · 17 unmodified lines | |||
| 1454 | return r; | 1454 | return r; |
| 1455 | for(p=vstack;p<=vtop;p++) { | 1455 | for(p=vstack;p<=vtop;p++) { |
| 1456 | if ((p->r & VT_VALMASK) == r || | 1456 | if ((p->r & VT_VALMASK) == r || |
| 1457 | (p->r2 & VT_VALMASK) == r) | 1457 | p->r2 == r) |
| 1458 | goto notfound; | 1458 | goto notfound; |
| 1459 | } | 1459 | } |
| 1460 | return r; | 1460 | return r; |
| @@ -1467,7 +1467,7 @@ ST_FUNC int get_reg(int rc) · 6 unmodified lines | |||
| 1467 | spill registers used in gen_opi()) */ | 1467 | spill registers used in gen_opi()) */ |
| 1468 | for(p=vstack;p<=vtop;p++) { | 1468 | for(p=vstack;p<=vtop;p++) { |
| 1469 | /* look at second register (if long long) */ | 1469 | /* look at second register (if long long) */ |
| 1470 | r = p->r2 & VT_VALMASK; | 1470 | r = p->r2; |
| 1471 | if (r < VT_CONST && (reg_classes[r] & rc)) | 1471 | if (r < VT_CONST && (reg_classes[r] & rc)) |
| 1472 | goto save_found; | 1472 | goto save_found; |
| 1473 | r = p->r & VT_VALMASK; | 1473 | r = p->r & VT_VALMASK; |
| @@ -1553,16 +1553,13 @@ ST_FUNC void gaddrof(void) · 79 unmodified lines | |||
| 1553 | vtop->r &= ~VT_LVAL; | 1553 | vtop->r &= ~VT_LVAL; |
| 1554 | /* tricky: if saved lvalue, then we can go back to lvalue */ | 1554 | /* tricky: if saved lvalue, then we can go back to lvalue */ |
| 1555 | if ((vtop->r & VT_VALMASK) == VT_LLOCAL) | 1555 | if ((vtop->r & VT_VALMASK) == VT_LLOCAL) |
| 1556 | vtop->r = (vtop->r & ~(VT_VALMASK | VT_LVAL_TYPE)) | VT_LOCAL | VT_LVAL; | 1556 | vtop->r = (vtop->r & ~VT_VALMASK) | VT_LOCAL | VT_LVAL; |
| 1557 | |||
| 1558 | |||
| 1559 | } | 1557 | } |
| 1560 | 1558 | ||
| 1561 | #ifdef CONFIG_TCC_BCHECK | 1559 | #ifdef CONFIG_TCC_BCHECK |
| 1562 | /* generate lvalue bound code */ | 1560 | /* generate lvalue bound code */ |
| 1563 | static void gbound(void) | 1561 | static void gbound(void) |
| 1564 | { | 1562 | { |
| 1565 | int lval_type; | ||
| 1566 | CType type1; | 1563 | CType type1; |
| 1567 | 1564 | ||
| 1568 | vtop->r &= ~VT_MUSTBOUND; | 1565 | vtop->r &= ~VT_MUSTBOUND; |
| @@ -1570,14 +1567,13 @@ static void gbound(void) · 1 unmodified line | |||
| 1570 | if (vtop->r & VT_LVAL) { | 1567 | if (vtop->r & VT_LVAL) { |
| 1571 | /* if not VT_BOUNDED value, then make one */ | 1568 | /* if not VT_BOUNDED value, then make one */ |
| 1572 | if (!(vtop->r & VT_BOUNDED)) { | 1569 | if (!(vtop->r & VT_BOUNDED)) { |
| 1573 | lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL); | ||
| 1574 | /* must save type because we must set it to int to get pointer */ | 1570 | /* must save type because we must set it to int to get pointer */ |
| 1575 | type1 = vtop->type; | 1571 | type1 = vtop->type; |
| 1576 | vtop->type.t = VT_PTR; | 1572 | vtop->type.t = VT_PTR; |
| 1577 | gaddrof(); | 1573 | gaddrof(); |
| 1578 | vpushi(0); | 1574 | vpushi(0); |
| 1579 | gen_bounded_ptr_add(); | 1575 | gen_bounded_ptr_add(); |
| 1580 | vtop->r |= lval_type; | 1576 | vtop->r |= VT_LVAL; |
| 1581 | vtop->type = type1; | 1577 | vtop->type = type1; |
| 1582 | } | 1578 | } |
| 1583 | /* then check for dereferencing */ | 1579 | /* then check for dereferencing */ |
| @@ -1603,12 +1599,10 @@ static void incr_bf_adr(int o) · 19 unmodified lines | |||
| 1603 | { | 1599 | { |
| 1604 | vtop->type = char_pointer_type; | 1600 | vtop->type = char_pointer_type; |
| 1605 | gaddrof(); | 1601 | gaddrof(); |
| 1606 | vpushi(o); | 1602 | vpushs(o); |
| 1607 | gen_op('+'); | 1603 | gen_op('+'); |
| 1608 | vtop->type.t = (vtop->type.t & ~(VT_BTYPE|VT_DEFSIGN)) | 1604 | vtop->type.t = VT_BYTE | VT_UNSIGNED; |
| 1609 | | (VT_BYTE|VT_UNSIGNED); | 1605 | vtop->r |= VT_LVAL; |
| 1610 | vtop->r = (vtop->r & ~VT_LVAL_TYPE) | ||
| 1611 | | (VT_LVAL_BYTE|VT_LVAL_UNSIGNED|VT_LVAL); | ||
| 1612 | } | 1606 | } |
| 1613 | 1607 | ||
| 1614 | /* single-byte load mode for packed or otherwise unaligned bitfields */ | 1608 | /* single-byte load mode for packed or otherwise unaligned bitfields */ |
| @@ -1688,7 +1682,7 @@ static int adjust_bf(SValue *sv, int bit_pos, int bit_size) · 73 unmodified lines | |||
| 1688 | t = sv->type.ref->auxtype; | 1682 | t = sv->type.ref->auxtype; |
| 1689 | if (t != -1 && t != VT_STRUCT) { | 1683 | if (t != -1 && t != VT_STRUCT) { |
| 1690 | sv->type.t = (sv->type.t & ~VT_BTYPE) | t; | 1684 | sv->type.t = (sv->type.t & ~VT_BTYPE) | t; |
| 1691 | sv->r = (sv->r & ~VT_LVAL_TYPE) | lvalue_type(sv->type.t); | 1685 | sv->r |= VT_LVAL; |
| 1692 | } | 1686 | } |
| 1693 | return t; | 1687 | return t; |
| 1694 | } | 1688 | } |
| @@ -1824,23 +1818,6 @@ ST_FUNC int gv(int rc) · 129 unmodified lines | |||
| 1824 | vtop->r2 = r2; | 1818 | vtop->r2 = r2; |
| 1825 | done: | 1819 | done: |
| 1826 | vtop->type.t = original_type; | 1820 | vtop->type.t = original_type; |
| 1827 | } else if ((vtop->r & VT_LVAL) && !is_float(vtop->type.t)) { | ||
| 1828 | int t1, t; | ||
| 1829 | /* lvalue of scalar type : need to use lvalue type | ||
| 1830 | because of possible cast */ | ||
| 1831 | t = vtop->type.t; | ||
| 1832 | t1 = t; | ||
| 1833 | /* compute memory access type */ | ||
| 1834 | if (vtop->r & VT_LVAL_BYTE) | ||
| 1835 | t = VT_BYTE; | ||
| 1836 | else if (vtop->r & VT_LVAL_SHORT) | ||
| 1837 | t = VT_SHORT; | ||
| 1838 | if (vtop->r & VT_LVAL_UNSIGNED) | ||
| 1839 | t |= VT_UNSIGNED; | ||
| 1840 | vtop->type.t = t; | ||
| 1841 | load(r, vtop); | ||
| 1842 | /* restore wanted type */ | ||
| 1843 | vtop->type.t = t1; | ||
| 1844 | } else { | 1821 | } else { |
| 1845 | if (vtop->r == VT_CMP) | 1822 | if (vtop->r == VT_CMP) |
| 1846 | vset_VT_JMP(); | 1823 | vset_VT_JMP(); |
| @@ -2983,16 +2960,11 @@ static void gen_cast(CType *type) · 1136 unmodified lines | |||
| 2983 | } | 2960 | } |
| 2984 | #endif | 2961 | #endif |
| 2985 | } | 2962 | } |
| 2986 | /* if lvalue and single word type, nothing to do because | ||
| 2987 | the lvalue already contains the real type size (see | ||
| 2988 | VT_LVAL_xxx constants) */ | ||
| 2989 | } | 2963 | } |
| 2964 | if ((vtop->r & VT_LVAL) | ||
| 2965 | && (dbt & VT_BTYPE) != (sbt & VT_BTYPE)) | ||
| 2966 | gv(RC_INT); | ||
| 2990 | } | 2967 | } |
| 2991 | } else if ((dbt & VT_BTYPE) == VT_PTR && !(vtop->r & VT_LVAL)) { | ||
| 2992 | /* if we are casting between pointer types, | ||
| 2993 | we must update the VT_LVAL_xxx size */ | ||
| 2994 | vtop->r = (vtop->r & ~VT_LVAL_TYPE) | ||
| 2995 | | (lvalue_type(type->ref->type.t) & VT_LVAL_TYPE); | ||
| 2996 | } | 2968 | } |
| 2997 | vtop->type = *type; | 2969 | vtop->type = *type; |
| 2998 | vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY ); | 2970 | vtop->type.t &= ~ ( VT_CONSTANT | VT_VOLATILE | VT_ARRAY ); |
| @@ -4850,23 +4822,6 @@ static CType *type_decl(CType *type, AttributeDef *ad, int *v, int td) · 1851 unmodified lines | |||
| 4850 | return ret; | 4822 | return ret; |
| 4851 | } | 4823 | } |
| 4852 | 4824 | ||
| 4853 | /* compute the lvalue VT_LVAL_xxx needed to match type t. */ | ||
| 4854 | ST_FUNC int lvalue_type(int t) | ||
| 4855 | { | ||
| 4856 | int bt, r; | ||
| 4857 | r = VT_LVAL; | ||
| 4858 | bt = t & VT_BTYPE; | ||
| 4859 | if (bt == VT_BYTE || bt == VT_BOOL) | ||
| 4860 | r |= VT_LVAL_BYTE; | ||
| 4861 | else if (bt == VT_SHORT) | ||
| 4862 | r |= VT_LVAL_SHORT; | ||
| 4863 | else | ||
| 4864 | return r; | ||
| 4865 | if (t & VT_UNSIGNED) | ||
| 4866 | r |= VT_LVAL_UNSIGNED; | ||
| 4867 | return r; | ||
| 4868 | } | ||
| 4869 | |||
| 4870 | /* indirection with full error checking and bound check */ | 4825 | /* indirection with full error checking and bound check */ |
| 4871 | ST_FUNC void indir(void) | 4826 | ST_FUNC void indir(void) |
| 4872 | { | 4827 | { |
| @@ -4879,9 +4834,9 @@ ST_FUNC void indir(void) · 6 unmodified lines | |||
| 4879 | gv(RC_INT); | 4834 | gv(RC_INT); |
| 4880 | vtop->type = *pointed_type(&vtop->type); | 4835 | vtop->type = *pointed_type(&vtop->type); |
| 4881 | /* Arrays and functions are never lvalues */ | 4836 | /* Arrays and functions are never lvalues */ |
| 4882 | if (!(vtop->type.t & VT_ARRAY) && !(vtop->type.t & VT_VLA) | 4837 | if (!(vtop->type.t & (VT_ARRAY | VT_VLA)) |
| 4883 | && (vtop->type.t & VT_BTYPE) != VT_FUNC) { | 4838 | && (vtop->type.t & VT_BTYPE) != VT_FUNC) { |
| 4884 | vtop->r |= lvalue_type(vtop->type.t); | 4839 | vtop->r |= VT_LVAL; |
| 4885 | /* if bound checking, the referenced pointer must be checked */ | 4840 | /* if bound checking, the referenced pointer must be checked */ |
| 4886 | #ifdef CONFIG_TCC_BCHECK | 4841 | #ifdef CONFIG_TCC_BCHECK |
| 4887 | if (tcc_state->do_bounds_check) | 4842 | if (tcc_state->do_bounds_check) |
| @@ -5087,7 +5042,7 @@ ST_FUNC void unary(void) · 199 unmodified lines | |||
| 5087 | r = VT_LOCAL; | 5042 | r = VT_LOCAL; |
| 5088 | /* all except arrays are lvalues */ | 5043 | /* all except arrays are lvalues */ |
| 5089 | if (!(type.t & VT_ARRAY)) | 5044 | if (!(type.t & VT_ARRAY)) |
| 5090 | r |= lvalue_type(type.t); | 5045 | r |= VT_LVAL; |
| 5091 | memset(&ad, 0, sizeof(AttributeDef)); | 5046 | memset(&ad, 0, sizeof(AttributeDef)); |
| 5092 | decl_initializer_alloc(&type, &ad, r, 1, 0, 0); | 5047 | decl_initializer_alloc(&type, &ad, r, 1, 0, 0); |
| 5093 | } else { | 5048 | } else { |
| @@ -5549,7 +5504,7 @@ special_math_val: · 455 unmodified lines | |||
| 5549 | vtop->type.t |= qualifiers; | 5504 | vtop->type.t |= qualifiers; |
| 5550 | /* an array is never an lvalue */ | 5505 | /* an array is never an lvalue */ |
| 5551 | if (!(vtop->type.t & VT_ARRAY)) { | 5506 | if (!(vtop->type.t & VT_ARRAY)) { |
| 5552 | vtop->r |= lvalue_type(vtop->type.t); | 5507 | vtop->r |= VT_LVAL; |
| 5553 | #ifdef CONFIG_TCC_BCHECK | 5508 | #ifdef CONFIG_TCC_BCHECK |
| 5554 | /* if bound checking, the referenced pointer must be checked */ | 5509 | /* if bound checking, the referenced pointer must be checked */ |
| 5555 | if (tcc_state->do_bounds_check && (vtop->r & VT_VALMASK) != VT_LOCAL) | 5510 | if (tcc_state->do_bounds_check && (vtop->r & VT_VALMASK) != VT_LOCAL) |
| @@ -7948,7 +7903,7 @@ found: · 2392 unmodified lines | |||
| 7948 | type.ref->f = ad.f; | 7903 | type.ref->f = ad.f; |
| 7949 | } else if (!(type.t & VT_ARRAY)) { | 7904 | } else if (!(type.t & VT_ARRAY)) { |
| 7950 | /* not lvalue if array */ | 7905 | /* not lvalue if array */ |
| 7951 | r |= lvalue_type(type.t); | 7906 | r |= VT_LVAL; |
| 7952 | } | 7907 | } |
| 7953 | has_init = (tok == '='); | 7908 | has_init = (tok == '='); |
| 7954 | if (has_init && (type.t & VT_VLA)) | 7909 | if (has_init && (type.t & VT_VLA)) |
| @@ -678,16 +678,7 @@ ST_FUNC void gen_bounded_ptr_deref(void) · 677 unmodified lines | |||
| 678 | if (nocode_wanted) | 678 | if (nocode_wanted) |
| 679 | return; | 679 | return; |
| 680 | 680 | ||
| 681 | size = 0; | 681 | size = type_size(&vtop->type, &align); |
| 682 | /* XXX: put that code in generic part of tcc */ | ||
| 683 | if (!is_float(vtop->type.t)) { | ||
| 684 | if (vtop->r & VT_LVAL_BYTE) | ||
| 685 | size = 1; | ||
| 686 | else if (vtop->r & VT_LVAL_SHORT) | ||
| 687 | size = 2; | ||
| 688 | } | ||
| 689 | if (!size) | ||
| 690 | size = type_size(&vtop->type, &align); | ||
| 691 | switch(size) { | 682 | switch(size) { |
| 692 | case 1: func = TOK___bound_ptr_indir1; break; | 683 | case 1: func = TOK___bound_ptr_indir1; break; |
| 693 | case 2: func = TOK___bound_ptr_indir2; break; | 684 | case 2: func = TOK___bound_ptr_indir2; break; |
| @@ -981,7 +972,7 @@ void gfunc_prolog(Sym *func_sym) · 287 unmodified lines | |||
| 981 | gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr); | 972 | gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr); |
| 982 | } | 973 | } |
| 983 | sym_push(sym->v & ~SYM_FIELD, type, | 974 | sym_push(sym->v & ~SYM_FIELD, type, |
| 984 | VT_LLOCAL | lvalue_type(type->t), addr); | 975 | VT_LLOCAL | VT_LVAL, addr); |
| 985 | } else { | 976 | } else { |
| 986 | if (reg_param_index < REGN) { | 977 | if (reg_param_index < REGN) { |
| 987 | /* save arguments passed by register */ | 978 | /* save arguments passed by register */ |
| @@ -995,7 +986,7 @@ void gfunc_prolog(Sym *func_sym) · 7 unmodified lines | |||
| 995 | } | 986 | } |
| 996 | } | 987 | } |
| 997 | sym_push(sym->v & ~SYM_FIELD, type, | 988 | sym_push(sym->v & ~SYM_FIELD, type, |
| 998 | VT_LOCAL | lvalue_type(type->t), addr); | 989 | VT_LOCAL | VT_LVAL, addr); |
| 999 | } | 990 | } |
| 1000 | addr += 8; | 991 | addr += 8; |
| 1001 | reg_param_index++; | 992 | reg_param_index++; |
| @@ -1205,7 +1196,16 @@ static X86_64_Mode classify_x86_64_arg(CType *ty, CType *ret, int *psize, int *p · 203 unmodified lines | |||
| 1205 | ret_t = VT_QLONG; | 1196 | ret_t = VT_QLONG; |
| 1206 | } else { | 1197 | } else { |
| 1207 | *reg_count = 1; | 1198 | *reg_count = 1; |
| 1208 | ret_t = (size > 4) ? VT_LLONG : VT_INT; | 1199 | if (size > 4) |
| 1200 | ret_t = VT_LLONG; | ||
| 1201 | else if (size > 2) | ||
| 1202 | ret_t = VT_INT; | ||
| 1203 | else if (size > 1) | ||
| 1204 | ret_t = VT_SHORT; | ||
| 1205 | else | ||
| 1206 | ret_t = VT_BYTE; | ||
| 1207 | if ((ty->t & VT_BTYPE) == VT_STRUCT || (ty->t & VT_UNSIGNED)) | ||
| 1208 | ret_t |= VT_UNSIGNED; | ||
| 1209 | } | 1209 | } |
| 1210 | break; | 1210 | break; |
| 1211 | 1211 | ||
| @@ -1321,7 +1321,7 @@ void gfunc_call(int nb_args) · 109 unmodified lines | |||
| 1321 | tcc_error("SSE disabled but floating point arguments passed"); | 1321 | tcc_error("SSE disabled but floating point arguments passed"); |
| 1322 | 1322 | ||
| 1323 | /* fetch cpu flag before generating any code */ | 1323 | /* fetch cpu flag before generating any code */ |
| 1324 | if (vtop >= vstack && (vtop->r & VT_VALMASK) == VT_CMP) | 1324 | if ((vtop->r & VT_VALMASK) == VT_CMP) |
| 1325 | gv(RC_INT); | 1325 | gv(RC_INT); |
| 1326 | 1326 | ||
| 1327 | /* for struct arguments, we need to call memcpy and the function | 1327 | /* for struct arguments, we need to call memcpy and the function |
| @@ -1635,7 +1635,7 @@ void gfunc_prolog(Sym *func_sym) · 307 unmodified lines | |||
| 1635 | default: break; /* nothing to be done for x86_64_mode_none */ | 1635 | default: break; /* nothing to be done for x86_64_mode_none */ |
| 1636 | } | 1636 | } |
| 1637 | sym_push(sym->v & ~SYM_FIELD, type, | 1637 | sym_push(sym->v & ~SYM_FIELD, type, |
| 1638 | VT_LOCAL | lvalue_type(type->t), param_addr); | 1638 | VT_LOCAL | VT_LVAL, param_addr); |
| 1639 | } | 1639 | } |
| 1640 | 1640 | ||
| 1641 | #ifdef CONFIG_TCC_BCHECK | 1641 | #ifdef CONFIG_TCC_BCHECK |