CIRCT
20.0.0git
|
This is intended to be the driving class for all pattern-based IR emission. More...
#include <EmissionPrinter.h>
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 ®ion) |
Emit the given region to the ostream associated with this printer. More... | |
void | emitRegion (Region ®ion, 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... | |
EmissionPrinter & | operator<< (StringRef str) |
EmissionPrinter & | operator<< (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 |
This is intended to be the driving class for all pattern-based IR emission.
Definition at line 27 of file EmissionPrinter.h.
|
inline |
Definition at line 29 of file EmissionPrinter.h.
|
inline |
Definition at line 38 of file EmissionPrinter.h.
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.
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.
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().
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().
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().
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.
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().
|
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().
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().
|
inline |
Definition at line 108 of file EmissionPrinter.h.
References os.
EmissionPrinter & EmissionPrinter::operator<< | ( | int64_t | num | ) |
Definition at line 129 of file EmissionPrinter.cpp.
References os.
EmissionPrinter & EmissionPrinter::operator<< | ( | StringRef | str | ) |
Definition at line 124 of file EmissionPrinter.cpp.
References os.
|
private |
Definition at line 118 of file EmissionPrinter.h.
Referenced by emitAttr().
|
private |
Definition at line 121 of file EmissionPrinter.h.
Referenced by emitAttr(), emitError(), emitOp(), emitType(), and getInlinable().
|
private |
Definition at line 120 of file EmissionPrinter.h.
Referenced by emitAttr(), emitError(), emitOp(), emitType(), exitState(), and getInlinable().
|
private |
Definition at line 116 of file EmissionPrinter.h.
Referenced by emitOp(), and getInlinable().
|
private |
Definition at line 119 of file EmissionPrinter.h.
Referenced by emitAttr(), emitError(), emitOp(), emitRegion(), emitType(), getInlinable(), getOstream(), and operator<<().
|
private |
Definition at line 117 of file EmissionPrinter.h.
Referenced by emitType().