CIRCT  19.0.0git
Public Member Functions | Private Attributes | List of all members
circt::ExportSystemC::EmissionPrinter Class Reference

This is intended to be the driving class for all pattern-based IR emission. More...

#include <EmissionPrinter.h>

Collaboration diagram for circt::ExportSystemC::EmissionPrinter:
Collaboration graph
[legend]

Public Member Functions

 EmissionPrinter (mlir::raw_indented_ostream &os, const FrozenOpEmissionPatternSet &opPatterns, const FrozenTypeEmissionPatternSet &typePatterns, const FrozenAttrEmissionPatternSet &attrPatterns, Location loc)
 
 EmissionPrinter (mlir::raw_indented_ostream &os, OpEmissionPatternSet &opPatterns, TypeEmissionPatternSet &typePatterns, AttrEmissionPatternSet &attrPatterns, Location loc)
 
void emitOp (Operation *op)
 Emit the given operation as a statement to the ostream associated with this printer according to the emission patterns registered. More...
 
InlineEmitter getInlinable (Value value)
 Emit the expression represented by the given value to the ostream associated with this printer according to the emission patterns registered. More...
 
void emitType (Type type)
 Emit the given type to the ostream associated with this printer according to the emission patterns registered. More...
 
void emitAttr (Attribute attr)
 Emit the given attribute to the ostream associated with this printer according to the emission patterns registered. More...
 
void emitRegion (Region &region)
 Emit the given region to the ostream associated with this printer. More...
 
void emitRegion (Region &region, mlir::raw_indented_ostream::DelimitedScope &scope)
 Emit the given region to the ostream associated with this printer. More...
 
InFlightDiagnostic emitError (Operation *op, const Twine &message)
 Emit an error on the operation and fail emission. More...
 
InFlightDiagnostic emitError (const Twine &message)
 Emit an error at the current location of the printer (the newest operation to be emitted as a statement). More...
 
EmissionPrinteroperator<< (StringRef str)
 
EmissionPrinteroperator<< (int64_t num)
 
mlir::raw_indented_ostream & getOstream () const
 
LogicalResult exitState () const
 Returns whether everything was printed successfully or some error occurred (e.g., there was an operation or type for which no emission pattern was valid). More...
 

Private Attributes

FrozenOpEmissionPatternSet opPatterns
 
FrozenTypeEmissionPatternSet typePatterns
 
FrozenAttrEmissionPatternSet attrPatterns
 
mlir::raw_indented_ostream & os
 
bool emissionFailed
 
Location currentLoc
 

Detailed Description

This is intended to be the driving class for all pattern-based IR emission.

Definition at line 27 of file EmissionPrinter.h.

Constructor & Destructor Documentation

◆ EmissionPrinter() [1/2]

circt::ExportSystemC::EmissionPrinter::EmissionPrinter ( mlir::raw_indented_ostream &  os,
const FrozenOpEmissionPatternSet opPatterns,
const FrozenTypeEmissionPatternSet typePatterns,
const FrozenAttrEmissionPatternSet attrPatterns,
Location  loc 
)
inline

Definition at line 29 of file EmissionPrinter.h.

◆ EmissionPrinter() [2/2]

circt::ExportSystemC::EmissionPrinter::EmissionPrinter ( mlir::raw_indented_ostream &  os,
OpEmissionPatternSet opPatterns,
TypeEmissionPatternSet typePatterns,
AttrEmissionPatternSet attrPatterns,
Location  loc 
)
inline

Definition at line 38 of file EmissionPrinter.h.

Member Function Documentation

◆ emitAttr()

void EmissionPrinter::emitAttr ( Attribute  attr)

Emit the given attribute to the ostream associated with this printer according to the emission patterns registered.

If multiple emission patterns match, the first one in the pattern set is chosen. If no pattern matches, a remark is left in the output and an error is added to stderr. Additionally, the exit-code to be obtained by the 'exitCode()' member-function is set to 'failure'.

Definition at line 54 of file EmissionPrinter.cpp.

References attrPatterns, currentLoc, emissionFailed, circt::ExportSystemC::FrozenEmissionPatternSet< PatternTy, KeyTy >::getSpecificNativePatterns(), and os.

◆ emitError() [1/2]

InFlightDiagnostic EmissionPrinter::emitError ( const Twine &  message)

Emit an error at the current location of the printer (the newest operation to be emitted as a statement).

This is primarily intended for types and attributes for which no location is available directly.

Definition at line 118 of file EmissionPrinter.cpp.

References currentLoc, emissionFailed, and os.

◆ emitError() [2/2]

InFlightDiagnostic EmissionPrinter::emitError ( Operation *  op,
const Twine &  message 
)

Emit an error on the operation and fail emission.

Preferred for operations, especially the ones that will be inlined, because it places the error more precisely.

Definition at line 111 of file EmissionPrinter.cpp.

References emissionFailed, and os.

Referenced by MemberAccessEmitter::emitInlined().

◆ emitOp()

void EmissionPrinter::emitOp ( Operation *  op)

Emit the given operation as a statement to the ostream associated with this printer according to the emission patterns registered.

An operation might also emit multiple statements, or nothing in case it can only be emitted as an expression. If multiple emission patterns match, the first one in the first one in the pattern set is chosen. If no pattern matches, a remark is left in the output and an error is added to stderr. Additionally, the exit-code to be obtained by the 'exitCode()' member-function is set to 'failure'.

Definition at line 18 of file EmissionPrinter.cpp.

References currentLoc, emissionFailed, circt::ExportSystemC::FrozenEmissionPatternSet< PatternTy, KeyTy >::getSpecificNativePatterns(), opPatterns, and os.

Referenced by emitFile(), and emitRegion().

◆ emitRegion() [1/2]

void EmissionPrinter::emitRegion ( Region &  region)

Emit the given region to the ostream associated with this printer.

Only regions with a single basic block are allowed. Prints the operations inside according to 'emitOp()' indented one level deeper and encloses the region in curly-braces.

Definition at line 96 of file EmissionPrinter.cpp.

References os.

Referenced by FuncEmitter::emitStatement().

◆ emitRegion() [2/2]

void EmissionPrinter::emitRegion ( Region &  region,
mlir::raw_indented_ostream::DelimitedScope &  scope 
)

Emit the given region to the ostream associated with this printer.

Only regions with a single basic block are allowed. Prints the operations inside according to 'emitOp()'. The enclosing delimiters and level of indentation is determined by the passed scope.

Definition at line 101 of file EmissionPrinter.cpp.

References assert(), and emitOp().

◆ emitType()

void EmissionPrinter::emitType ( Type  type)

Emit the given type to the ostream associated with this printer according to the emission patterns registered.

If multiple emission patterns match, the first one in the pattern set is chosen. If no pattern matches, a remark is left in the output and an error is added to stderr. Additionally, the exit-code to be obtained by the 'exitCode()' member-function is set to 'failure'.

Definition at line 36 of file EmissionPrinter.cpp.

References currentLoc, emissionFailed, circt::ExportSystemC::FrozenEmissionPatternSet< PatternTy, KeyTy >::getSpecificNativePatterns(), os, and typePatterns.

Referenced by FuncEmitter::emitStatement(), and VariableEmitter::emitStatement().

◆ exitState()

LogicalResult circt::ExportSystemC::EmissionPrinter::exitState ( ) const
inline

Returns whether everything was printed successfully or some error occurred (e.g., there was an operation or type for which no emission pattern was valid).

Definition at line 113 of file EmissionPrinter.h.

References emissionFailed.

Referenced by emitFile().

◆ getInlinable()

InlineEmitter EmissionPrinter::getInlinable ( Value  value)

Emit the expression represented by the given value to the ostream associated with this printer according to the emission patterns registered.

This will emit exactly one expression and does not emit any statements. If multiple emission patterns match, the first one in the first one in the pattern set is chosen. If no pattern matches, a remark is left in the output and an error is added to stderr. Additionally, the exit-code to be obtained by the 'exitCode()' member-function is set to 'failure'.

Definition at line 70 of file EmissionPrinter.cpp.

References currentLoc, emissionFailed, circt::ExportSystemC::MatchResult::failed(), circt::ExportSystemC::MatchResult::getPrecedence(), circt::ExportSystemC::FrozenEmissionPatternSet< PatternTy, KeyTy >::getSpecificNativePatterns(), circt::ExportSystemC::LIT, opPatterns, and os.

Referenced by MemberAccessEmitter::emitInlined(), AssignEmitter::emitStatement(), BindPortEmitter::emitStatement(), ReturnEmitter::emitStatement(), VariableEmitter::emitStatement(), and CallIndirectEmitter::printCall().

◆ getOstream()

mlir::raw_indented_ostream& circt::ExportSystemC::EmissionPrinter::getOstream ( ) const
inline

Definition at line 108 of file EmissionPrinter.h.

References os.

◆ operator<<() [1/2]

EmissionPrinter & EmissionPrinter::operator<< ( int64_t  num)

Definition at line 129 of file EmissionPrinter.cpp.

References os.

◆ operator<<() [2/2]

EmissionPrinter & EmissionPrinter::operator<< ( StringRef  str)

Definition at line 124 of file EmissionPrinter.cpp.

References os.

Member Data Documentation

◆ attrPatterns

FrozenAttrEmissionPatternSet circt::ExportSystemC::EmissionPrinter::attrPatterns
private

Definition at line 118 of file EmissionPrinter.h.

Referenced by emitAttr().

◆ currentLoc

Location circt::ExportSystemC::EmissionPrinter::currentLoc
private

Definition at line 121 of file EmissionPrinter.h.

Referenced by emitAttr(), emitError(), emitOp(), emitType(), and getInlinable().

◆ emissionFailed

bool circt::ExportSystemC::EmissionPrinter::emissionFailed
private

Definition at line 120 of file EmissionPrinter.h.

Referenced by emitAttr(), emitError(), emitOp(), emitType(), exitState(), and getInlinable().

◆ opPatterns

FrozenOpEmissionPatternSet circt::ExportSystemC::EmissionPrinter::opPatterns
private

Definition at line 116 of file EmissionPrinter.h.

Referenced by emitOp(), and getInlinable().

◆ os

mlir::raw_indented_ostream& circt::ExportSystemC::EmissionPrinter::os
private

◆ typePatterns

FrozenTypeEmissionPatternSet circt::ExportSystemC::EmissionPrinter::typePatterns
private

Definition at line 117 of file EmissionPrinter.h.

Referenced by emitType().


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