This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Porting question: define_expand Vs define_split
- From: Daniel Jacobowitz <drow at false dot org>
- To: Balaji S <sivanbalaji at acmet dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 3 Nov 2004 11:52:43 -0500
- Subject: Re: Porting question: define_expand Vs define_split
- References: <41887D89.4020109@acmet.com>
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