History

remove VT_LVAL_BYTE etc.

For some reason there was no point for that anymore.

grischka committed 6 years ago

Commit 35475b51 parent 5914f4d8 files · +42 −102Browse files

Unified · Split

8 files
  1. arm-gen.c +1 −1
  2. arm64-gen.c +4 −4
  3. c67-gen.c +1 −1
  4. i386-gen.c +2 −11
  5. riscv64-gen.c +1 −1
  6. tcc.h +0 −6
  7. tccgen.c +18 −63
  8. x86_64-gen.c +15 −15
arm-gen.c+1−1
@@ -1363,7 +1363,7 @@ from_stack: · 1362 unmodified lines
13631363 addr = (n + nf + sn) * 4;
13641364 sn += size;
13651365 }
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,
13671367 addr + 12);
13681368 }
13691369 last_itod_magic=0;
arm64-gen.c+4−4
@@ -446,7 +446,7 @@ static void arm64_load_cmp(int r, SValue *sv); · 445 unmodified lines
446446 ST_FUNC void load(int r, SValue *sv)
447447 {
448448 int svtt = sv->type.t;
449− int svr = sv->r & ~VT_LVAL_TYPE;
449+ int svr = sv->r;
450450 int svrv = svr & VT_VALMASK;
451451 uint64_t svcul = (uint32_t)sv->c.i;
452452 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
546546 ST_FUNC void store(int r, SValue *sv)
547547 {
548548 int svtt = sv->type.t;
549− int svr = sv->r & ~VT_LVAL_TYPE;
549+ int svr = sv->r;
550550 int svrv = svr & VT_VALMASK;
551551 uint64_t svcul = (uint32_t)sv->c.i;
552552 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
10391039 a[i] < 32 ? 16 + (a[i] - 16) / 2 * 16 :
10401040 224 + ((a[i] - 32) >> 1 << 1));
10411041 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,
10431043 off);
10441044
10451045 if (a[i] < 16) {
@@ -1126,7 +1126,7 @@ ST_FUNC void gen_va_arg(CType *t) · 80 unmodified lines
11261126 gaddrof();
11271127 r0 = intr(gv(RC_INT));
11281128 r1 = get_reg(RC_INT);
1129− vtop[0].r = r1 | lvalue_type(t->t);
1129+ vtop[0].r = r1 | VT_LVAL;
11301130 r1 = intr(r1);
11311131
11321132 if (!hfa) {
c67-gen.c+1−1
@@ -1964,7 +1964,7 @@ void gfunc_prolog(Sym *func_sym) · 1963 unmodified lines
19641964 /* define parameters */
19651965 while ((sym = sym->next) != NULL) {
19661966 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);
19681968 size = type_size(type, &align);
19691969 size = (size + 3) & ~3;
19701970
i386-gen.c+2−11
@@ -587,7 +587,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 586 unmodified lines
587587 addr += size;
588588 }
589589 sym_push(sym->v & ~SYM_FIELD, type,
590− VT_LOCAL | lvalue_type(type->t), param_addr);
590+ VT_LOCAL | VT_LVAL, param_addr);
591591 param_index++;
592592 }
593593 func_ret_sub = 0;
@@ -1084,16 +1084,7 @@ ST_FUNC void gen_bounded_ptr_deref(void) · 490 unmodified lines
10841084 if (nocode_wanted)
10851085 return;
10861086
1087− size = 0;
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);
1087+ size = type_size(&vtop->type, &align);
10971088 switch(size) {
10981089 case 1: func = TOK___bound_ptr_indir1; break;
10991090 case 2: func = TOK___bound_ptr_indir2; break;
riscv64-gen.c+1−1
@@ -681,7 +681,7 @@ ST_FUNC void gfunc_prolog(Sym *func_sym) · 680 unmodified lines
681681 }
682682 }
683683 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,
685685 param_addr);
686686 }
687687 func_va_list_ofs = addr;
tcc.h+0−6
@@ -932,11 +932,6 @@ struct filespec { · 931 unmodified lines
932932 dereferencing value */
933933 #define VT_BOUNDED 0x8000 /* value is bounded. The address of the
934934 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−
940935 /* types */
941936 #define VT_BTYPE 0x000f /* mask for basic type */
942937 #define VT_VOID 0 /* void type */
@@ -1426,7 +1421,6 @@ ST_FUNC void vstore(void); · 483 unmodified lines
14261421 ST_FUNC void inc(int post, int c);
14271422 ST_FUNC void parse_mult_str (CString *astr, const char *msg);
14281423 ST_FUNC void parse_asm_str(CString *astr);
1429−ST_FUNC int lvalue_type(int t);
14301424 ST_FUNC void indir(void);
14311425 ST_FUNC void unary(void);
14321426 ST_FUNC void expr_prod(void);
tccgen.c+18−63
@@ -1408,7 +1408,7 @@ ST_FUNC void save_reg_upstack(int r, int n) · 1407 unmodified lines
14081408 p->c.i */
14091409 p->r = (p->r & ~(VT_VALMASK | VT_BOUNDED)) | VT_LLOCAL;
14101410 } else {
1411− p->r = lvalue_type(p->type.t) | VT_LOCAL;
1411+ p->r = VT_LVAL | VT_LOCAL;
14121412 }
14131413 p->r2 = VT_CONST;
14141414 p->c.i = l;
@@ -1430,7 +1430,7 @@ ST_FUNC int get_reg_ex(int rc, int rc2) · 15 unmodified lines
14301430 n=0;
14311431 for(p = vstack; p <= vtop; p++) {
14321432 if ((p->r & VT_VALMASK) == r ||
1433− (p->r2 & VT_VALMASK) == r)
1433+ p->r2 == r)
14341434 n++;
14351435 }
14361436 if (n <= 1)
@@ -1454,7 +1454,7 @@ ST_FUNC int get_reg(int rc) · 17 unmodified lines
14541454 return r;
14551455 for(p=vstack;p<=vtop;p++) {
14561456 if ((p->r & VT_VALMASK) == r ||
1457− (p->r2 & VT_VALMASK) == r)
1457+ p->r2 == r)
14581458 goto notfound;
14591459 }
14601460 return r;
@@ -1467,7 +1467,7 @@ ST_FUNC int get_reg(int rc) · 6 unmodified lines
14671467 spill registers used in gen_opi()) */
14681468 for(p=vstack;p<=vtop;p++) {
14691469 /* look at second register (if long long) */
1470− r = p->r2 & VT_VALMASK;
1470+ r = p->r2;
14711471 if (r < VT_CONST && (reg_classes[r] & rc))
14721472 goto save_found;
14731473 r = p->r & VT_VALMASK;
@@ -1553,16 +1553,13 @@ ST_FUNC void gaddrof(void) · 79 unmodified lines
15531553 vtop->r &= ~VT_LVAL;
15541554 /* tricky: if saved lvalue, then we can go back to lvalue */
15551555 if ((vtop->r & VT_VALMASK) == VT_LLOCAL)
1556− vtop->r = (vtop->r & ~(VT_VALMASK | VT_LVAL_TYPE)) | VT_LOCAL | VT_LVAL;
1557−
1558−
1556+ vtop->r = (vtop->r & ~VT_VALMASK) | VT_LOCAL | VT_LVAL;
15591557 }
15601558
15611559 #ifdef CONFIG_TCC_BCHECK
15621560 /* generate lvalue bound code */
15631561 static void gbound(void)
15641562 {
1565− int lval_type;
15661563 CType type1;
15671564
15681565 vtop->r &= ~VT_MUSTBOUND;
@@ -1570,14 +1567,13 @@ static void gbound(void) · 1 unmodified line
15701567 if (vtop->r & VT_LVAL) {
15711568 /* if not VT_BOUNDED value, then make one */
15721569 if (!(vtop->r & VT_BOUNDED)) {
1573− lval_type = vtop->r & (VT_LVAL_TYPE | VT_LVAL);
15741570 /* must save type because we must set it to int to get pointer */
15751571 type1 = vtop->type;
15761572 vtop->type.t = VT_PTR;
15771573 gaddrof();
15781574 vpushi(0);
15791575 gen_bounded_ptr_add();
1580− vtop->r |= lval_type;
1576+ vtop->r |= VT_LVAL;
15811577 vtop->type = type1;
15821578 }
15831579 /* then check for dereferencing */
@@ -1603,12 +1599,10 @@ static void incr_bf_adr(int o) · 19 unmodified lines
16031599 {
16041600 vtop->type = char_pointer_type;
16051601 gaddrof();
1606− vpushi(o);
1602+ vpushs(o);
16071603 gen_op('+');
1608− vtop->type.t = (vtop->type.t & ~(VT_BTYPE|VT_DEFSIGN))
1609− | (VT_BYTE|VT_UNSIGNED);
1610− vtop->r = (vtop->r & ~VT_LVAL_TYPE)
1611− | (VT_LVAL_BYTE|VT_LVAL_UNSIGNED|VT_LVAL);
1604+ vtop->type.t = VT_BYTE | VT_UNSIGNED;
1605+ vtop->r |= VT_LVAL;
16121606 }
16131607
16141608 /* 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
16881682 t = sv->type.ref->auxtype;
16891683 if (t != -1 && t != VT_STRUCT) {
16901684 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;
16921686 }
16931687 return t;
16941688 }
@@ -1824,23 +1818,6 @@ ST_FUNC int gv(int rc) · 129 unmodified lines
18241818 vtop->r2 = r2;
18251819 done:
18261820 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;
18441821 } else {
18451822 if (vtop->r == VT_CMP)
18461823 vset_VT_JMP();
@@ -2983,16 +2960,11 @@ static void gen_cast(CType *type) · 1136 unmodified lines
29832960 }
29842961 #endif
29852962 }
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) */
29892963 }
2964+ if ((vtop->r & VT_LVAL)
2965+ && (dbt & VT_BTYPE) != (sbt & VT_BTYPE))
2966+ gv(RC_INT);
29902967 }
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);
29962968 }
29972969 vtop->type = *type;
29982970 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
48504822 return ret;
48514823 }
48524824
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−
48704825 /* indirection with full error checking and bound check */
48714826 ST_FUNC void indir(void)
48724827 {
@@ -4879,9 +4834,9 @@ ST_FUNC void indir(void) · 6 unmodified lines
48794834 gv(RC_INT);
48804835 vtop->type = *pointed_type(&vtop->type);
48814836 /* 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))
48834838 && (vtop->type.t & VT_BTYPE) != VT_FUNC) {
4884− vtop->r |= lvalue_type(vtop->type.t);
4839+ vtop->r |= VT_LVAL;
48854840 /* if bound checking, the referenced pointer must be checked */
48864841 #ifdef CONFIG_TCC_BCHECK
48874842 if (tcc_state->do_bounds_check)
@@ -5087,7 +5042,7 @@ ST_FUNC void unary(void) · 199 unmodified lines
50875042 r = VT_LOCAL;
50885043 /* all except arrays are lvalues */
50895044 if (!(type.t & VT_ARRAY))
5090− r |= lvalue_type(type.t);
5045+ r |= VT_LVAL;
50915046 memset(&ad, 0, sizeof(AttributeDef));
50925047 decl_initializer_alloc(&type, &ad, r, 1, 0, 0);
50935048 } else {
@@ -5549,7 +5504,7 @@ special_math_val: · 455 unmodified lines
55495504 vtop->type.t |= qualifiers;
55505505 /* an array is never an lvalue */
55515506 if (!(vtop->type.t & VT_ARRAY)) {
5552− vtop->r |= lvalue_type(vtop->type.t);
5507+ vtop->r |= VT_LVAL;
55535508 #ifdef CONFIG_TCC_BCHECK
55545509 /* if bound checking, the referenced pointer must be checked */
55555510 if (tcc_state->do_bounds_check && (vtop->r & VT_VALMASK) != VT_LOCAL)
@@ -7948,7 +7903,7 @@ found: · 2392 unmodified lines
79487903 type.ref->f = ad.f;
79497904 } else if (!(type.t & VT_ARRAY)) {
79507905 /* not lvalue if array */
7951− r |= lvalue_type(type.t);
7906+ r |= VT_LVAL;
79527907 }
79537908 has_init = (tok == '=');
79547909 if (has_init && (type.t & VT_VLA))
x86_64-gen.c+15−15
@@ -678,16 +678,7 @@ ST_FUNC void gen_bounded_ptr_deref(void) · 677 unmodified lines
678678 if (nocode_wanted)
679679 return;
680680
681− size = 0;
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);
681+ size = type_size(&vtop->type, &align);
691682 switch(size) {
692683 case 1: func = TOK___bound_ptr_indir1; break;
693684 case 2: func = TOK___bound_ptr_indir2; break;
@@ -981,7 +972,7 @@ void gfunc_prolog(Sym *func_sym) · 287 unmodified lines
981972 gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr);
982973 }
983974 sym_push(sym->v & ~SYM_FIELD, type,
984− VT_LLOCAL | lvalue_type(type->t), addr);
975+ VT_LLOCAL | VT_LVAL, addr);
985976 } else {
986977 if (reg_param_index < REGN) {
987978 /* save arguments passed by register */
@@ -995,7 +986,7 @@ void gfunc_prolog(Sym *func_sym) · 7 unmodified lines
995986 }
996987 }
997988 sym_push(sym->v & ~SYM_FIELD, type,
998− VT_LOCAL | lvalue_type(type->t), addr);
989+ VT_LOCAL | VT_LVAL, addr);
999990 }
1000991 addr += 8;
1001992 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
12051196 ret_t = VT_QLONG;
12061197 } else {
12071198 *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;
12091209 }
12101210 break;
12111211
@@ -1321,7 +1321,7 @@ void gfunc_call(int nb_args) · 109 unmodified lines
13211321 tcc_error("SSE disabled but floating point arguments passed");
13221322
13231323 /* 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)
13251325 gv(RC_INT);
13261326
13271327 /* for struct arguments, we need to call memcpy and the function
@@ -1635,7 +1635,7 @@ void gfunc_prolog(Sym *func_sym) · 307 unmodified lines
16351635 default: break; /* nothing to be done for x86_64_mode_none */
16361636 }
16371637 sym_push(sym->v & ~SYM_FIELD, type,
1638− VT_LOCAL | lvalue_type(type->t), param_addr);
1638+ VT_LOCAL | VT_LVAL, param_addr);
16391639 }
16401640
16411641 #ifdef CONFIG_TCC_BCHECK

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