Skip to content

Latest commit

 

History

History

ir

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

P4C Intermediate Representation (P4C-IR) Classes

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.

File Description
ir.h Top-level include file that includes everything else. Code outside this folder generally just includes this file.
ir-inline.h, ir-tree-macros.h, ir-util.h IR support files. ir-inline.h contains inline methods for header files that can't be defined until after other headers are included. ir-tree-macros.h has macros for generating code referring to all IR classes, used by the visitors.
node.h, node.cpp IR::Node base class.
id.h 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).
ir.def, ir.cpp Miscellaneous front-end IR classes.
v1.def, v1.cpp IR classes only needed to process P4 v1.0 / v1.1 programs.
expression.def, expression.cpp IR classes related to expressions. The Expression abstract class is the base for all expressions and contains a type field. Subclasses include Operation, Unary, Binary, and Ternary. Concrete subclasses are detailed as follows:
        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, ...
File Description
typedecl.def, type.cpp IR subclasses related to types and declarations.
namemap.h NameMap template, 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.
vector.h Vector template, which holds a vector of IR objects. It is a subclass of IR::Node with traversal code and automatically flattens any sub-Vector objects and removes nulls when transforms on elements of the vector return them.
indexed_vector.h IndexedVector: Contains a Vector and also an index mapping cstrings to IDeclarations for all objects in the vector that are IDeclarations.
dbprint.h, dbprint.cpp, dbprint-expression.cpp, dbprint-p4.cpp Debug printing routines. Most IR classes declare a dbprint method, defined here. The header contains flags and support that dbprint methods use to communicate formatting information (indentation, precedence, and format mode).
std.h Using directives for frequently used std:: classes. std::vector is wrapped with bounds-checking for all indexed accesses.
visitor.h, visitor.cpp Visitor base class and subclass definitions, including Inspector, Modifier, Transform, ControlFlowVisitor, Backtrack, and P4WriteContext mixin interfaces.
pass_manager.h, pass_manager.cpp PassManager subclass (of Visitor) that manages an arbitrary sequence of Visitors and handles backtracking between passes.