sched-int.h 59 KB

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