public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Setting insn mnemonic partly automagically
@ 2024-06-17 19:13 Stefan Schulze Frielinghaus
  2024-06-21 19:50 ` Georg-Johann Lay
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Schulze Frielinghaus @ 2024-06-17 19:13 UTC (permalink / raw)
  To: 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-06-22 16:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 19:13 Setting insn mnemonic partly automagically Stefan Schulze Frielinghaus
2024-06-21 19:50 ` Georg-Johann Lay
2024-06-22  8:46   ` Stefan Schulze Frielinghaus
2024-06-22 11:00     ` Georg-Johann Lay
2024-06-22 15:24       ` Stefan Schulze Frielinghaus

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).