Mercurial > hg > CbC > old > device
diff mc-code-powerpc.c @ 327:da2e3f2d127d
macro/codegen reorganization
author | kono |
---|---|
date | Mon, 21 Jun 2004 23:50:34 +0900 |
parents | e5d40f8c4cce |
children | 7ecb023d29b8 |
line wrap: on
line diff
--- a/mc-code-powerpc.c Sun Jun 20 20:54:24 2004 +0900 +++ b/mc-code-powerpc.c Mon Jun 21 23:50:34 2004 +0900 @@ -1,8 +1,9 @@ /* Micro-C Code Generation Part for Power PC (Mac OS X) */ /* $Id$ */ -#define EXTERN extern +#include <stdio.h> #include "mc.h" +#include "mc-parse.h" #include "mc-code.h" #include "mc-codegen.h" @@ -13,7 +14,8 @@ // __builtin_expect(a,t) branch prediction -char *init_src = "\ +static +char *init_src0 = "\ #define __ppc__ 1\n\ #define __BIG_ENDIAN__ 1\n\ #define __STDC__ 1\n\ @@ -61,13 +63,6 @@ #define SIZE_OF_LONGLONG 8 #define ENDIAN 1 -int size_of_int = SIZE_OF_INT; -int size_of_short = SIZE_OF_SHORT; -int size_of_float = SIZE_OF_FLOAT; -int size_of_double = SIZE_OF_DOUBLE; -int size_of_longlong = SIZE_OF_LONGLONG; -int endian = ENDIAN; - static int reg_sp; /* REGister Stack-Pointer */ static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */ @@ -413,39 +408,29 @@ void code_init(void) { -#if 0 - macro_define("__ppc__ 1\n"); - macro_define("__BIG_ENDIAN__ 1\n"); -// macro_define("_BSD_CT_RUNE_T_ int\n"); -// macro_define("__STDC__ 1\n"); - macro_define("__builtin_va_list int\n"); -#endif + /* called only once */ + + init_src = init_src0; + size_of_int = SIZE_OF_INT; + size_of_short = SIZE_OF_SHORT; + size_of_float = SIZE_OF_FLOAT; + size_of_double = SIZE_OF_DOUBLE; + size_of_longlong = SIZE_OF_LONGLONG; + endian = ENDIAN; + init_ptr_cache(); regv_l(RET_LREGISTER) = RET_LREGISTER_L; regv_h(RET_LREGISTER) = RET_LREGISTER_H; } +extern void +emit_reinit() +{ + /* called for each file */ +} + void gexpr_code_init(void){ -#if 0 - int new_reg,old_reg,dm; - /* register shuffling */ - if (is_int_reg(creg)) { - dm = get_register(); - new_reg = get_register(); - old_reg = creg; - ireg = creg = new_reg; - free_register(old_reg); - free_register(dm); - } else if (is_float_reg(creg)) { - dm = get_dregister(1); - new_reg = get_dregister(1); - old_reg = creg; - freg = creg = new_reg; - free_register(old_reg); - free_register(dm); - } -#endif } void @@ -961,6 +946,8 @@ emit_init(void) { + /* called before each declaration */ + free_all_register(); max_reg_var=-1; max_freg_var=-1; reg_sp = 0; @@ -2719,7 +2706,7 @@ printf("\tb\tL_%d\n",l); } -void +extern void gen_comment(char *s) { if (chk) return; @@ -4979,8 +4966,8 @@ 1 can't be used in input */ -int -asm_operand(char *p,int e1,int mode,int repl,int n,int repl0) +extern int +code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0) { int r; int c; @@ -5035,7 +5022,7 @@ } void -free_asm_operand(int repl) +code_free_asm_operand(int repl) { for(;repl;repl=cadr(repl)) { if (car(car(repl))==REGISTER) @@ -5045,7 +5032,7 @@ extern void -replace_asm_string(char *asm_str,int repl) +code_asm(char *asm_str,int repl) { int c,i,rstr,val; char *p;