Quellcode durchsuchen

Hidden some names, fixed STR 1 bug, use stdio instead of print module

ceriel vor 33 Jahren
Ursprung
Commit
c9302b5a06

+ 23 - 21
mach/sparc/ce/EM_table.x

@@ -19,7 +19,7 @@ define(`BP_OFFSET',`'WINDOWSIZE)
 define(`'`EM_BSIZE',EM_BSIZE)
 define(STACK_CLICK,4)
 
-#if RESOLVE_debug
+#if RESOLV_debug
 define(Comment0)
 define(Comment)
 define(Comment2)
@@ -190,7 +190,7 @@ C_lxl
 				a = alloc_reg();
 				b = alloc_reg();
 				c = alloc_reg();
-				sprintf(n_str, "%d", $1);
+				sprint(n_str, "%d", $1);
 				"set	$n_str, $a";
 				"mov 	$reg_lb, $b";
 			"1:	ld	[$b + EM_BSIZE], $c";
@@ -671,7 +671,7 @@ C_mli
 
 				if (n0) {
 					a = alloc_reg();
-					sprintf(n_str, "%d", n0);
+					sprint(n_str, "%d", n0);
 					"sll	$orig, $n_str, $a";
 					free_reg(orig);
 					orig = a;
@@ -689,7 +689,7 @@ C_mli
 					n <<= n1;
 				} else {
 					a = alloc_reg();
-					sprintf(n_str, "%d", n1);
+					sprint(n_str, "%d", n1);
 					"sll	$orig, $n_str, $a";
 					b = alloc_reg();
 					"sub	$a, $orig, $b";
@@ -738,7 +738,7 @@ C_dvi
 		if (type_of_tos() == T_cst &&
 			power_of_2(top_const(), &n_exp))
 		{
-			sprintf (n_exp_str, "%d", n_exp);
+			sprint (n_exp_str, "%d", n_exp);
 			n= pop_const(NULL);
 			a= pop_reg();
 			if (n <0)
@@ -921,7 +921,7 @@ C_dvu
 		if (type_of_tos() == T_cst &&
 			uns_power_of_2(top_const(), &n_exp))
 		{
-			sprintf (n_exp_str, "%d", n_exp);
+			sprint (n_exp_str, "%d", n_exp);
 			n= pop_const(NULL);
 			a= pop_reg();
 			b= alloc_reg();
@@ -1450,7 +1450,7 @@ C_ine..		==>
 			b= alloc_reg();
 
 			ename= $1;
-			sprintf(evalue, "%d", $2);
+			sprint(evalue, "%d", $2);
 			"sethi	%hi($ename+$evalue), $a";
 			"ld	[$a+%lo($ename+$evalue)], $b";
 			"inc	$b";
@@ -1497,7 +1497,7 @@ C_dee..		==>
 			b= alloc_reg();
 
 			ename= $1;
-			sprintf(evalue, "%d", $2);
+			sprint(evalue, "%d", $2);
 			"sethi	%hi($ename+$evalue), $a";
 			"ld	[$a+%lo($ename+$evalue)], $b";
 			"dec	$b";
@@ -1533,7 +1533,7 @@ C_zre..		==>
 			a= alloc_reg();
 
 			ename= $1;
-			sprintf(evalue, "%d", $2);
+			sprint(evalue, "%d", $2);
 			"sethi	%hi($ename+$evalue), $a";
 			"st	%g0, [$a+%lo($ename+$evalue)]"
 			free_reg(a);
@@ -2744,7 +2744,7 @@ C_com_narg	==>
 				b= alloc_reg();
 				for (i= 0; i< n; i += 4)
 				{
-					sprintf(i_str, "%d", i);
+					sprint(i_str, "%d", i);
 					"ld	[$reg_sp+$i_str], $a";
 					"not	$a, $b";
 					"st	$b, [$reg_sp+$i_str]";
@@ -2796,9 +2796,9 @@ C_rol
 					a= pop_reg();
 					b= alloc_reg();
 					c= alloc_reg();
-					sprintf(n_str, "%d", n);
+					sprint(n_str, "%d", n);
 					"sll	$a, $n_str, $b";
-					sprintf(n_str, "%d", 32-n);
+					sprint(n_str, "%d", 32-n);
 					"srl	$a, $n_str, $c";
 					"or	$b, $c, $a";
 					push_reg(a);
@@ -2855,9 +2855,9 @@ C_ror
 					a= pop_reg();
 					b= alloc_reg();
 					c= alloc_reg();
-					sprintf(n_str, "%d", n);
+					sprint(n_str, "%d", n);
 					"srl	$a, $n_str, $b";
-					sprintf(n_str, "%d", 32-n);
+					sprint(n_str, "%d", 32-n);
 					"sll	$a, $n_str, $c";
 					"or	$b, $c, $a";
 					push_reg(a);
@@ -3020,7 +3020,7 @@ C_inn_narg	==>
 			}
 		}
 		else
-			arg_error ("inn_narg");
+			not_implemented ("inn_narg");
 	}.
 
 C_set	==>	Comment( set, $1);
@@ -3055,7 +3055,7 @@ C_set_narg	==>
 				c= alloc_reg();
 				d= alloc_reg();
 				flush_cache();
-				sprintf(n_str, "%d", n);
+				sprint(n_str, "%d", n);
 				"set	$n_str, $a";
 				"sub	$reg_sp, $a, $reg_sp";
 			"1:";
@@ -4164,7 +4164,7 @@ C_dus
 				"sub	$reg_sp, $n_str, $reg_sp";
 				for (i=0; i<n; i += 4)
 				{
-					sprintf(i_str, "%d", i);
+					sprint(i_str, "%d", i);
 					"ld	[$reg_sp+$i_str+$n_str], $a";
 					"st	$a, [$reg_sp+$i_str]";
 				}
@@ -4239,8 +4239,8 @@ C_exg_narg	==>
 				flush_cache();
 				for (i=0; i<n; i += 4)
 				{
-					sprintf(i_str, "%d", i);
-					sprintf(in_str, "%d", i+n);
+					sprint(i_str, "%d", i);
+					sprint(in_str, "%d", i+n);
 					"ld	[$reg_sp+$i_str], $a";
 					"ld	[$reg_sp+$in_str], $b";
 					"st	$b, [$reg_sp+$i_str]";
@@ -4344,7 +4344,7 @@ C_lin		==>
 #ifdef FAST_LIN_LNI_FIL
 			{
 				const_str_t n_str;
-				sprintf(n_str, "%d", $1);
+				sprint(n_str, "%d", $1);
 				"set	$n_str, $reg_fil";
 			}.
 #else
@@ -4506,6 +4506,7 @@ C_sim		==>
 C_str
 	$1 == 0		==>
 				Comment( str , $1 );
+				flush_cache();
 				"ld	[$reg_sp], $reg_lb";
 				"add	$reg_lb, 4, %fp";
 				"and	%fp, -8, %fp";
@@ -4514,7 +4515,8 @@ C_str
 	$1 == 1		==>
 	{
 		Comment( str , $1 );
-		pop_reg_as(reg_sp);
+		flush_cache();
+		"ld [$reg_sp], $reg_sp";
 	}.
 	$1 == 2		==>
 	{

+ 28 - 24
mach/sparc/ce/cache.c.x

@@ -12,7 +12,7 @@
 #define POP1 cache_need(1);
 #define POP2 { --tos; assert(c_count); --c_count; }
 
-int indent_count = 0;
+static int indent_count = 0;
 
 #define enter(x) indent_count++;
 #define indent() { int i = indent_count; while (i--) putc('\t', stderr); }
@@ -32,7 +32,7 @@ int indent_count = 0;
 		push_ext(char *)
 		flush_cache()		after branches and labels
 		cache_read(int)		read-ahead. optimization only
-		dump_cache(FILE *)	debug info: show current stack
+		dump_cache(File *)	debug info: show current stack
 		pop_nop()		remove element from cache
 
 		reg_t alloc_reg()
@@ -57,7 +57,10 @@ typedef struct cache_elt {
 	arith	cst;
 } cache_elt;
 */
-char regnam[][8] = {
+
+#define REG_NUM(r) (((char(*)[8])(r))-regnam)
+
+static char regnam[][8] = {
 /*x*/	"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
 /*x*/	"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i6", "%i7",
 /*x*/	"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
@@ -76,7 +79,7 @@ reg_t reg_f0;
 reg_t reg_sp, reg_lb, reg_gap;
 reg_t reg_tmp, reg_lin, reg_fil;
 
-struct regdat_t reg[NR_REGS];
+static struct regdat_t reg[NR_REGS];
 
 #define POP_SIZE 1	/* maybe >1  (read-ahead cache) or explicit?! */
 #define CACHE_SIZE 32	/* ? */
@@ -90,14 +93,15 @@ struct regdat_t reg[NR_REGS];
 #define HI_OUT		31
 #define LO_FLOAT	32
 #define HI_FLOAT	63
+
 const13(x) 
 {
 	return (x < 4096 && x >= -4096);
 }
 
-struct cache_elt cache[CACHE_SIZE], *tos = 0;
-int c_count = 0;
-const_str_t s;
+static struct cache_elt cache[CACHE_SIZE], *tos = 0;
+static int c_count = 0;
+static const_str_t s;
 
 static void panic(s)
 char *s;
@@ -224,15 +228,15 @@ enter("flush_part_cache");
 	j = i;
 	if (i)
 	{
-		sprintf (i_str, "%d", 4*i);
+		sprint (i_str, "%d", 4*i);
 		"dec	$i_str, $reg_sp";
 		while (i--)
 		{
-			sprintf(i_str, "%d", 4*(j-1-i));
+			sprint(i_str, "%d", 4*(j-1-i));
 			if (cache[i].ext)
 			{
 				ext= cache[i].ext;
-				sprintf (e_str, "%d", cache[i].cst);
+				sprint (e_str, "%d", cache[i].cst);
 				"set	$ext+$e_str, $reg_tmp";
 				"st	$reg_tmp, [$reg_sp+$i_str]";
 				free(ext);
@@ -249,7 +253,7 @@ enter("flush_part_cache");
 				}
 				if (!const13(cache[i].cst))
 				{
-					sprintf(n_str, "%d",
+					sprint(n_str, "%d",
 						cache[i].cst);
 					"sethi	%hi($n_str), $reg_tmp";
 					if (cache[i].reg != reg_g0)
@@ -265,7 +269,7 @@ enter("flush_part_cache");
 				}
 				if (cache[i].cst)
 				{
-					sprintf(n_str, "%d", cache[i].cst);
+					sprint(n_str, "%d", cache[i].cst);
 					"add	$rh, $n_str, $reg_tmp";
 					rh= reg_tmp;
 				}
@@ -658,16 +662,16 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); }
 		assert(tos->reg == reg_g0);
 		S1 = alloc_reg();
 		V1 = tos->ext;
-		sprintf(V2, "%d", tos->cst);
+		sprint(V2, "%d", tos->cst);
 		"sethi	%hi($V1+$V2), $S1";
-		sprintf(n, "%%lo(%s+%d)", tos->ext, tos->cst);
+		sprint(n, "%%lo(%s+%d)", tos->ext, tos->cst);
 		free(V1);
 		POP2;
 	} else {
 		S1 = tos->reg;
 		if (!(const13(tos->cst))) {
 			S3 = alloc_reg();
-			sprintf(V2, "%d", tos->cst);
+			sprint(V2, "%d", tos->cst);
 			"sethi	%hi($V2), $S3";
 			if (tos->reg != reg_g0) {
 				S2 = alloc_reg();
@@ -678,7 +682,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); }
 			}
 			tos->cst &= 0x3FF;
 		}
-		sprintf(n, "%d", tos->cst);
+		sprint(n, "%d", tos->cst);
 		POP2;
 	}
 if (debug) { indent(); fprint(codefile, "\t\t! %s+%s cache:", S1, n); dump_cache(codefile);}
@@ -833,7 +837,7 @@ enter("pop_const");
 	x = top_const();
 	POP2;
 	if (n)
-		sprintf(n, "%d", x);
+		sprint(n, "%d", x);
 if (debug) { indent(); fprint(codefile, "\t\t! %d cache:", x); dump_cache(codefile); }
 leave("pop_const");
 	return x;
@@ -890,7 +894,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); }
 	} else if (tos->ext) {
 		assert(tos->reg == reg_g0);
 		V1 = tos->ext;
-		sprintf(V2, "%d", tos->cst);
+		sprint(V2, "%d", tos->cst);
 		"set	$V1+$V2, $r";
 		free(V1);
 		POP2;
@@ -911,7 +915,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); }
 				soft_alloc_reg(r);
 				tos_reg2= r;
 			}
-			sprintf(c_str, "%d", tos_cst);
+			sprint(c_str, "%d", tos_cst);
 			"sethi	%hi($c_str), $tos_reg2";
 			tos_cst &= 0x3ff;
 			if (tos_reg == reg_g0)
@@ -938,7 +942,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); }
 		}
 		if (tos_cst)
 		{
-			sprintf(c_str, "%d", tos_cst);
+			sprint(c_str, "%d", tos_cst);
 			soft_alloc_reg(r);
 			"add	$tos_reg, $c_str, $r";
 			free_reg(tos_reg);
@@ -1134,7 +1138,7 @@ enter("pop_nop");
 		POP2;
 	}
 	if (i) {
-		sprintf(V1, "%d", 4*i);
+		sprint(V1, "%d", 4*i);
 		if (const13(4*i)) {
 			"inc	$V1, %l0";
 		} else {
@@ -1195,7 +1199,7 @@ if (debug) { indent(); fprintf(stderr,"cache_read(%d, %d)\n", n,i); }
 		S1= alloc_reg();
 		old_c_count = cache_read(n, i+1);
 
-		sprintf(V1, "%d", (old_c_count-1-i) * 4);
+		sprint(V1, "%d", (old_c_count-1-i) * 4);
 		"ld	[%l0+$V1], $S1";
 		cache[i].reg= S1;
 		cache[i].reg2= reg_g0;
@@ -1203,7 +1207,7 @@ if (debug) { indent(); fprintf(stderr,"cache_read(%d, %d)\n", n,i); }
 		cache[i].cst= 0;
 		if (!i)
 		{
-			sprintf(V1, "%d", (old_c_count)*4);
+			sprint(V1, "%d", (old_c_count)*4);
 			"add	$reg_sp, $V1, $reg_sp";
 		}
 	}
@@ -1277,7 +1281,7 @@ enter("dup_tos");
 			soft_alloc_reg(tos->reg2);
 		} else {
 			a= alloc_reg();
-			sprintf(i_str, "%d", (n-c_count)*4);
+			sprint(i_str, "%d", (n-c_count)*4);
 			"ld	[$reg_sp+$i_str], $a";
 			tos->reg = a;
 		}

+ 83 - 5
mach/sparc/ce/mach.h

@@ -5,9 +5,87 @@ mach.h
 #ifndef MACH_H
 #define MACH_H
 
-#define con_str B_constr
-#define rom_str B_romstr
-#define gen_str B_genstr
+#define alloc_double B_alloc_double
+#define alloc_double_var B_allc_double_var
+#define alloc_float B_alloc_float
+#define alloc_float_var B_allc_float_var
+#define alloc_reg B_alloc_reg
+#define alloc_reg_var B_allc_reg_var
+#define free_reg B_free_reg
+#define free_output B_free_output
+#define free_double_reg B_free_double_reg
+#define forced_alloc_reg B_forced_alloc_reg
+#define force_alloc_output B_forcallocoutput
+#define flush_cache B_flush_cache
+#define dup_tos B_dup_tos
+#define con_float B_con_float
+#define check_cache B_check_cache
+#define change_reg B_change_reg
+#define arg_error B_arg_error
+#define const13 B_const13
+#define type_of_tos B_typeoftos
+#define top_const B_top_const
+#define soft_alloc_reg B_soft_alloc_reg
+#define push_reg B_pushreg
+#define push_ext B_pushext
+#define push_double_reg B_pushdoublereg
+#define push_const B_pushconst
+#define pop_reg_reg B_pop_reg_reg
+#define pop_reg_c13 B_popregc13
+#define pop_reg_as B_popas
+#define pop_reg B_popr
+#define pop_nop B_popnop
+#define pop_float B_popfloat
+#define pop_double_reg_as B_popdouble_reg_as
+#define pop_double B_pop_double
+#define pop_const B_pop_const
+#define init_cache B_init_cache
+#define inc_tos_reg B_inc_tos_reg
+#define inc_tos B_inctos
+
+#define reg_g0 B_regg0
+#define reg_g1 B_regg1
+#define reg_g2 B_regg2
+#define reg_g3 B_regg3
+#define reg_g4 B_regg4
+#define reg_g5 B_regg5
+#define reg_g6 B_regg6
+#define reg_g7 B_regg7
+
+#define reg_i0 B_regi0
+#define reg_i1 B_regi1
+#define reg_i2 B_regi2
+#define reg_i3 B_regi3
+#define reg_i4 B_regi4
+#define reg_i5 B_regi5
+#define reg_i6 B_regi6
+#define reg_i7 B_regi7
+
+#define reg_o0 B_rego0
+#define reg_o1 B_rego1
+#define reg_o2 B_rego2
+#define reg_o3 B_rego3
+#define reg_o4 B_rego4
+#define reg_o5 B_rego5
+#define reg_o6 B_rego6
+#define reg_o7 B_rego7
+
+#define reg_l0 B_regl0
+#define reg_l1 B_regl1
+#define reg_l2 B_regl2
+#define reg_l3 B_regl3
+#define reg_l4 B_regl4
+#define reg_l5 B_regl5
+#define reg_l6 B_regl6
+#define reg_l7 B_regl7
+
+#define reg_f0 B_regf0
+#define reg_gap B_reggap
+#define reg_lb B_reglb
+#define reg_sp B_regsp
+#define reg_tmp B_regtmp
+#define reg_lin B_reglin
+#define reg_fil B_regfil
 
 #include "ctype.h"
 #include "mach_em.h"
@@ -16,9 +94,9 @@ mach.h
 #include "misc.h"
 
 #if RESOLV_debug
-	#define debug 0
+#define debug 0
 #else
-	extern int debug;
+extern int debug;
 #endif
 
 #endif /* MACH_H */

+ 3 - 1
mach/sparc/ce/mach_em.h

@@ -1,4 +1,4 @@
-#define DEBUG 1
+#undef DEBUG 1
 #include <sun4/asm_linkage.h>
 
 #define BYTES_REVERSED
@@ -55,5 +55,7 @@
 #define MATH_DIVIDE	1
 
 #ifndef DEBUG
+#undef arg_error
 #define arg_error(s,i)
+#define RESOLV_debug 1
 #endif

+ 3 - 0
mach/sparc/ce/misc.h

@@ -5,6 +5,9 @@ misc.h
 #ifndef MISC_H
 #define MISC_H
 
+#define power_of_2 B_power_of_2
+#define uns_power_of_2 B_uns_power_of_2
+
 _PROTOTYPE( int power_of_2, (int n, int *ref_exp));
 
 #endif /* MISC_H */

+ 6 - 0
mach/sparc/ce/ms_reg.h

@@ -5,6 +5,12 @@
 
 #include "push_pop.h"
 
+#define init_reg_man B_init_reg_man
+#define free_all_reg_vars B_free_all_reg_vars
+#define alloc_all_reg_vars B_alloc_all_reg_vars
+#define load_float_regs B_load_float_regs
+#define find_local B_find_local
+
 _PROTOTYPE(reg_t find_local, (int, reg_t*));
 
 #endif

+ 0 - 2
mach/sparc/ce/push_pop.h

@@ -17,8 +17,6 @@ typedef struct cache_elt {
 	arith	cst;
 } cache_elt;
 
-#define REG_NUM(r) (((char(*)[8])(r))-regnam)
-
 #define T_cst	1
 #define T_ext	2
 #define T_reg	4