Hidden some names, fixed STR 1 bug, use stdio instead of print module
This commit is contained in:
		
							parent
							
								
									6a02543de2
								
							
						
					
					
						commit
						63c9fea5c2
					
				
					 7 changed files with 146 additions and 53 deletions
				
			
		| 
						 | 
					@ -19,7 +19,7 @@ define(`BP_OFFSET',`'WINDOWSIZE)
 | 
				
			||||||
define(`'`EM_BSIZE',EM_BSIZE)
 | 
					define(`'`EM_BSIZE',EM_BSIZE)
 | 
				
			||||||
define(STACK_CLICK,4)
 | 
					define(STACK_CLICK,4)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if RESOLVE_debug
 | 
					#if RESOLV_debug
 | 
				
			||||||
define(Comment0)
 | 
					define(Comment0)
 | 
				
			||||||
define(Comment)
 | 
					define(Comment)
 | 
				
			||||||
define(Comment2)
 | 
					define(Comment2)
 | 
				
			||||||
| 
						 | 
					@ -190,7 +190,7 @@ C_lxl
 | 
				
			||||||
				a = alloc_reg();
 | 
									a = alloc_reg();
 | 
				
			||||||
				b = alloc_reg();
 | 
									b = alloc_reg();
 | 
				
			||||||
				c = alloc_reg();
 | 
									c = alloc_reg();
 | 
				
			||||||
				sprintf(n_str, "%d", $1);
 | 
									sprint(n_str, "%d", $1);
 | 
				
			||||||
				"set	$n_str, $a";
 | 
									"set	$n_str, $a";
 | 
				
			||||||
				"mov 	$reg_lb, $b";
 | 
									"mov 	$reg_lb, $b";
 | 
				
			||||||
			"1:	ld	[$b + EM_BSIZE], $c";
 | 
								"1:	ld	[$b + EM_BSIZE], $c";
 | 
				
			||||||
| 
						 | 
					@ -671,7 +671,7 @@ C_mli
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (n0) {
 | 
									if (n0) {
 | 
				
			||||||
					a = alloc_reg();
 | 
										a = alloc_reg();
 | 
				
			||||||
					sprintf(n_str, "%d", n0);
 | 
										sprint(n_str, "%d", n0);
 | 
				
			||||||
					"sll	$orig, $n_str, $a";
 | 
										"sll	$orig, $n_str, $a";
 | 
				
			||||||
					free_reg(orig);
 | 
										free_reg(orig);
 | 
				
			||||||
					orig = a;
 | 
										orig = a;
 | 
				
			||||||
| 
						 | 
					@ -689,7 +689,7 @@ C_mli
 | 
				
			||||||
					n <<= n1;
 | 
										n <<= n1;
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
					a = alloc_reg();
 | 
										a = alloc_reg();
 | 
				
			||||||
					sprintf(n_str, "%d", n1);
 | 
										sprint(n_str, "%d", n1);
 | 
				
			||||||
					"sll	$orig, $n_str, $a";
 | 
										"sll	$orig, $n_str, $a";
 | 
				
			||||||
					b = alloc_reg();
 | 
										b = alloc_reg();
 | 
				
			||||||
					"sub	$a, $orig, $b";
 | 
										"sub	$a, $orig, $b";
 | 
				
			||||||
| 
						 | 
					@ -738,7 +738,7 @@ C_dvi
 | 
				
			||||||
		if (type_of_tos() == T_cst &&
 | 
							if (type_of_tos() == T_cst &&
 | 
				
			||||||
			power_of_2(top_const(), &n_exp))
 | 
								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);
 | 
								n= pop_const(NULL);
 | 
				
			||||||
			a= pop_reg();
 | 
								a= pop_reg();
 | 
				
			||||||
			if (n <0)
 | 
								if (n <0)
 | 
				
			||||||
| 
						 | 
					@ -921,7 +921,7 @@ C_dvu
 | 
				
			||||||
		if (type_of_tos() == T_cst &&
 | 
							if (type_of_tos() == T_cst &&
 | 
				
			||||||
			uns_power_of_2(top_const(), &n_exp))
 | 
								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);
 | 
								n= pop_const(NULL);
 | 
				
			||||||
			a= pop_reg();
 | 
								a= pop_reg();
 | 
				
			||||||
			b= alloc_reg();
 | 
								b= alloc_reg();
 | 
				
			||||||
| 
						 | 
					@ -1450,7 +1450,7 @@ C_ine..		==>
 | 
				
			||||||
			b= alloc_reg();
 | 
								b= alloc_reg();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ename= $1;
 | 
								ename= $1;
 | 
				
			||||||
			sprintf(evalue, "%d", $2);
 | 
								sprint(evalue, "%d", $2);
 | 
				
			||||||
			"sethi	%hi($ename+$evalue), $a";
 | 
								"sethi	%hi($ename+$evalue), $a";
 | 
				
			||||||
			"ld	[$a+%lo($ename+$evalue)], $b";
 | 
								"ld	[$a+%lo($ename+$evalue)], $b";
 | 
				
			||||||
			"inc	$b";
 | 
								"inc	$b";
 | 
				
			||||||
| 
						 | 
					@ -1497,7 +1497,7 @@ C_dee..		==>
 | 
				
			||||||
			b= alloc_reg();
 | 
								b= alloc_reg();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ename= $1;
 | 
								ename= $1;
 | 
				
			||||||
			sprintf(evalue, "%d", $2);
 | 
								sprint(evalue, "%d", $2);
 | 
				
			||||||
			"sethi	%hi($ename+$evalue), $a";
 | 
								"sethi	%hi($ename+$evalue), $a";
 | 
				
			||||||
			"ld	[$a+%lo($ename+$evalue)], $b";
 | 
								"ld	[$a+%lo($ename+$evalue)], $b";
 | 
				
			||||||
			"dec	$b";
 | 
								"dec	$b";
 | 
				
			||||||
| 
						 | 
					@ -1533,7 +1533,7 @@ C_zre..		==>
 | 
				
			||||||
			a= alloc_reg();
 | 
								a= alloc_reg();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			ename= $1;
 | 
								ename= $1;
 | 
				
			||||||
			sprintf(evalue, "%d", $2);
 | 
								sprint(evalue, "%d", $2);
 | 
				
			||||||
			"sethi	%hi($ename+$evalue), $a";
 | 
								"sethi	%hi($ename+$evalue), $a";
 | 
				
			||||||
			"st	%g0, [$a+%lo($ename+$evalue)]"
 | 
								"st	%g0, [$a+%lo($ename+$evalue)]"
 | 
				
			||||||
			free_reg(a);
 | 
								free_reg(a);
 | 
				
			||||||
| 
						 | 
					@ -2744,7 +2744,7 @@ C_com_narg	==>
 | 
				
			||||||
				b= alloc_reg();
 | 
									b= alloc_reg();
 | 
				
			||||||
				for (i= 0; i< n; i += 4)
 | 
									for (i= 0; i< n; i += 4)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					sprintf(i_str, "%d", i);
 | 
										sprint(i_str, "%d", i);
 | 
				
			||||||
					"ld	[$reg_sp+$i_str], $a";
 | 
										"ld	[$reg_sp+$i_str], $a";
 | 
				
			||||||
					"not	$a, $b";
 | 
										"not	$a, $b";
 | 
				
			||||||
					"st	$b, [$reg_sp+$i_str]";
 | 
										"st	$b, [$reg_sp+$i_str]";
 | 
				
			||||||
| 
						 | 
					@ -2796,9 +2796,9 @@ C_rol
 | 
				
			||||||
					a= pop_reg();
 | 
										a= pop_reg();
 | 
				
			||||||
					b= alloc_reg();
 | 
										b= alloc_reg();
 | 
				
			||||||
					c= alloc_reg();
 | 
										c= alloc_reg();
 | 
				
			||||||
					sprintf(n_str, "%d", n);
 | 
										sprint(n_str, "%d", n);
 | 
				
			||||||
					"sll	$a, $n_str, $b";
 | 
										"sll	$a, $n_str, $b";
 | 
				
			||||||
					sprintf(n_str, "%d", 32-n);
 | 
										sprint(n_str, "%d", 32-n);
 | 
				
			||||||
					"srl	$a, $n_str, $c";
 | 
										"srl	$a, $n_str, $c";
 | 
				
			||||||
					"or	$b, $c, $a";
 | 
										"or	$b, $c, $a";
 | 
				
			||||||
					push_reg(a);
 | 
										push_reg(a);
 | 
				
			||||||
| 
						 | 
					@ -2855,9 +2855,9 @@ C_ror
 | 
				
			||||||
					a= pop_reg();
 | 
										a= pop_reg();
 | 
				
			||||||
					b= alloc_reg();
 | 
										b= alloc_reg();
 | 
				
			||||||
					c= alloc_reg();
 | 
										c= alloc_reg();
 | 
				
			||||||
					sprintf(n_str, "%d", n);
 | 
										sprint(n_str, "%d", n);
 | 
				
			||||||
					"srl	$a, $n_str, $b";
 | 
										"srl	$a, $n_str, $b";
 | 
				
			||||||
					sprintf(n_str, "%d", 32-n);
 | 
										sprint(n_str, "%d", 32-n);
 | 
				
			||||||
					"sll	$a, $n_str, $c";
 | 
										"sll	$a, $n_str, $c";
 | 
				
			||||||
					"or	$b, $c, $a";
 | 
										"or	$b, $c, $a";
 | 
				
			||||||
					push_reg(a);
 | 
										push_reg(a);
 | 
				
			||||||
| 
						 | 
					@ -3020,7 +3020,7 @@ C_inn_narg	==>
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			arg_error ("inn_narg");
 | 
								not_implemented ("inn_narg");
 | 
				
			||||||
	}.
 | 
						}.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
C_set	==>	Comment( set, $1);
 | 
					C_set	==>	Comment( set, $1);
 | 
				
			||||||
| 
						 | 
					@ -3055,7 +3055,7 @@ C_set_narg	==>
 | 
				
			||||||
				c= alloc_reg();
 | 
									c= alloc_reg();
 | 
				
			||||||
				d= alloc_reg();
 | 
									d= alloc_reg();
 | 
				
			||||||
				flush_cache();
 | 
									flush_cache();
 | 
				
			||||||
				sprintf(n_str, "%d", n);
 | 
									sprint(n_str, "%d", n);
 | 
				
			||||||
				"set	$n_str, $a";
 | 
									"set	$n_str, $a";
 | 
				
			||||||
				"sub	$reg_sp, $a, $reg_sp";
 | 
									"sub	$reg_sp, $a, $reg_sp";
 | 
				
			||||||
			"1:";
 | 
								"1:";
 | 
				
			||||||
| 
						 | 
					@ -4164,7 +4164,7 @@ C_dus
 | 
				
			||||||
				"sub	$reg_sp, $n_str, $reg_sp";
 | 
									"sub	$reg_sp, $n_str, $reg_sp";
 | 
				
			||||||
				for (i=0; i<n; i += 4)
 | 
									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";
 | 
										"ld	[$reg_sp+$i_str+$n_str], $a";
 | 
				
			||||||
					"st	$a, [$reg_sp+$i_str]";
 | 
										"st	$a, [$reg_sp+$i_str]";
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -4239,8 +4239,8 @@ C_exg_narg	==>
 | 
				
			||||||
				flush_cache();
 | 
									flush_cache();
 | 
				
			||||||
				for (i=0; i<n; i += 4)
 | 
									for (i=0; i<n; i += 4)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					sprintf(i_str, "%d", i);
 | 
										sprint(i_str, "%d", i);
 | 
				
			||||||
					sprintf(in_str, "%d", i+n);
 | 
										sprint(in_str, "%d", i+n);
 | 
				
			||||||
					"ld	[$reg_sp+$i_str], $a";
 | 
										"ld	[$reg_sp+$i_str], $a";
 | 
				
			||||||
					"ld	[$reg_sp+$in_str], $b";
 | 
										"ld	[$reg_sp+$in_str], $b";
 | 
				
			||||||
					"st	$b, [$reg_sp+$i_str]";
 | 
										"st	$b, [$reg_sp+$i_str]";
 | 
				
			||||||
| 
						 | 
					@ -4344,7 +4344,7 @@ C_lin		==>
 | 
				
			||||||
#ifdef FAST_LIN_LNI_FIL
 | 
					#ifdef FAST_LIN_LNI_FIL
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				const_str_t n_str;
 | 
									const_str_t n_str;
 | 
				
			||||||
				sprintf(n_str, "%d", $1);
 | 
									sprint(n_str, "%d", $1);
 | 
				
			||||||
				"set	$n_str, $reg_fil";
 | 
									"set	$n_str, $reg_fil";
 | 
				
			||||||
			}.
 | 
								}.
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
| 
						 | 
					@ -4506,6 +4506,7 @@ C_sim		==>
 | 
				
			||||||
C_str
 | 
					C_str
 | 
				
			||||||
	$1 == 0		==>
 | 
						$1 == 0		==>
 | 
				
			||||||
				Comment( str , $1 );
 | 
									Comment( str , $1 );
 | 
				
			||||||
 | 
									flush_cache();
 | 
				
			||||||
				"ld	[$reg_sp], $reg_lb";
 | 
									"ld	[$reg_sp], $reg_lb";
 | 
				
			||||||
				"add	$reg_lb, 4, %fp";
 | 
									"add	$reg_lb, 4, %fp";
 | 
				
			||||||
				"and	%fp, -8, %fp";
 | 
									"and	%fp, -8, %fp";
 | 
				
			||||||
| 
						 | 
					@ -4514,7 +4515,8 @@ C_str
 | 
				
			||||||
	$1 == 1		==>
 | 
						$1 == 1		==>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Comment( str , $1 );
 | 
							Comment( str , $1 );
 | 
				
			||||||
		pop_reg_as(reg_sp);
 | 
							flush_cache();
 | 
				
			||||||
 | 
							"ld [$reg_sp], $reg_sp";
 | 
				
			||||||
	}.
 | 
						}.
 | 
				
			||||||
	$1 == 2		==>
 | 
						$1 == 2		==>
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,7 @@
 | 
				
			||||||
#define POP1 cache_need(1);
 | 
					#define POP1 cache_need(1);
 | 
				
			||||||
#define POP2 { --tos; assert(c_count); --c_count; }
 | 
					#define POP2 { --tos; assert(c_count); --c_count; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int indent_count = 0;
 | 
					static int indent_count = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define enter(x) indent_count++;
 | 
					#define enter(x) indent_count++;
 | 
				
			||||||
#define indent() { int i = indent_count; while (i--) putc('\t', stderr); }
 | 
					#define indent() { int i = indent_count; while (i--) putc('\t', stderr); }
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ int indent_count = 0;
 | 
				
			||||||
		push_ext(char *)
 | 
							push_ext(char *)
 | 
				
			||||||
		flush_cache()		after branches and labels
 | 
							flush_cache()		after branches and labels
 | 
				
			||||||
		cache_read(int)		read-ahead. optimization only
 | 
							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
 | 
							pop_nop()		remove element from cache
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		reg_t alloc_reg()
 | 
							reg_t alloc_reg()
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,10 @@ typedef struct cache_elt {
 | 
				
			||||||
	arith	cst;
 | 
						arith	cst;
 | 
				
			||||||
} cache_elt;
 | 
					} 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*/	"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
 | 
				
			||||||
/*x*/	"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i6", "%i7",
 | 
					/*x*/	"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i6", "%i7",
 | 
				
			||||||
/*x*/	"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
 | 
					/*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_sp, reg_lb, reg_gap;
 | 
				
			||||||
reg_t reg_tmp, reg_lin, reg_fil;
 | 
					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 POP_SIZE 1	/* maybe >1  (read-ahead cache) or explicit?! */
 | 
				
			||||||
#define CACHE_SIZE 32	/* ? */
 | 
					#define CACHE_SIZE 32	/* ? */
 | 
				
			||||||
| 
						 | 
					@ -90,14 +93,15 @@ struct regdat_t reg[NR_REGS];
 | 
				
			||||||
#define HI_OUT		31
 | 
					#define HI_OUT		31
 | 
				
			||||||
#define LO_FLOAT	32
 | 
					#define LO_FLOAT	32
 | 
				
			||||||
#define HI_FLOAT	63
 | 
					#define HI_FLOAT	63
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const13(x) 
 | 
					const13(x) 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return (x < 4096 && x >= -4096);
 | 
						return (x < 4096 && x >= -4096);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct cache_elt cache[CACHE_SIZE], *tos = 0;
 | 
					static struct cache_elt cache[CACHE_SIZE], *tos = 0;
 | 
				
			||||||
int c_count = 0;
 | 
					static int c_count = 0;
 | 
				
			||||||
const_str_t s;
 | 
					static const_str_t s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void panic(s)
 | 
					static void panic(s)
 | 
				
			||||||
char *s;
 | 
					char *s;
 | 
				
			||||||
| 
						 | 
					@ -224,15 +228,15 @@ enter("flush_part_cache");
 | 
				
			||||||
	j = i;
 | 
						j = i;
 | 
				
			||||||
	if (i)
 | 
						if (i)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sprintf (i_str, "%d", 4*i);
 | 
							sprint (i_str, "%d", 4*i);
 | 
				
			||||||
		"dec	$i_str, $reg_sp";
 | 
							"dec	$i_str, $reg_sp";
 | 
				
			||||||
		while (i--)
 | 
							while (i--)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			sprintf(i_str, "%d", 4*(j-1-i));
 | 
								sprint(i_str, "%d", 4*(j-1-i));
 | 
				
			||||||
			if (cache[i].ext)
 | 
								if (cache[i].ext)
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ext= 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";
 | 
									"set	$ext+$e_str, $reg_tmp";
 | 
				
			||||||
				"st	$reg_tmp, [$reg_sp+$i_str]";
 | 
									"st	$reg_tmp, [$reg_sp+$i_str]";
 | 
				
			||||||
				free(ext);
 | 
									free(ext);
 | 
				
			||||||
| 
						 | 
					@ -249,7 +253,7 @@ enter("flush_part_cache");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if (!const13(cache[i].cst))
 | 
									if (!const13(cache[i].cst))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					sprintf(n_str, "%d",
 | 
										sprint(n_str, "%d",
 | 
				
			||||||
						cache[i].cst);
 | 
											cache[i].cst);
 | 
				
			||||||
					"sethi	%hi($n_str), $reg_tmp";
 | 
										"sethi	%hi($n_str), $reg_tmp";
 | 
				
			||||||
					if (cache[i].reg != reg_g0)
 | 
										if (cache[i].reg != reg_g0)
 | 
				
			||||||
| 
						 | 
					@ -265,7 +269,7 @@ enter("flush_part_cache");
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				if (cache[i].cst)
 | 
									if (cache[i].cst)
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					sprintf(n_str, "%d", cache[i].cst);
 | 
										sprint(n_str, "%d", cache[i].cst);
 | 
				
			||||||
					"add	$rh, $n_str, $reg_tmp";
 | 
										"add	$rh, $n_str, $reg_tmp";
 | 
				
			||||||
					rh= reg_tmp;
 | 
										rh= reg_tmp;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -658,16 +662,16 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); }
 | 
				
			||||||
		assert(tos->reg == reg_g0);
 | 
							assert(tos->reg == reg_g0);
 | 
				
			||||||
		S1 = alloc_reg();
 | 
							S1 = alloc_reg();
 | 
				
			||||||
		V1 = tos->ext;
 | 
							V1 = tos->ext;
 | 
				
			||||||
		sprintf(V2, "%d", tos->cst);
 | 
							sprint(V2, "%d", tos->cst);
 | 
				
			||||||
		"sethi	%hi($V1+$V2), $S1";
 | 
							"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);
 | 
							free(V1);
 | 
				
			||||||
		POP2;
 | 
							POP2;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		S1 = tos->reg;
 | 
							S1 = tos->reg;
 | 
				
			||||||
		if (!(const13(tos->cst))) {
 | 
							if (!(const13(tos->cst))) {
 | 
				
			||||||
			S3 = alloc_reg();
 | 
								S3 = alloc_reg();
 | 
				
			||||||
			sprintf(V2, "%d", tos->cst);
 | 
								sprint(V2, "%d", tos->cst);
 | 
				
			||||||
			"sethi	%hi($V2), $S3";
 | 
								"sethi	%hi($V2), $S3";
 | 
				
			||||||
			if (tos->reg != reg_g0) {
 | 
								if (tos->reg != reg_g0) {
 | 
				
			||||||
				S2 = alloc_reg();
 | 
									S2 = alloc_reg();
 | 
				
			||||||
| 
						 | 
					@ -678,7 +682,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_c13()=...\n"); }
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			tos->cst &= 0x3FF;
 | 
								tos->cst &= 0x3FF;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		sprintf(n, "%d", tos->cst);
 | 
							sprint(n, "%d", tos->cst);
 | 
				
			||||||
		POP2;
 | 
							POP2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
if (debug) { indent(); fprint(codefile, "\t\t! %s+%s cache:", S1, n); dump_cache(codefile);}
 | 
					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();
 | 
						x = top_const();
 | 
				
			||||||
	POP2;
 | 
						POP2;
 | 
				
			||||||
	if (n)
 | 
						if (n)
 | 
				
			||||||
		sprintf(n, "%d", x);
 | 
							sprint(n, "%d", x);
 | 
				
			||||||
if (debug) { indent(); fprint(codefile, "\t\t! %d cache:", x); dump_cache(codefile); }
 | 
					if (debug) { indent(); fprint(codefile, "\t\t! %d cache:", x); dump_cache(codefile); }
 | 
				
			||||||
leave("pop_const");
 | 
					leave("pop_const");
 | 
				
			||||||
	return x;
 | 
						return x;
 | 
				
			||||||
| 
						 | 
					@ -890,7 +894,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); }
 | 
				
			||||||
	} else if (tos->ext) {
 | 
						} else if (tos->ext) {
 | 
				
			||||||
		assert(tos->reg == reg_g0);
 | 
							assert(tos->reg == reg_g0);
 | 
				
			||||||
		V1 = tos->ext;
 | 
							V1 = tos->ext;
 | 
				
			||||||
		sprintf(V2, "%d", tos->cst);
 | 
							sprint(V2, "%d", tos->cst);
 | 
				
			||||||
		"set	$V1+$V2, $r";
 | 
							"set	$V1+$V2, $r";
 | 
				
			||||||
		free(V1);
 | 
							free(V1);
 | 
				
			||||||
		POP2;
 | 
							POP2;
 | 
				
			||||||
| 
						 | 
					@ -911,7 +915,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); }
 | 
				
			||||||
				soft_alloc_reg(r);
 | 
									soft_alloc_reg(r);
 | 
				
			||||||
				tos_reg2= r;
 | 
									tos_reg2= r;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			sprintf(c_str, "%d", tos_cst);
 | 
								sprint(c_str, "%d", tos_cst);
 | 
				
			||||||
			"sethi	%hi($c_str), $tos_reg2";
 | 
								"sethi	%hi($c_str), $tos_reg2";
 | 
				
			||||||
			tos_cst &= 0x3ff;
 | 
								tos_cst &= 0x3ff;
 | 
				
			||||||
			if (tos_reg == reg_g0)
 | 
								if (tos_reg == reg_g0)
 | 
				
			||||||
| 
						 | 
					@ -938,7 +942,7 @@ if (debug) { indent(); fprintf(stderr,"pop_reg_as(%s)=...\n", r); }
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (tos_cst)
 | 
							if (tos_cst)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			sprintf(c_str, "%d", tos_cst);
 | 
								sprint(c_str, "%d", tos_cst);
 | 
				
			||||||
			soft_alloc_reg(r);
 | 
								soft_alloc_reg(r);
 | 
				
			||||||
			"add	$tos_reg, $c_str, $r";
 | 
								"add	$tos_reg, $c_str, $r";
 | 
				
			||||||
			free_reg(tos_reg);
 | 
								free_reg(tos_reg);
 | 
				
			||||||
| 
						 | 
					@ -1134,7 +1138,7 @@ enter("pop_nop");
 | 
				
			||||||
		POP2;
 | 
							POP2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (i) {
 | 
						if (i) {
 | 
				
			||||||
		sprintf(V1, "%d", 4*i);
 | 
							sprint(V1, "%d", 4*i);
 | 
				
			||||||
		if (const13(4*i)) {
 | 
							if (const13(4*i)) {
 | 
				
			||||||
			"inc	$V1, %l0";
 | 
								"inc	$V1, %l0";
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					@ -1195,7 +1199,7 @@ if (debug) { indent(); fprintf(stderr,"cache_read(%d, %d)\n", n,i); }
 | 
				
			||||||
		S1= alloc_reg();
 | 
							S1= alloc_reg();
 | 
				
			||||||
		old_c_count = cache_read(n, i+1);
 | 
							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";
 | 
							"ld	[%l0+$V1], $S1";
 | 
				
			||||||
		cache[i].reg= S1;
 | 
							cache[i].reg= S1;
 | 
				
			||||||
		cache[i].reg2= reg_g0;
 | 
							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;
 | 
							cache[i].cst= 0;
 | 
				
			||||||
		if (!i)
 | 
							if (!i)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			sprintf(V1, "%d", (old_c_count)*4);
 | 
								sprint(V1, "%d", (old_c_count)*4);
 | 
				
			||||||
			"add	$reg_sp, $V1, $reg_sp";
 | 
								"add	$reg_sp, $V1, $reg_sp";
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -1277,7 +1281,7 @@ enter("dup_tos");
 | 
				
			||||||
			soft_alloc_reg(tos->reg2);
 | 
								soft_alloc_reg(tos->reg2);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			a= alloc_reg();
 | 
								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";
 | 
								"ld	[$reg_sp+$i_str], $a";
 | 
				
			||||||
			tos->reg = a;
 | 
								tos->reg = a;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,9 +5,87 @@ mach.h
 | 
				
			||||||
#ifndef MACH_H
 | 
					#ifndef MACH_H
 | 
				
			||||||
#define MACH_H
 | 
					#define MACH_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define con_str B_constr
 | 
					#define alloc_double B_alloc_double
 | 
				
			||||||
#define rom_str B_romstr
 | 
					#define alloc_double_var B_allc_double_var
 | 
				
			||||||
#define gen_str B_genstr
 | 
					#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 "ctype.h"
 | 
				
			||||||
#include "mach_em.h"
 | 
					#include "mach_em.h"
 | 
				
			||||||
| 
						 | 
					@ -16,9 +94,9 @@ mach.h
 | 
				
			||||||
#include "misc.h"
 | 
					#include "misc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if RESOLV_debug
 | 
					#if RESOLV_debug
 | 
				
			||||||
	#define debug 0
 | 
					#define debug 0
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	extern int debug;
 | 
					extern int debug;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* MACH_H */
 | 
					#endif /* MACH_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
#define DEBUG 1
 | 
					#undef DEBUG 1
 | 
				
			||||||
#include <sun4/asm_linkage.h>
 | 
					#include <sun4/asm_linkage.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define BYTES_REVERSED
 | 
					#define BYTES_REVERSED
 | 
				
			||||||
| 
						 | 
					@ -55,5 +55,7 @@
 | 
				
			||||||
#define MATH_DIVIDE	1
 | 
					#define MATH_DIVIDE	1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef DEBUG
 | 
					#ifndef DEBUG
 | 
				
			||||||
 | 
					#undef arg_error
 | 
				
			||||||
#define arg_error(s,i)
 | 
					#define arg_error(s,i)
 | 
				
			||||||
 | 
					#define RESOLV_debug 1
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,9 @@ misc.h
 | 
				
			||||||
#ifndef MISC_H
 | 
					#ifndef MISC_H
 | 
				
			||||||
#define 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));
 | 
					_PROTOTYPE( int power_of_2, (int n, int *ref_exp));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* MISC_H */
 | 
					#endif /* MISC_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,12 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "push_pop.h"
 | 
					#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*));
 | 
					_PROTOTYPE(reg_t find_local, (int, reg_t*));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,8 +17,6 @@ typedef struct cache_elt {
 | 
				
			||||||
	arith	cst;
 | 
						arith	cst;
 | 
				
			||||||
} cache_elt;
 | 
					} cache_elt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define REG_NUM(r) (((char(*)[8])(r))-regnam)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define T_cst	1
 | 
					#define T_cst	1
 | 
				
			||||||
#define T_ext	2
 | 
					#define T_ext	2
 | 
				
			||||||
#define T_reg	4
 | 
					#define T_reg	4
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue