[PATCH 2/5] Add function tree_code_in_cst.

Jan Hubicka hubicka@ucw.cz
Fri May 29 21:03:34 GMT 2020


> 
> ---
>  gcc/tree.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/gcc/tree.h b/gcc/tree.h
> index bd0c51b2a18..86a4542f58b 100644
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -6156,6 +6156,17 @@ int_bit_position (const_tree field)
>  	  + wi::to_offset (DECL_FIELD_BIT_OFFSET (field))).to_shwi ();
>  }
> 
> +/* Determine if tree code is a constant */
> +inline bool
> +tree_code_is_cst (tree op)
> +{
> +  int code = TREE_CODE (op);
> +  if (code == INTEGER_CST || code == REAL_CST || code == COMPLEX_CST
> +      || code == VECTOR_CST)
> +    return true;
> +  return false;

We have is_gimple_ip_invariant which I think should suit your purpose -
it return true if tree is a constant, it also accepts things like
addresses of (global) variables, functions and labels.
> +}
> +
>  /* Return true if it makes sense to consider alias set for a type T.  */
> 
>  inline bool
> -- 
> 2.18.1
> 


More information about the Gcc-patches mailing list