Mercurial > hg > CbC > old > device
changeset 906:b9d8ad7ea0ad
i64 on linux/gcc fixes
author | kono |
---|---|
date | Wed, 09 Apr 2014 11:34:58 +0900 |
parents | df2d5295218f |
children | cccef9d74932 |
files | Makefile mc-code-i64.c mc-parse.c test/strinit.c |
diffstat | 4 files changed, 14 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Apr 08 17:30:05 2014 +0900 +++ b/Makefile Wed Apr 09 11:34:58 2014 +0900 @@ -1,4 +1,4 @@ -GCC = clang +GCC = gcc CC = $(GCC) -std=c99 $(CCEXT) $(M) -fgnu89-inline # -O3 # MCFLAG = -DUSE_CODE_KEYWORD
--- a/mc-code-i64.c Tue Apr 08 17:30:05 2014 +0900 +++ b/mc-code-i64.c Wed Apr 09 11:34:58 2014 +0900 @@ -1470,7 +1470,7 @@ } } else if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { - n->sc = (car(type)==POINTER && lp64) ?LREGISTER:REGISTER; + n->sc = ((type>0&&car(type)==POINTER) && lp64) ?LREGISTER:REGISTER; n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; @@ -1627,8 +1627,8 @@ void code_gvar(int e1,int creg) { use_int(creg); + NMTBL *nptr = ncaddr(e1); #ifdef __APPLE__ - NMTBL *nptr = ncaddr(e1); if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) { printf("\tleaq _%s+%d(%%rip),%s\n", nptr->nm,cadr(e1),register_name(creg,0)); return; @@ -1658,8 +1658,8 @@ code_crgvar(e1,creg,0,SIZE_OF_INT); return; } + NMTBL *nptr = ncaddr(e1); #ifdef __APPLE__ - NMTBL *nptr = ncaddr(e1); if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) { printf("\tmovl _%s+%d(%%rip),%s\n", nptr->nm,cadr(e1),register_name(creg,SIZE_OF_INT)); return; @@ -1696,8 +1696,8 @@ void code_crgvar(int e1,int creg,int sign,int sz){ use_int(creg); + NMTBL *nptr = ncaddr(e1); #ifdef __APPLE__ - NMTBL *nptr = ncaddr(e1); if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) { printf("\t%s _%s+%d(%%rip),%s\n", cload(sign,sz),nptr->nm,cadr(e1),register_name(creg,regu(sign,sz,0))); return; @@ -1741,10 +1741,6 @@ void code_rlvar(int e2,int reg) { use_int(reg); - if (car(e2)==URLVAR) { - code_crlvar(e2,creg,0,SIZE_OF_INT); - return; - } printf("\tmovl "); lvar(e2); printf(",%s\n",register_name(reg,SIZE_OF_INT)); } @@ -4260,7 +4256,6 @@ static int code_dload_1(int d, int g) { - int r; NMTBL *one; // load 1 if (d) { @@ -4900,6 +4895,7 @@ printf("\tsubl\t$%d,%s\n",min,crnl); printf("\tcmpl\t$%d,%s\n",max-min,crnl); printf("\tja\t_%d\n",dlabel); + // this assumes 32bit offset, but it may too small if (delta==1) { #ifdef __APPLE__ printf("\tleaq\t_%d(%%rip),%%rbx\n",l); @@ -4929,7 +4925,7 @@ printf("\taddq\t%%rbx,%s\n",crn); printf("\tjmp\t*%s\n",crn); #else - printf("\tjmp\t*_%d(,%%eax,2)\n",l); + printf("\tjmp\t*_%d(,%%eax,4)\n",l); #endif break; case 4: @@ -4942,7 +4938,7 @@ printf("\taddq\t%%rbx,%s\n",crn); printf("\tjmp\t*%s\n",crn); #else - printf("\tjmp\t*_%d(%%eax)\n",l); + printf("\tjmp\t*_%d(,%%eax,2)\n",l); #endif break; default: @@ -4956,7 +4952,7 @@ printf("\taddq\t%%rbx,%s\n",crn); printf("\tjmp\t*%s\n",crn); #else - printf("\tjmp\t*_%d(,%%rax,4)\n",l); + printf("\tjmp\t*_%d(,%%rax,8)\n",l); #endif break; } @@ -4981,7 +4977,7 @@ #ifdef __APPLE__ printf("\t.long _%d-_%d\n",label,table_top); #else - printf("\t.long _%d\n",label); + printf("\t.quad _%d\n",label); #endif }
--- a/mc-parse.c Tue Apr 08 17:30:05 2014 +0900 +++ b/mc-parse.c Wed Apr 09 11:34:58 2014 +0900 @@ -51,7 +51,7 @@ extern double strtod(const char *nptr, char **endptr); #endif -int parse_mode = 1; // generate parse tree for all code +int parse_mode = 0; // generate parse tree for all code static int HEAP_REPORT = 0; static int lfree_type_limit; // debugging purpose
--- a/test/strinit.c Tue Apr 08 17:30:05 2014 +0900 +++ b/test/strinit.c Wed Apr 09 11:34:58 2014 +0900 @@ -38,12 +38,12 @@ struct temp temp4 = { 1,2,3,4,5,6,7}; struct temp temp7 = { 1,2,3,4,{5,6},7}; -#if 1 struct temp temp10 = { - .m = (struct hoge){ .k = 3 }, // not allowed in mc +#if __llvm__ + .m = (struct hoge){ .k = 3 }, // not allowed in gcc ( llvm allowed this ) // .c = (int)&b, // int/long trancation is not allowed in global +#endif }; -#endif INLINE void linux_kernel();