annotate gcc/rtlhash.c @ 128:fe568345ddd5

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