This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Prefer reg as first operand in commutative operator


On Wed, Feb 15, 2012 at 10:04:15AM +0000, Paulo J. Matos wrote:
> It doesn't look like you can actually do that because, according to
> the internals manual:
> "For a named pattern, the condition (if present) may not depend on
> the data in the insn being matched, but only the target-machine-type
> flags. The compiler needs to test these conditions during
> initialization in order to learn exactly which named instructions
> are available in a particular run."
> 
> And GCC complains with:
> insn-opinit.c: In function 'init_all_optabs':
> insn-opinit.c:24: error: 'operands' undeclared (first use in this function)
> insn-opinit.c:24: error: (Each undeclared identifier is reported only once
> insn-opinit.c:24: error: for each function it appears in.)
> 
> Did I miss something in the example?

In define_expand (or define_insn of a standard named pattern) you can't use
operands, those conditions are used to select whether the given insn is
available at all.  But you can use it in define_insn conditions for other
insn patterns.
So you can have
(define_expand "iorqi3"
  ...
  "")

(define_insn "*iorqi3"
  ...
  "register_operand (operands[1], QImode) || register_operand (operands[2], QImode)"
...
)

See config/i386/i386.md for thousands of examples.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]