The IR classes are automatically generated by tools/ir-generator from *.def files. The .def files contain class definitions with boilerplate removed, which the ir-generator generates.
Top level include file that just includes everything else. Code outside this folder generally just includes this file.
IR support stuff. ir-inline.h
has inline methods for things in header
files that can't be defined until after other header files are included.
ir-tree-macros.h
has macros for generating code referring to all IR
classes, used by the visitors.
IR::Node
base class.
Defines the ID
struct, which is not a standalone IR class, but is used
in many places in IR classes, representing an identifier with associated
source location (for error reporting).
Miscelaneous front-end IR classes.
IR classes only needed to process P4 v1.0 / v1.1 programs
IR classes related to expressions. The Expression
abstract class is
base for all expressions, and contains a type
field. Abstract subclasses
include Operation
, Unary
, Binary
, and Trinary
, with concrete
subclasses:
Expression
+-- Operation
| +-- Operation_Unary
| | +-- Neg, Cmpl, LNot, UPlus
| | \-- Member, Cast
| +-- Operation_Binary
| | +-- Mul, Div, Mode, Add, Sub, Shl, Shr
| | +-- Operation_Relation
| | | \-- Equ, New, Lss, Leq, Grt, Geq
| | +-- BAnd, BOr, BXor, LAnd, LOr
| | \-- Concat, ArrayIndex, Range, Mask
| +-- Operation_Trinary
| | \-- Slice, Mux
| \-- Primitive
\-- Constant, ...
IR subclasses related to types and declarations.
IR subclass template NameMap
, which holds a set of named IR objects and
supports lookups by name. NameMap
supports transforms that return null or
additional NameMap
objects for IR objects in the NameMap
to modify the
NameMap
.
IR subclass template Vector
, which holds a vector of IR objects.
This is largely equivalent to a vector
, except that it is a subclass
of IR::Node
so it can be included in an IR tree as a first-class
member, with its own traversal code (visitor subclass preorder and
postorder functions). Automatically flattens any sub-Vector
objects
and removes null when transforms on elements of the vector return them.
IndexedVector: contains a Vector and also an index mapping cstrings to IDeclarations for all objects in the vector that are IDeclarations.
Debug printing routines. Most IR classes declared a dbprint
method,
which are defined here. The header contains flags and support that
dbprint methods use to communicate formatting information (indentation,
precendence, and format mode).
using directives for a bunch of std::
classes that are heavily used in
the code. std::vector
is instead wrapped (as vector
) with a version
that automatically uses bounds-checking for all indexed accesses.
Visitor
base class, and Inspector
, Modifier
, and Transform
subclass
definitions, along with ControlFlowVisitor
, Backtrack
and P4WriteContext
mixin interfaces.
PassManager
subclass (of Visitor
) which manages an arbitrary sequence of
Visitor
s, and handles backtracking between passes.