Skip to content

Latest commit

 

History

History

ir

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Intermediate Representation (IR) Classes {#irdefs}

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.

ir.h

Top level include file that just includes everything else. Code outside this folder generally just includes this file.

ir-inline.h ir-tree-macros.h ir-util.h

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.

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

Miscelaneous 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 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, ...
typedecl.def type.cpp

IR subclasses related to types and declarations.

namemap.h

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.

vector.h

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.

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 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).

std.h

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.h visitor.cpp

Visitor base class, and Inspector, Modifier, and Transform subclass definitions, along with ControlFlowVisitor, Backtrack and P4WriteContext mixin interfaces.

pass_manager.h pass_manager.cpp

PassManager subclass (of Visitor) which manages an arbitrary sequence of Visitors, and handles backtracking between passes.