12#include <mlir/TableGen/Operator.h>
14#include <llvm/Support/FormatVariadic.h>
20 llvm::raw_string_ostream oss(params);
22 if (!op.allResultTypesKnown()) {
24 for (
auto [i, result] : llvm::enumerate(op.getResults())) {
25 llvm::StringRef name = result.name;
26 genResult(oss, result, name.empty() ? llvm::formatv(
"result{0}", i).str() : name.str());
32 for (
const mlir::tblgen::NamedTypeConstraint &operand : op.getOperands()) {
36 auto attrs = op.getAttributes();
39 for (
const mlir::tblgen::NamedAttribute &namedAttr : attrs) {
46 auto regions = op.getRegions();
47 if (!regions.empty()) {
49 for (
const mlir::tblgen::NamedRegion ®ion : regions) {
virtual void genRegionsSuffix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate region section suffix code to os. Default does nothing.
virtual void genOperand(llvm::raw_ostream &os, const mlir::tblgen::NamedTypeConstraint &operand)=0
Generate code for operand to os.
std::string gen(const mlir::tblgen::Operator &op)
Generate string from the operation pieces.
virtual void genAttributesSuffix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate attribute section suffix code to os. Default does nothing.
virtual void genResultInferred(llvm::raw_ostream &os)
Generate code to os when result type is inferred. Default does nothing.
virtual void genHeader(llvm::raw_ostream &os)
Generate header code to os. Default does nothing.
virtual void genRegion(llvm::raw_ostream &os, const mlir::tblgen::NamedRegion ®ion)=0
Generate code for region to os.
virtual void genAttributesPrefix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate attribute section prefix code to os. Default does nothing.
virtual void genResult(llvm::raw_ostream &os, const mlir::tblgen::NamedTypeConstraint &result, const std::string &resultName)=0
Generate code for result to os.
virtual void genAttribute(llvm::raw_ostream &os, const mlir::tblgen::NamedAttribute &attr)=0
Generate code for attr to os.
virtual void genRegionsPrefix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate region section prefix code to os. Default does nothing.