Node:Mode Switching, Next:Target Attributes, Previous:Cross-compilation, Up:Target Macros
The following macros control mode switching optimizations:
OPTIMIZE_MODE_SWITCHING (entity)
For an example, the SH4 can perform both single and double precision
floating point operations, but to perform a single precision operation,
the FPSCR PR bit has to be cleared, while for a double precision
operation, this bit has to be set. Changing the PR bit requires a general
purpose register as a scratch register, hence these FPSCR sets have to
be inserted before reload, i.e. you can't put this into instruction emitting
or MACHINE_DEPENDENT_REORG
.
You can have multiple entities that are mode-switched, and select at run time
which entities actually need it. OPTIMIZE_MODE_SWITCHING
should
return nonzero for any entity that needs mode-switching.
If you define this macro, you also have to define
NUM_MODES_FOR_MODE_SWITCHING
, MODE_NEEDED
,
MODE_PRIORITY_TO_MODE
and EMIT_MODE_SET
.
NORMAL_MODE
is optional.
NUM_MODES_FOR_MODE_SWITCHING
OPTIMIZE_MODE_SWITCHING
, you have to define this as
initializer for an array of integers. Each initializer element
N refers to an entity that needs mode switching, and specifies the number
of different modes that might need to be set for this entity.
The position of the initializer in the initializer - starting counting at
zero - determines the integer that is used to refer to the mode-switched
entity in question.
In macros that take mode arguments / yield a mode result, modes are
represented as numbers 0 ... N - 1. N is used to specify that no mode
switch is needed / supplied.
MODE_NEEDED (entity, insn)
OPTIMIZE_MODE_SWITCHING
is defined, you must define this macro to
return an integer value not larger than the corresponding element in
NUM_MODES_FOR_MODE_SWITCHING
, to denote the mode that entity must
be switched into prior to the execution of insn.
NORMAL_MODE (entity)
MODE_PRIORITY_TO_MODE (entity, n)
NUM_MODES_FOR_MODE_SWITCHING[entity] - 1
the
lowest. The value of the macro should be an integer designating a mode
for entity. For any fixed entity, mode_priority_to_mode
(entity, n) shall be a bijection in 0 ...
num_modes_for_mode_switching[entity] - 1
.
EMIT_MODE_SET (entity, mode, hard_regs_live)