extern state_t curr_state;
/* Type to represent status of a dependence. */
-typedef int ds_t;
+typedef unsigned int ds_t;
+#define BITS_PER_DEP_STATUS HOST_BITS_PER_INT
/* Type to represent weakness of speculative dependence. */
-typedef int dw_t;
+typedef unsigned int dw_t;
extern enum reg_note ds_to_dk (ds_t);
extern ds_t dk_to_ds (enum reg_note);
unsigned int cant_move : 1;
};
+\f
/* Bits used for storing values of the fields in the following
structure. */
#define INCREASE_BITS 8
#define IS_SPECULATION_BRANCHY_CHECK_P(INSN) \
(RECOVERY_BLOCK (INSN) != NULL && RECOVERY_BLOCK (INSN) != EXIT_BLOCK_PTR)
-/* Dep status (aka ds_t) of the link encapsulates information, that is needed
- for speculative scheduling. Namely, it is 4 integers in the range
- [0, MAX_DEP_WEAK] and 3 bits.
- The integers correspond to the probability of the dependence to *not*
- exist, it is the probability, that overcoming of this dependence will
- not be followed by execution of the recovery code. Nevertheless,
- whatever high the probability of success is, recovery code should still
- be generated to preserve semantics of the program. To find a way to
- get/set these integers, please refer to the {get, set}_dep_weak ()
- functions in sched-deps.c .
- The 3 bits in the DEP_STATUS correspond to 3 dependence types: true-,
- output- and anti- dependence. It is not enough for speculative scheduling
- to know just the major type of all the dependence between two instructions,
- as only true dependence can be overcome.
- There also is the 4-th bit in the DEP_STATUS (HARD_DEP), that is reserved
- for using to describe instruction's status. It is set whenever instruction
- has at least one dependence, that cannot be overcame.
- See also: check_dep_status () in sched-deps.c . */
+\f
+/* Dep status (aka ds_t) of the link encapsulates all information for a given
+ dependency, including everything that is needed for speculative scheduling.
+
+ The lay-out of a ds_t is as follows:
+
+ 1. Integers corresponding to the probability of the dependence to *not*
+ exist. This is the probability that overcoming this dependence will
+ not be followed by execution of the recovery code. Note that however
+ high this probability is, the recovery code should still always be
+ generated to preserve semantics of the program.
+
+ The probability values can be set or retrieved using the functions
+ the set_dep_weak() and get_dep_weak() in sched-deps.c. The values
+ are always in the range [0, MAX_DEP_WEAK].
+
+ BEGIN_DATA : BITS_PER_DEP_WEAK
+ BE_IN_DATA : BITS_PER_DEP_WEAK
+ BEGIN_CONTROL : BITS_PER_DEP_WEAK
+ BE_IN_CONTROL : BITS_PER_DEP_WEAK
+
+ The basic type of DS_T is a host int. For a 32-bits int, the values
+ will each take 6 bits.
-/* We exclude sign bit. */
-#define BITS_PER_DEP_STATUS (HOST_BITS_PER_INT - 1)
+ 2. The type of dependence. This supercedes the old-style REG_NOTE_KIND
+ values. TODO: Use this field instead of DEP_TYPE, or make DEP_TYPE
+ extract the dependence type from here.
-/* First '6' stands for 4 dep type bits and the HARD_DEP and DEP_CANCELLED
- bits.
- Second '4' stands for BEGIN_{DATA, CONTROL}, BE_IN_{DATA, CONTROL}
- dep weakness. */
-#define BITS_PER_DEP_WEAK ((BITS_PER_DEP_STATUS - 6) / 4)
+ dep_type : 4 => DEP_{TRUE|OUTPUT|ANTI|CONTROL}
+
+ 3. Various flags:
+
+ HARD_DEP : 1 => Set if an instruction has a non-speculative
+ dependence. This is an instruction property
+ so this bit can only appear in the TODO_SPEC
+ field of an instruction.
+ DEP_POSTPONED : 1 => Like HARD_DEP, but the hard dependence may
+ still be broken by adjusting the instruction.
+ DEP_CANCELLED : 1 => Set if a dependency has been broken using
+ some form of speculation.
+ RESERVED : 1 => Reserved for use in the delay slot scheduler.
+
+ See also: check_dep_status () in sched-deps.c . */
+
+/* The number of bits per weakness probability. There are 4 weakness types
+ and we need 8 bits for other data in a DS_T. */
+#define BITS_PER_DEP_WEAK ((BITS_PER_DEP_STATUS - 8) / 4)
/* Mask of speculative weakness in dep_status. */
#define DEP_WEAK_MASK ((1 << BITS_PER_DEP_WEAK) - 1)
#define MIN_DEP_WEAK 1
/* This constant represents 100% probability.
- E.g. it is used to represent weakness of dependence, that doesn't exist. */
+ E.g. it is used to represent weakness of dependence, that doesn't exist.
+ This value never appears in a ds_t, it is only used for computing the
+ weakness of a dependence. */
#define NO_DEP_WEAK (MAX_DEP_WEAK + MIN_DEP_WEAK)
/* Default weakness of speculative dependence. Used when we can't say
BE_IN_CONTROL_BITS_OFFSET = BEGIN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK
};
-/* The following defines provide numerous constants used to distinguish between
- different types of speculative dependencies. */
+/* The following defines provide numerous constants used to distinguish
+ between different types of speculative dependencies. They are also
+ used as masks to clear/preserve the bits corresponding to the type
+ of dependency weakness. */
/* Dependence can be overcome with generation of new data speculative
instruction. */
/* Instruction has non-speculative dependence. This bit represents the
property of an instruction - not the one of a dependence.
- Therefore, it can appear only in TODO_SPEC field of an instruction. */
+ Therefore, it can appear only in the TODO_SPEC field of an instruction. */
#define HARD_DEP (DEP_CONTROL << 1)
-/* Set in the TODO_SPEC field of an instruction for which new_ready
- has decided not to schedule it speculatively. */
+/* Like HARD_DEP, but dependencies can perhaps be broken by modifying
+ the instructions. This is used for example to change:
+
+ rn++ => rm=[rn + 4]
+ rm=[rn] rn++
+
+ For instructions that have this bit set, one of the dependencies of
+ the instructions will have a non-NULL REPLACE field in its DEP_T.
+ Just like HARD_DEP, this bit is only ever set in TODO_SPEC. */
#define DEP_POSTPONED (HARD_DEP << 1)
+/* Set if a dependency is cancelled via speculation. */
#define DEP_CANCELLED (DEP_POSTPONED << 1)
+\f
/* This represents the results of calling sched-deps.c functions,
which modify dependencies. */
enum DEPS_ADJUST_RESULT {
extern void remove_from_deps (struct deps_desc *, rtx);
extern void init_insn_reg_pressure_info (rtx);
-extern dw_t get_dep_weak_1 (ds_t, ds_t);
extern dw_t get_dep_weak (ds_t, ds_t);
extern ds_t set_dep_weak (ds_t, ds_t, dw_t);
extern dw_t estimate_dep_weak (rtx, rtx);
"Given the current cost, @var{cost}, of an insn, @var{insn}, calculate and\
return a new cost based on its relationship to @var{dep_insn} through the\
dependence of weakness @var{dw}. The default is to make no adjustment.",
- int, (rtx insn, int dep_type1, rtx dep_insn, int cost, int dw), NULL)
+ int, (rtx insn, int dep_type1, rtx dep_insn, int cost, unsigned int dw), NULL)
/* The following member value is a pointer to a function called
by the insn scheduler. This hook is called to notify the backend
DEFHOOK
(speculate_insn,
"",
- int, (rtx insn, int request, rtx *new_pat), NULL)
+ int, (rtx insn, unsigned int dep_status, rtx *new_pat), NULL)
/* The following member value is a pointer to a function called
by the insn scheduler. It should return true if the check instruction
DEFHOOK
(needs_block_p,
"",
- bool, (int dep_status), NULL)
+ bool, (unsigned int dep_status), NULL)
/* The following member value is a pointer to a function called
by the insn scheduler. It should return a pattern for the check
instruction.
The first parameter is a speculative instruction, the second parameter
is the label of the corresponding recovery block (or null, if it is a
- simple check). If the mutation of the check is requested (e.g. from
- ld.c to chk.a), the third parameter is true - in this case the first
- parameter is the previous check. */
+ simple check). The third parameter is the kind of speculation that
+ is being performed. */
DEFHOOK
(gen_spec_check,
"",
- rtx, (rtx insn, rtx label, int mutate_p), NULL)
+ rtx, (rtx insn, rtx label, unsigned int ds), NULL)
/* The following member value is a pointer to a function controlling
what insns from the ready insn queue will be considered for the
DEFHOOK_UNDOC
(get_insn_spec_ds,
"Return speculation types of instruction @var{insn}.",
- int, (rtx insn), NULL)
+ unsigned int, (rtx insn), NULL)
DEFHOOK_UNDOC
(get_insn_checked_ds,
"Return speculation types that are checked for instruction @var{insn}",
- int, (rtx insn), NULL)
+ unsigned int, (rtx insn), NULL)
DEFHOOK_UNDOC
(skip_rtx_p,