Header file for SSA iterators.
Copyright (C) 2013-2024 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
Immediate use lists are used to directly access all uses for an SSA
name and get pointers to the statement for each use.
The structure ssa_use_operand_t consists of PREV and NEXT pointers
to maintain the list. A USE pointer, which points to address where
the use is located and a LOC pointer which can point to the
statement where the use is located, or, in the case of the root
node, it points to the SSA name itself.
The list is anchored by an occurrence of ssa_operand_d *in* the
ssa_name node itself (named 'imm_uses'). This node is uniquely
identified by having a NULL USE pointer. and the LOC pointer
pointing back to the ssa_name node itself. This node forms the
base for a circular list, and initially this is the only node in
the list.
Fast iteration allows each use to be examined, but does not allow
any modifications to the uses or stmts.
Normal iteration allows insertion, deletion, and modification. the
iterator manages this by inserting a marker node into the list
immediately before the node currently being examined in the list.
this marker node is uniquely identified by having null stmt *and* a
null use pointer.
When iterating to the next use, the iteration routines check to see
if the node after the marker has changed. if it has, then the node
following the marker is now the next one to be visited. if not, the
marker node is moved past that node in the list (visualize it as
bumping the marker node through the list). this continues until
the marker node is moved to the original anchor position. the
marker node is then removed from the list.
If iteration is halted early, the marker node must be removed from
the list before continuing.