sched-int.h 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684
  1. /* Instruction scheduling pass. This file contains definitions used
  2. internally in the scheduler.
  3. Copyright (C) 1992-2019 Free Software Foundation, Inc.
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef GCC_SCHED_INT_H
  17. #define GCC_SCHED_INT_H
  18. #ifdef INSN_SCHEDULING
  19. /* Identificator of a scheduler pass. */
  20. enum sched_pass_id_t { SCHED_PASS_UNKNOWN, SCHED_RGN_PASS, SCHED_EBB_PASS,
  21. SCHED_SMS_PASS, SCHED_SEL_PASS };
  22. /* The algorithm used to implement -fsched-pressure. */
  23. enum sched_pressure_algorithm
  24. {
  25. SCHED_PRESSURE_NONE,
  26. SCHED_PRESSURE_WEIGHTED,
  27. SCHED_PRESSURE_MODEL
  28. };
  29. typedef vec<basic_block> bb_vec_t;
  30. typedef vec<rtx_insn *> insn_vec_t;
  31. typedef vec<rtx_insn *> rtx_vec_t;
  32. extern void sched_init_bbs (void);
  33. extern void sched_extend_luids (void);
  34. extern void sched_init_insn_luid (rtx_insn *);
  35. extern void sched_init_luids (bb_vec_t);
  36. extern void sched_finish_luids (void);
  37. extern void sched_extend_target (void);
  38. extern void haifa_init_h_i_d (bb_vec_t);
  39. extern void haifa_finish_h_i_d (void);
  40. /* Hooks that are common to all the schedulers. */
  41. struct common_sched_info_def
  42. {
  43. /* Called after blocks were rearranged due to movement of jump instruction.
  44. The first parameter - index of basic block, in which jump currently is.
  45. The second parameter - index of basic block, in which jump used
  46. to be.
  47. The third parameter - index of basic block, that follows the second
  48. parameter. */
  49. void (*fix_recovery_cfg) (int, int, int);
  50. /* Called to notify frontend, that new basic block is being added.
  51. The first parameter - new basic block.
  52. The second parameter - block, after which new basic block is being added,
  53. or the exit block, if recovery block is being added,
  54. or NULL, if standalone block is being added. */
  55. void (*add_block) (basic_block, basic_block);
  56. /* Estimate number of insns in the basic block. */
  57. int (*estimate_number_of_insns) (basic_block);
  58. /* Given a non-insn (!INSN_P (x)) return
  59. -1 - if this rtx don't need a luid.
  60. 0 - if it should have the same luid as the previous insn.
  61. 1 - if it needs a separate luid. */
  62. int (*luid_for_non_insn) (rtx);
  63. /* Scheduler pass identifier. It is preferably used in assertions. */
  64. enum sched_pass_id_t sched_pass_id;
  65. };
  66. extern struct common_sched_info_def *common_sched_info;
  67. extern const struct common_sched_info_def haifa_common_sched_info;
  68. /* Return true if selective scheduling pass is working. */
  69. static inline bool
  70. sel_sched_p (void)
  71. {
  72. return common_sched_info->sched_pass_id == SCHED_SEL_PASS;
  73. }
  74. /* Returns maximum priority that an insn was assigned to. */
  75. extern int get_rgn_sched_max_insns_priority (void);
  76. /* Increases effective priority for INSN by AMOUNT. */
  77. extern void sel_add_to_insn_priority (rtx, int);
  78. /* True if during selective scheduling we need to emulate some of haifa
  79. scheduler behavior. */
  80. extern int sched_emulate_haifa_p;
  81. /* Mapping from INSN_UID to INSN_LUID. In the end all other per insn data
  82. structures should be indexed by luid. */
  83. extern vec<int> sched_luids;
  84. #define INSN_LUID(INSN) (sched_luids[INSN_UID (INSN)])
  85. #define LUID_BY_UID(UID) (sched_luids[UID])
  86. #define SET_INSN_LUID(INSN, LUID) \
  87. (sched_luids[INSN_UID (INSN)] = (LUID))
  88. /* The highest INSN_LUID. */
  89. extern int sched_max_luid;
  90. extern int insn_luid (rtx);
  91. /* This list holds ripped off notes from the current block. These notes will
  92. be attached to the beginning of the block when its scheduling is
  93. finished. */
  94. extern rtx_insn *note_list;
  95. extern void remove_notes (rtx_insn *, rtx_insn *);
  96. extern rtx_insn *restore_other_notes (rtx_insn *, basic_block);
  97. extern void sched_insns_init (rtx);
  98. extern void sched_insns_finish (void);
  99. extern void *xrecalloc (void *, size_t, size_t, size_t);
  100. extern void reemit_notes (rtx_insn *);
  101. /* Functions in haifa-sched.c. */
  102. extern int haifa_classify_insn (const_rtx);
  103. /* Functions in sel-sched-ir.c. */
  104. extern void sel_find_rgns (void);
  105. extern void sel_mark_hard_insn (rtx);
  106. extern size_t dfa_state_size;
  107. extern void advance_state (state_t);
  108. extern void setup_sched_dump (void);
  109. extern void sched_init (void);
  110. extern void sched_finish (void);
  111. extern bool sel_insn_is_speculation_check (rtx);
  112. /* Describe the ready list of the scheduler.
  113. VEC holds space enough for all insns in the current region. VECLEN
  114. says how many exactly.
  115. FIRST is the index of the element with the highest priority; i.e. the
  116. last one in the ready list, since elements are ordered by ascending
  117. priority.
  118. N_READY determines how many insns are on the ready list.
  119. N_DEBUG determines how many debug insns are on the ready list. */
  120. struct ready_list
  121. {
  122. rtx_insn **vec;
  123. int veclen;
  124. int first;
  125. int n_ready;
  126. int n_debug;
  127. };
  128. extern signed char *ready_try;
  129. extern struct ready_list ready;
  130. extern int max_issue (struct ready_list *, int, state_t, bool, int *);
  131. extern void ebb_compute_jump_reg_dependencies (rtx, regset);
  132. extern edge find_fallthru_edge_from (basic_block);
  133. extern void (* sched_init_only_bb) (basic_block, basic_block);
  134. extern basic_block (* sched_split_block) (basic_block, rtx);
  135. extern basic_block sched_split_block_1 (basic_block, rtx);
  136. extern basic_block (* sched_create_empty_bb) (basic_block);
  137. extern basic_block sched_create_empty_bb_1 (basic_block);
  138. extern basic_block sched_create_recovery_block (basic_block *);
  139. extern void sched_create_recovery_edges (basic_block, basic_block,
  140. basic_block);
  141. /* Pointer to data describing the current DFA state. */
  142. extern state_t curr_state;
  143. /* Type to represent status of a dependence. */
  144. typedef unsigned int ds_t;
  145. #define BITS_PER_DEP_STATUS HOST_BITS_PER_INT
  146. /* Type to represent weakness of speculative dependence. */
  147. typedef unsigned int dw_t;
  148. extern enum reg_note ds_to_dk (ds_t);
  149. extern ds_t dk_to_ds (enum reg_note);
  150. /* Describe a dependency that can be broken by making a replacement
  151. in one of the patterns. LOC is the location, ORIG and NEWVAL the
  152. two alternative contents, and INSN the instruction that must be
  153. changed. */
  154. struct dep_replacement
  155. {
  156. rtx *loc;
  157. rtx orig;
  158. rtx newval;
  159. rtx_insn *insn;
  160. };
  161. /* Information about the dependency. */
  162. struct _dep
  163. {
  164. /* Producer. */
  165. rtx_insn *pro;
  166. /* Consumer. */
  167. rtx_insn *con;
  168. /* If nonnull, holds a pointer to information about how to break the
  169. dependency by making a replacement in one of the insns. There is
  170. only one such dependency for each insn that must be modified in
  171. order to break such a dependency. */
  172. struct dep_replacement *replace;
  173. /* Dependency status. This field holds all dependency types and additional
  174. information for speculative dependencies. */
  175. ds_t status;
  176. /* Dependency major type. This field is superseded by STATUS above.
  177. Though, it is still in place because some targets use it. */
  178. ENUM_BITFIELD(reg_note) type:6;
  179. unsigned nonreg:1;
  180. unsigned multiple:1;
  181. /* Cached cost of the dependency. Make sure to update UNKNOWN_DEP_COST
  182. when changing the size of this field. */
  183. int cost:20;
  184. };
  185. #define UNKNOWN_DEP_COST ((int) ((unsigned int) -1 << 19))
  186. typedef struct _dep dep_def;
  187. typedef dep_def *dep_t;
  188. #define DEP_PRO(D) ((D)->pro)
  189. #define DEP_CON(D) ((D)->con)
  190. #define DEP_TYPE(D) ((D)->type)
  191. #define DEP_STATUS(D) ((D)->status)
  192. #define DEP_COST(D) ((D)->cost)
  193. #define DEP_NONREG(D) ((D)->nonreg)
  194. #define DEP_MULTIPLE(D) ((D)->multiple)
  195. #define DEP_REPLACE(D) ((D)->replace)
  196. /* Functions to work with dep. */
  197. extern void init_dep_1 (dep_t, rtx_insn *, rtx_insn *, enum reg_note, ds_t);
  198. extern void init_dep (dep_t, rtx_insn *, rtx_insn *, enum reg_note);
  199. extern void sd_debug_dep (dep_t);
  200. /* Definition of this struct resides below. */
  201. struct _dep_node;
  202. typedef struct _dep_node *dep_node_t;
  203. /* A link in the dependency list. This is essentially an equivalent of a
  204. single {INSN, DEPS}_LIST rtx. */
  205. struct _dep_link
  206. {
  207. /* Dep node with all the data. */
  208. dep_node_t node;
  209. /* Next link in the list. For the last one it is NULL. */
  210. struct _dep_link *next;
  211. /* Pointer to the next field of the previous link in the list.
  212. For the first link this points to the deps_list->first.
  213. With help of this field it is easy to remove and insert links to the
  214. list. */
  215. struct _dep_link **prev_nextp;
  216. };
  217. typedef struct _dep_link *dep_link_t;
  218. #define DEP_LINK_NODE(N) ((N)->node)
  219. #define DEP_LINK_NEXT(N) ((N)->next)
  220. #define DEP_LINK_PREV_NEXTP(N) ((N)->prev_nextp)
  221. /* Macros to work dep_link. For most usecases only part of the dependency
  222. information is need. These macros conveniently provide that piece of
  223. information. */
  224. #define DEP_LINK_DEP(N) (DEP_NODE_DEP (DEP_LINK_NODE (N)))
  225. #define DEP_LINK_PRO(N) (DEP_PRO (DEP_LINK_DEP (N)))
  226. #define DEP_LINK_CON(N) (DEP_CON (DEP_LINK_DEP (N)))
  227. #define DEP_LINK_TYPE(N) (DEP_TYPE (DEP_LINK_DEP (N)))
  228. #define DEP_LINK_STATUS(N) (DEP_STATUS (DEP_LINK_DEP (N)))
  229. /* A list of dep_links. */
  230. struct _deps_list
  231. {
  232. /* First element. */
  233. dep_link_t first;
  234. /* Total number of elements in the list. */
  235. int n_links;
  236. };
  237. typedef struct _deps_list *deps_list_t;
  238. #define DEPS_LIST_FIRST(L) ((L)->first)
  239. #define DEPS_LIST_N_LINKS(L) ((L)->n_links)
  240. /* Suppose we have a dependence Y between insn pro1 and con1, where pro1 has
  241. additional dependents con0 and con2, and con1 is dependent on additional
  242. insns pro0 and pro1:
  243. .con0 pro0
  244. . ^ |
  245. . | |
  246. . | |
  247. . X A
  248. . | |
  249. . | |
  250. . | V
  251. .pro1--Y-->con1
  252. . | ^
  253. . | |
  254. . | |
  255. . Z B
  256. . | |
  257. . | |
  258. . V |
  259. .con2 pro2
  260. This is represented using a "dep_node" for each dependence arc, which are
  261. connected as follows (diagram is centered around Y which is fully shown;
  262. other dep_nodes shown partially):
  263. . +------------+ +--------------+ +------------+
  264. . : dep_node X : | dep_node Y | : dep_node Z :
  265. . : : | | : :
  266. . : : | | : :
  267. . : forw : | forw | : forw :
  268. . : +--------+ : | +--------+ | : +--------+ :
  269. forw_deps : |dep_link| : | |dep_link| | : |dep_link| :
  270. +-----+ : | +----+ | : | | +----+ | | : | +----+ | :
  271. |first|----->| |next|-+------+->| |next|-+--+----->| |next|-+--->NULL
  272. +-----+ : | +----+ | : | | +----+ | | : | +----+ | :
  273. . ^ ^ : | ^ | : | | ^ | | : | | :
  274. . | | : | | | : | | | | | : | | :
  275. . | +--<----+--+ +--+---<--+--+--+ +--+--+--<---+--+ | :
  276. . | : | | | : | | | | | : | | | :
  277. . | : | +----+ | : | | +----+ | | : | +----+ | :
  278. . | : | |prev| | : | | |prev| | | : | |prev| | :
  279. . | : | |next| | : | | |next| | | : | |next| | :
  280. . | : | +----+ | : | | +----+ | | : | +----+ | :
  281. . | : | | :<-+ | | | |<-+ : | | :<-+
  282. . | : | +----+ | : | | | +----+ | | | : | +----+ | : |
  283. . | : | |node|-+----+ | | |node|-+--+--+ : | |node|-+----+
  284. . | : | +----+ | : | | +----+ | | : | +----+ | :
  285. . | : | | : | | | | : | | :
  286. . | : +--------+ : | +--------+ | : +--------+ :
  287. . | : : | | : :
  288. . | : SAME pro1 : | +--------+ | : SAME pro1 :
  289. . | : DIFF con0 : | |dep | | : DIFF con2 :
  290. . | : : | | | | : :
  291. . | | | +----+ | |
  292. .RTX<------------------------+--+-|pro1| | |
  293. .pro1 | | +----+ | |
  294. . | | | |
  295. . | | +----+ | |
  296. .RTX<------------------------+--+-|con1| | |
  297. .con1 | | +----+ | |
  298. . | | | | |
  299. . | | | +----+ | |
  300. . | | | |kind| | |
  301. . | | | +----+ | |
  302. . | : : | | |stat| | | : :
  303. . | : DIFF pro0 : | | +----+ | | : DIFF pro2 :
  304. . | : SAME con1 : | | | | : SAME con1 :
  305. . | : : | +--------+ | : :
  306. . | : : | | : :
  307. . | : back : | back | : back :
  308. . v : +--------+ : | +--------+ | : +--------+ :
  309. back_deps : |dep_link| : | |dep_link| | : |dep_link| :
  310. +-----+ : | +----+ | : | | +----+ | | : | +----+ | :
  311. |first|----->| |next|-+------+->| |next|-+--+----->| |next|-+--->NULL
  312. +-----+ : | +----+ | : | | +----+ | | : | +----+ | :
  313. . ^ : | ^ | : | | ^ | | : | | :
  314. . | : | | | : | | | | | : | | :
  315. . +--<----+--+ +--+---<--+--+--+ +--+--+--<---+--+ | :
  316. . : | | | : | | | | | : | | | :
  317. . : | +----+ | : | | +----+ | | : | +----+ | :
  318. . : | |prev| | : | | |prev| | | : | |prev| | :
  319. . : | |next| | : | | |next| | | : | |next| | :
  320. . : | +----+ | : | | +----+ | | : | +----+ | :
  321. . : | | :<-+ | | | |<-+ : | | :<-+
  322. . : | +----+ | : | | | +----+ | | | : | +----+ | : |
  323. . : | |node|-+----+ | | |node|-+--+--+ : | |node|-+----+
  324. . : | +----+ | : | | +----+ | | : | +----+ | :
  325. . : | | : | | | | : | | :
  326. . : +--------+ : | +--------+ | : +--------+ :
  327. . : : | | : :
  328. . : dep_node A : | dep_node Y | : dep_node B :
  329. . +------------+ +--------------+ +------------+
  330. */
  331. struct _dep_node
  332. {
  333. /* Backward link. */
  334. struct _dep_link back;
  335. /* The dep. */
  336. struct _dep dep;
  337. /* Forward link. */
  338. struct _dep_link forw;
  339. };
  340. #define DEP_NODE_BACK(N) (&(N)->back)
  341. #define DEP_NODE_DEP(N) (&(N)->dep)
  342. #define DEP_NODE_FORW(N) (&(N)->forw)
  343. /* The following enumeration values tell us what dependencies we
  344. should use to implement the barrier. We use true-dependencies for
  345. TRUE_BARRIER and anti-dependencies for MOVE_BARRIER. */
  346. enum reg_pending_barrier_mode
  347. {
  348. NOT_A_BARRIER = 0,
  349. MOVE_BARRIER,
  350. TRUE_BARRIER
  351. };
  352. /* Whether a register movement is associated with a call. */
  353. enum post_call_group
  354. {
  355. not_post_call,
  356. post_call,
  357. post_call_initial
  358. };
  359. /* Insns which affect pseudo-registers. */
  360. struct deps_reg
  361. {
  362. rtx_insn_list *uses;
  363. rtx_insn_list *sets;
  364. rtx_insn_list *implicit_sets;
  365. rtx_insn_list *control_uses;
  366. rtx_insn_list *clobbers;
  367. int uses_length;
  368. int clobbers_length;
  369. };
  370. /* Describe state of dependencies used during sched_analyze phase. */
  371. struct deps_desc
  372. {
  373. /* The *_insns and *_mems are paired lists. Each pending memory operation
  374. will have a pointer to the MEM rtx on one list and a pointer to the
  375. containing insn on the other list in the same place in the list. */
  376. /* We can't use add_dependence like the old code did, because a single insn
  377. may have multiple memory accesses, and hence needs to be on the list
  378. once for each memory access. Add_dependence won't let you add an insn
  379. to a list more than once. */
  380. /* An INSN_LIST containing all insns with pending read operations. */
  381. rtx_insn_list *pending_read_insns;
  382. /* An EXPR_LIST containing all MEM rtx's which are pending reads. */
  383. rtx_expr_list *pending_read_mems;
  384. /* An INSN_LIST containing all insns with pending write operations. */
  385. rtx_insn_list *pending_write_insns;
  386. /* An EXPR_LIST containing all MEM rtx's which are pending writes. */
  387. rtx_expr_list *pending_write_mems;
  388. /* An INSN_LIST containing all jump insns. */
  389. rtx_insn_list *pending_jump_insns;
  390. /* We must prevent the above lists from ever growing too large since
  391. the number of dependencies produced is at least O(N*N),
  392. and execution time is at least O(4*N*N), as a function of the
  393. length of these pending lists. */
  394. /* Indicates the length of the pending_read list. */
  395. int pending_read_list_length;
  396. /* Indicates the length of the pending_write list. */
  397. int pending_write_list_length;
  398. /* Length of the pending memory flush list plus the length of the pending
  399. jump insn list. Large functions with no calls may build up extremely
  400. large lists. */
  401. int pending_flush_length;
  402. /* The last insn upon which all memory references must depend.
  403. This is an insn which flushed the pending lists, creating a dependency
  404. between it and all previously pending memory references. This creates
  405. a barrier (or a checkpoint) which no memory reference is allowed to cross.
  406. This includes all non constant CALL_INSNs. When we do interprocedural
  407. alias analysis, this restriction can be relaxed.
  408. This may also be an INSN that writes memory if the pending lists grow
  409. too large. */
  410. rtx_insn_list *last_pending_memory_flush;
  411. /* A list of the last function calls we have seen. We use a list to
  412. represent last function calls from multiple predecessor blocks.
  413. Used to prevent register lifetimes from expanding unnecessarily. */
  414. rtx_insn_list *last_function_call;
  415. /* A list of the last function calls that may not return normally
  416. we have seen. We use a list to represent last function calls from
  417. multiple predecessor blocks. Used to prevent moving trapping insns
  418. across such calls. */
  419. rtx_insn_list *last_function_call_may_noreturn;
  420. /* A list of insns which use a pseudo register that does not already
  421. cross a call. We create dependencies between each of those insn
  422. and the next call insn, to ensure that they won't cross a call after
  423. scheduling is done. */
  424. rtx_insn_list *sched_before_next_call;
  425. /* Similarly, a list of insns which should not cross a branch. */
  426. rtx_insn_list *sched_before_next_jump;
  427. /* Used to keep post-call pseudo/hard reg movements together with
  428. the call. */
  429. enum post_call_group in_post_call_group_p;
  430. /* The last debug insn we've seen. */
  431. rtx_insn *last_debug_insn;
  432. /* The last insn bearing REG_ARGS_SIZE that we've seen. */
  433. rtx_insn *last_args_size;
  434. /* A list of all prologue insns we have seen without intervening epilogue
  435. insns, and one of all epilogue insns we have seen without intervening
  436. prologue insns. This is used to prevent mixing prologue and epilogue
  437. insns. See PR78029. */
  438. rtx_insn_list *last_prologue;
  439. rtx_insn_list *last_epilogue;
  440. /* Whether the last *logue insn was an epilogue insn or a prologue insn
  441. instead. */
  442. bool last_logue_was_epilogue;
  443. /* The maximum register number for the following arrays. Before reload
  444. this is max_reg_num; after reload it is FIRST_PSEUDO_REGISTER. */
  445. int max_reg;
  446. /* Element N is the next insn that sets (hard or pseudo) register
  447. N within the current basic block; or zero, if there is no
  448. such insn. Needed for new registers which may be introduced
  449. by splitting insns. */
  450. struct deps_reg *reg_last;
  451. /* Element N is set for each register that has any nonzero element
  452. in reg_last[N].{uses,sets,clobbers}. */
  453. regset_head reg_last_in_use;
  454. /* Shows the last value of reg_pending_barrier associated with the insn. */
  455. enum reg_pending_barrier_mode last_reg_pending_barrier;
  456. /* True when this context should be treated as a readonly by
  457. the analysis. */
  458. BOOL_BITFIELD readonly : 1;
  459. };
  460. typedef struct deps_desc *deps_t;
  461. /* This structure holds some state of the current scheduling pass, and
  462. contains some function pointers that abstract out some of the non-generic
  463. functionality from functions such as schedule_block or schedule_insn.
  464. There is one global variable, current_sched_info, which points to the
  465. sched_info structure currently in use. */
  466. struct haifa_sched_info
  467. {
  468. /* Add all insns that are initially ready to the ready list. Called once
  469. before scheduling a set of insns. */
  470. void (*init_ready_list) (void);
  471. /* Called after taking an insn from the ready list. Returns nonzero if
  472. this insn can be scheduled, nonzero if we should silently discard it. */
  473. int (*can_schedule_ready_p) (rtx_insn *);
  474. /* Return nonzero if there are more insns that should be scheduled. */
  475. int (*schedule_more_p) (void);
  476. /* Called after an insn has all its hard dependencies resolved.
  477. Adjusts status of instruction (which is passed through second parameter)
  478. to indicate if instruction should be moved to the ready list or the
  479. queue, or if it should silently discard it (until next resolved
  480. dependence). */
  481. ds_t (*new_ready) (rtx_insn *, ds_t);
  482. /* Compare priority of two insns. Return a positive number if the second
  483. insn is to be preferred for scheduling, and a negative one if the first
  484. is to be preferred. Zero if they are equally good. */
  485. int (*rank) (rtx_insn *, rtx_insn *);
  486. /* Return a string that contains the insn uid and optionally anything else
  487. necessary to identify this insn in an output. It's valid to use a
  488. static buffer for this. The ALIGNED parameter should cause the string
  489. to be formatted so that multiple output lines will line up nicely. */
  490. const char *(*print_insn) (const rtx_insn *, int);
  491. /* Return nonzero if an insn should be included in priority
  492. calculations. */
  493. int (*contributes_to_priority) (rtx_insn *, rtx_insn *);
  494. /* Return true if scheduling insn (passed as the parameter) will trigger
  495. finish of scheduling current block. */
  496. bool (*insn_finishes_block_p) (rtx_insn *);
  497. /* The boundaries of the set of insns to be scheduled. */
  498. rtx_insn *prev_head, *next_tail;
  499. /* Filled in after the schedule is finished; the first and last scheduled
  500. insns. */
  501. rtx_insn *head, *tail;
  502. /* If nonzero, enables an additional sanity check in schedule_block. */
  503. unsigned int queue_must_finish_empty:1;
  504. /* Maximum priority that has been assigned to an insn. */
  505. int sched_max_insns_priority;
  506. /* Hooks to support speculative scheduling. */
  507. /* Called to notify frontend that instruction is being added (second
  508. parameter == 0) or removed (second parameter == 1). */
  509. void (*add_remove_insn) (rtx_insn *, int);
  510. /* Called to notify the frontend that instruction INSN is being
  511. scheduled. */
  512. void (*begin_schedule_ready) (rtx_insn *insn);
  513. /* Called to notify the frontend that an instruction INSN is about to be
  514. moved to its correct place in the final schedule. This is done for all
  515. insns in order of the schedule. LAST indicates the last scheduled
  516. instruction. */
  517. void (*begin_move_insn) (rtx_insn *insn, rtx_insn *last);
  518. /* If the second parameter is not NULL, return nonnull value, if the
  519. basic block should be advanced.
  520. If the second parameter is NULL, return the next basic block in EBB.
  521. The first parameter is the current basic block in EBB. */
  522. basic_block (*advance_target_bb) (basic_block, rtx_insn *);
  523. /* Allocate memory, store the frontend scheduler state in it, and
  524. return it. */
  525. void *(*save_state) (void);
  526. /* Restore frontend scheduler state from the argument, and free the
  527. memory. */
  528. void (*restore_state) (void *);
  529. /* ??? FIXME: should use straight bitfields inside sched_info instead of
  530. this flag field. */
  531. unsigned int flags;
  532. };
  533. /* This structure holds description of the properties for speculative
  534. scheduling. */
  535. struct spec_info_def
  536. {
  537. /* Holds types of allowed speculations: BEGIN_{DATA|CONTROL},
  538. BE_IN_{DATA_CONTROL}. */
  539. int mask;
  540. /* A dump file for additional information on speculative scheduling. */
  541. FILE *dump;
  542. /* Minimal cumulative weakness of speculative instruction's
  543. dependencies, so that insn will be scheduled. */
  544. dw_t data_weakness_cutoff;
  545. /* Minimal usefulness of speculative instruction to be considered for
  546. scheduling. */
  547. int control_weakness_cutoff;
  548. /* Flags from the enum SPEC_SCHED_FLAGS. */
  549. int flags;
  550. };
  551. typedef struct spec_info_def *spec_info_t;
  552. extern spec_info_t spec_info;
  553. extern struct haifa_sched_info *current_sched_info;
  554. /* Do register pressure sensitive insn scheduling if the flag is set
  555. up. */
  556. extern enum sched_pressure_algorithm sched_pressure;
  557. /* Map regno -> its pressure class. The map defined only when
  558. SCHED_PRESSURE_P is true. */
  559. extern enum reg_class *sched_regno_pressure_class;
  560. /* Indexed by INSN_UID, the collection of all data associated with
  561. a single instruction. */
  562. struct _haifa_deps_insn_data
  563. {
  564. /* The number of incoming edges in the forward dependency graph.
  565. As scheduling proceeds, counts are decreased. An insn moves to
  566. the ready queue when its counter reaches zero. */
  567. int dep_count;
  568. /* Nonzero if instruction has internal dependence
  569. (e.g. add_dependence was invoked with (insn == elem)). */
  570. unsigned int has_internal_dep;
  571. /* NB: We can't place 'struct _deps_list' here instead of deps_list_t into
  572. h_i_d because when h_i_d extends, addresses of the deps_list->first
  573. change without updating deps_list->first->next->prev_nextp. Thus
  574. BACK_DEPS and RESOLVED_BACK_DEPS are allocated on the heap and FORW_DEPS
  575. list is allocated on the obstack. */
  576. /* A list of hard backward dependencies. The insn is a consumer of all the
  577. deps mentioned here. */
  578. deps_list_t hard_back_deps;
  579. /* A list of speculative (weak) dependencies. The insn is a consumer of all
  580. the deps mentioned here. */
  581. deps_list_t spec_back_deps;
  582. /* A list of insns which depend on the instruction. Unlike 'back_deps',
  583. it represents forward dependencies. */
  584. deps_list_t forw_deps;
  585. /* A list of scheduled producers of the instruction. Links are being moved
  586. from 'back_deps' to 'resolved_back_deps' while scheduling. */
  587. deps_list_t resolved_back_deps;
  588. /* A list of scheduled consumers of the instruction. Links are being moved
  589. from 'forw_deps' to 'resolved_forw_deps' while scheduling to fasten the
  590. search in 'forw_deps'. */
  591. deps_list_t resolved_forw_deps;
  592. /* If the insn is conditional (either through COND_EXEC, or because
  593. it is a conditional branch), this records the condition. NULL
  594. for insns that haven't been seen yet or don't have a condition;
  595. const_true_rtx to mark an insn without a condition, or with a
  596. condition that has been clobbered by a subsequent insn. */
  597. rtx cond;
  598. /* For a conditional insn, a list of insns that could set the condition
  599. register. Used when generating control dependencies. */
  600. rtx_insn_list *cond_deps;
  601. /* True if the condition in 'cond' should be reversed to get the actual
  602. condition. */
  603. unsigned int reverse_cond : 1;
  604. /* Some insns (e.g. call) are not allowed to move across blocks. */
  605. unsigned int cant_move : 1;
  606. };
  607. /* Bits used for storing values of the fields in the following
  608. structure. */
  609. #define INCREASE_BITS 8
  610. /* The structure describes how the corresponding insn increases the
  611. register pressure for each pressure class. */
  612. struct reg_pressure_data
  613. {
  614. /* Pressure increase for given class because of clobber. */
  615. unsigned int clobber_increase : INCREASE_BITS;
  616. /* Increase in register pressure for given class because of register
  617. sets. */
  618. unsigned int set_increase : INCREASE_BITS;
  619. /* Pressure increase for given class because of unused register
  620. set. */
  621. unsigned int unused_set_increase : INCREASE_BITS;
  622. /* Pressure change: #sets - #deaths. */
  623. int change : INCREASE_BITS;
  624. };
  625. /* The following structure describes usage of registers by insns. */
  626. struct reg_use_data
  627. {
  628. /* Regno used in the insn. */
  629. int regno;
  630. /* Insn using the regno. */
  631. rtx_insn *insn;
  632. /* Cyclic list of elements with the same regno. */
  633. struct reg_use_data *next_regno_use;
  634. /* List of elements with the same insn. */
  635. struct reg_use_data *next_insn_use;
  636. };
  637. /* The following structure describes used sets of registers by insns.
  638. Registers are pseudos whose pressure class is not NO_REGS or hard
  639. registers available for allocations. */
  640. struct reg_set_data
  641. {
  642. /* Regno used in the insn. */
  643. int regno;
  644. /* Insn setting the regno. */
  645. rtx insn;
  646. /* List of elements with the same insn. */
  647. struct reg_set_data *next_insn_set;
  648. };
  649. enum autopref_multipass_data_status {
  650. /* Entry is irrelevant for auto-prefetcher. */
  651. AUTOPREF_MULTIPASS_DATA_IRRELEVANT = -2,
  652. /* Entry is uninitialized. */
  653. AUTOPREF_MULTIPASS_DATA_UNINITIALIZED = -1,
  654. /* Entry is relevant for auto-prefetcher and insn can be delayed
  655. to allow another insn through. */
  656. AUTOPREF_MULTIPASS_DATA_NORMAL = 0,
  657. /* Entry is relevant for auto-prefetcher, but insn should not be
  658. delayed as that will break scheduling. */
  659. AUTOPREF_MULTIPASS_DATA_DONT_DELAY = 1
  660. };
  661. /* Data for modeling cache auto-prefetcher. */
  662. struct autopref_multipass_data_
  663. {
  664. /* Base part of memory address. */
  665. rtx base;
  666. /* Memory offsets from the base. */
  667. int offset;
  668. /* Entry status. */
  669. enum autopref_multipass_data_status status;
  670. };
  671. typedef struct autopref_multipass_data_ autopref_multipass_data_def;
  672. typedef autopref_multipass_data_def *autopref_multipass_data_t;
  673. struct _haifa_insn_data
  674. {
  675. /* We can't place 'struct _deps_list' into h_i_d instead of deps_list_t
  676. because when h_i_d extends, addresses of the deps_list->first
  677. change without updating deps_list->first->next->prev_nextp. */
  678. /* Logical uid gives the original ordering of the insns. */
  679. int luid;
  680. /* A priority for each insn. */
  681. int priority;
  682. /* The fusion priority for each insn. */
  683. int fusion_priority;
  684. /* The minimum clock tick at which the insn becomes ready. This is
  685. used to note timing constraints for the insns in the pending list. */
  686. int tick;
  687. /* For insns that are scheduled at a fixed difference from another,
  688. this records the tick in which they must be ready. */
  689. int exact_tick;
  690. /* INTER_TICK is used to adjust INSN_TICKs of instructions from the
  691. subsequent blocks in a region. */
  692. int inter_tick;
  693. /* Used temporarily to estimate an INSN_TICK value for an insn given
  694. current knowledge. */
  695. int tick_estimate;
  696. /* See comment on QUEUE_INDEX macro in haifa-sched.c. */
  697. int queue_index;
  698. short cost;
  699. /* '> 0' if priority is valid,
  700. '== 0' if priority was not yet computed,
  701. '< 0' if priority in invalid and should be recomputed. */
  702. signed char priority_status;
  703. /* Set if there's DEF-USE dependence between some speculatively
  704. moved load insn and this one. */
  705. unsigned int fed_by_spec_load : 1;
  706. unsigned int is_load_insn : 1;
  707. /* Nonzero if this insn has negative-cost forward dependencies against
  708. an already scheduled insn. */
  709. unsigned int feeds_backtrack_insn : 1;
  710. /* Nonzero if this insn is a shadow of another, scheduled after a fixed
  711. delay. We only emit shadows at the end of a cycle, with no other
  712. real insns following them. */
  713. unsigned int shadow_p : 1;
  714. /* Used internally in unschedule_insns_until to mark insns that must have
  715. their TODO_SPEC recomputed. */
  716. unsigned int must_recompute_spec : 1;
  717. /* What speculations are necessary to apply to schedule the instruction. */
  718. ds_t todo_spec;
  719. /* What speculations were already applied. */
  720. ds_t done_spec;
  721. /* What speculations are checked by this instruction. */
  722. ds_t check_spec;
  723. /* Recovery block for speculation checks. */
  724. basic_block recovery_block;
  725. /* Original pattern of the instruction. */
  726. rtx orig_pat;
  727. /* For insns with DEP_CONTROL dependencies, the predicated pattern if it
  728. was ever successfully constructed. */
  729. rtx predicated_pat;
  730. /* The following array contains info how the insn increases register
  731. pressure. There is an element for each cover class of pseudos
  732. referenced in insns. */
  733. struct reg_pressure_data *reg_pressure;
  734. /* The following array contains maximal reg pressure between last
  735. scheduled insn and given insn. There is an element for each
  736. pressure class of pseudos referenced in insns. This info updated
  737. after scheduling each insn for each insn between the two
  738. mentioned insns. */
  739. int *max_reg_pressure;
  740. /* The following list contains info about used pseudos and hard
  741. registers available for allocation. */
  742. struct reg_use_data *reg_use_list;
  743. /* The following list contains info about set pseudos and hard
  744. registers available for allocation. */
  745. struct reg_set_data *reg_set_list;
  746. /* Info about how scheduling the insn changes cost of register
  747. pressure excess (between source and target). */
  748. int reg_pressure_excess_cost_change;
  749. int model_index;
  750. /* Original order of insns in the ready list. */
  751. int rfs_debug_orig_order;
  752. /* The deciding reason for INSN's place in the ready list. */
  753. int last_rfs_win;
  754. /* Two entries for cache auto-prefetcher model: one for mem reads,
  755. and one for mem writes. */
  756. autopref_multipass_data_def autopref_multipass_data[2];
  757. };
  758. typedef struct _haifa_insn_data haifa_insn_data_def;
  759. typedef haifa_insn_data_def *haifa_insn_data_t;
  760. extern vec<haifa_insn_data_def> h_i_d;
  761. #define HID(INSN) (&h_i_d[INSN_UID (INSN)])
  762. /* Accessor macros for h_i_d. There are more in haifa-sched.c and
  763. sched-rgn.c. */
  764. #define INSN_PRIORITY(INSN) (HID (INSN)->priority)
  765. #define INSN_FUSION_PRIORITY(INSN) (HID (INSN)->fusion_priority)
  766. #define INSN_REG_PRESSURE(INSN) (HID (INSN)->reg_pressure)
  767. #define INSN_MAX_REG_PRESSURE(INSN) (HID (INSN)->max_reg_pressure)
  768. #define INSN_REG_USE_LIST(INSN) (HID (INSN)->reg_use_list)
  769. #define INSN_REG_SET_LIST(INSN) (HID (INSN)->reg_set_list)
  770. #define INSN_REG_PRESSURE_EXCESS_COST_CHANGE(INSN) \
  771. (HID (INSN)->reg_pressure_excess_cost_change)
  772. #define INSN_PRIORITY_STATUS(INSN) (HID (INSN)->priority_status)
  773. #define INSN_MODEL_INDEX(INSN) (HID (INSN)->model_index)
  774. #define INSN_AUTOPREF_MULTIPASS_DATA(INSN) \
  775. (HID (INSN)->autopref_multipass_data)
  776. typedef struct _haifa_deps_insn_data haifa_deps_insn_data_def;
  777. typedef haifa_deps_insn_data_def *haifa_deps_insn_data_t;
  778. extern vec<haifa_deps_insn_data_def> h_d_i_d;
  779. #define HDID(INSN) (&h_d_i_d[INSN_LUID (INSN)])
  780. #define INSN_DEP_COUNT(INSN) (HDID (INSN)->dep_count)
  781. #define HAS_INTERNAL_DEP(INSN) (HDID (INSN)->has_internal_dep)
  782. #define INSN_FORW_DEPS(INSN) (HDID (INSN)->forw_deps)
  783. #define INSN_RESOLVED_BACK_DEPS(INSN) (HDID (INSN)->resolved_back_deps)
  784. #define INSN_RESOLVED_FORW_DEPS(INSN) (HDID (INSN)->resolved_forw_deps)
  785. #define INSN_HARD_BACK_DEPS(INSN) (HDID (INSN)->hard_back_deps)
  786. #define INSN_SPEC_BACK_DEPS(INSN) (HDID (INSN)->spec_back_deps)
  787. #define INSN_CACHED_COND(INSN) (HDID (INSN)->cond)
  788. #define INSN_REVERSE_COND(INSN) (HDID (INSN)->reverse_cond)
  789. #define INSN_COND_DEPS(INSN) (HDID (INSN)->cond_deps)
  790. #define CANT_MOVE(INSN) (HDID (INSN)->cant_move)
  791. #define CANT_MOVE_BY_LUID(LUID) (h_d_i_d[LUID].cant_move)
  792. #define INSN_PRIORITY(INSN) (HID (INSN)->priority)
  793. #define INSN_PRIORITY_STATUS(INSN) (HID (INSN)->priority_status)
  794. #define INSN_PRIORITY_KNOWN(INSN) (INSN_PRIORITY_STATUS (INSN) > 0)
  795. #define TODO_SPEC(INSN) (HID (INSN)->todo_spec)
  796. #define DONE_SPEC(INSN) (HID (INSN)->done_spec)
  797. #define CHECK_SPEC(INSN) (HID (INSN)->check_spec)
  798. #define RECOVERY_BLOCK(INSN) (HID (INSN)->recovery_block)
  799. #define ORIG_PAT(INSN) (HID (INSN)->orig_pat)
  800. #define PREDICATED_PAT(INSN) (HID (INSN)->predicated_pat)
  801. /* INSN is either a simple or a branchy speculation check. */
  802. #define IS_SPECULATION_CHECK_P(INSN) \
  803. (sel_sched_p () ? sel_insn_is_speculation_check (INSN) : RECOVERY_BLOCK (INSN) != NULL)
  804. /* INSN is a speculation check that will simply reexecute the speculatively
  805. scheduled instruction if the speculation fails. */
  806. #define IS_SPECULATION_SIMPLE_CHECK_P(INSN) \
  807. (RECOVERY_BLOCK (INSN) == EXIT_BLOCK_PTR_FOR_FN (cfun))
  808. /* INSN is a speculation check that will branch to RECOVERY_BLOCK if the
  809. speculation fails. Insns in that block will reexecute the speculatively
  810. scheduled code and then will return immediately after INSN thus preserving
  811. semantics of the program. */
  812. #define IS_SPECULATION_BRANCHY_CHECK_P(INSN) \
  813. (RECOVERY_BLOCK (INSN) != NULL \
  814. && RECOVERY_BLOCK (INSN) != EXIT_BLOCK_PTR_FOR_FN (cfun))
  815. /* Dep status (aka ds_t) of the link encapsulates all information for a given
  816. dependency, including everything that is needed for speculative scheduling.
  817. The lay-out of a ds_t is as follows:
  818. 1. Integers corresponding to the probability of the dependence to *not*
  819. exist. This is the probability that overcoming this dependence will
  820. not be followed by execution of the recovery code. Note that however
  821. high this probability is, the recovery code should still always be
  822. generated to preserve semantics of the program.
  823. The probability values can be set or retrieved using the functions
  824. the set_dep_weak() and get_dep_weak() in sched-deps.c. The values
  825. are always in the range [0, MAX_DEP_WEAK].
  826. BEGIN_DATA : BITS_PER_DEP_WEAK
  827. BE_IN_DATA : BITS_PER_DEP_WEAK
  828. BEGIN_CONTROL : BITS_PER_DEP_WEAK
  829. BE_IN_CONTROL : BITS_PER_DEP_WEAK
  830. The basic type of DS_T is a host int. For a 32-bits int, the values
  831. will each take 6 bits.
  832. 2. The type of dependence. This supercedes the old-style REG_NOTE_KIND
  833. values. TODO: Use this field instead of DEP_TYPE, or make DEP_TYPE
  834. extract the dependence type from here.
  835. dep_type : 4 => DEP_{TRUE|OUTPUT|ANTI|CONTROL}
  836. 3. Various flags:
  837. HARD_DEP : 1 => Set if an instruction has a non-speculative
  838. dependence. This is an instruction property
  839. so this bit can only appear in the TODO_SPEC
  840. field of an instruction.
  841. DEP_POSTPONED : 1 => Like HARD_DEP, but the hard dependence may
  842. still be broken by adjusting the instruction.
  843. DEP_CANCELLED : 1 => Set if a dependency has been broken using
  844. some form of speculation.
  845. RESERVED : 1 => Reserved for use in the delay slot scheduler.
  846. See also: check_dep_status () in sched-deps.c . */
  847. /* The number of bits per weakness probability. There are 4 weakness types
  848. and we need 8 bits for other data in a DS_T. */
  849. #define BITS_PER_DEP_WEAK ((BITS_PER_DEP_STATUS - 8) / 4)
  850. /* Mask of speculative weakness in dep_status. */
  851. #define DEP_WEAK_MASK ((1 << BITS_PER_DEP_WEAK) - 1)
  852. /* This constant means that dependence is fake with 99.999...% probability.
  853. This is the maximum value, that can appear in dep_status.
  854. Note, that we don't want MAX_DEP_WEAK to be the same as DEP_WEAK_MASK for
  855. debugging reasons. Though, it can be set to DEP_WEAK_MASK, and, when
  856. done so, we'll get fast (mul for)/(div by) NO_DEP_WEAK. */
  857. #define MAX_DEP_WEAK (DEP_WEAK_MASK - 1)
  858. /* This constant means that dependence is 99.999...% real and it is a really
  859. bad idea to overcome it (though this can be done, preserving program
  860. semantics). */
  861. #define MIN_DEP_WEAK 1
  862. /* This constant represents 100% probability.
  863. E.g. it is used to represent weakness of dependence, that doesn't exist.
  864. This value never appears in a ds_t, it is only used for computing the
  865. weakness of a dependence. */
  866. #define NO_DEP_WEAK (MAX_DEP_WEAK + MIN_DEP_WEAK)
  867. /* Default weakness of speculative dependence. Used when we can't say
  868. neither bad nor good about the dependence. */
  869. #define UNCERTAIN_DEP_WEAK (MAX_DEP_WEAK - MAX_DEP_WEAK / 4)
  870. /* Offset for speculative weaknesses in dep_status. */
  871. enum SPEC_TYPES_OFFSETS {
  872. BEGIN_DATA_BITS_OFFSET = 0,
  873. BE_IN_DATA_BITS_OFFSET = BEGIN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK,
  874. BEGIN_CONTROL_BITS_OFFSET = BE_IN_DATA_BITS_OFFSET + BITS_PER_DEP_WEAK,
  875. BE_IN_CONTROL_BITS_OFFSET = BEGIN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK
  876. };
  877. /* The following defines provide numerous constants used to distinguish
  878. between different types of speculative dependencies. They are also
  879. used as masks to clear/preserve the bits corresponding to the type
  880. of dependency weakness. */
  881. /* Dependence can be overcome with generation of new data speculative
  882. instruction. */
  883. #define BEGIN_DATA (((ds_t) DEP_WEAK_MASK) << BEGIN_DATA_BITS_OFFSET)
  884. /* This dependence is to the instruction in the recovery block, that was
  885. formed to recover after data-speculation failure.
  886. Thus, this dependence can overcome with generating of the copy of
  887. this instruction in the recovery block. */
  888. #define BE_IN_DATA (((ds_t) DEP_WEAK_MASK) << BE_IN_DATA_BITS_OFFSET)
  889. /* Dependence can be overcome with generation of new control speculative
  890. instruction. */
  891. #define BEGIN_CONTROL (((ds_t) DEP_WEAK_MASK) << BEGIN_CONTROL_BITS_OFFSET)
  892. /* This dependence is to the instruction in the recovery block, that was
  893. formed to recover after control-speculation failure.
  894. Thus, this dependence can be overcome with generating of the copy of
  895. this instruction in the recovery block. */
  896. #define BE_IN_CONTROL (((ds_t) DEP_WEAK_MASK) << BE_IN_CONTROL_BITS_OFFSET)
  897. /* A few convenient combinations. */
  898. #define BEGIN_SPEC (BEGIN_DATA | BEGIN_CONTROL)
  899. #define DATA_SPEC (BEGIN_DATA | BE_IN_DATA)
  900. #define CONTROL_SPEC (BEGIN_CONTROL | BE_IN_CONTROL)
  901. #define SPECULATIVE (DATA_SPEC | CONTROL_SPEC)
  902. #define BE_IN_SPEC (BE_IN_DATA | BE_IN_CONTROL)
  903. /* Constants, that are helpful in iterating through dep_status. */
  904. #define FIRST_SPEC_TYPE BEGIN_DATA
  905. #define LAST_SPEC_TYPE BE_IN_CONTROL
  906. #define SPEC_TYPE_SHIFT BITS_PER_DEP_WEAK
  907. /* Dependence on instruction can be of multiple types
  908. (e.g. true and output). This fields enhance REG_NOTE_KIND information
  909. of the dependence. */
  910. #define DEP_TRUE (((ds_t) 1) << (BE_IN_CONTROL_BITS_OFFSET + BITS_PER_DEP_WEAK))
  911. #define DEP_OUTPUT (DEP_TRUE << 1)
  912. #define DEP_ANTI (DEP_OUTPUT << 1)
  913. #define DEP_CONTROL (DEP_ANTI << 1)
  914. #define DEP_TYPES (DEP_TRUE | DEP_OUTPUT | DEP_ANTI | DEP_CONTROL)
  915. /* Instruction has non-speculative dependence. This bit represents the
  916. property of an instruction - not the one of a dependence.
  917. Therefore, it can appear only in the TODO_SPEC field of an instruction. */
  918. #define HARD_DEP (DEP_CONTROL << 1)
  919. /* Like HARD_DEP, but dependencies can perhaps be broken by modifying
  920. the instructions. This is used for example to change:
  921. rn++ => rm=[rn + 4]
  922. rm=[rn] rn++
  923. For instructions that have this bit set, one of the dependencies of
  924. the instructions will have a non-NULL REPLACE field in its DEP_T.
  925. Just like HARD_DEP, this bit is only ever set in TODO_SPEC. */
  926. #define DEP_POSTPONED (HARD_DEP << 1)
  927. /* Set if a dependency is cancelled via speculation. */
  928. #define DEP_CANCELLED (DEP_POSTPONED << 1)
  929. /* This represents the results of calling sched-deps.c functions,
  930. which modify dependencies. */
  931. enum DEPS_ADJUST_RESULT {
  932. /* No dependence needed (e.g. producer == consumer). */
  933. DEP_NODEP,
  934. /* Dependence is already present and wasn't modified. */
  935. DEP_PRESENT,
  936. /* Existing dependence was modified to include additional information. */
  937. DEP_CHANGED,
  938. /* New dependence has been created. */
  939. DEP_CREATED
  940. };
  941. /* Represents the bits that can be set in the flags field of the
  942. sched_info structure. */
  943. enum SCHED_FLAGS {
  944. /* If set, generate links between instruction as DEPS_LIST.
  945. Otherwise, generate usual INSN_LIST links. */
  946. USE_DEPS_LIST = 1,
  947. /* Perform data or control (or both) speculation.
  948. Results in generation of data and control speculative dependencies.
  949. Requires USE_DEPS_LIST set. */
  950. DO_SPECULATION = USE_DEPS_LIST << 1,
  951. DO_BACKTRACKING = DO_SPECULATION << 1,
  952. DO_PREDICATION = DO_BACKTRACKING << 1,
  953. DONT_BREAK_DEPENDENCIES = DO_PREDICATION << 1,
  954. SCHED_RGN = DONT_BREAK_DEPENDENCIES << 1,
  955. SCHED_EBB = SCHED_RGN << 1,
  956. /* Scheduler can possibly create new basic blocks. Used for assertions. */
  957. NEW_BBS = SCHED_EBB << 1,
  958. SEL_SCHED = NEW_BBS << 1
  959. };
  960. enum SPEC_SCHED_FLAGS {
  961. COUNT_SPEC_IN_CRITICAL_PATH = 1,
  962. SEL_SCHED_SPEC_DONT_CHECK_CONTROL = COUNT_SPEC_IN_CRITICAL_PATH << 1
  963. };
  964. #define NOTE_NOT_BB_P(NOTE) (NOTE_P (NOTE) && (NOTE_KIND (NOTE) \
  965. != NOTE_INSN_BASIC_BLOCK))
  966. extern FILE *sched_dump;
  967. extern int sched_verbose;
  968. extern spec_info_t spec_info;
  969. extern bool haifa_recovery_bb_ever_added_p;
  970. /* Exception Free Loads:
  971. We define five classes of speculative loads: IFREE, IRISKY,
  972. PFREE, PRISKY, and MFREE.
  973. IFREE loads are loads that are proved to be exception-free, just
  974. by examining the load insn. Examples for such loads are loads
  975. from TOC and loads of global data.
  976. IRISKY loads are loads that are proved to be exception-risky,
  977. just by examining the load insn. Examples for such loads are
  978. volatile loads and loads from shared memory.
  979. PFREE loads are loads for which we can prove, by examining other
  980. insns, that they are exception-free. Currently, this class consists
  981. of loads for which we are able to find a "similar load", either in
  982. the target block, or, if only one split-block exists, in that split
  983. block. Load2 is similar to load1 if both have same single base
  984. register. We identify only part of the similar loads, by finding
  985. an insn upon which both load1 and load2 have a DEF-USE dependence.
  986. PRISKY loads are loads for which we can prove, by examining other
  987. insns, that they are exception-risky. Currently we have two proofs for
  988. such loads. The first proof detects loads that are probably guarded by a
  989. test on the memory address. This proof is based on the
  990. backward and forward data dependence information for the region.
  991. Let load-insn be the examined load.
  992. Load-insn is PRISKY iff ALL the following hold:
  993. - insn1 is not in the same block as load-insn
  994. - there is a DEF-USE dependence chain (insn1, ..., load-insn)
  995. - test-insn is either a compare or a branch, not in the same block
  996. as load-insn
  997. - load-insn is reachable from test-insn
  998. - there is a DEF-USE dependence chain (insn1, ..., test-insn)
  999. This proof might fail when the compare and the load are fed
  1000. by an insn not in the region. To solve this, we will add to this
  1001. group all loads that have no input DEF-USE dependence.
  1002. The second proof detects loads that are directly or indirectly
  1003. fed by a speculative load. This proof is affected by the
  1004. scheduling process. We will use the flag fed_by_spec_load.
  1005. Initially, all insns have this flag reset. After a speculative
  1006. motion of an insn, if insn is either a load, or marked as
  1007. fed_by_spec_load, we will also mark as fed_by_spec_load every
  1008. insn1 for which a DEF-USE dependence (insn, insn1) exists. A
  1009. load which is fed_by_spec_load is also PRISKY.
  1010. MFREE (maybe-free) loads are all the remaining loads. They may be
  1011. exception-free, but we cannot prove it.
  1012. Now, all loads in IFREE and PFREE classes are considered
  1013. exception-free, while all loads in IRISKY and PRISKY classes are
  1014. considered exception-risky. As for loads in the MFREE class,
  1015. these are considered either exception-free or exception-risky,
  1016. depending on whether we are pessimistic or optimistic. We have
  1017. to take the pessimistic approach to assure the safety of
  1018. speculative scheduling, but we can take the optimistic approach
  1019. by invoking the -fsched_spec_load_dangerous option. */
  1020. enum INSN_TRAP_CLASS
  1021. {
  1022. TRAP_FREE = 0, IFREE = 1, PFREE_CANDIDATE = 2,
  1023. PRISKY_CANDIDATE = 3, IRISKY = 4, TRAP_RISKY = 5
  1024. };
  1025. #define WORST_CLASS(class1, class2) \
  1026. ((class1 > class2) ? class1 : class2)
  1027. #ifndef __GNUC__
  1028. #define __inline
  1029. #endif
  1030. #ifndef HAIFA_INLINE
  1031. #define HAIFA_INLINE __inline
  1032. #endif
  1033. struct sched_deps_info_def
  1034. {
  1035. /* Called when computing dependencies for a JUMP_INSN. This function
  1036. should store the set of registers that must be considered as set by
  1037. the jump in the regset. */
  1038. void (*compute_jump_reg_dependencies) (rtx, regset);
  1039. /* Start analyzing insn. */
  1040. void (*start_insn) (rtx_insn *);
  1041. /* Finish analyzing insn. */
  1042. void (*finish_insn) (void);
  1043. /* Start analyzing insn LHS (Left Hand Side). */
  1044. void (*start_lhs) (rtx);
  1045. /* Finish analyzing insn LHS. */
  1046. void (*finish_lhs) (void);
  1047. /* Start analyzing insn RHS (Right Hand Side). */
  1048. void (*start_rhs) (rtx);
  1049. /* Finish analyzing insn RHS. */
  1050. void (*finish_rhs) (void);
  1051. /* Note set of the register. */
  1052. void (*note_reg_set) (int);
  1053. /* Note clobber of the register. */
  1054. void (*note_reg_clobber) (int);
  1055. /* Note use of the register. */
  1056. void (*note_reg_use) (int);
  1057. /* Note memory dependence of type DS between MEM1 and MEM2 (which is
  1058. in the INSN2). */
  1059. void (*note_mem_dep) (rtx mem1, rtx mem2, rtx_insn *insn2, ds_t ds);
  1060. /* Note a dependence of type DS from the INSN. */
  1061. void (*note_dep) (rtx_insn *, ds_t ds);
  1062. /* Nonzero if we should use cselib for better alias analysis. This
  1063. must be 0 if the dependency information is used after sched_analyze
  1064. has completed, e.g. if we're using it to initialize state for successor
  1065. blocks in region scheduling. */
  1066. unsigned int use_cselib : 1;
  1067. /* If set, generate links between instruction as DEPS_LIST.
  1068. Otherwise, generate usual INSN_LIST links. */
  1069. unsigned int use_deps_list : 1;
  1070. /* Generate data and control speculative dependencies.
  1071. Requires USE_DEPS_LIST set. */
  1072. unsigned int generate_spec_deps : 1;
  1073. };
  1074. extern struct sched_deps_info_def *sched_deps_info;
  1075. /* Functions in sched-deps.c. */
  1076. extern rtx sched_get_reverse_condition_uncached (const rtx_insn *);
  1077. extern bool sched_insns_conditions_mutex_p (const rtx_insn *,
  1078. const rtx_insn *);
  1079. extern bool sched_insn_is_legitimate_for_speculation_p (const rtx_insn *, ds_t);
  1080. extern void add_dependence (rtx_insn *, rtx_insn *, enum reg_note);
  1081. extern void sched_analyze (struct deps_desc *, rtx_insn *, rtx_insn *);
  1082. extern void init_deps (struct deps_desc *, bool);
  1083. extern void init_deps_reg_last (struct deps_desc *);
  1084. extern void free_deps (struct deps_desc *);
  1085. extern void init_deps_global (void);
  1086. extern void finish_deps_global (void);
  1087. extern void deps_analyze_insn (struct deps_desc *, rtx_insn *);
  1088. extern void remove_from_deps (struct deps_desc *, rtx_insn *);
  1089. extern void init_insn_reg_pressure_info (rtx_insn *);
  1090. extern void get_implicit_reg_pending_clobbers (HARD_REG_SET *, rtx_insn *);
  1091. extern dw_t get_dep_weak (ds_t, ds_t);
  1092. extern ds_t set_dep_weak (ds_t, ds_t, dw_t);
  1093. extern dw_t estimate_dep_weak (rtx, rtx);
  1094. extern ds_t ds_merge (ds_t, ds_t);
  1095. extern ds_t ds_full_merge (ds_t, ds_t, rtx, rtx);
  1096. extern ds_t ds_max_merge (ds_t, ds_t);
  1097. extern dw_t ds_weak (ds_t);
  1098. extern ds_t ds_get_speculation_types (ds_t);
  1099. extern ds_t ds_get_max_dep_weak (ds_t);
  1100. extern void sched_deps_init (bool);
  1101. extern void sched_deps_finish (void);
  1102. extern void haifa_note_reg_set (int);
  1103. extern void haifa_note_reg_clobber (int);
  1104. extern void haifa_note_reg_use (int);
  1105. extern void maybe_extend_reg_info_p (void);
  1106. extern void deps_start_bb (struct deps_desc *, rtx_insn *);
  1107. extern enum reg_note ds_to_dt (ds_t);
  1108. extern bool deps_pools_are_empty_p (void);
  1109. extern void sched_free_deps (rtx_insn *, rtx_insn *, bool);
  1110. extern void extend_dependency_caches (int, bool);
  1111. extern void debug_ds (ds_t);
  1112. /* Functions in haifa-sched.c. */
  1113. extern void initialize_live_range_shrinkage (void);
  1114. extern void finish_live_range_shrinkage (void);
  1115. extern void sched_init_region_reg_pressure_info (void);
  1116. extern void free_global_sched_pressure_data (void);
  1117. extern int haifa_classify_insn (const_rtx);
  1118. extern void get_ebb_head_tail (basic_block, basic_block,
  1119. rtx_insn **, rtx_insn **);
  1120. extern int no_real_insns_p (const rtx_insn *, const rtx_insn *);
  1121. extern int insn_sched_cost (rtx_insn *);
  1122. extern int dep_cost_1 (dep_t, dw_t);
  1123. extern int dep_cost (dep_t);
  1124. extern int set_priorities (rtx_insn *, rtx_insn *);
  1125. extern void sched_setup_bb_reg_pressure_info (basic_block, rtx_insn *);
  1126. extern bool schedule_block (basic_block *, state_t);
  1127. extern int cycle_issued_insns;
  1128. extern int issue_rate;
  1129. extern int dfa_lookahead;
  1130. extern int autopref_multipass_dfa_lookahead_guard (rtx_insn *, int);
  1131. extern rtx_insn *ready_element (struct ready_list *, int);
  1132. extern rtx_insn **ready_lastpos (struct ready_list *);
  1133. extern int try_ready (rtx_insn *);
  1134. extern void sched_extend_ready_list (int);
  1135. extern void sched_finish_ready_list (void);
  1136. extern void sched_change_pattern (rtx, rtx);
  1137. extern int sched_speculate_insn (rtx_insn *, ds_t, rtx *);
  1138. extern void unlink_bb_notes (basic_block, basic_block);
  1139. extern void add_block (basic_block, basic_block);
  1140. extern rtx_note *bb_note (basic_block);
  1141. extern void concat_note_lists (rtx_insn *, rtx_insn **);
  1142. extern rtx_insn *sched_emit_insn (rtx);
  1143. extern rtx_insn *get_ready_element (int);
  1144. extern int number_in_ready (void);
  1145. /* Types and functions in sched-ebb.c. */
  1146. extern basic_block schedule_ebb (rtx_insn *, rtx_insn *, bool);
  1147. extern void schedule_ebbs_init (void);
  1148. extern void schedule_ebbs_finish (void);
  1149. /* Types and functions in sched-rgn.c. */
  1150. /* A region is the main entity for interblock scheduling: insns
  1151. are allowed to move between blocks in the same region, along
  1152. control flow graph edges, in the 'up' direction. */
  1153. struct region
  1154. {
  1155. /* Number of extended basic blocks in region. */
  1156. int rgn_nr_blocks;
  1157. /* cblocks in the region (actually index in rgn_bb_table). */
  1158. int rgn_blocks;
  1159. /* Dependencies for this region are already computed. Basically, indicates,
  1160. that this is a recovery block. */
  1161. unsigned int dont_calc_deps : 1;
  1162. /* This region has at least one non-trivial ebb. */
  1163. unsigned int has_real_ebb : 1;
  1164. };
  1165. extern int nr_regions;
  1166. extern region *rgn_table;
  1167. extern int *rgn_bb_table;
  1168. extern int *block_to_bb;
  1169. extern int *containing_rgn;
  1170. /* Often used short-hand in the scheduler. The rest of the compiler uses
  1171. BLOCK_FOR_INSN(INSN) and an indirect reference to get the basic block
  1172. number ("index"). For historical reasons, the scheduler does not. */
  1173. #define BLOCK_NUM(INSN) (BLOCK_FOR_INSN (INSN)->index + 0)
  1174. #define RGN_NR_BLOCKS(rgn) (rgn_table[rgn].rgn_nr_blocks)
  1175. #define RGN_BLOCKS(rgn) (rgn_table[rgn].rgn_blocks)
  1176. #define RGN_DONT_CALC_DEPS(rgn) (rgn_table[rgn].dont_calc_deps)
  1177. #define RGN_HAS_REAL_EBB(rgn) (rgn_table[rgn].has_real_ebb)
  1178. #define BLOCK_TO_BB(block) (block_to_bb[block])
  1179. #define CONTAINING_RGN(block) (containing_rgn[block])
  1180. /* The mapping from ebb to block. */
  1181. extern int *ebb_head;
  1182. #define BB_TO_BLOCK(ebb) (rgn_bb_table[ebb_head[ebb]])
  1183. #define EBB_FIRST_BB(ebb) BASIC_BLOCK_FOR_FN (cfun, BB_TO_BLOCK (ebb))
  1184. #define EBB_LAST_BB(ebb) \
  1185. BASIC_BLOCK_FOR_FN (cfun, rgn_bb_table[ebb_head[ebb + 1] - 1])
  1186. #define INSN_BB(INSN) (BLOCK_TO_BB (BLOCK_NUM (INSN)))
  1187. extern int current_nr_blocks;
  1188. extern int current_blocks;
  1189. extern int target_bb;
  1190. extern bool sched_no_dce;
  1191. extern void set_modulo_params (int, int, int, int);
  1192. extern void record_delay_slot_pair (rtx_insn *, rtx_insn *, int, int);
  1193. extern rtx_insn *real_insn_for_shadow (rtx_insn *);
  1194. extern void discard_delay_pairs_above (int);
  1195. extern void free_delay_pairs (void);
  1196. extern void add_delay_dependencies (rtx_insn *);
  1197. extern bool sched_is_disabled_for_current_region_p (void);
  1198. extern void sched_rgn_init (bool);
  1199. extern void sched_rgn_finish (void);
  1200. extern void rgn_setup_region (int);
  1201. extern void sched_rgn_compute_dependencies (int);
  1202. extern void sched_rgn_local_init (int);
  1203. extern void sched_rgn_local_finish (void);
  1204. extern void sched_rgn_local_free (void);
  1205. extern void extend_regions (void);
  1206. extern void rgn_make_new_region_out_of_new_block (basic_block);
  1207. extern void compute_priorities (void);
  1208. extern void increase_insn_priority (rtx_insn *, int);
  1209. extern void debug_rgn_dependencies (int);
  1210. extern void debug_dependencies (rtx_insn *, rtx_insn *);
  1211. extern void dump_rgn_dependencies_dot (FILE *);
  1212. extern void dump_rgn_dependencies_dot (const char *);
  1213. extern void free_rgn_deps (void);
  1214. extern int contributes_to_priority (rtx_insn *, rtx_insn *);
  1215. extern void extend_rgns (int *, int *, sbitmap, int *);
  1216. extern void deps_join (struct deps_desc *, struct deps_desc *);
  1217. extern void rgn_setup_common_sched_info (void);
  1218. extern void rgn_setup_sched_infos (void);
  1219. extern void debug_regions (void);
  1220. extern void debug_region (int);
  1221. extern void dump_region_dot (FILE *, int);
  1222. extern void dump_region_dot_file (const char *, int);
  1223. extern void haifa_sched_init (void);
  1224. extern void haifa_sched_finish (void);
  1225. extern void find_modifiable_mems (rtx_insn *, rtx_insn *);
  1226. /* sched-deps.c interface to walk, add, search, update, resolve, delete
  1227. and debug instruction dependencies. */
  1228. /* Constants defining dependences lists. */
  1229. /* No list. */
  1230. #define SD_LIST_NONE (0)
  1231. /* hard_back_deps. */
  1232. #define SD_LIST_HARD_BACK (1)
  1233. /* spec_back_deps. */
  1234. #define SD_LIST_SPEC_BACK (2)
  1235. /* forw_deps. */
  1236. #define SD_LIST_FORW (4)
  1237. /* resolved_back_deps. */
  1238. #define SD_LIST_RES_BACK (8)
  1239. /* resolved_forw_deps. */
  1240. #define SD_LIST_RES_FORW (16)
  1241. #define SD_LIST_BACK (SD_LIST_HARD_BACK | SD_LIST_SPEC_BACK)
  1242. /* A type to hold above flags. */
  1243. typedef int sd_list_types_def;
  1244. extern void sd_next_list (const_rtx, sd_list_types_def *, deps_list_t *, bool *);
  1245. /* Iterator to walk through, resolve and delete dependencies. */
  1246. struct _sd_iterator
  1247. {
  1248. /* What lists to walk. Can be any combination of SD_LIST_* flags. */
  1249. sd_list_types_def types;
  1250. /* Instruction dependencies lists of which will be walked. */
  1251. rtx insn;
  1252. /* Pointer to the next field of the previous element. This is not
  1253. simply a pointer to the next element to allow easy deletion from the
  1254. list. When a dep is being removed from the list the iterator
  1255. will automatically advance because the value in *linkp will start
  1256. referring to the next element. */
  1257. dep_link_t *linkp;
  1258. /* True if the current list is a resolved one. */
  1259. bool resolved_p;
  1260. };
  1261. typedef struct _sd_iterator sd_iterator_def;
  1262. /* ??? We can move some definitions that are used in below inline functions
  1263. out of sched-int.h to sched-deps.c provided that the below functions will
  1264. become global externals.
  1265. These definitions include:
  1266. * struct _deps_list: opaque pointer is needed at global scope.
  1267. * struct _dep_link: opaque pointer is needed at scope of sd_iterator_def.
  1268. * struct _dep_node: opaque pointer is needed at scope of
  1269. struct _deps_link. */
  1270. /* Return initialized iterator. */
  1271. static inline sd_iterator_def
  1272. sd_iterator_start (rtx insn, sd_list_types_def types)
  1273. {
  1274. /* Some dep_link a pointer to which will return NULL. */
  1275. static dep_link_t null_link = NULL;
  1276. sd_iterator_def i;
  1277. i.types = types;
  1278. i.insn = insn;
  1279. i.linkp = &null_link;
  1280. /* Avoid 'uninitialized warning'. */
  1281. i.resolved_p = false;
  1282. return i;
  1283. }
  1284. /* Return the current element. */
  1285. static inline bool
  1286. sd_iterator_cond (sd_iterator_def *it_ptr, dep_t *dep_ptr)
  1287. {
  1288. while (true)
  1289. {
  1290. dep_link_t link = *it_ptr->linkp;
  1291. if (link != NULL)
  1292. {
  1293. *dep_ptr = DEP_LINK_DEP (link);
  1294. return true;
  1295. }
  1296. else
  1297. {
  1298. sd_list_types_def types = it_ptr->types;
  1299. if (types != SD_LIST_NONE)
  1300. /* Switch to next list. */
  1301. {
  1302. deps_list_t list;
  1303. sd_next_list (it_ptr->insn,
  1304. &it_ptr->types, &list, &it_ptr->resolved_p);
  1305. if (list)
  1306. {
  1307. it_ptr->linkp = &DEPS_LIST_FIRST (list);
  1308. continue;
  1309. }
  1310. }
  1311. *dep_ptr = NULL;
  1312. return false;
  1313. }
  1314. }
  1315. }
  1316. /* Advance iterator. */
  1317. static inline void
  1318. sd_iterator_next (sd_iterator_def *it_ptr)
  1319. {
  1320. it_ptr->linkp = &DEP_LINK_NEXT (*it_ptr->linkp);
  1321. }
  1322. /* A cycle wrapper. */
  1323. #define FOR_EACH_DEP(INSN, LIST_TYPES, ITER, DEP) \
  1324. for ((ITER) = sd_iterator_start ((INSN), (LIST_TYPES)); \
  1325. sd_iterator_cond (&(ITER), &(DEP)); \
  1326. sd_iterator_next (&(ITER)))
  1327. #define IS_DISPATCH_ON 1
  1328. #define IS_CMP 2
  1329. #define DISPATCH_VIOLATION 3
  1330. #define FITS_DISPATCH_WINDOW 4
  1331. #define DISPATCH_INIT 5
  1332. #define ADD_TO_DISPATCH_WINDOW 6
  1333. extern int sd_lists_size (const_rtx, sd_list_types_def);
  1334. extern bool sd_lists_empty_p (const_rtx, sd_list_types_def);
  1335. extern void sd_init_insn (rtx_insn *);
  1336. extern void sd_finish_insn (rtx_insn *);
  1337. extern dep_t sd_find_dep_between (rtx, rtx, bool);
  1338. extern void sd_add_dep (dep_t, bool);
  1339. extern enum DEPS_ADJUST_RESULT sd_add_or_update_dep (dep_t, bool);
  1340. extern void sd_resolve_dep (sd_iterator_def);
  1341. extern void sd_unresolve_dep (sd_iterator_def);
  1342. extern void sd_copy_back_deps (rtx_insn *, rtx_insn *, bool);
  1343. extern void sd_delete_dep (sd_iterator_def);
  1344. extern void sd_debug_lists (rtx, sd_list_types_def);
  1345. /* Macros and declarations for scheduling fusion. */
  1346. #define FUSION_MAX_PRIORITY (INT_MAX)
  1347. extern bool sched_fusion;
  1348. #endif /* INSN_SCHEDULING */
  1349. #endif /* GCC_SCHED_INT_H */