gccint: Predicates

1 
1 17.7 Predicates
1 ===============
1 
1 A predicate determines whether a 'match_operand' or 'match_operator'
1 expression matches, and therefore whether the surrounding instruction
1 pattern will be used for that combination of operands.  GCC has a number
1 of machine-independent predicates, and you can define machine-specific
1 predicates as needed.  By convention, predicates used with
1 'match_operand' have names that end in '_operand', and those used with
1 'match_operator' have names that end in '_operator'.
1 
1  All predicates are boolean functions (in the mathematical sense) of two
1 arguments: the RTL expression that is being considered at that position
1 in the instruction pattern, and the machine mode that the
1 'match_operand' or 'match_operator' specifies.  In this section, the
1 first argument is called OP and the second argument MODE.  Predicates
1 can be called from C as ordinary two-argument functions; this can be
1 useful in output templates or other machine-specific code.
1 
1  Operand predicates can allow operands that are not actually acceptable
1 to the hardware, as long as the constraints give reload the ability to
1 fix them up (⇒Constraints).  However, GCC will usually generate
1 better code if the predicates specify the requirements of the machine
1 instructions as closely as possible.  Reload cannot fix up operands that
1 must be constants ("immediate operands"); you must use a predicate that
1 allows only constants, or else enforce the requirement in the extra
1 condition.
1 
1  Most predicates handle their MODE argument in a uniform manner.  If
1 MODE is 'VOIDmode' (unspecified), then OP can have any mode.  If MODE is
1 anything else, then OP must have the same mode, unless OP is a
1 'CONST_INT' or integer 'CONST_DOUBLE'.  These RTL expressions always
1 have 'VOIDmode', so it would be counterproductive to check that their
1 mode matches.  Instead, predicates that accept 'CONST_INT' and/or
1 integer 'CONST_DOUBLE' check that the value stored in the constant will
1 fit in the requested mode.
1 
1  Predicates with this behavior are called "normal".  'genrecog' can
1 optimize the instruction recognizer based on knowledge of how normal
1 predicates treat modes.  It can also diagnose certain kinds of common
1 errors in the use of normal predicates; for instance, it is almost
1 always an error to use a normal predicate without specifying a mode.
1 
1  Predicates that do something different with their MODE argument are
1 called "special".  The generic predicates 'address_operand' and
1 'pmode_register_operand' are special predicates.  'genrecog' does not do
1 any optimizations or diagnosis when special predicates are used.
1 

Menu