Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 331:f25aa4f03198
bit-field continue...
author | kono |
---|---|
date | Wed, 23 Jun 2004 22:37:32 +0900 |
parents | fa4c7b15d7ed |
children | ce85d6106119 |
line wrap: on
line diff
--- a/mc-code-powerpc.c Wed Jun 23 17:12:33 2004 +0900 +++ b/mc-code-powerpc.c Wed Jun 23 22:37:32 2004 +0900 @@ -1858,6 +1858,9 @@ increment_function_arg(int e3,int *pnargs,int *preg_arg,int *pfreg_arg) { int nargs=0,reg_arg=0,freg_arg=0; int t=caddr(e3); + if (t>=0&&(car(t)==BIT_FIELD)) { + t = cadr(t); + } if(scalar(t)) { nargs ++ ; reg_arg++; } else if (t==LONGLONG||t==ULONGLONG) { @@ -1886,6 +1889,9 @@ static int get_input_arg(int t,int mode,int nargs,int reg_arg,int freg_arg) { + if (t>=0&&(car(t)==BIT_FIELD)) { + t = cadr(t); + } if(scalar(t)) { if (mode==AS_SAVE) { return get_register_var(0); @@ -5080,6 +5086,7 @@ set_bitsz(int type,int *psign,int *pbitsz,int *palign,int *pl) { int sign=0,bitsz; + int align,l=0; switch(cadr(type)) { case INT: sign=1; bitsz=32; align=4;break; case UNSIGNED: bitsz=32; align=4;break; @@ -5105,13 +5112,13 @@ extern int code_bit_field_disp(int type,int *poffset,int *bfd,int *sz) { - int sign,bitsz; + int sign,bitsz,align; int i; int bitpos = *bfd; int offset = *poffset; int l; int bitsize = cadddr(type); - set_bitsz(type,&sign,&bitsz,&l); + set_bitsz(type,&sign,&bitsz,&align,&l); if (bitsize>bitsz) { error(BTERR); bitsize = i; } @@ -5150,29 +5157,29 @@ /* reg contains container value, result should be in reg */ extern void -code_bit_field(int type,int bit_offset,int bit_size,int reg) +code_bit_field(int type,int bitpos,int reg) { - int sign,bitsz,l; + int sign,bitsz,l,align; int bitsize = cadddr(type); int i; - set_bitsz(type,&sign,&bitsz,&l); + set_bitsz(type,&sign,&bitsz,&align,&l); /* this implementation returns -1 for int i:1; */ if (l==1) { use_longlong(reg); /* shift left */ - if (bit_offset) - loprtc(LLSHIFT,reg,bit_offset); + if (bitpos) + loprtc(LLSHIFT,reg,bitpos); /* shift right */ if ((i=bitsz-bitsize)) - loprtc(sign?LRSHIFT:LRUSHIFT,reg,i); + loprtc(sign?LRSHIFT:LURSHIFT,reg,i); } else { use_int(reg); /* shift left */ - if (bit_offset) - oprtc(LSHIFT,reg,bit_offset); + if (bitpos) + oprtc(LSHIFT,reg,bitpos); /* shift right */ if ((i=bitsz-bitsize)) - oprtc(sign?RSHIFT:RUSHIFT,reg,i); + oprtc(sign?RSHIFT:URSHIFT,reg,i); } } @@ -5185,15 +5192,16 @@ int bit = 1; int i; if (from<0||from>32) error(-1); - for (i=31;from<=i;i--,bit<<1) { + for (i=31;from<=i;i--,bit<<=1) { if (i<=to) { mask |= bit; } } + return mask; } static void -make_mask_and_or(int mask,int tmp,char *trn,*crn,*lrn) +make_mask_and_or(int mask,int tmp,char *trn,char *crn,char *lrn) { code_const(~mask,tmp); printf("\tor %s,%s,%s\n",trn,crn,trn); @@ -5207,21 +5215,22 @@ } extern void -code_bit_replace(int value,int lvalue,int type,int bit_offset) +code_bit_replace(int value,int lvalue,int type,int bitpos) { - int sign,bitsz,l; + int sign,bitsz,l,align; int bitsize = cadddr(type); int mask = 0; int tmp = -1; + int i; char *crn,*lrn,*trn; - set_bitsz(type,&sign,&bitsz,&l); + set_bitsz(type,&sign,&bitsz,&align,&l); if (l) { use_longlong(value); crn = lregister_name_low(value); lrn = lregister_name_low(lvalue); /* shift left */ if ((i=bitsz-bitsize-bitpos)) - loprtc(LLSHIFT,reg,i); + loprtc(LLSHIFT,value,i); trn = register_name(tmp = get_register()); if (bitpos+bitsize>32) { /* make and-mask lower */ @@ -5241,7 +5250,7 @@ lrn = register_name(lvalue); /* shift left */ if ((i=bitsz-bitsize-bitpos)) - oprtc(LSHIFT,reg,i); + oprtc(LSHIFT,value,i); trn = register_name(tmp = get_register()); /* make and-mask */ mask = make_mask(bitpos+(32-bitsz),bitpos+bitsize);