rtl.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. /* RTL utility routines.
  2. Copyright (C) 1987-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. /* This file is compiled twice: once for the generator programs
  16. once for the compiler. */
  17. #ifdef GENERATOR_FILE
  18. #include "bconfig.h"
  19. #else
  20. #include "config.h"
  21. #endif
  22. #include "system.h"
  23. #include "coretypes.h"
  24. #include "tm.h"
  25. #include "ggc.h"
  26. #include "rtl.h"
  27. #ifdef GENERATOR_FILE
  28. # include "errors.h"
  29. #else
  30. # include "rtlhash.h"
  31. # include "diagnostic-core.h"
  32. #endif
  33. /* Indexed by rtx code, gives number of operands for an rtx with that code.
  34. Does NOT include rtx header data (code and links). */
  35. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) sizeof FORMAT - 1 ,
  36. const unsigned char rtx_length[NUM_RTX_CODE] = {
  37. #include "rtl.def"
  38. };
  39. #undef DEF_RTL_EXPR
  40. /* Indexed by rtx code, gives the name of that kind of rtx, as a C string. */
  41. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) NAME ,
  42. const char * const rtx_name[NUM_RTX_CODE] = {
  43. #include "rtl.def" /* rtl expressions are documented here */
  44. };
  45. #undef DEF_RTL_EXPR
  46. /* Indexed by rtx code, gives a sequence of operand-types for
  47. rtx's of that code. The sequence is a C string in which
  48. each character describes one operand. */
  49. const char * const rtx_format[NUM_RTX_CODE] = {
  50. /* "*" undefined.
  51. can cause a warning message
  52. "0" field is unused (or used in a phase-dependent manner)
  53. prints nothing
  54. "i" an integer
  55. prints the integer
  56. "n" like "i", but prints entries from `note_insn_name'
  57. "w" an integer of width HOST_BITS_PER_WIDE_INT
  58. prints the integer
  59. "s" a pointer to a string
  60. prints the string
  61. "S" like "s", but optional:
  62. the containing rtx may end before this operand
  63. "T" like "s", but treated specially by the RTL reader;
  64. only found in machine description patterns.
  65. "e" a pointer to an rtl expression
  66. prints the expression
  67. "E" a pointer to a vector that points to a number of rtl expressions
  68. prints a list of the rtl expressions
  69. "V" like "E", but optional:
  70. the containing rtx may end before this operand
  71. "u" a pointer to another insn
  72. prints the uid of the insn.
  73. "b" is a pointer to a bitmap header.
  74. "B" is a basic block pointer.
  75. "t" is a tree pointer. */
  76. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) FORMAT ,
  77. #include "rtl.def" /* rtl expressions are defined here */
  78. #undef DEF_RTL_EXPR
  79. };
  80. /* Indexed by rtx code, gives a character representing the "class" of
  81. that rtx code. See rtl.def for documentation on the defined classes. */
  82. const enum rtx_class rtx_class[NUM_RTX_CODE] = {
  83. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) CLASS,
  84. #include "rtl.def" /* rtl expressions are defined here */
  85. #undef DEF_RTL_EXPR
  86. };
  87. /* Indexed by rtx code, gives the size of the rtx in bytes. */
  88. const unsigned char rtx_code_size[NUM_RTX_CODE] = {
  89. #define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \
  90. (((ENUM) == CONST_INT || (ENUM) == CONST_DOUBLE \
  91. || (ENUM) == CONST_FIXED || (ENUM) == CONST_WIDE_INT) \
  92. ? RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (HOST_WIDE_INT) \
  93. : RTX_HDR_SIZE + (sizeof FORMAT - 1) * sizeof (rtunion)),
  94. #include "rtl.def"
  95. #undef DEF_RTL_EXPR
  96. };
  97. /* Names for kinds of NOTEs and REG_NOTEs. */
  98. const char * const note_insn_name[NOTE_INSN_MAX] =
  99. {
  100. #define DEF_INSN_NOTE(NAME) #NAME,
  101. #include "insn-notes.def"
  102. #undef DEF_INSN_NOTE
  103. };
  104. const char * const reg_note_name[REG_NOTE_MAX] =
  105. {
  106. #define DEF_REG_NOTE(NAME) #NAME,
  107. #include "reg-notes.def"
  108. #undef DEF_REG_NOTE
  109. };
  110. static int rtx_alloc_counts[(int) LAST_AND_UNUSED_RTX_CODE];
  111. static int rtx_alloc_sizes[(int) LAST_AND_UNUSED_RTX_CODE];
  112. static int rtvec_alloc_counts;
  113. static int rtvec_alloc_sizes;
  114. /* Allocate an rtx vector of N elements.
  115. Store the length, and initialize all elements to zero. */
  116. rtvec
  117. rtvec_alloc (int n)
  118. {
  119. rtvec rt;
  120. rt = ggc_alloc_rtvec_sized (n);
  121. /* Clear out the vector. */
  122. memset (&rt->elem[0], 0, n * sizeof (rtx));
  123. PUT_NUM_ELEM (rt, n);
  124. if (GATHER_STATISTICS)
  125. {
  126. rtvec_alloc_counts++;
  127. rtvec_alloc_sizes += n * sizeof (rtx);
  128. }
  129. return rt;
  130. }
  131. /* Create a bitwise copy of VEC. */
  132. rtvec
  133. shallow_copy_rtvec (rtvec vec)
  134. {
  135. rtvec newvec;
  136. int n;
  137. n = GET_NUM_ELEM (vec);
  138. newvec = rtvec_alloc (n);
  139. memcpy (&newvec->elem[0], &vec->elem[0], sizeof (rtx) * n);
  140. return newvec;
  141. }
  142. /* Return the number of bytes occupied by rtx value X. */
  143. unsigned int
  144. rtx_size (const_rtx x)
  145. {
  146. if (CONST_WIDE_INT_P (x))
  147. return (RTX_HDR_SIZE
  148. + sizeof (struct hwivec_def)
  149. + ((CONST_WIDE_INT_NUNITS (x) - 1)
  150. * sizeof (HOST_WIDE_INT)));
  151. if (GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_HAS_BLOCK_INFO_P (x))
  152. return RTX_HDR_SIZE + sizeof (struct block_symbol);
  153. return RTX_CODE_SIZE (GET_CODE (x));
  154. }
  155. /* Allocate an rtx of code CODE with EXTRA bytes in it. The CODE is
  156. stored in the rtx; all the rest is initialized to zero. */
  157. rtx
  158. rtx_alloc_stat_v (RTX_CODE code MEM_STAT_DECL, int extra)
  159. {
  160. rtx rt = ggc_alloc_rtx_def_stat (RTX_CODE_SIZE (code) + extra
  161. PASS_MEM_STAT);
  162. /* We want to clear everything up to the FLD array. Normally, this
  163. is one int, but we don't want to assume that and it isn't very
  164. portable anyway; this is. */
  165. memset (rt, 0, RTX_HDR_SIZE);
  166. PUT_CODE (rt, code);
  167. if (GATHER_STATISTICS)
  168. {
  169. rtx_alloc_counts[code]++;
  170. rtx_alloc_sizes[code] += RTX_CODE_SIZE (code);
  171. }
  172. return rt;
  173. }
  174. /* Allocate an rtx of code CODE. The CODE is stored in the rtx;
  175. all the rest is initialized to zero. */
  176. rtx
  177. rtx_alloc_stat (RTX_CODE code MEM_STAT_DECL)
  178. {
  179. return rtx_alloc_stat_v (code PASS_MEM_STAT, 0);
  180. }
  181. /* Write the wide constant X to OUTFILE. */
  182. void
  183. cwi_output_hex (FILE *outfile, const_rtx x)
  184. {
  185. int i = CWI_GET_NUM_ELEM (x);
  186. gcc_assert (i > 0);
  187. if (CWI_ELT (x, i - 1) == 0)
  188. /* The HOST_WIDE_INT_PRINT_HEX prepends a 0x only if the val is
  189. non zero. We want all numbers to have a 0x prefix. */
  190. fprintf (outfile, "0x");
  191. fprintf (outfile, HOST_WIDE_INT_PRINT_HEX, CWI_ELT (x, --i));
  192. while (--i >= 0)
  193. fprintf (outfile, HOST_WIDE_INT_PRINT_PADDED_HEX, CWI_ELT (x, i));
  194. }
  195. /* Return true if ORIG is a sharable CONST. */
  196. bool
  197. shared_const_p (const_rtx orig)
  198. {
  199. gcc_assert (GET_CODE (orig) == CONST);
  200. /* CONST can be shared if it contains a SYMBOL_REF. If it contains
  201. a LABEL_REF, it isn't sharable. */
  202. return (GET_CODE (XEXP (orig, 0)) == PLUS
  203. && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
  204. && CONST_INT_P (XEXP (XEXP (orig, 0), 1)));
  205. }
  206. /* Create a new copy of an rtx.
  207. Recursively copies the operands of the rtx,
  208. except for those few rtx codes that are sharable. */
  209. rtx
  210. copy_rtx (rtx orig)
  211. {
  212. rtx copy;
  213. int i, j;
  214. RTX_CODE code;
  215. const char *format_ptr;
  216. code = GET_CODE (orig);
  217. switch (code)
  218. {
  219. case REG:
  220. case DEBUG_EXPR:
  221. case VALUE:
  222. CASE_CONST_ANY:
  223. case SYMBOL_REF:
  224. case CODE_LABEL:
  225. case PC:
  226. case CC0:
  227. case RETURN:
  228. case SIMPLE_RETURN:
  229. case SCRATCH:
  230. /* SCRATCH must be shared because they represent distinct values. */
  231. return orig;
  232. case CLOBBER:
  233. /* Share clobbers of hard registers (like cc0), but do not share pseudo reg
  234. clobbers or clobbers of hard registers that originated as pseudos.
  235. This is needed to allow safe register renaming. */
  236. if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < FIRST_PSEUDO_REGISTER
  237. && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0)))
  238. return orig;
  239. break;
  240. case CONST:
  241. if (shared_const_p (orig))
  242. return orig;
  243. break;
  244. /* A MEM with a constant address is not sharable. The problem is that
  245. the constant address may need to be reloaded. If the mem is shared,
  246. then reloading one copy of this mem will cause all copies to appear
  247. to have been reloaded. */
  248. default:
  249. break;
  250. }
  251. /* Copy the various flags, fields, and other information. We assume
  252. that all fields need copying, and then clear the fields that should
  253. not be copied. That is the sensible default behavior, and forces
  254. us to explicitly document why we are *not* copying a flag. */
  255. copy = shallow_copy_rtx (orig);
  256. /* We do not copy the USED flag, which is used as a mark bit during
  257. walks over the RTL. */
  258. RTX_FLAG (copy, used) = 0;
  259. format_ptr = GET_RTX_FORMAT (GET_CODE (copy));
  260. for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
  261. switch (*format_ptr++)
  262. {
  263. case 'e':
  264. if (XEXP (orig, i) != NULL)
  265. XEXP (copy, i) = copy_rtx (XEXP (orig, i));
  266. break;
  267. case 'E':
  268. case 'V':
  269. if (XVEC (orig, i) != NULL)
  270. {
  271. XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
  272. for (j = 0; j < XVECLEN (copy, i); j++)
  273. XVECEXP (copy, i, j) = copy_rtx (XVECEXP (orig, i, j));
  274. }
  275. break;
  276. case 't':
  277. case 'w':
  278. case 'i':
  279. case 's':
  280. case 'S':
  281. case 'T':
  282. case 'u':
  283. case 'B':
  284. case '0':
  285. /* These are left unchanged. */
  286. break;
  287. default:
  288. gcc_unreachable ();
  289. }
  290. return copy;
  291. }
  292. /* Create a new copy of an rtx. Only copy just one level. */
  293. rtx
  294. shallow_copy_rtx_stat (const_rtx orig MEM_STAT_DECL)
  295. {
  296. const unsigned int size = rtx_size (orig);
  297. rtx const copy = ggc_alloc_rtx_def_stat (size PASS_MEM_STAT);
  298. return (rtx) memcpy (copy, orig, size);
  299. }
  300. /* Nonzero when we are generating CONCATs. */
  301. int generating_concat_p;
  302. /* Nonzero when we are expanding trees to RTL. */
  303. int currently_expanding_to_rtl;
  304. /* Same as rtx_equal_p, but call CB on each pair of rtx if CB is not NULL.
  305. When the callback returns true, we continue with the new pair.
  306. Whenever changing this function check if rtx_equal_p below doesn't need
  307. changing as well. */
  308. int
  309. rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb)
  310. {
  311. int i;
  312. int j;
  313. enum rtx_code code;
  314. const char *fmt;
  315. rtx nx, ny;
  316. if (x == y)
  317. return 1;
  318. if (x == 0 || y == 0)
  319. return 0;
  320. /* Invoke the callback first. */
  321. if (cb != NULL
  322. && ((*cb) (&x, &y, &nx, &ny)))
  323. return rtx_equal_p_cb (nx, ny, cb);
  324. code = GET_CODE (x);
  325. /* Rtx's of different codes cannot be equal. */
  326. if (code != GET_CODE (y))
  327. return 0;
  328. /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
  329. (REG:SI x) and (REG:HI x) are NOT equivalent. */
  330. if (GET_MODE (x) != GET_MODE (y))
  331. return 0;
  332. /* MEMs referring to different address space are not equivalent. */
  333. if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
  334. return 0;
  335. /* Some RTL can be compared nonrecursively. */
  336. switch (code)
  337. {
  338. case REG:
  339. return (REGNO (x) == REGNO (y));
  340. case LABEL_REF:
  341. return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y);
  342. case SYMBOL_REF:
  343. return XSTR (x, 0) == XSTR (y, 0);
  344. case DEBUG_EXPR:
  345. case VALUE:
  346. case SCRATCH:
  347. CASE_CONST_UNIQUE:
  348. return 0;
  349. case DEBUG_IMPLICIT_PTR:
  350. return DEBUG_IMPLICIT_PTR_DECL (x)
  351. == DEBUG_IMPLICIT_PTR_DECL (y);
  352. case DEBUG_PARAMETER_REF:
  353. return DEBUG_PARAMETER_REF_DECL (x)
  354. == DEBUG_PARAMETER_REF_DECL (x);
  355. case ENTRY_VALUE:
  356. return rtx_equal_p_cb (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y), cb);
  357. default:
  358. break;
  359. }
  360. /* Compare the elements. If any pair of corresponding elements
  361. fail to match, return 0 for the whole thing. */
  362. fmt = GET_RTX_FORMAT (code);
  363. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  364. {
  365. switch (fmt[i])
  366. {
  367. case 'w':
  368. if (XWINT (x, i) != XWINT (y, i))
  369. return 0;
  370. break;
  371. case 'n':
  372. case 'i':
  373. if (XINT (x, i) != XINT (y, i))
  374. {
  375. #ifndef GENERATOR_FILE
  376. if (((code == ASM_OPERANDS && i == 6)
  377. || (code == ASM_INPUT && i == 1))
  378. && XINT (x, i) == XINT (y, i))
  379. break;
  380. #endif
  381. return 0;
  382. }
  383. break;
  384. case 'V':
  385. case 'E':
  386. /* Two vectors must have the same length. */
  387. if (XVECLEN (x, i) != XVECLEN (y, i))
  388. return 0;
  389. /* And the corresponding elements must match. */
  390. for (j = 0; j < XVECLEN (x, i); j++)
  391. if (rtx_equal_p_cb (XVECEXP (x, i, j),
  392. XVECEXP (y, i, j), cb) == 0)
  393. return 0;
  394. break;
  395. case 'e':
  396. if (rtx_equal_p_cb (XEXP (x, i), XEXP (y, i), cb) == 0)
  397. return 0;
  398. break;
  399. case 'S':
  400. case 's':
  401. if ((XSTR (x, i) || XSTR (y, i))
  402. && (! XSTR (x, i) || ! XSTR (y, i)
  403. || strcmp (XSTR (x, i), XSTR (y, i))))
  404. return 0;
  405. break;
  406. case 'u':
  407. /* These are just backpointers, so they don't matter. */
  408. break;
  409. case '0':
  410. case 't':
  411. break;
  412. /* It is believed that rtx's at this level will never
  413. contain anything but integers and other rtx's,
  414. except for within LABEL_REFs and SYMBOL_REFs. */
  415. default:
  416. gcc_unreachable ();
  417. }
  418. }
  419. return 1;
  420. }
  421. /* Return 1 if X and Y are identical-looking rtx's.
  422. This is the Lisp function EQUAL for rtx arguments.
  423. Whenever changing this function check if rtx_equal_p_cb above doesn't need
  424. changing as well. */
  425. int
  426. rtx_equal_p (const_rtx x, const_rtx y)
  427. {
  428. int i;
  429. int j;
  430. enum rtx_code code;
  431. const char *fmt;
  432. if (x == y)
  433. return 1;
  434. if (x == 0 || y == 0)
  435. return 0;
  436. code = GET_CODE (x);
  437. /* Rtx's of different codes cannot be equal. */
  438. if (code != GET_CODE (y))
  439. return 0;
  440. /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.
  441. (REG:SI x) and (REG:HI x) are NOT equivalent. */
  442. if (GET_MODE (x) != GET_MODE (y))
  443. return 0;
  444. /* MEMs referring to different address space are not equivalent. */
  445. if (code == MEM && MEM_ADDR_SPACE (x) != MEM_ADDR_SPACE (y))
  446. return 0;
  447. /* Some RTL can be compared nonrecursively. */
  448. switch (code)
  449. {
  450. case REG:
  451. return (REGNO (x) == REGNO (y));
  452. case LABEL_REF:
  453. return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y);
  454. case SYMBOL_REF:
  455. return XSTR (x, 0) == XSTR (y, 0);
  456. case DEBUG_EXPR:
  457. case VALUE:
  458. case SCRATCH:
  459. CASE_CONST_UNIQUE:
  460. return 0;
  461. case DEBUG_IMPLICIT_PTR:
  462. return DEBUG_IMPLICIT_PTR_DECL (x)
  463. == DEBUG_IMPLICIT_PTR_DECL (y);
  464. case DEBUG_PARAMETER_REF:
  465. return DEBUG_PARAMETER_REF_DECL (x)
  466. == DEBUG_PARAMETER_REF_DECL (y);
  467. case ENTRY_VALUE:
  468. return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y));
  469. default:
  470. break;
  471. }
  472. /* Compare the elements. If any pair of corresponding elements
  473. fail to match, return 0 for the whole thing. */
  474. fmt = GET_RTX_FORMAT (code);
  475. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  476. {
  477. switch (fmt[i])
  478. {
  479. case 'w':
  480. if (XWINT (x, i) != XWINT (y, i))
  481. return 0;
  482. break;
  483. case 'n':
  484. case 'i':
  485. if (XINT (x, i) != XINT (y, i))
  486. {
  487. #ifndef GENERATOR_FILE
  488. if (((code == ASM_OPERANDS && i == 6)
  489. || (code == ASM_INPUT && i == 1))
  490. && XINT (x, i) == XINT (y, i))
  491. break;
  492. #endif
  493. return 0;
  494. }
  495. break;
  496. case 'V':
  497. case 'E':
  498. /* Two vectors must have the same length. */
  499. if (XVECLEN (x, i) != XVECLEN (y, i))
  500. return 0;
  501. /* And the corresponding elements must match. */
  502. for (j = 0; j < XVECLEN (x, i); j++)
  503. if (rtx_equal_p (XVECEXP (x, i, j), XVECEXP (y, i, j)) == 0)
  504. return 0;
  505. break;
  506. case 'e':
  507. if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
  508. return 0;
  509. break;
  510. case 'S':
  511. case 's':
  512. if ((XSTR (x, i) || XSTR (y, i))
  513. && (! XSTR (x, i) || ! XSTR (y, i)
  514. || strcmp (XSTR (x, i), XSTR (y, i))))
  515. return 0;
  516. break;
  517. case 'u':
  518. /* These are just backpointers, so they don't matter. */
  519. break;
  520. case '0':
  521. case 't':
  522. break;
  523. /* It is believed that rtx's at this level will never
  524. contain anything but integers and other rtx's,
  525. except for within LABEL_REFs and SYMBOL_REFs. */
  526. default:
  527. gcc_unreachable ();
  528. }
  529. }
  530. return 1;
  531. }
  532. void
  533. dump_rtx_statistics (void)
  534. {
  535. int i;
  536. int total_counts = 0;
  537. int total_sizes = 0;
  538. if (! GATHER_STATISTICS)
  539. {
  540. fprintf (stderr, "No RTX statistics\n");
  541. return;
  542. }
  543. fprintf (stderr, "\nRTX Kind Count Bytes\n");
  544. fprintf (stderr, "---------------------------------------\n");
  545. for (i = 0; i < LAST_AND_UNUSED_RTX_CODE; i++)
  546. if (rtx_alloc_counts[i])
  547. {
  548. fprintf (stderr, "%-20s %7d %10d\n", GET_RTX_NAME (i),
  549. rtx_alloc_counts[i], rtx_alloc_sizes[i]);
  550. total_counts += rtx_alloc_counts[i];
  551. total_sizes += rtx_alloc_sizes[i];
  552. }
  553. if (rtvec_alloc_counts)
  554. {
  555. fprintf (stderr, "%-20s %7d %10d\n", "rtvec",
  556. rtvec_alloc_counts, rtvec_alloc_sizes);
  557. total_counts += rtvec_alloc_counts;
  558. total_sizes += rtvec_alloc_sizes;
  559. }
  560. fprintf (stderr, "---------------------------------------\n");
  561. fprintf (stderr, "%-20s %7d %10d\n",
  562. "Total", total_counts, total_sizes);
  563. fprintf (stderr, "---------------------------------------\n");
  564. }
  565. #if defined ENABLE_RTL_CHECKING && (GCC_VERSION >= 2007)
  566. void
  567. rtl_check_failed_bounds (const_rtx r, int n, const char *file, int line,
  568. const char *func)
  569. {
  570. internal_error
  571. ("RTL check: access of elt %d of '%s' with last elt %d in %s, at %s:%d",
  572. n, GET_RTX_NAME (GET_CODE (r)), GET_RTX_LENGTH (GET_CODE (r)) - 1,
  573. func, trim_filename (file), line);
  574. }
  575. void
  576. rtl_check_failed_type1 (const_rtx r, int n, int c1, const char *file, int line,
  577. const char *func)
  578. {
  579. internal_error
  580. ("RTL check: expected elt %d type '%c', have '%c' (rtx %s) in %s, at %s:%d",
  581. n, c1, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
  582. func, trim_filename (file), line);
  583. }
  584. void
  585. rtl_check_failed_type2 (const_rtx r, int n, int c1, int c2, const char *file,
  586. int line, const char *func)
  587. {
  588. internal_error
  589. ("RTL check: expected elt %d type '%c' or '%c', have '%c' (rtx %s) in %s, at %s:%d",
  590. n, c1, c2, GET_RTX_FORMAT (GET_CODE (r))[n], GET_RTX_NAME (GET_CODE (r)),
  591. func, trim_filename (file), line);
  592. }
  593. void
  594. rtl_check_failed_code1 (const_rtx r, enum rtx_code code, const char *file,
  595. int line, const char *func)
  596. {
  597. internal_error ("RTL check: expected code '%s', have '%s' in %s, at %s:%d",
  598. GET_RTX_NAME (code), GET_RTX_NAME (GET_CODE (r)), func,
  599. trim_filename (file), line);
  600. }
  601. void
  602. rtl_check_failed_code2 (const_rtx r, enum rtx_code code1, enum rtx_code code2,
  603. const char *file, int line, const char *func)
  604. {
  605. internal_error
  606. ("RTL check: expected code '%s' or '%s', have '%s' in %s, at %s:%d",
  607. GET_RTX_NAME (code1), GET_RTX_NAME (code2), GET_RTX_NAME (GET_CODE (r)),
  608. func, trim_filename (file), line);
  609. }
  610. void
  611. rtl_check_failed_code_mode (const_rtx r, enum rtx_code code, machine_mode mode,
  612. bool not_mode, const char *file, int line,
  613. const char *func)
  614. {
  615. internal_error ((not_mode
  616. ? ("RTL check: expected code '%s' and not mode '%s', "
  617. "have code '%s' and mode '%s' in %s, at %s:%d")
  618. : ("RTL check: expected code '%s' and mode '%s', "
  619. "have code '%s' and mode '%s' in %s, at %s:%d")),
  620. GET_RTX_NAME (code), GET_MODE_NAME (mode),
  621. GET_RTX_NAME (GET_CODE (r)), GET_MODE_NAME (GET_MODE (r)),
  622. func, trim_filename (file), line);
  623. }
  624. /* Report that line LINE of FILE tried to access the block symbol fields
  625. of a non-block symbol. FUNC is the function that contains the line. */
  626. void
  627. rtl_check_failed_block_symbol (const char *file, int line, const char *func)
  628. {
  629. internal_error
  630. ("RTL check: attempt to treat non-block symbol as a block symbol "
  631. "in %s, at %s:%d", func, trim_filename (file), line);
  632. }
  633. /* XXX Maybe print the vector? */
  634. void
  635. cwi_check_failed_bounds (const_rtx x, int n, const char *file, int line,
  636. const char *func)
  637. {
  638. internal_error
  639. ("RTL check: access of hwi elt %d of vector with last elt %d in %s, at %s:%d",
  640. n, CWI_GET_NUM_ELEM (x) - 1, func, trim_filename (file), line);
  641. }
  642. /* XXX Maybe print the vector? */
  643. void
  644. rtvec_check_failed_bounds (const_rtvec r, int n, const char *file, int line,
  645. const char *func)
  646. {
  647. internal_error
  648. ("RTL check: access of elt %d of vector with last elt %d in %s, at %s:%d",
  649. n, GET_NUM_ELEM (r) - 1, func, trim_filename (file), line);
  650. }
  651. #endif /* ENABLE_RTL_CHECKING */
  652. #if defined ENABLE_RTL_FLAG_CHECKING
  653. void
  654. rtl_check_failed_flag (const char *name, const_rtx r, const char *file,
  655. int line, const char *func)
  656. {
  657. internal_error
  658. ("RTL flag check: %s used with unexpected rtx code '%s' in %s, at %s:%d",
  659. name, GET_RTX_NAME (GET_CODE (r)), func, trim_filename (file), line);
  660. }
  661. #endif /* ENABLE_RTL_FLAG_CHECKING */