Mode Switching Instructions#
The following macros control mode switching optimizations:
-
OPTIMIZE_MODE_SWITCHING(entity)#
Define this macro if the port needs extra instructions inserted for mode switching in an optimizing compilation.
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 cannot put this into instruction emitting or
TARGET_MACHINE_DEPENDENT_REORG.You can have multiple entities that are mode-switched, and select at run time which entities actually need it.
OPTIMIZE_MODE_SWITCHINGshould return nonzero for anyentitythat needs mode-switching. If you define this macro, you also have to defineNUM_MODES_FOR_MODE_SWITCHING,TARGET_MODE_NEEDED,TARGET_MODE_PRIORITYandTARGET_MODE_EMIT.TARGET_MODE_AFTER,TARGET_MODE_ENTRY, andTARGET_MODE_EXITare optional.
-
NUM_MODES_FOR_MODE_SWITCHING#
If you define
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.
-
void TARGET_MODE_EMIT(int entity, int mode, int prev_mode, HARD_REG_SET regs_live)#
Generate one or more insns to set
entitytomode.hard_reg_liveis the set of hard registers live at the point where the insn(s) are to be inserted.prev_moxdeindicates the mode to switch from. Sets of a lower numbered entity will be emitted before sets of a higher numbered entity to a mode of the same or lower priority.
-
int TARGET_MODE_NEEDED(int entity, rtx_insn *insn)#
entityis an integer specifying a mode-switched entity. IfOPTIMIZE_MODE_SWITCHINGis defined, you must define this macro to return an integer value not larger than the corresponding element inNUM_MODES_FOR_MODE_SWITCHING, to denote the mode thatentitymust be switched into prior to the execution ofinsn.
-
int TARGET_MODE_AFTER(int entity, int mode, rtx_insn *insn)#
entityis an integer specifying a mode-switched entity. If this macro is defined, it is evaluated for everyinsnduring mode switching. It determines the mode that an insn results in (if different from the incoming mode).
-
int TARGET_MODE_ENTRY(int entity)#
If this macro is defined, it is evaluated for every
entitythat needs mode switching. It should evaluate to an integer, which is a mode thatentityis assumed to be switched to at function entry. IfTARGET_MODE_ENTRYis defined thenTARGET_MODE_EXITmust be defined.
-
int TARGET_MODE_EXIT(int entity)#
If this macro is defined, it is evaluated for every
entitythat needs mode switching. It should evaluate to an integer, which is a mode thatentityis assumed to be switched to at function exit. IfTARGET_MODE_EXITis defined thenTARGET_MODE_ENTRYmust be defined.
-
int TARGET_MODE_PRIORITY(int entity, int n)#
This macro specifies the order in which modes for
entityare processed. 0 is the highest priority,NUM_MODES_FOR_MODE_SWITCHING[entity] - 1the lowest. The value of the macro should be an integer designating a mode forentity. For any fixedentity,mode_priority(entity,n) shall be a bijection in 0 …num_modes_for_mode_switching[entity] - 1.