From 6929530c31ab3090b77ba9ee1e6c1c26ffe6ce27 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 29 Oct 2014 14:06:31 -0400 Subject: Introduce gpredict subclass and use it for all gimple_predict_ accessors gcc/ChangeLog.gimple-classes: * coretypes.h (struct gpredict): Add forward declaration. * doc/gimple.texi (Class hierarchy of GIMPLE statements): Add gpredict. * gimple-pretty-print.c (pp_gimple_stmt_1): Within case GIMPLE_PREDICT, add local "predict_stmt" via a checked cast and use it in place of "stmt". * gimple.c (gimple_build_predict): Strengthen return type and local "p" from gimple to gpredict *. * gimple.h (struct gpredict): New subclass of gimple_statement_base, adding invariant that code is GIMPLE_PREDICT. (is_a_helper ::test): New. (gimple_build_predict): Strengthen return type from gimple to gpredict *. (gimple_predict_predictor): Strengthen param from const_gimple to const gpredict *. (gimple_predict_outcome): Likewise. (gimple_predict_set_predictor): Strengthen param from gimple to gpredict *. (gimple_predict_set_outcome): Likewise. * predict.c (tree_bb_level_predictions): Convert check for GIMPLE_PREDICT to a dyn_cast, introducing local "predict_stmt" and using it in place of "stmt" for typesafety. --- gcc/gimple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/gimple.c') diff --git a/gcc/gimple.c b/gcc/gimple.c index 1421afe1c37..b58c9db800b 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1136,10 +1136,10 @@ gimple_build_transaction (gimple_seq body, tree label) /* Build a GIMPLE_PREDICT statement. PREDICT is one of the predictors from predict.def, OUTCOME is NOT_TAKEN or TAKEN. */ -gimple +gpredict * gimple_build_predict (enum br_predictor predictor, enum prediction outcome) { - gimple p = gimple_alloc (GIMPLE_PREDICT, 0); + gpredict *p = as_a (gimple_alloc (GIMPLE_PREDICT, 0)); /* Ensure all the predictors fit into the lower bits of the subcode. */ gcc_assert ((int) END_PREDICTORS <= GF_PREDICT_TAKEN); gimple_predict_set_predictor (p, predictor); -- cgit v1.2.1