Mercurial > hg > CbC > old > device
changeset 518:9f2d6aea201f
cstring fix.... finally
author | kono |
---|---|
date | Mon, 26 Dec 2005 12:29:10 +0900 |
parents | d686497e8fd2 |
children | b6eb97f0c11d |
files | Changes mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-code.h mc-codegen.c |
diffstat | 7 files changed, 74 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Mon Dec 26 12:17:23 2005 +0900 +++ b/Changes Mon Dec 26 12:29:10 2005 +0900 @@ -7576,7 +7576,9 @@ .cstring とかのデータモードとglobalラベルが変。 - - - - +これねぇ。string をconstに置くかどうかは arch によるわけだから、 +mc-code-*.c で解決するのが正しいわけだけど、emit_data に分散して +しまっているね。 + + +
--- a/mc-code-arm.c Mon Dec 26 12:17:23 2005 +0900 +++ b/mc-code-arm.c Mon Dec 26 12:29:10 2005 +0900 @@ -55,6 +55,7 @@ static void code_assign_input_float_int(int e1,int e2) ; #endif static void use_input_reg(int reg,int mode); +static void ascii(char *s); static int creg; static int output_mode = TEXT_EMIT_MODE; @@ -3554,7 +3555,7 @@ } } -void +static void ascii(char *s) { printf("\t.ascii \""); @@ -3585,6 +3586,20 @@ return lb; } +extern void +emit_string(char *s,int t) +{ + t = type_value(t); + if (car(t)==ARRAY && + (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { + ascii(s); + } else { + int l = emit_string_label(); + ascii(s); + emit_label(l); + } + return; +} void emit_global(NMTBL *n,int a,int e)
--- a/mc-code-ia32.c Mon Dec 26 12:17:23 2005 +0900 +++ b/mc-code-ia32.c Mon Dec 26 12:29:10 2005 +0900 @@ -168,6 +168,8 @@ static char *reg_name_l[4]; static char *reg_name_w[4]; +static void ascii(char *s); + static void use_register(int virt, int real, int move); static int virtual(int real); static void shift(char *op, int reg,int creg); @@ -2015,6 +2017,21 @@ return lb; } +extern void +emit_string(char *s,int t) +{ + t = type_value(t); + if (car(t)==ARRAY && + (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { + ascii(s); + } else { + int l = emit_string_label(); + ascii(s); + emit_label(l); + } + return; +} + void align(int t) {
--- a/mc-code-mips.c Mon Dec 26 12:17:23 2005 +0900 +++ b/mc-code-mips.c Mon Dec 26 12:29:10 2005 +0900 @@ -31,6 +31,8 @@ static void register_usage(char *s); static int get_input_dregister_var0(int i,int reg_var,NMTBL *n,int is_code,int d); +static void ascii(char *s); + static int creg; static int output_mode = TEXT_EMIT_MODE; @@ -3264,6 +3266,20 @@ return lb; } +extern void +emit_string(char *s,int t) +{ + t = type_value(t); + if (car(t)==ARRAY && + (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { + ascii(s); + } else { + int l = emit_string_label(); + ascii(s); + emit_label(l); + } + return; +} extern void emit_global(NMTBL *n,int a,int e)
--- a/mc-code-powerpc.c Mon Dec 26 12:17:23 2005 +0900 +++ b/mc-code-powerpc.c Mon Dec 26 12:29:10 2005 +0900 @@ -34,6 +34,8 @@ static void local_table(void); static void shift(char *op, int creg,int reg); static int push_struct(int e4,int t,int arg); +static void ascii(char *s); + static int creg; @@ -1489,7 +1491,6 @@ // #define MAX_COPY_LEN 10 void - emit_copy(int from,int to,int length,int offset,int value,int det) { char *frn; @@ -2953,6 +2954,21 @@ return lb; } +extern void +emit_string(char *s,int t) +{ + t = type_value(t); + if (car(t)==ARRAY && + (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { + ascii(s); + } else { + int l = emit_string_label(); + ascii(s); + emit_label(l); + } + return; +} + void align(int t) {
--- a/mc-code.h Mon Dec 26 12:17:23 2005 +0900 +++ b/mc-code.h Mon Dec 26 12:29:10 2005 +0900 @@ -141,7 +141,7 @@ extern void emit_address(char *s,int offset); extern void emit_label(int labelno); extern int emit_string_label(); -extern void ascii(char *s); +extern void emit_string(char *,int type); extern void code_i2c(int reg); extern void code_i2s(int reg);
--- a/mc-codegen.c Mon Dec 26 12:17:23 2005 +0900 +++ b/mc-codegen.c Mon Dec 26 12:29:10 2005 +0900 @@ -2906,7 +2906,6 @@ static void emit_data(int e, int t, NMTBL *n) { - int l; t = type_value(t); if(mode!=GDECL && mode!=STADECL) { error(-1); return; @@ -2970,15 +2969,7 @@ emit_address(((NMTBL *)caddr(e))->nm,0); return; case STRING: - t = type_value(n->ty); - if (car(t)==ARRAY && - (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { - ascii((char *)cadr(e)); - } else { - l = emit_string_label(); - ascii((char *)cadr(e)); - emit_label(l); - } + emit_string((char *)cadr(e),n->ty); return; } // fprintf(stderr,"## type= %d\n",t);