]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/rtlhash.c
More is_a <scalar_int_mode>
[thirdparty/gcc.git] / gcc / rtlhash.c
CommitLineData
f768061c 1/* RTL hash functions.
cbe34bb5 2 Copyright (C) 1987-2017 Free Software Foundation, Inc.
f768061c
AK
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along 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"
f768061c
AK
24#include "rtl.h"
25#include "rtlhash.h"
26
27namespace inchash
28{
29
30/* Iteratively hash rtx X into HSTATE. */
31
32void
33add_rtx (const_rtx x, hash &hstate)
34{
35 enum rtx_code code;
ef4bddc2 36 machine_mode mode;
f768061c
AK
37 int i, j;
38 const char *fmt;
39
40 if (x == NULL_RTX)
41 return;
42 code = GET_CODE (x);
43 hstate.add_object (code);
44 mode = GET_MODE (x);
45 hstate.add_object (mode);
46 switch (code)
47 {
48 case REG:
49 hstate.add_int (REGNO (x));
50 return;
51 case CONST_INT:
52 hstate.add_object (INTVAL (x));
53 return;
54 case CONST_WIDE_INT:
55 for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
56 hstate.add_object (CONST_WIDE_INT_ELT (x, i));
57 return;
58 case SYMBOL_REF:
59 if (XSTR (x, 0))
60 hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
61 return;
62 case LABEL_REF:
63 case DEBUG_EXPR:
64 case VALUE:
65 case SCRATCH:
66 case CONST_DOUBLE:
67 case CONST_FIXED:
68 case DEBUG_IMPLICIT_PTR:
69 case DEBUG_PARAMETER_REF:
70 return;
71 default:
72 break;
73 }
74
75 fmt = GET_RTX_FORMAT (code);
76 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
77 switch (fmt[i])
78 {
79 case 'w':
80 hstate.add_object (XWINT (x, i));
81 break;
82 case 'n':
83 case 'i':
84 hstate.add_object (XINT (x, i));
85 break;
86 case 'V':
87 case 'E':
88 j = XVECLEN (x, i);
89 hstate.add_int (j);
90 for (j = 0; j < XVECLEN (x, i); j++)
91 inchash::add_rtx (XVECEXP (x, i, j), hstate);
92 break;
93 case 'e':
94 inchash::add_rtx (XEXP (x, i), hstate);
95 break;
96 case 'S':
97 case 's':
98 if (XSTR (x, i))
99 hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
100 break;
101 default:
102 break;
103 }
104}
105
106}