This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Porting question: define_expand Vs define_split


On Wed, Nov 03, 2004 at 12:11:13PM +0530, Balaji S wrote:
> Hi all,
> I am porting GCC to a new architecture using stormy16 as base.
> 
> In my architecture there is no instruction for /neg/ operation. So i 
> planned to handle it using /sub/. I am able to accomplish this job by using 
> either define_expand or define_split without knowing its internals as 
> follows:
> 
> (define_expand "neghi2"
>  [(set (match_operand:HI 0 "register_operand" "")
> 	(const_int 0))
>   (set (match_dup 0)
> 	(minus:HI (match_dup 0)
> 		  (match_operand:HI 1 "register_operand" "")))]
>  ""
>  "")
> 
> (define_insn_and_split "neghi2"
>  [(set (match_operand:HI 0 "register_operand" "=r")
> 	(neg:HI (match_operand:HI 1 "register_operand" "0")))]
>  ""
>  "#"
>  "reload_completed"
>  [(set (match_dup 0)
> 	(const_int 0))
>   (set (match_dup 0)
> 	(minus:HI (match_dup 0)
> 		  (match_dup 1)))]
>  "")
> 
> I do not know whether the above m/c descriptions are correct. Please 
> correct me if any mistakes.

The splitter is not correct.  You have constrained the input and output
to be in the same register, and are overwriting that register with 0. 
The constraints would have to be "=&r" and "r".

-- 
Daniel Jacobowitz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]