rtlanal: Add some new helper classes
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 17 Dec 2020 00:15:09 +0000 (00:15 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 17 Dec 2020 00:15:09 +0000 (00:15 +0000)
commit04ee46ed1c06cbbffcd8eb0626b4ab6c3a5082d9
treee013d7869c88e489c212f733856b114a91375a97
parenta240ea024dd8533d898c8cd779dedd0747bbbf2e
rtlanal: Add some new helper classes

This patch adds some classes for gathering the list of registers
and memory that are read and written by an instruction, along
with various properties about the accesses.  In some ways it's
similar to the information that DF collects for registers,
but extended to memory.  The main reason for using it instead
of DF is that it can analyse tentative changes to instructions
before they've been committed.

The classes also collect general information about the instruction,
since it's cheap to do and helps to avoid multiple walks of the same
RTL pattern.

I've tried to optimise the code quite a bit, since with later patches
it becomes relatively performance-sensitive.  See the discussion in
the comments for the trade-offs involved.

I put the declarations in a new rtlanal.h header file since it
seemed a bit excessive to put so much new inline stuff in rtl.h.

gcc/
* rtlanal.h: New file.
(MEM_REGNO): New constant.
(rtx_obj_flags): New namespace.
(rtx_obj_reference, rtx_properties): New classes.
(growing_rtx_properties, vec_rtx_properties_base): Likewise.
(vec_rtx_properties): New alias.
* rtlanal.c: Include it.
(rtx_properties::try_to_add_reg): New function.
(rtx_properties::try_to_add_dest): Likewise.
(rtx_properties::try_to_add_src): Likewise.
(rtx_properties::try_to_add_pattern): Likewise.
(rtx_properties::try_to_add_insn): Likewise.
(vec_rtx_properties_base::grow): Likewise.
gcc/rtlanal.c
gcc/rtlanal.h [new file with mode: 0644]