Header file for SSA iterators.
Copyright (C) 2013-2025 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 via FOR_EACH_IMM_USE_FAST allows each use to be
examined, but does not allow any modifications to the uses or stmts.
Safe iteration via FOR_EACH_IMM_USE_STMT and FOR_EACH_IMM_USE_ON_STMT
allows insertion, deletion, and modification of SSA operands within
the current stmt iterated. The iterator manages this by re-sorting
the immediate uses to batch uses on a single stmt after each other.
If using an inner FOR_EACH_IMM_USE_ON_STMT iteration only the active
use may be manipulated. Safety relies on new immediate uses being
inserted at the front of immediate use lists.