From: Ian Lance Taylor <iant@google.com>
To: Boris Boesler <baembel@gmx.de>
Cc: GCC <gcc@gcc.gnu.org>
Subject: Re: Allocating scratch register
Date: Wed, 09 Jan 2008 22:55:00 -0000 [thread overview]
Message-ID: <m3wsqir4o2.fsf@localhost.localdomain> (raw)
In-Reply-To: <35528597-A9DA-4D81-8EE4-4192FE591628@gmx.de>
Boris Boesler <baembel@gmx.de> writes:
> I'm trying to allocate a scratch register: write immediate constant
> into scratch register r, write register r into memory
>
> ;; write imm into memory
> (define_insn_and_split "mov<mode>_imm_by_store"
> [(set (match_operand:I8I16 0 "memory_operand" "=m")
> (match_operand:I8I16 1 "immediate_operand" " i"))
> (clobber (match_scratch:I8I16 2 "=r"))]
> ""
> "#"
> ""
> [(parallel
> [(set (match_dup 2) (match_dup 1))
> (set (match_dup 0) (match_dup 2))])]
> ""
> )
>
> I found that in a mips back-end. But this pattern is not recognized
> during code-generation [char c1; c1 = 1;]:
> simple-memory.c:19: error: unrecognizable insn:
> (insn 12 11 14 3 (set (mem/c/i:QI (reg/f:SI 105) [0 c1+0 S8])
> (const_int 1 [0x1])) -1 (nil)
> (nil))
>
> If I remove the clobber command and replace (match_dup 2) by
> (reg:I8I16 A15_REGNUM) code will be generated (but not as wanted).
>
> What is wrong with the code above?
There is nothing wrong with that code, but nothing is going to make
the compiler use it. Moves are special. If you need a scratch
register to do a move, then you need to look at the
TARGET_SECONDARY_RELOAD hook.
But if the problem is only that you need a register to store a
constant into memory, then you should be able to do that using
register constraints on your mov<mode> insn.
Ian
next prev parent reply other threads:[~2008-01-09 22:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-09 18:26 Boris Boesler
2008-01-09 22:55 ` Ian Lance Taylor [this message]
2008-01-10 16:22 ` Boris Boesler
2008-01-10 16:47 ` Paul Brook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3wsqir4o2.fsf@localhost.localdomain \
--to=iant@google.com \
--cc=baembel@gmx.de \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).