annotate gcc/gimple-predict.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Gimple prediction routines.
kono
parents:
diff changeset
2
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 Copyright (C) 2007-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
10 version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
15 for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 #ifndef GCC_GIMPLE_PREDICT_H
kono
parents:
diff changeset
22 #define GCC_GIMPLE_PREDICT_H
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 #include "predict.h"
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 /* Return the predictor of GIMPLE_PREDICT statement GS. */
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 static inline enum br_predictor
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
29 gimple_predict_predictor (const gimple *gs)
111
kono
parents:
diff changeset
30 {
kono
parents:
diff changeset
31 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
kono
parents:
diff changeset
32 return (enum br_predictor) (gs->subcode & ~GF_PREDICT_TAKEN);
kono
parents:
diff changeset
33 }
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 static inline void
kono
parents:
diff changeset
39 gimple_predict_set_predictor (gimple *gs, enum br_predictor predictor)
kono
parents:
diff changeset
40 {
kono
parents:
diff changeset
41 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
kono
parents:
diff changeset
42 gs->subcode = (gs->subcode & GF_PREDICT_TAKEN)
kono
parents:
diff changeset
43 | (unsigned) predictor;
kono
parents:
diff changeset
44 }
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 /* Return the outcome of GIMPLE_PREDICT statement GS. */
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 static inline enum prediction
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
50 gimple_predict_outcome (const gimple *gs)
111
kono
parents:
diff changeset
51 {
kono
parents:
diff changeset
52 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
kono
parents:
diff changeset
53 return (gs->subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
kono
parents:
diff changeset
54 }
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 static inline void
kono
parents:
diff changeset
60 gimple_predict_set_outcome (gimple *gs, enum prediction outcome)
kono
parents:
diff changeset
61 {
kono
parents:
diff changeset
62 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
kono
parents:
diff changeset
63 if (outcome == TAKEN)
kono
parents:
diff changeset
64 gs->subcode |= GF_PREDICT_TAKEN;
kono
parents:
diff changeset
65 else
kono
parents:
diff changeset
66 gs->subcode &= ~GF_PREDICT_TAKEN;
kono
parents:
diff changeset
67 }
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Build a GIMPLE_PREDICT statement. PREDICT is one of the predictors from
kono
parents:
diff changeset
70 predict.def, OUTCOME is NOT_TAKEN or TAKEN. */
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 inline gimple *
kono
parents:
diff changeset
73 gimple_build_predict (enum br_predictor predictor, enum prediction outcome)
kono
parents:
diff changeset
74 {
kono
parents:
diff changeset
75 gimple *p = gimple_alloc (GIMPLE_PREDICT, 0);
kono
parents:
diff changeset
76 /* Ensure all the predictors fit into the lower bits of the subcode. */
kono
parents:
diff changeset
77 gcc_assert ((int) END_PREDICTORS <= GF_PREDICT_TAKEN);
kono
parents:
diff changeset
78 gimple_predict_set_predictor (p, predictor);
kono
parents:
diff changeset
79 gimple_predict_set_outcome (p, outcome);
kono
parents:
diff changeset
80 return p;
kono
parents:
diff changeset
81 }
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 /* Return true if GS is a GIMPLE_PREDICT statement. */
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 static inline bool
kono
parents:
diff changeset
86 is_gimple_predict (const gimple *gs)
kono
parents:
diff changeset
87 {
kono
parents:
diff changeset
88 return gimple_code (gs) == GIMPLE_PREDICT;
kono
parents:
diff changeset
89 }
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 #endif /* GCC_GIMPLE_PREDICT_H */