hooks.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. /* General-purpose hooks.
  2. Copyright (C) 2002-2015 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU General Public License as published by the
  5. Free Software Foundation; either version 3, or (at your option) any
  6. later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; see the file COPYING3. If not see
  13. <http://www.gnu.org/licenses/>.
  14. In other words, you are welcome to use, share and improve this program.
  15. You are forbidden to forbid anyone else to use, share and improve
  16. what you give them. Help stamp out software-hoarding! */
  17. /* This file contains generic hooks that can be used as defaults for
  18. target or language-dependent hook initializers. */
  19. #include "config.h"
  20. #include "system.h"
  21. #include "coretypes.h"
  22. #include "tm.h"
  23. #include "hooks.h"
  24. /* Generic hook that does absolutely zappo. */
  25. void
  26. hook_void_void (void)
  27. {
  28. }
  29. /* Generic hook that takes no arguments and returns false. */
  30. bool
  31. hook_bool_void_false (void)
  32. {
  33. return false;
  34. }
  35. /* Generic hook that takes no arguments and returns true. */
  36. bool
  37. hook_bool_void_true (void)
  38. {
  39. return true;
  40. }
  41. /* Generic hook that takes (bool) and returns false. */
  42. bool
  43. hook_bool_bool_false (bool a ATTRIBUTE_UNUSED)
  44. {
  45. return false;
  46. }
  47. /* Generic hook that takes (bool, struct gcc_options *) and returns false. */
  48. bool
  49. hook_bool_bool_gcc_optionsp_false (bool a ATTRIBUTE_UNUSED,
  50. struct gcc_options *opts ATTRIBUTE_UNUSED)
  51. {
  52. return false;
  53. }
  54. /* Generic hook that takes const int, const int) and returns true. */
  55. bool hook_bool_const_int_const_int_true (const int a ATTRIBUTE_UNUSED,
  56. const int b ATTRIBUTE_UNUSED)
  57. {
  58. return true;
  59. }
  60. /* Generic hook that takes (machine_mode) and returns false. */
  61. bool
  62. hook_bool_mode_false (machine_mode mode ATTRIBUTE_UNUSED)
  63. {
  64. return false;
  65. }
  66. /* Generic hook that takes (machine_mode) and returns true. */
  67. bool
  68. hook_bool_mode_true (machine_mode mode ATTRIBUTE_UNUSED)
  69. {
  70. return true;
  71. }
  72. /* Generic hook that takes (machine_mode, const_rtx) and returns false. */
  73. bool
  74. hook_bool_mode_const_rtx_false (machine_mode mode ATTRIBUTE_UNUSED,
  75. const_rtx value ATTRIBUTE_UNUSED)
  76. {
  77. return false;
  78. }
  79. /* Generic hook that takes (machine_mode, const_rtx) and returns true. */
  80. bool
  81. hook_bool_mode_const_rtx_true (machine_mode mode ATTRIBUTE_UNUSED,
  82. const_rtx value ATTRIBUTE_UNUSED)
  83. {
  84. return true;
  85. }
  86. /* Generic hook that takes (machine_mode, rtx) and returns false. */
  87. bool
  88. hook_bool_mode_rtx_false (machine_mode mode ATTRIBUTE_UNUSED,
  89. rtx value ATTRIBUTE_UNUSED)
  90. {
  91. return false;
  92. }
  93. /* Generic hook that takes (machine_mode, rtx) and returns true. */
  94. bool
  95. hook_bool_mode_rtx_true (machine_mode mode ATTRIBUTE_UNUSED,
  96. rtx value ATTRIBUTE_UNUSED)
  97. {
  98. return true;
  99. }
  100. /* Generic hook that takes (const rtx_insn *, const rtx_insn *) and returns true. */
  101. bool
  102. hook_bool_const_rtx_insn_const_rtx_insn_true (const rtx_insn *follower ATTRIBUTE_UNUSED,
  103. const rtx_insn *followee ATTRIBUTE_UNUSED)
  104. {
  105. return true;
  106. }
  107. /* Generic hook that takes (machine_mode, unsigned HOST_WIDE_INT)
  108. and returns false. */
  109. bool
  110. hook_bool_mode_uhwi_false (machine_mode mode ATTRIBUTE_UNUSED,
  111. unsigned HOST_WIDE_INT value ATTRIBUTE_UNUSED)
  112. {
  113. return false;
  114. }
  115. /* Generic hook that takes (FILE *, const char *) and does nothing. */
  116. void
  117. hook_void_FILEptr_constcharptr (FILE *a ATTRIBUTE_UNUSED, const char *b ATTRIBUTE_UNUSED)
  118. {
  119. }
  120. /* Generic hook that takes (FILE *, const char *, constr_tree *) and does
  121. nothing. */
  122. void
  123. hook_void_FILEptr_constcharptr_const_tree (FILE *, const char *, const_tree)
  124. {
  125. }
  126. /* Generic hook that takes (FILE *, rtx) and returns false. */
  127. bool
  128. hook_bool_FILEptr_rtx_false (FILE *a ATTRIBUTE_UNUSED,
  129. rtx b ATTRIBUTE_UNUSED)
  130. {
  131. return false;
  132. }
  133. /* Generic hook that takes (gimple_stmt_iterator *) and returns
  134. false. */
  135. bool
  136. hook_bool_gsiptr_false (gimple_stmt_iterator *a ATTRIBUTE_UNUSED)
  137. {
  138. return false;
  139. }
  140. /* Used for the TARGET_ASM_CAN_OUTPUT_MI_THUNK hook. */
  141. bool
  142. hook_bool_const_tree_hwi_hwi_const_tree_false (const_tree a ATTRIBUTE_UNUSED,
  143. HOST_WIDE_INT b ATTRIBUTE_UNUSED,
  144. HOST_WIDE_INT c ATTRIBUTE_UNUSED,
  145. const_tree d ATTRIBUTE_UNUSED)
  146. {
  147. return false;
  148. }
  149. bool
  150. hook_bool_const_tree_hwi_hwi_const_tree_true (const_tree a ATTRIBUTE_UNUSED,
  151. HOST_WIDE_INT b ATTRIBUTE_UNUSED,
  152. HOST_WIDE_INT c ATTRIBUTE_UNUSED,
  153. const_tree d ATTRIBUTE_UNUSED)
  154. {
  155. return true;
  156. }
  157. bool
  158. default_can_output_mi_thunk_no_vcall (const_tree a ATTRIBUTE_UNUSED,
  159. HOST_WIDE_INT b ATTRIBUTE_UNUSED,
  160. HOST_WIDE_INT c,
  161. const_tree d ATTRIBUTE_UNUSED)
  162. {
  163. return c == 0;
  164. }
  165. int
  166. hook_int_uint_mode_1 (unsigned int a ATTRIBUTE_UNUSED,
  167. machine_mode b ATTRIBUTE_UNUSED)
  168. {
  169. return 1;
  170. }
  171. int
  172. hook_int_const_tree_0 (const_tree a ATTRIBUTE_UNUSED)
  173. {
  174. return 0;
  175. }
  176. /* ??? Used for comp_type_attributes, which ought to return bool. */
  177. int
  178. hook_int_const_tree_const_tree_1 (const_tree a ATTRIBUTE_UNUSED, const_tree b ATTRIBUTE_UNUSED)
  179. {
  180. return 1;
  181. }
  182. int
  183. hook_int_rtx_0 (rtx a ATTRIBUTE_UNUSED)
  184. {
  185. return 0;
  186. }
  187. int
  188. hook_int_rtx_1 (rtx)
  189. {
  190. return 1;
  191. }
  192. int
  193. hook_int_rtx_insn_unreachable (rtx_insn *)
  194. {
  195. gcc_unreachable ();
  196. }
  197. int
  198. hook_int_rtx_bool_0 (rtx a ATTRIBUTE_UNUSED, bool b ATTRIBUTE_UNUSED)
  199. {
  200. return 0;
  201. }
  202. int
  203. hook_int_rtx_mode_as_bool_0 (rtx, machine_mode, addr_space_t, bool)
  204. {
  205. return 0;
  206. }
  207. unsigned int
  208. hook_uint_void_0 (void)
  209. {
  210. return 0;
  211. }
  212. void
  213. hook_void_tree (tree a ATTRIBUTE_UNUSED)
  214. {
  215. }
  216. void
  217. hook_void_rtx_tree (rtx, tree)
  218. {
  219. }
  220. void
  221. hook_void_constcharptr (const char *a ATTRIBUTE_UNUSED)
  222. {
  223. }
  224. void
  225. hook_void_tree_treeptr (tree a ATTRIBUTE_UNUSED, tree *b ATTRIBUTE_UNUSED)
  226. {
  227. }
  228. void
  229. hook_void_int_int (int a ATTRIBUTE_UNUSED, int b ATTRIBUTE_UNUSED)
  230. {
  231. }
  232. bool
  233. hook_bool_tree_false (tree a ATTRIBUTE_UNUSED)
  234. {
  235. return false;
  236. }
  237. bool
  238. hook_bool_const_tree_false (const_tree a ATTRIBUTE_UNUSED)
  239. {
  240. return false;
  241. }
  242. bool
  243. hook_bool_tree_true (tree a ATTRIBUTE_UNUSED)
  244. {
  245. return true;
  246. }
  247. bool
  248. hook_bool_const_tree_true (const_tree a ATTRIBUTE_UNUSED)
  249. {
  250. return true;
  251. }
  252. bool
  253. hook_bool_tree_tree_false (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
  254. {
  255. return false;
  256. }
  257. bool
  258. hook_bool_tree_tree_true (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
  259. {
  260. return true;
  261. }
  262. bool
  263. hook_bool_tree_bool_false (tree a ATTRIBUTE_UNUSED, bool b ATTRIBUTE_UNUSED)
  264. {
  265. return false;
  266. }
  267. bool
  268. hook_bool_rtx_insn_true (rtx_insn *insn ATTRIBUTE_UNUSED)
  269. {
  270. return true;
  271. }
  272. bool
  273. hook_bool_rtx_false (rtx a ATTRIBUTE_UNUSED)
  274. {
  275. return false;
  276. }
  277. bool
  278. hook_bool_uintp_uintp_false (unsigned int *a ATTRIBUTE_UNUSED,
  279. unsigned int *b ATTRIBUTE_UNUSED)
  280. {
  281. return false;
  282. }
  283. bool
  284. hook_bool_rtx_int_int_int_intp_bool_false (rtx a ATTRIBUTE_UNUSED,
  285. int b ATTRIBUTE_UNUSED,
  286. int c ATTRIBUTE_UNUSED,
  287. int d ATTRIBUTE_UNUSED,
  288. int *e ATTRIBUTE_UNUSED,
  289. bool speed_p ATTRIBUTE_UNUSED)
  290. {
  291. return false;
  292. }
  293. bool
  294. hook_bool_wint_wint_uint_bool_true (const widest_int &, const widest_int &,
  295. unsigned int, bool)
  296. {
  297. return true;
  298. }
  299. /* Generic hook that takes an rtx and returns it. */
  300. rtx
  301. hook_rtx_rtx_identity (rtx x)
  302. {
  303. return x;
  304. }
  305. /* Generic hook that takes an rtx and returns NULL_RTX. */
  306. rtx
  307. hook_rtx_rtx_null (rtx x ATTRIBUTE_UNUSED)
  308. {
  309. return NULL;
  310. }
  311. /* Generic hook that takes a tree and an int and returns NULL_RTX. */
  312. rtx
  313. hook_rtx_tree_int_null (tree a ATTRIBUTE_UNUSED, int b ATTRIBUTE_UNUSED)
  314. {
  315. return NULL;
  316. }
  317. /* Generic hook that takes a machine mode and returns an unsigned int 0. */
  318. unsigned int
  319. hook_uint_mode_0 (machine_mode m ATTRIBUTE_UNUSED)
  320. {
  321. return 0;
  322. }
  323. /* Generic hook that takes three trees and returns the last one as is. */
  324. tree
  325. hook_tree_tree_tree_tree_3rd_identity (tree a ATTRIBUTE_UNUSED,
  326. tree b ATTRIBUTE_UNUSED, tree c)
  327. {
  328. return c;
  329. }
  330. /* Generic hook that takes no arguments and returns a NULL const string. */
  331. const char *
  332. hook_constcharptr_void_null (void)
  333. {
  334. return NULL;
  335. }
  336. /* Generic hook that takes no arguments and returns a NULL string. */
  337. char *
  338. hook_charptr_void_null (void)
  339. {
  340. return NULL;
  341. }
  342. /* Generic hook that takes a tree and returns a NULL string. */
  343. const char *
  344. hook_constcharptr_const_tree_null (const_tree t ATTRIBUTE_UNUSED)
  345. {
  346. return NULL;
  347. }
  348. tree
  349. hook_tree_tree_int_treep_bool_null (tree t0 ATTRIBUTE_UNUSED,
  350. int i ATTRIBUTE_UNUSED,
  351. tree *p ATTRIBUTE_UNUSED,
  352. bool ignore ATTRIBUTE_UNUSED)
  353. {
  354. return NULL;
  355. }
  356. tree
  357. hook_tree_tree_tree_null (tree t0 ATTRIBUTE_UNUSED, tree t1 ATTRIBUTE_UNUSED)
  358. {
  359. return NULL;
  360. }
  361. tree
  362. hook_tree_tree_tree_tree_null (tree t0 ATTRIBUTE_UNUSED,
  363. tree t1 ATTRIBUTE_UNUSED,
  364. tree t2 ATTRIBUTE_UNUSED)
  365. {
  366. return NULL;
  367. }
  368. /* Generic hook that takes an rtx_insn *and returns a NULL string. */
  369. const char *
  370. hook_constcharptr_const_rtx_insn_null (const rtx_insn *insn ATTRIBUTE_UNUSED)
  371. {
  372. return NULL;
  373. }
  374. const char *
  375. hook_constcharptr_const_tree_const_tree_null (const_tree t0 ATTRIBUTE_UNUSED,
  376. const_tree t1 ATTRIBUTE_UNUSED)
  377. {
  378. return NULL;
  379. }
  380. const char *
  381. hook_constcharptr_int_const_tree_null (int i ATTRIBUTE_UNUSED,
  382. const_tree t0 ATTRIBUTE_UNUSED)
  383. {
  384. return NULL;
  385. }
  386. const char *
  387. hook_constcharptr_int_const_tree_const_tree_null (int i ATTRIBUTE_UNUSED,
  388. const_tree t0 ATTRIBUTE_UNUSED,
  389. const_tree t1 ATTRIBUTE_UNUSED)
  390. {
  391. return NULL;
  392. }
  393. /* Generic hook that takes a const_tree and returns NULL_TREE. */
  394. tree
  395. hook_tree_const_tree_null (const_tree t ATTRIBUTE_UNUSED)
  396. {
  397. return NULL;
  398. }
  399. /* Generic hook that takes a rtx_insn * and an int and returns a bool. */
  400. bool
  401. hook_bool_rtx_insn_int_false (rtx_insn *insn ATTRIBUTE_UNUSED,
  402. int mode ATTRIBUTE_UNUSED)
  403. {
  404. return false;
  405. }
  406. /* Generic hook that takes a rtx_insn * and an int and returns void. */
  407. void
  408. hook_void_rtx_insn_int (rtx_insn *insn ATTRIBUTE_UNUSED,
  409. int mode ATTRIBUTE_UNUSED)
  410. {
  411. }
  412. /* Generic hook that takes a struct gcc_options * and returns void. */
  413. void
  414. hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED)
  415. {
  416. }