Branch data Line data Source code
1 : : /* RTL hash functions.
2 : : Copyright (C) 1987-2025 Free Software Foundation, Inc.
3 : :
4 : : This file is part of GCC.
5 : :
6 : : GCC is free software; you can redistribute it and/or modify it under
7 : : the terms of the GNU General Public License as published by the Free
8 : : Software Foundation; either version 3, or (at your option) any later
9 : : version.
10 : :
11 : : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : : for more details.
15 : :
16 : : You should have received a copy of the GNU General Public License
17 : : along with GCC; see the file COPYING3. If not see
18 : : <http://www.gnu.org/licenses/>. */
19 : :
20 : : #include "config.h"
21 : : #include "system.h"
22 : : #include "coretypes.h"
23 : : #include "tm.h"
24 : : #include "rtl.h"
25 : : #include "rtlhash.h"
26 : :
27 : : namespace inchash
28 : : {
29 : :
30 : : /* Iteratively hash rtx X into HSTATE. */
31 : :
32 : : void
33 : 632796 : add_rtx (const_rtx x, hash &hstate)
34 : : {
35 : 632796 : enum rtx_code code;
36 : 632796 : machine_mode mode;
37 : 632796 : int i, j;
38 : 632796 : const char *fmt;
39 : :
40 : 632796 : if (x == NULL_RTX)
41 : 483090 : return;
42 : 632796 : code = GET_CODE (x);
43 : 632796 : hstate.add_object (code);
44 : 632796 : mode = GET_MODE (x);
45 : 632796 : hstate.add_object (mode);
46 : 632796 : switch (code)
47 : : {
48 : 0 : case REG:
49 : 0 : hstate.add_int (REGNO (x));
50 : 0 : return;
51 : 73809 : case CONST_INT:
52 : 73809 : hstate.add_object (INTVAL (x));
53 : 73809 : return;
54 : : case CONST_WIDE_INT:
55 : 0 : for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
56 : 0 : hstate.add_object (CONST_WIDE_INT_ELT (x, i));
57 : : return;
58 : : case CONST_POLY_INT:
59 : 0 : for (i = 0; i < NUM_POLY_INT_COEFFS; ++i)
60 : 0 : hstate.add_wide_int (CONST_POLY_INT_COEFFS (x)[i]);
61 : : break;
62 : 409273 : case SYMBOL_REF:
63 : 409273 : if (XSTR (x, 0))
64 : 409273 : hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
65 : : return;
66 : : case LABEL_REF:
67 : : case DEBUG_EXPR:
68 : : case VALUE:
69 : : case SCRATCH:
70 : : case CONST_DOUBLE:
71 : : case CONST_FIXED:
72 : : case DEBUG_IMPLICIT_PTR:
73 : : case DEBUG_PARAMETER_REF:
74 : : return;
75 : : default:
76 : : break;
77 : : }
78 : :
79 : 149706 : fmt = GET_RTX_FORMAT (code);
80 : 374629 : for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
81 : 224923 : switch (fmt[i])
82 : : {
83 : 0 : case 'w':
84 : 0 : hstate.add_hwi (XWINT (x, i));
85 : 0 : break;
86 : 1408 : case 'n':
87 : 1408 : case 'i':
88 : 1408 : hstate.add_int (XINT (x, i));
89 : 1408 : break;
90 : 0 : case 'L':
91 : 0 : hstate.add_hwi (XLOC (x, i));
92 : 0 : break;
93 : 0 : case 'p':
94 : 0 : hstate.add_poly_int (SUBREG_BYTE (x));
95 : 0 : break;
96 : 1408 : case 'V':
97 : 1408 : case 'E':
98 : 1408 : j = XVECLEN (x, i);
99 : 1408 : hstate.add_int (j);
100 : 2816 : for (j = 0; j < XVECLEN (x, i); j++)
101 : 1408 : inchash::add_rtx (XVECEXP (x, i, j), hstate);
102 : : break;
103 : 222107 : case 'e':
104 : 222107 : inchash::add_rtx (XEXP (x, i), hstate);
105 : 222107 : break;
106 : 0 : case 'S':
107 : 0 : case 's':
108 : 0 : if (XSTR (x, i))
109 : 0 : hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
110 : : break;
111 : : default:
112 : : break;
113 : : }
114 : : }
115 : :
116 : : }
|