* include/bits/basic_string.h (getline): Qualify call to prevent ADL
[official-gcc.git] / gcc / rtlhash.c
blobed4ee7a74b5dcabe495930c55e3e2ee430db3d0b
1 /* RTL hash functions.
2 Copyright (C) 1987-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "ggc.h"
25 #include "rtl.h"
26 #include "rtlhash.h"
28 namespace inchash
31 /* Iteratively hash rtx X into HSTATE. */
33 void
34 add_rtx (const_rtx x, hash &hstate)
36 enum rtx_code code;
37 enum machine_mode mode;
38 int i, j;
39 const char *fmt;
41 if (x == NULL_RTX)
42 return;
43 code = GET_CODE (x);
44 hstate.add_object (code);
45 mode = GET_MODE (x);
46 hstate.add_object (mode);
47 switch (code)
49 case REG:
50 hstate.add_int (REGNO (x));
51 return;
52 case CONST_INT:
53 hstate.add_object (INTVAL (x));
54 return;
55 case CONST_WIDE_INT:
56 for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
57 hstate.add_object (CONST_WIDE_INT_ELT (x, i));
58 return;
59 case SYMBOL_REF:
60 if (XSTR (x, 0))
61 hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
62 return;
63 case LABEL_REF:
64 case DEBUG_EXPR:
65 case VALUE:
66 case SCRATCH:
67 case CONST_DOUBLE:
68 case CONST_FIXED:
69 case DEBUG_IMPLICIT_PTR:
70 case DEBUG_PARAMETER_REF:
71 return;
72 default:
73 break;
76 fmt = GET_RTX_FORMAT (code);
77 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
78 switch (fmt[i])
80 case 'w':
81 hstate.add_object (XWINT (x, i));
82 break;
83 case 'n':
84 case 'i':
85 hstate.add_object (XINT (x, i));
86 break;
87 case 'V':
88 case 'E':
89 j = XVECLEN (x, i);
90 hstate.add_int (j);
91 for (j = 0; j < XVECLEN (x, i); j++)
92 inchash::add_rtx (XVECEXP (x, i, j), hstate);
93 break;
94 case 'e':
95 inchash::add_rtx (XEXP (x, i), hstate);
96 break;
97 case 'S':
98 case 's':
99 if (XSTR (x, i))
100 hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
101 break;
102 default:
103 break;