[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: patch, shift on sparc64
From:       Anders Magnusson <ragge () ludd ! ltu ! se>
Date:       2008-06-19 21:08:15
Message-ID: 485ACABF.8090006 () ludd ! ltu ! se
[Download RAW message or body]

Karl Knutsson wrote:
> Hi,
>
> There is a problem with how the sparc64 backend generates shift 
> instructions. Without any optimization pcc generates shift 
> instructions that operate on memory addresses. This causes the 
> attached test program to fail with:
>   
>> pcc shift.c
>>     
> /tmp/ctm.21744a: Assembler messages:
> /tmp/ctm.21744a:12: Error: Illegal operands
>
> The offending assembly line looks like this:
> 	sll %o0,%fp+2039,%o0			! shift left
>
> The attached patch fixes the problem.
>   
Thanks for your patch, the sparc maintainer is currently offline, but I
have checked in your patch now anyway :-)

-- Ragge


> br
> Karl Knutsson
>
>
>
>
>   
> ------------------------------------------------------------------------
>
> Index: table.c
> ===================================================================
> RCS file: /cvsroot/pcc/arch/sparc64/table.c,v
> retrieving revision 1.22
> diff -u -r1.22 table.c
> --- table.c	11 Feb 2008 17:48:32 -0000	1.22
> +++ table.c	20 Apr 2008 13:44:51 -0000
> @@ -264,25 +264,25 @@
>  
>  { RS,	INAREG,
>  	SAREG,	TINT|TUNSIGNED|TSHORT|TUSHORT|TCHAR|TUCHAR,
> -	SANY,	TANY,
> +	SAREG|SCON,	TINT|TUNSIGNED|TSHORT|TUSHORT|TCHAR|TUCHAR,
>  		NAREG|NASL,	RESC1,
>  		"	sra AL,AR,A1			! shift right\n", },
>  
>  { RS,	INAREG,
>  	SAREG,	T64,
> -	SANY,	TANY,
> +	SAREG|SCON,	TINT|TUNSIGNED|TSHORT|TUSHORT|TCHAR|TUCHAR,
>  		NAREG|NASL,	RESC1,
>  		"	srax AL,AR,A1			! shift right\n", },
>  
>  { LS,	INAREG,
>  	SAREG,	TINT|TUNSIGNED|TSHORT|TUSHORT|TCHAR|TUCHAR,
> -	SANY,	TANY,
> +	SAREG|SCON,	TINT|TUNSIGNED|TSHORT|TUSHORT|TCHAR|TUCHAR,
>  		NAREG|NASL,	RESC1,
>  		"	sll AL,AR,A1			! shift left\n", },
>  
>  { LS,	INAREG,
>  	SAREG,	T64,
> -	SANY,	TANY,
> +	SAREG|SCON,	TINT|TUNSIGNED|TSHORT|TUSHORT|TCHAR|TUCHAR,
>  		NAREG|NASL,	RESC1,
>  		"	sllx AL,AR,A1			! shift left\n", },
>  
>   
> ------------------------------------------------------------------------
>
>
> unsigned int
> shift(unsigned int a)
> {
> 	unsigned int ret;
>
> 	ret = 1 << a;
>
> 	return ret;
> }
>
> int
> main()
> {
> 	unsigned int i = 1;
>
> 	i = shift(1);
>
> 	return 0;
> }
>
>   

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic