Mercurial > hg > CbC > old > device
changeset 738:1ba0d5c4d277
i64 continue...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Nov 2010 20:16:43 +0900 |
parents | d8b207cfbafe |
children | 0c7a6ae119ba |
files | mc-code-i64.c |
diffstat | 1 files changed, 155 insertions(+), 156 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-i64.c Mon Nov 08 02:12:03 2010 +0900 +++ b/mc-code-i64.c Mon Nov 08 20:16:43 2010 +0900 @@ -40,126 +40,126 @@ static char *init_src0 = "\ -#define __DBL_MIN_EXP__ (-1021) -#define __FLT_MIN__ 1.17549435e-38F -#define __DEC64_DEN__ 0.000000000000001E-383DD -#define __CHAR_BIT__ 8 -#define __WCHAR_MAX__ 2147483647 -#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 -#define __FLT_EVAL_METHOD__ 0 -#define __DBL_MIN_10_EXP__ (-307) -#define __FINITE_MATH_ONLY__ 0 -#define __DEC64_MAX_EXP__ 384 -#define __SHRT_MAX__ 32767 -#define __LDBL_MAX__ 1.18973149535723176502e+4932L -#define __APPLE_CC__ 5664 -#define __UINTMAX_TYPE__ long unsigned int -#define __DEC32_EPSILON__ 1E-6DF -#define __SCHAR_MAX__ 127 -#define __USER_LABEL_PREFIX__ _ -#define __STDC_HOSTED__ 1 -#define __DEC64_MIN_EXP__ (-383) -#define __DBL_DIG__ 15 -#define __FLT_EPSILON__ 1.19209290e-7F -#define __LDBL_MIN__ 3.36210314311209350626e-4932L -#define __DEC32_MAX__ 9.999999E96DF -#define __strong -#define __APPLE__ 1 -#define __DECIMAL_DIG__ 21 -#define __LDBL_HAS_QUIET_NAN__ 1 -#define __DYNAMIC__ 1 -#define __GNUC__ 4 -#define __MMX__ 1 -#define __FLT_HAS_DENORM__ 1 -#define __DBL_MAX__ 1.7976931348623157e+308 -#define __DBL_HAS_INFINITY__ 1 -#define __DEC32_MIN_EXP__ (-95) -#define OBJC_NEW_PROPERTIES 1 -#define __STRICT_ANSI__ 1 -#define __LDBL_HAS_DENORM__ 1 -#define __DEC32_MIN__ 1E-95DF -#define __weak __attribute__((objc_gc(weak))) -#define __DBL_MAX_EXP__ 1024 -#define __DEC128_EPSILON__ 1E-33DL -#define __SSE2_MATH__ 1 -#define __amd64 1 -#define __tune_core2__ 1 -#define __LONG_LONG_MAX__ 9223372036854775807LL -#define __GXX_ABI_VERSION 1002 -#define __FLT_MIN_EXP__ (-125) -#define __x86_64 1 -#define __DBL_MIN__ 2.2250738585072014e-308 -#define __LP64__ 1 -#define __DBL_HAS_QUIET_NAN__ 1 -#define __DEC128_MIN__ 1E-6143DL -#define __REGISTER_PREFIX__ -#define __DBL_HAS_DENORM__ 1 -#define __NO_INLINE__ 1 -#define __DEC_EVAL_METHOD__ 2 -#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL -#define __FLT_MANT_DIG__ 24 -#define __VERSION__ "4.2.1 (Apple Inc. build 5664)" -#define __DEC64_EPSILON__ 1E-15DD -#define __DEC128_MIN_EXP__ (-6143) -#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 1064 -#define __SIZE_TYPE__ long unsigned int -#define __DEC32_DEN__ 0.000001E-95DF -#define __FLT_RADIX__ 2 -#define __LDBL_EPSILON__ 1.08420217248550443401e-19L -#define __SSE_MATH__ 1 -#define __k8 1 -#define __LDBL_DIG__ 18 -#define __x86_64__ 1 -#define __FLT_HAS_QUIET_NAN__ 1 -#define __FLT_MAX_10_EXP__ 38 -#define __LONG_MAX__ 9223372036854775807L -#define __FLT_HAS_INFINITY__ 1 -#define __DEC64_MAX__ 9.999999999999999E384DD -#define __DEC64_MANT_DIG__ 16 -#define __STDC_VERSION__ 199901L -#define __DEC32_MAX_EXP__ 96 -#define __DEC128_DEN__ 0.000000000000000000000000000000001E-6143DL -#define __LITTLE_ENDIAN__ 1 -#define __LDBL_MANT_DIG__ 64 -#define __CONSTANT_CFSTRINGS__ 1 -#define __DEC32_MANT_DIG__ 7 -#define __k8__ 1 -#define __WCHAR_TYPE__ int -#define __pic__ 2 -#define __FLT_DIG__ 6 -#define __INT_MAX__ 2147483647 -#define __FLT_MAX_EXP__ 128 -#define __DBL_MANT_DIG__ 53 -#define __DEC64_MIN__ 1E-383DD -#define __WINT_TYPE__ int -#define __SSE__ 1 -#define __LDBL_MIN_EXP__ (-16381) -#define __MACH__ 1 -#define __amd64__ 1 -#define __LDBL_MAX_EXP__ 16384 -#define __SSP__ 1 -#define __LDBL_MAX_10_EXP__ 4932 -#define __DBL_EPSILON__ 2.2204460492503131e-16 -#define _LP64 1 -#define __GNUC_PATCHLEVEL__ 1 -#define __LDBL_HAS_INFINITY__ 1 -#define __GNUC_STDC_INLINE__ 1 -#define __INTMAX_MAX__ 9223372036854775807L -#define __FLT_DENORM_MIN__ 1.40129846e-45F -#define __PIC__ 2 -#define __FLT_MAX__ 3.40282347e+38F -#define __SSE2__ 1 -#define __FLT_MIN_10_EXP__ (-37) -#define __INTMAX_TYPE__ long int -#define __DEC128_MAX_EXP__ 6144 -#define __GNUC_MINOR__ 2 -#define __DBL_MAX_10_EXP__ 308 -#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L -#define __STDC__ 1 -#define __PTRDIFF_TYPE__ long int -#define __DEC128_MANT_DIG__ 34 -#define __LDBL_MIN_10_EXP__ (-4931) -#define __SSE3__ 1 +#define __DBL_MIN_EXP__ (-1021) \ +#define __FLT_MIN__ 1.17549435e-38F \ +#define __DEC64_DEN__ 0.000000000000001E-383DD \ +#define __CHAR_BIT__ 8 \ +#define __WCHAR_MAX__ 2147483647 \ +#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 \ +#define __FLT_EVAL_METHOD__ 0 \ +#define __DBL_MIN_10_EXP__ (-307) \ +#define __FINITE_MATH_ONLY__ 0 \ +#define __DEC64_MAX_EXP__ 384 \ +#define __SHRT_MAX__ 32767 \ +#define __LDBL_MAX__ 1.18973149535723176502e+4932L \ +#define __APPLE_CC__ 5664 \ +#define __UINTMAX_TYPE__ long unsigned int \ +#define __DEC32_EPSILON__ 1E-6DF \ +#define __SCHAR_MAX__ 127 \ +#define __USER_LABEL_PREFIX__ _ \ +#define __STDC_HOSTED__ 1 \ +#define __DEC64_MIN_EXP__ (-383) \ +#define __DBL_DIG__ 15 \ +#define __FLT_EPSILON__ 1.19209290e-7F \ +#define __LDBL_MIN__ 3.36210314311209350626e-4932L \ +#define __DEC32_MAX__ 9.999999E96DF \ +#define __strong \ +#define __APPLE__ 1 \ +#define __DECIMAL_DIG__ 21 \ +#define __LDBL_HAS_QUIET_NAN__ 1 \ +#define __DYNAMIC__ 1 \ +#define __GNUC__ 4 \ +#define __MMX__ 1 \ +#define __FLT_HAS_DENORM__ 1 \ +#define __DBL_MAX__ 1.7976931348623157e+308 \ +#define __DBL_HAS_INFINITY__ 1 \ +#define __DEC32_MIN_EXP__ (-95) \ +#define OBJC_NEW_PROPERTIES 1 \ +#define __STRICT_ANSI__ 1 \ +#define __LDBL_HAS_DENORM__ 1 \ +#define __DEC32_MIN__ 1E-95DF \ +#define __weak __attribute__((objc_gc(weak))) \ +#define __DBL_MAX_EXP__ 1024 \ +#define __DEC128_EPSILON__ 1E-33DL \ +#define __SSE2_MATH__ 1 \ +#define __amd64 1 \ +#define __tune_core2__ 1 \ +#define __LONG_LONG_MAX__ 9223372036854775807LL \ +#define __GXX_ABI_VERSION 1002 \ +#define __FLT_MIN_EXP__ (-125) \ +#define __x86_64 1 \ +#define __DBL_MIN__ 2.2250738585072014e-308 \ +#define __LP64__ 1 \ +#define __DBL_HAS_QUIET_NAN__ 1 \ +#define __DEC128_MIN__ 1E-6143DL \ +#define __REGISTER_PREFIX__ \ +#define __DBL_HAS_DENORM__ 1 \ +#define __NO_INLINE__ 1 \ +#define __DEC_EVAL_METHOD__ 2 \ +#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL \ +#define __FLT_MANT_DIG__ 24 \ +#define __VERSION__ \"Micro C\" \ +#define __DEC64_EPSILON__ 1E-15DD \ +#define __DEC128_MIN_EXP__ (-6143) \ +#define __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ 1064 \ +#define __SIZE_TYPE__ long unsigned int \ +#define __DEC32_DEN__ 0.000001E-95DF \ +#define __FLT_RADIX__ 2 \ +#define __LDBL_EPSILON__ 1.08420217248550443401e-19L \ +#define __SSE_MATH__ 1 \ +#define __k8 1 \ +#define __LDBL_DIG__ 18 \ +#define __x86_64__ 1 \ +#define __FLT_HAS_QUIET_NAN__ 1 \ +#define __FLT_MAX_10_EXP__ 38 \ +#define __LONG_MAX__ 9223372036854775807L \ +#define __FLT_HAS_INFINITY__ 1 \ +#define __DEC64_MAX__ 9.999999999999999E384DD \ +#define __DEC64_MANT_DIG__ 16 \ +#define __STDC_VERSION__ 199901L \ +#define __DEC32_MAX_EXP__ 96 \ +#define __DEC128_DEN__ 0.000000000000000000000000000000001E-6143DL \ +#define __LITTLE_ENDIAN__ 1 \ +#define __LDBL_MANT_DIG__ 64 \ +#define __CONSTANT_CFSTRINGS__ 1 \ +#define __DEC32_MANT_DIG__ 7 \ +#define __k8__ 1 \ +#define __WCHAR_TYPE__ int \ +#define __pic__ 2 \ +#define __FLT_DIG__ 6 \ +#define __INT_MAX__ 2147483647 \ +#define __FLT_MAX_EXP__ 128 \ +#define __DBL_MANT_DIG__ 53 \ +#define __DEC64_MIN__ 1E-383DD \ +#define __WINT_TYPE__ int \ +#define __SSE__ 1 \ +#define __LDBL_MIN_EXP__ (-16381) \ +#define __MACH__ 1 \ +#define __amd64__ 1 \ +#define __LDBL_MAX_EXP__ 16384 \ +#define __SSP__ 1 \ +#define __LDBL_MAX_10_EXP__ 4932 \ +#define __DBL_EPSILON__ 2.2204460492503131e-16 \ +#define _LP64 1 \ +#define __GNUC_PATCHLEVEL__ 1 \ +#define __LDBL_HAS_INFINITY__ 1 \ +#define __GNUC_STDC_INLINE__ 1 \ +#define __INTMAX_MAX__ 9223372036854775807L \ +#define __FLT_DENORM_MIN__ 1.40129846e-45F \ +#define __PIC__ 2 \ +#define __FLT_MAX__ 3.40282347e+38F \ +#define __SSE2__ 1 \ +#define __FLT_MIN_10_EXP__ (-37) \ +#define __INTMAX_TYPE__ long int \ +#define __DEC128_MAX_EXP__ 6144 \ +#define __GNUC_MINOR__ 2 \ +#define __DBL_MAX_10_EXP__ 308 \ +#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L \ +#define __STDC__ 1 \ +#define __PTRDIFF_TYPE__ long int \ +#define __DEC128_MANT_DIG__ 34 \ +#define __LDBL_MIN_10_EXP__ (-4931) \ +#define __SSE3__ 1 \ " #ifdef __APPLE__ "#define __APPLE__ 1\n" @@ -261,16 +261,20 @@ int code_lassop_p = 1; #define MAX_REGISTER 14 /* intel386のレジスタを6つまで使う*/ -#define REAL_MAX_REGISTER (1+16+16) /* intel386のレジスタが8つということ*/ +#define REAL_MAX_REGISTER (1+16) /* intel386のレジスタが8つということ*/ int MAX_REGISTER_VAR=6; +#define REAL_MAX_DREGISTER (1+16) /* intel386のレジスタが8つということ*/ static int MAX_DREGISTER=16; int MAX_DREGISTER_VAR=8; -static int MAX_INPUT_REGISTER_VAR = 6; +#define MIN_TMP_FREG 6 +#define MAX_TMP_FREG 9 + +int MAX_INPUT_REGISTER_VAR = 6; int MAX_CODE_INPUT_REGISTER_VAR = 6; -static int MAX_INPUT_DREGISTER_VAR = 6; +int MAX_INPUT_DREGISTER_VAR = 6; // static int MAX_INPUT_FREGISTER_VAR = 0; -static int MAX_CODE_INPUT_DREGISTER_VAR = 6; +int MAX_CODE_INPUT_DREGISTER_VAR = 6; static int reg_sp; /* REGister Stack-Pointer */ static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */ @@ -281,8 +285,7 @@ static int freg_sp; /* floating point REGister Stack-Pointer */ static int freg_stack[MAX_MAX]; /* 実際のレジスタの領域 */ -static int reg_var; - +static int max_reg_var, max_freg_var; /* local2 -8 @@ -322,12 +325,10 @@ kept in FPU stack (no register) */ -static int ia32regs[1+REAL_MAX_REGISTER]; +static int ia32regs[1+REAL_MAX_REGISTER+REAL_MAX_DREGISTER]; static int *regs = ia32regs; -static int ia32fregs[1+MAX_DREGISTER]; -static int *fregs = ia32fregs; static int freg; // register number should start 1 @@ -338,6 +339,8 @@ // 2 (REG_VAR) register variable // 3 pointer cache (not used in ia32) +#define FREG_START 18 + #define REG_ESP 1 #define REG_EBP 2 #define REG_EDI 3 // first argument register @@ -439,7 +442,9 @@ "%r14", "%r15", "%r16", - "%xmm0", // 18 +}; + +static char *reg_name_d[] = {0, "%xmm0", // 18 "%xmm1", "%xmm2", "%xmm3", @@ -668,7 +673,7 @@ return i; } -#define fregister_name(reg) reg_name_q[reg] +#define fregister_name(reg) reg_name_d[reg-FREG_START] static void set_freg(int reg,int mode) @@ -710,7 +715,7 @@ } #define is_long_reg(reg) is_int_reg(reg) -#define use_longlong(reg) use_data_reg(reg) +#define use_longlong(reg) use_int(reg) static void set_lreg(int reg,int mode) @@ -736,7 +741,6 @@ struct_align = size_of_int; - MAX_DATA_REG=6; } @@ -754,7 +758,7 @@ char * register_name(int i,int byte) { - if (i<=0) { + if (i<=0 || i>=FREG_START) { error(REG_ERR); return "%rax"; } @@ -779,8 +783,6 @@ code_gexpr(int e){ if ((is_int_reg(creg))&®s[creg]==REG_VAR) creg = ireg = 0; - else if ((creg==REG_L)&®s[creg]==REG_VAR) - creg = lreg = 0; } int @@ -849,12 +851,7 @@ void free_register(int i) { /* いらなくなったレジスタを開放 */ - if (i==REG_L) { - reg_var=0; - regs[REG_ESI]=regs[REG_EDI]=0; - } else if (regs[i]==REG_VAR) { reg_var--; - } else if(i==REG_LCREG) { //? REG_L? - regs[REG_EAX]=regs[REG_EDX]=0; + if (regs[i]==REG_VAR) { reg_var--; } regs[i]=0; } @@ -909,21 +906,20 @@ int get_input_dregister_var(int i,NMTBL *nptr,int is_code,int d) { - return 0; + if (is_code) { + if(!(i<MAX_INPUT_DREGISTER_VAR)) return 0; + i = FREG_START+i; + } else { + if(!(i<MAX_INPUT_DREGISTER_VAR)) return 0; + i = FREG_START+i; + } + return list3n(FREGISTER,i,nptr); } int get_input_lregister_var(int i,NMTBL *nptr,int is_code) { - int h,l; - if (is_code) { - if (i+1>=MAX_CODE_INPUT_REGISTER_VAR) return 0; - h = REG_ESI; - l = REG_EDI; - regs[h]=regs[l]=INPUT_REG; - return list2(LREGISTER,REG_L); - } - return 0; + return get_input_register_var(i,nptr,is_code); } #if FLOAT_CODE @@ -931,7 +927,7 @@ get_dregister(int d) { /* 使われていないレジスタを調べる */ int i,reg; - for(i=MAX_TMP_FREG+FREG_OFFSET;i>MIN_TMP_FREG+FREG_OFFSET;i--) { + for(i=MAX_TMP_FREG+FREG_START;i>MIN_TMP_FREG+FREG_START;i--) { if (regs[i]) continue; /* 使われている */ regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */ return i; /* その場所を表す番号を返す */ @@ -946,7 +942,7 @@ } } for(i=0;i<FREG_VAR_BASE-REG_VAR_MIN;i++) { - reg =FREG_VAR_BASE-i+FREG_OFFSET; + reg =FREG_VAR_BASE-i+FREG_START; if (! regs[reg]) { /* 使われていないなら */ regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */ if (i>max_freg_var) max_freg_var=i; @@ -1100,6 +1096,7 @@ free_all_register(); reg_sp = 0; freg_sp = 0; + max_reg_var=-1; max_freg_var=-1; } int @@ -2122,6 +2119,8 @@ void code_jmp(char *s) { + max_reg_var = REG_VAR_BASE-REG_VAR_MIN; + max_freg_var = FREG_VAR_BASE-FREG_VAR_MIN; printf("\tjmp _%s\n",s); } @@ -4532,7 +4531,7 @@ a = ~mask|c; if (a!=-1) { /* do conjunction */ - if (reg<MAX_DATA_REG && ((a& ~0xffff)==~0xffff)) { + if (is_data_reg(reg) && ((a& ~0xffff)==~0xffff)) { if ((a& ~0xff)==~0xff) printf("\tandb $%d,%s\n",a&0xff,register_name(reg,1)); else @@ -4544,7 +4543,7 @@ c = mask&c; if (c!=0) { /* do disjunction */ - if (reg<MAX_DATA_REG && (!(c& ~0xffff))) { + if (is_data(reg) && (!(c& ~0xffff))) { if (!(c& ~0xff)) printf("\torb $%d,%s\n",c&0xff,register_name(reg,1)); else