What replaces FOR_EACH_LOOP_FN
Marek Polacek
polacek@redhat.com
Wed Mar 2 22:14:02 GMT 2022
On Wed, Mar 02, 2022 at 10:04:40PM +0000, Gary Oblock via Gcc wrote:
> Guys,
>
> I've been working on an optimization for quite a bit of time and
> in an attempt to move it to GCC 12 I found that FOR_EACH_LOOP_FN
> no longer exists. I poked around in the archives and tried a Google
> search but found nothing on it.
>
> It suited my needs and I'd hate to have to rewrite a bunch of stuff.
> What replaces it and how do I use?
Look at this commit:
commit e41ba804ba5f5ca433e09238d561b1b4c8b10985
Author: Kewen Lin <linkw@linux.ibm.com>
Date: Thu Jul 29 22:26:25 2021 -0500
Use range-based for loops for traversing loops
This patch follows Martin's suggestion here[1], to support
range based loop for iterating loops, analogously to the
patch for vec[2].
For example, use below range-based for loop
for (auto loop : loops_list (cfun, 0))
to replace the previous macro FOR_EACH_LOOP
FOR_EACH_LOOP (loop, 0)
which shows a number of examples like
- loop_p loop;
- FOR_EACH_LOOP_FN (fn, loop, LI_INCLUDE_ROOT)
+ for (auto loop : loops_list (fn, LI_INCLUDE_ROOT))
Marek
More information about the Gcc
mailing list