[PATCH 2/5] Add function tree_code_in_cst.
Erick Ochoa
erick.ochoa@theobroma-systems.com
Tue Jun 2 12:30:28 GMT 2020
On 02/06/2020 14:29, Richard Biener wrote:
> On Sat, May 30, 2020 at 12:18 AM Jan Hubicka <hubicka@ucw.cz> wrote:
>>
>>>
>>> ---
>>> 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.
>
> And otherwise there's CONSTANT_CLASS_P ().
>
> Richard.
Thanks, I'll check these suggestions and remove unnecessary code!
>
>>> +}
>>> +
>>> /* 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