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

Reply via email to