public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Georg-Johann Lay <avr@gjlay.de>
To: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>, gcc@gcc.gnu.org
Subject: Re: Setting insn mnemonic partly automagically
Date: Fri, 21 Jun 2024 21:50:43 +0200	[thread overview]
Message-ID: <fca3155c-7064-4ed2-9105-faf58b9c91b8@gjlay.de> (raw)
In-Reply-To: <ZnCK4TFSA66NOzzY@li-819a89cc-2401-11b2-a85c-cca1ce6aa768.ibm.com>



Am 17.06.24 um 21:13 schrieb Stefan Schulze Frielinghaus via Gcc:
> Hi all,
> 
> I'm trying to add an alternative to an existing insn foobar:
> 
> (define_insn "foobar"
>    [(set (match_operand ...)
>          (match_operand ...))]
>    ""
>    "@
>     foo
>     bar
>     #")
> 
> Since the asm output depends on the operands in a non-trivial way which isn't
> easily solved via iterators, I went for a general C function and came up with:
> 
> (define_insn "foobar"
>    [(set (match_operand ...)
>          (match_operand ...))]
>    ""
>    "@
>     foo
>     * return foobar_helper (operands[0], operands[1]);
>     bar
>     #"
>    [(set_attr_alternative "mnemonic" [(const_string "foo")
>                                       (const_string "specialcase")
>                                       (const_string "bar")
>                                       (const_string "unknown")])])
> 
> If there exist a lot of alternatives, then setting the mnemonic attribute like
> this feels repetitive and is error prone.  Furthermore, if there exists no
> other insn with an output template containing foo/bar, then I would have to
> declare foo/bar via
> 
> (define_attr "mnemonic" "...,foo,bar,..." (const_string "unknown"))
> 
> which again is repetitive.  Thus, I'm wondering if there exists a more elegant
> way to achieve this?  Ultimately, I would like to set the mnemonic
> attribute only manually for the alternative which is implemented via C
> code and let the mnemonic attribute for the remaining alternatives be
> set automagically.  Not sure whether this is supported?
> 
> If all fails, I have another idea how to solve this by utilizing PRINT_OPERAND.
> However, now I'm curious whether my current attempt is feasible or not.
> 
> Cheers,
> Stefan

It's a bit unclear to me what you are trying to do, as you are not only
adding an insn alternative, but also are adding insn attribute
"mnemonic", which the original insn did not have.

Also, it's unclear how PRINT_OPERAND would help with setting the attribute.

Johann

  reply	other threads:[~2024-06-21 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 19:13 Stefan Schulze Frielinghaus
2024-06-21 19:50 ` Georg-Johann Lay [this message]
2024-06-22  8:46   ` Stefan Schulze Frielinghaus
2024-06-22 11:00     ` Georg-Johann Lay
2024-06-22 15:24       ` Stefan Schulze Frielinghaus

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=fca3155c-7064-4ed2-9105-faf58b9c91b8@gjlay.de \
    --to=avr@gjlay.de \
    --cc=gcc@gcc.gnu.org \
    --cc=stefansf@linux.ibm.com \
    /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).