patch to fix SH4 mode-switching problems
Joern Rennecke
amylaar@cygnus.co.uk
Wed Jan 12 09:18:00 GMT 2000
> You're missing the entire point. FPSCR should not be appearing at
> all in the generic source.
The examples for other uses you have mentioned so far involve a floating
point control register of some description.
> Think at a higher level, please.
>
> Conceptually you want the generic code to query the backend about whether or
> not an insn has a particular property. The optimizer doesn't know or care
> about the property itself.
>
> The property in your case is the state of fpscr, for another chip it
> might be the rounding mode of the FPU, or something completely unrelated.
Well, it must be related in some way, otherwise we wouldn't bother to
shoe-horn the existing code to do some work for us.
Since you mentioned optimize_mode_switching as a function name proposal,
I suppose I can assume that mode-switching of some kind is to be handled.
In general, there might be multiple entities that need their mode switched.
So I propose the following macros:
NUM_MODES_FOR_MODE_SWITCHING
This is an 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.
OPTIMIZE_MODE_SWITCHING(ENTITY)
This macro return nonzero if optimized mode-switching insertion is to be
performed for ENTITY in an optimized compilation.
MODE_USES_IN_EXIT_BLOCK
If this macro is defined, it is called for each exit block. Its return
value should be the pattern of an insn, or a sequence of insns. It is
emitted before the return insn / use insns at the end of the exit block.
This is done before insns are examined for their need of any mode switching.
MODE_NEEDED(ENTITY, INSN):
ENTITY is an integer specifying a mode-switched entity. This macro must
return an integer value not larger than the corresponding element in
NUM_MODES_FOR_MODE_SWITCHING, to denote the mode the entity must be switched
into prior to the execution of INSN.
MODE_AT_ENTRY(ENTITY)
If this macro is defined, it is evaluated for every ENTITY that needs mode
switching. It should evaluate to an integer, which is a mode that ENTITY
is assumed to be switched to at function entry.
MODE_PRIORITY_TO_MODE(ENTITY, N)
This macro specifies the order in which modes for ENTITY are processed.
0 is the highest priority, 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)
Generate one or more insns to set ENTITY to MODE. HARD_REG_LIVE is
the set of hard registers live at the point where the insn(s) are to
be inserted.
More information about the Gcc-patches
mailing list