Halide
Halide::Internal::IRPrinter Class Reference

An IRVisitor that emits IR to the given output stream in a human readable form. More...

#include <IRPrinter.h>

Inherits Halide::Internal::IRVisitor.

Inherited by Halide::Internal::CodeGen_C, and Halide::Internal::CodeGen_PyTorch.

Public Member Functions

 IRPrinter (std::ostream &)
 Construct an IRPrinter pointed at a given output stream (e.g. More...
 
void print (const Expr &)
 emit an expression on the output stream More...
 
void print_no_parens (const Expr &)
 Emit an expression on the output stream without enclosing parens. More...
 
void print (const Stmt &)
 emit a statement on the output stream More...
 
void print_list (const std::vector< Expr > &exprs)
 emit a comma delimited list of exprs, without any leading or trailing punctuation. More...
 
- Public Member Functions inherited from Halide::Internal::IRVisitor
 IRVisitor ()
 
virtual ~IRVisitor ()
 

Static Public Member Functions

static void test ()
 

Protected Member Functions

Indentation get_indent () const
 
void open ()
 Either emits "(" or "", depending on the value of implicit_parens. More...
 
void close ()
 Either emits ")" or "", depending on the value of implicit_parens. More...
 
void print_lets (const Let *let)
 A helper for printing a chain of lets with line breaks. More...
 
void visit (const IntImm *) override
 
void visit (const UIntImm *) override
 
void visit (const FloatImm *) override
 
void visit (const StringImm *) override
 
void visit (const Cast *) override
 
void visit (const Variable *) override
 
void visit (const Add *) override
 
void visit (const Sub *) override
 
void visit (const Mul *) override
 
void visit (const Div *) override
 
void visit (const Mod *) override
 
void visit (const Min *) override
 
void visit (const Max *) override
 
void visit (const EQ *) override
 
void visit (const NE *) override
 
void visit (const LT *) override
 
void visit (const LE *) override
 
void visit (const GT *) override
 
void visit (const GE *) override
 
void visit (const And *) override
 
void visit (const Or *) override
 
void visit (const Not *) override
 
void visit (const Select *) override
 
void visit (const Load *) override
 
void visit (const Ramp *) override
 
void visit (const Broadcast *) override
 
void visit (const Call *) override
 
void visit (const Let *) override
 
void visit (const LetStmt *) override
 
void visit (const AssertStmt *) override
 
void visit (const ProducerConsumer *) override
 
void visit (const For *) override
 
void visit (const Acquire *) override
 
void visit (const Store *) override
 
void visit (const Provide *) override
 
void visit (const Allocate *) override
 
void visit (const Free *) override
 
void visit (const Realize *) override
 
void visit (const Block *) override
 
void visit (const Fork *) override
 
void visit (const IfThenElse *) override
 
void visit (const Evaluate *) override
 
void visit (const Shuffle *) override
 
void visit (const VectorReduce *) override
 
void visit (const Prefetch *) override
 
void visit (const Atomic *) override
 

Protected Attributes

std::ostream & stream
 The stream on which we're outputting. More...
 
int indent = 0
 The current indentation level, useful for pretty-printing statements. More...
 
bool implicit_parens = false
 Certain expressions do not need parens around them, e.g. More...
 
Scope known_type
 The symbols whose types can be inferred from values printed already. More...
 

Detailed Description

An IRVisitor that emits IR to the given output stream in a human readable form.

Can be subclassed if you want to modify the way in which it prints.

Definition at line 98 of file IRPrinter.h.

Constructor & Destructor Documentation

◆ IRPrinter()

Halide::Internal::IRPrinter::IRPrinter ( std::ostream &  )
explicit

Construct an IRPrinter pointed at a given output stream (e.g.

std::cout, or a std::ofstream)

Member Function Documentation

◆ print() [1/2]

void Halide::Internal::IRPrinter::print ( const Expr )

emit an expression on the output stream

◆ print_no_parens()

void Halide::Internal::IRPrinter::print_no_parens ( const Expr )

Emit an expression on the output stream without enclosing parens.

◆ print() [2/2]

void Halide::Internal::IRPrinter::print ( const Stmt )

emit a statement on the output stream

◆ print_list()

void Halide::Internal::IRPrinter::print_list ( const std::vector< Expr > &  exprs)

emit a comma delimited list of exprs, without any leading or trailing punctuation.

◆ test()

static void Halide::Internal::IRPrinter::test ( )
static

◆ get_indent()

Indentation Halide::Internal::IRPrinter::get_indent ( ) const
inlineprotected

Definition at line 120 of file IRPrinter.h.

References indent.

◆ open()

void Halide::Internal::IRPrinter::open ( )
protected

Either emits "(" or "", depending on the value of implicit_parens.

◆ close()

void Halide::Internal::IRPrinter::close ( )
protected

Either emits ")" or "", depending on the value of implicit_parens.

◆ print_lets()

void Halide::Internal::IRPrinter::print_lets ( const Let let)
protected

A helper for printing a chain of lets with line breaks.

◆ visit() [1/46]

void Halide::Internal::IRPrinter::visit ( const IntImm )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [2/46]

void Halide::Internal::IRPrinter::visit ( const UIntImm )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [3/46]

void Halide::Internal::IRPrinter::visit ( const FloatImm )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [4/46]

void Halide::Internal::IRPrinter::visit ( const StringImm )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [5/46]

void Halide::Internal::IRPrinter::visit ( const Cast )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [6/46]

void Halide::Internal::IRPrinter::visit ( const Variable )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [7/46]

void Halide::Internal::IRPrinter::visit ( const Add )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [8/46]

void Halide::Internal::IRPrinter::visit ( const Sub )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [9/46]

void Halide::Internal::IRPrinter::visit ( const Mul )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [10/46]

void Halide::Internal::IRPrinter::visit ( const Div )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [11/46]

void Halide::Internal::IRPrinter::visit ( const Mod )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [12/46]

void Halide::Internal::IRPrinter::visit ( const Min )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [13/46]

void Halide::Internal::IRPrinter::visit ( const Max )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [14/46]

void Halide::Internal::IRPrinter::visit ( const EQ )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [15/46]

void Halide::Internal::IRPrinter::visit ( const NE )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [16/46]

void Halide::Internal::IRPrinter::visit ( const LT )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [17/46]

void Halide::Internal::IRPrinter::visit ( const LE )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [18/46]

void Halide::Internal::IRPrinter::visit ( const GT )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [19/46]

void Halide::Internal::IRPrinter::visit ( const GE )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [20/46]

void Halide::Internal::IRPrinter::visit ( const And )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [21/46]

void Halide::Internal::IRPrinter::visit ( const Or )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [22/46]

void Halide::Internal::IRPrinter::visit ( const Not )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [23/46]

void Halide::Internal::IRPrinter::visit ( const Select )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [24/46]

void Halide::Internal::IRPrinter::visit ( const Load )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [25/46]

void Halide::Internal::IRPrinter::visit ( const Ramp )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [26/46]

void Halide::Internal::IRPrinter::visit ( const Broadcast )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [27/46]

void Halide::Internal::IRPrinter::visit ( const Call )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [28/46]

void Halide::Internal::IRPrinter::visit ( const Let )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [29/46]

void Halide::Internal::IRPrinter::visit ( const LetStmt )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [30/46]

void Halide::Internal::IRPrinter::visit ( const AssertStmt )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [31/46]

void Halide::Internal::IRPrinter::visit ( const ProducerConsumer )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [32/46]

void Halide::Internal::IRPrinter::visit ( const For )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [33/46]

void Halide::Internal::IRPrinter::visit ( const Acquire )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [34/46]

void Halide::Internal::IRPrinter::visit ( const Store )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [35/46]

void Halide::Internal::IRPrinter::visit ( const Provide )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [36/46]

void Halide::Internal::IRPrinter::visit ( const Allocate )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [37/46]

void Halide::Internal::IRPrinter::visit ( const Free )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [38/46]

void Halide::Internal::IRPrinter::visit ( const Realize )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [39/46]

void Halide::Internal::IRPrinter::visit ( const Block )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [40/46]

void Halide::Internal::IRPrinter::visit ( const Fork )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [41/46]

void Halide::Internal::IRPrinter::visit ( const IfThenElse )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [42/46]

void Halide::Internal::IRPrinter::visit ( const Evaluate )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [43/46]

void Halide::Internal::IRPrinter::visit ( const Shuffle )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [44/46]

void Halide::Internal::IRPrinter::visit ( const VectorReduce )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [45/46]

void Halide::Internal::IRPrinter::visit ( const Prefetch )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

◆ visit() [46/46]

void Halide::Internal::IRPrinter::visit ( const Atomic )
overrideprotectedvirtual

Reimplemented from Halide::Internal::IRVisitor.

Member Data Documentation

◆ stream

std::ostream& Halide::Internal::IRPrinter::stream
protected

The stream on which we're outputting.

Definition at line 125 of file IRPrinter.h.

◆ indent

int Halide::Internal::IRPrinter::indent = 0
protected

The current indentation level, useful for pretty-printing statements.

Definition at line 129 of file IRPrinter.h.

Referenced by get_indent().

◆ implicit_parens

bool Halide::Internal::IRPrinter::implicit_parens = false
protected

Certain expressions do not need parens around them, e.g.

the args to a call are already separated by commas and a surrounding set of parens.

Definition at line 134 of file IRPrinter.h.

◆ known_type

Scope Halide::Internal::IRPrinter::known_type
protected

The symbols whose types can be inferred from values printed already.

Definition at line 144 of file IRPrinter.h.


The documentation for this class was generated from the following file: