14 #include "../EmissionPrinter.h"
15 #include "mlir/IR/BuiltinOps.h"
16 #include "llvm/ADT/SmallString.h"
19 using namespace circt;
31 using OpEmissionPattern::OpEmissionPattern;
33 auto scope = p.
getOstream().scope(
"",
"",
false);
48 bool match(Type type)
override {
49 if (!isa<IntegerType>(type))
52 unsigned bw = type.getIntOrFloatBitWidth();
53 return bw == 1 || bw == 8 || bw == 16 || bw == 32 || bw == 64;
57 unsigned bitWidth = type.getIntOrFloatBitWidth();
66 p << (type.isSigned() ?
"" :
"u") <<
"int" << bitWidth <<
"_t";
69 p.
emitError(
"in the IntegerType emitter all cases allowed by the 'match' "
70 "function must be covered")
71 <<
", got uncovered case " << type;
78 void emitType(IndexType type,
EmissionPrinter &p)
override { p <<
"size_t"; }
97 auto val = attr.getValue();
99 if (val.getBitWidth() == 1) {
100 p << (val.getBoolValue() ?
"true" :
"false");
102 bool isSigned =
false;
103 if (
auto integer = dyn_cast<IntegerType>(attr.getType()))
104 isSigned = integer.isSigned();
106 SmallString<128> strValue;
107 val.toString(strValue, 10, isSigned);
121 patterns.add<ModuleEmitter>(context);
126 patterns.add<IntegerTypeEmitter, IndexTypeEmitter>();
131 patterns.add<StringAttrEmitter, IntegerAttrEmitter>();
This class collects a set of emission patterns with base type 'PatternTy'.
This is intended to be the driving class for all pattern-based IR emission.
void emitRegion(Region ®ion)
Emit the given region to the ostream associated with this printer.
mlir::raw_indented_ostream & getOstream() const
InFlightDiagnostic emitError(Operation *op, const Twine &message)
Emit an error on the operation and fail emission.
void populateBuiltinOpEmitters(OpEmissionPatternSet &patterns, MLIRContext *context)
Register Builtin operation emission patterns.
void populateBuiltinAttrEmitters(AttrEmissionPatternSet &patterns)
Register Builtin attribute emission patterns.
void populateBuiltinTypeEmitters(TypeEmissionPatternSet &patterns)
Register Builtin type emission patterns.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
This is a convenience class providing default implementations for attribute emission patterns.
This is a convenience class providing default implementations for operation emission patterns.
This is a convenience class providing default implementations for type emission patterns.