History

tcc on i386 are still having problems at work.Thank Roy report again. Struck on several variables can be connected to commit in the register. I am worried whether tcc can run the os. Since my machine is ubuntu 64 bits I can test my machine.

jiang committed 12 years ago

Commit 089dea31 parent a0d45c16 files · +32 −38Browse files

Unified · Split

6 files
  1. arm-gen.c +9 −1
  2. c67-gen.c +10 −1
  3. i386-gen.c +5 −5
  4. tcc.h +0 −2
  5. tccgen.c +7 −28
  6. x86_64-gen.c +1 −1
arm-gen.c+9−1
@@ -61,7 +61,7 @@ · 60 unmodified lines
6161 #define RC_IRET RC_R0 /* function return: integer register */
6262 #define RC_LRET RC_R1 /* function return: second integer register */
6363 #define RC_FRET RC_F0 /* function return: float register */
64−
64+#define RC_MASK (RC_INT|RC_FLOAT)
6565 /* pretty names for the registers */
6666 enum {
6767 TREG_R0 = 0,
@@ -540,6 +540,14 @@ void load(int r, SValue *sv) · 472 unmodified lines
540540 v = fr & VT_VALMASK;
541541 if (fr & VT_LVAL) {
542542 uint32_t base = 0xB; // fp
543+ if(fr & VT_TMP){
544+ int size, align;
545+ if((ft & VT_BTYPE) == VT_FUNC)
546+ size = PTR_SIZE;
547+ else
548+ size = type_size(&sv->type, &align);
549+ loc_stack(size, 0);
550+ }
543551 if(v == VT_LLOCAL) {
544552 v1.type.t = VT_PTR;
545553 v1.r = VT_LOCAL | VT_LVAL;
c67-gen.c+10−1
@@ -58,7 +58,7 @@ · 57 unmodified lines
5858 #define RC_IRET RC_C67_A4 /* function return: integer register */
5959 #define RC_LRET RC_C67_A5 /* function return: second integer register */
6060 #define RC_FRET RC_C67_A4 /* function return: float register */
61−
61+#define RC_MASK (RC_INT|RC_FLOAT)
6262 /* pretty names for the registers */
6363 enum {
6464 TREG_EAX = 0, // really A2
@@ -1571,12 +1571,21 @@ void load(int r, SValue * sv) · 1506 unmodified lines
15711571
15721572 v = fr & VT_VALMASK;
15731573 if (fr & VT_LVAL) {
1574+ if(fr & VT_TMP){
1575+ int size, align;
1576+ if((ft & VT_BTYPE) == VT_FUNC)
1577+ size = PTR_SIZE;
1578+ else
1579+ size = type_size(&sv->type, &align);
1580+ loc_stack(size, 0);
1581+ }
15741582 if (v == VT_LLOCAL) {
15751583 v1.type.t = VT_INT;
15761584 v1.r = VT_LOCAL | VT_LVAL;
15771585 v1.c.ul = fc;
15781586 load(r, &v1);
15791587 fr = r;
1588+ fc = 0;
15801589 } else if ((ft & VT_BTYPE) == VT_LDOUBLE) {
15811590 tcc_error("long double not supported");
15821591 } else if ((ft & VT_TYPE) == VT_BYTE) {
i386-gen.c+5−5
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121 #ifdef TARGET_DEFS_ONLY
2222
2323 /* number of available registers */
24−#define NB_REGS 4
24+#define NB_REGS 8
2525 #define NB_ASM_REGS 8
2626
2727 /* a register can belong to several classes. The classes must be
@@ -41,7 +41,6 @@ · 13 unmodified lines
4141 #define RC_LRET RC_EDX /* function return: second integer register */
4242 #define RC_FRET RC_ST0 /* function return: float register */
4343 #define RC_MASK (RC_INT|RC_INT2|RC_FLOAT)
44−
4544 /* pretty names for the registers */
4645 enum {
4746 TREG_EAX = 0,
@@ -104,8 +103,8 @@ ST_DATA const int reg_classes[NB_REGS] = { · 56 unmodified lines
104103 RC_INT|RC_INT2|RC_EBX,
105104 0,
106105 /* st0 */ RC_FLOAT | RC_ST0,
107− RC_RSI|RC_INT2,
108− RC_RDI|RC_INT2,
106+ RC_ESI|RC_INT2,
107+ RC_EDI|RC_INT2,
109108 };
110109
111110 static unsigned long func_sub_sp_offset;
@@ -241,7 +240,7 @@ ST_FUNC void load(int r, SValue *sv) · 129 unmodified lines
241240 if(fr & VT_TMP){
242241 int size, align;
243242 if((ft & VT_BTYPE) == VT_FUNC)
244− size = 4;
243+ size = PTR_SIZE;
245244 else
246245 size = type_size(&sv->type, &align);
247246 loc_stack(size, 0);
@@ -254,6 +253,7 @@ ST_FUNC void load(int r, SValue *sv) · 6 unmodified lines
254253 if (!(reg_classes[fr] & RC_INT))
255254 fr = get_reg(RC_INT);
256255 load(fr, &v1);
256+ fc = 0;
257257 }
258258 if ((ft & VT_BTYPE) == VT_FLOAT) {
259259 o(0xd9); /* flds */
tcc.h+0−2
@@ -1350,8 +1350,6 @@ ST_FUNC void gen_le16(int c); · 1349 unmodified lines
13501350 ST_FUNC void gen_le32(int c);
13511351 ST_FUNC void gen_addr32(int r, Sym *sym, int c);
13521352 ST_FUNC void gen_addrpc32(int r, Sym *sym, int c);
1353−ST_FUNC void struct_copy(SValue *d, SValue *s, SValue *c);
1354−ST_FUNC void gen_putz(SValue *d, int size);
13551353 #endif
13561354
13571355 #ifdef CONFIG_TCC_BCHECK
tccgen.c+7−28
@@ -873,7 +873,7 @@ ST_FUNC int gv(int rc) · 872 unmodified lines
873873 #endif
874874
875875 r = vtop->r & VT_VALMASK;
876− if((rc & ~RC_MASK) && (rc != RC_ST0))
876+ if(rc & ~RC_MASK)
877877 rc2 = ex_rc;
878878 else
879879 rc2 = (rc & RC_FLOAT) ? RC_FLOAT : RC_INT;
@@ -2624,20 +2624,19 @@ ST_FUNC void vstore(void) · 1744 unmodified lines
26242624 vtop -=2;
26252625 }else{
26262626 size = type_size(&vtop->type, &align);
2627−#ifndef TCC_TARGET_X86_64
26282627 /* destination */
26292628 vswap();
26302629 vtop->type.t = VT_PTR;
26312630 gaddrof();
26322631
26332632 /* address of memcpy() */
2634−# ifdef TCC_ARM_EABI
2633+#ifdef TCC_ARM_EABI
26352634 if(!(align & 7))
26362635 vpush_global_sym(&func_old_type, TOK_memcpy8);
26372636 else if(!(align & 3))
26382637 vpush_global_sym(&func_old_type, TOK_memcpy4);
26392638 else
2640−# endif
2639+#endif
26412640 vpush_global_sym(&func_old_type, TOK_memcpy);
26422641
26432642 vswap();
@@ -2646,22 +2645,8 @@ ST_FUNC void vstore(void) · 2 unmodified lines
26462645 vtop->type.t = VT_PTR;
26472646 gaddrof();
26482647 /* type size */
2649− vpushs(size);
2648+ vpushi(size);
26502649 gfunc_call(3);
2651−#else
2652− /* destination */
2653− vswap();
2654− vtop->type.t = VT_PTR;
2655− gaddrof();
2656− /* source */
2657− vpushv(vtop - 1);
2658− vtop->type.t = VT_PTR;
2659− gaddrof();
2660− /* size */
2661− vpushs(size);
2662− struct_copy(&vtop[-2], &vtop[-1], &vtop[0]);
2663− vtop -=3;
2664−#endif
26652650 }
26662651 } else {
26672652 vswap();
@@ -5354,22 +5339,16 @@ static void init_putz(CType *t, Section *sec, unsigned long c, int size) · 2686 unmodified lines
53545339 if (sec) {
53555340 /* nothing to do because globals are already set to zero */
53565341 } else {
5357−#ifndef TCC_TARGET_X86_64
53585342 vpush_global_sym(&func_old_type, TOK_memset);
53595343 vseti(VT_LOCAL, c);
5360−# ifdef TCC_TARGET_ARM
5344+#ifdef TCC_TARGET_ARM
53615345 vpushs(size);
53625346 vpushi(0);
5363−# else
5347+#else
53645348 vpushi(0);
53655349 vpushs(size);
5366−# endif
5367− gfunc_call(3);
5368−#else
5369− vseti(VT_LOCAL, c);
5370− gen_putz(vtop, size);
5371− vtop--;
53725350 #endif
5351+ gfunc_call(3);
53735352 }
53745353 }
53755354
x86_64-gen.c+1−1
@@ -408,7 +408,7 @@ void load(int r, SValue *sv) · 407 unmodified lines
408408 if(fr & VT_TMP){
409409 int size, align;
410410 if((ft & VT_BTYPE) == VT_FUNC)
411− size = 8;
411+ size = PTR_SIZE;
412412 else
413413 size = type_size(&sv->type, &align);
414414 loc_stack(size, 0);

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