It is occasionally useful to test a constraint from C code rather than
implicitly via the constraint string in a
generated file tm_p.h declares a few interfaces for working
with machine-specific constraints. None of these interfaces work with
the generic constraints described in Simple Constraints. This
may change in the future.
Warning: tm_p.h may declare other functions that operate on constraints, besides the ones documented here. Do not use those functions from machine-dependent code. They exist to implement the old constraint interface that machine-independent components of the compiler still expect. They will change or disappear in the future.
Some valid constraint names are not valid C identifiers, so there is a mangling scheme for referring to them from C. Constraint names that do not contain angle brackets or underscores are left unchanged. Underscores are doubled, each `<' is replaced with `_l', and each `>' with `_g'. Here are some examples:
Throughout this section, the variable c is either a constraint
in the abstract sense, or a constant from
the variable m is a mangled constraint name (usually as part of
a larger identifier).
For each machine-specific constraint, there is a corresponding enumeration constant: `CONSTRAINT_' plus the mangled name of the constraint. Functions that take an
enum constraint_numas an argument expect one of these constants.
Machine-independent constraints do not have associated constants. This may change in the future.
For each machine-specific, non-register constraint m, there is one of these functions; it returns
trueif exp satisfies the constraint. These functions are only visible if rtl.h was included before tm_p.h.
satisfies_constraint_m functions, but the constraint to test is given as an argument, c. If c specifies a register constraint, this function will always return
Returns the register class associated with c. If c is not a register constraint, or those registers are not available for the currently selected subtarget, returns
Here is an example use of
peephole optimizations (see Peephole Definitions), operand
constraint strings are ignored, so if there are relevant constraints,
they must be tested in the C condition. In the example, the
optimization is applied if operand 2 does not satisfy the
`K' constraint. (This is a simplified version of a peephole
definition from the i386 machine description.)
(define_peephole2 [(match_scratch:SI 3 "r") (set (match_operand:SI 0 "register_operand" "") (mult:SI (match_operand:SI 1 "memory_operand" "") (match_operand:SI 2 "immediate_operand" "")))] "!satisfies_constraint_K (operands)" [(set (match_dup 3) (match_dup 1)) (set (match_dup 0) (mult:SI (match_dup 3) (match_dup 2)))] "")