i386: Rewrite check for AVX512 features
[official-gcc.git] / gcc / gimple-predict.h
blob0e6c2e1ea019f640f3163f2b10e0b5be71c711b2
1 /* Gimple prediction routines.
3 Copyright (C) 2007-2017 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_GIMPLE_PREDICT_H
22 #define GCC_GIMPLE_PREDICT_H
24 #include "predict.h"
26 /* Return the predictor of GIMPLE_PREDICT statement GS. */
28 static inline enum br_predictor
29 gimple_predict_predictor (gimple *gs)
31 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
32 return (enum br_predictor) (gs->subcode & ~GF_PREDICT_TAKEN);
36 /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT. */
38 static inline void
39 gimple_predict_set_predictor (gimple *gs, enum br_predictor predictor)
41 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
42 gs->subcode = (gs->subcode & GF_PREDICT_TAKEN)
43 | (unsigned) predictor;
47 /* Return the outcome of GIMPLE_PREDICT statement GS. */
49 static inline enum prediction
50 gimple_predict_outcome (gimple *gs)
52 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
53 return (gs->subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
57 /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME. */
59 static inline void
60 gimple_predict_set_outcome (gimple *gs, enum prediction outcome)
62 GIMPLE_CHECK (gs, GIMPLE_PREDICT);
63 if (outcome == TAKEN)
64 gs->subcode |= GF_PREDICT_TAKEN;
65 else
66 gs->subcode &= ~GF_PREDICT_TAKEN;
69 /* Build a GIMPLE_PREDICT statement. PREDICT is one of the predictors from
70 predict.def, OUTCOME is NOT_TAKEN or TAKEN. */
72 inline gimple *
73 gimple_build_predict (enum br_predictor predictor, enum prediction outcome)
75 gimple *p = gimple_alloc (GIMPLE_PREDICT, 0);
76 /* Ensure all the predictors fit into the lower bits of the subcode. */
77 gcc_assert ((int) END_PREDICTORS <= GF_PREDICT_TAKEN);
78 gimple_predict_set_predictor (p, predictor);
79 gimple_predict_set_outcome (p, outcome);
80 return p;
83 /* Return true if GS is a GIMPLE_PREDICT statement. */
85 static inline bool
86 is_gimple_predict (const gimple *gs)
88 return gimple_code (gs) == GIMPLE_PREDICT;
91 #endif /* GCC_GIMPLE_PREDICT_H */