LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
OpCAPIParamHelper.h
Go to the documentation of this file.
1//===- OpCAPIParamHelper.h ------------------------------------------------===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9//
10// Helpers for generating C API and C API link tests for Operations.
11//
12//===----------------------------------------------------------------------===//
13
14#pragma once
15
16#include <mlir/TableGen/Argument.h>
17#include <mlir/TableGen/Operator.h>
18
19#include <string>
20
23 virtual ~GenStringFromOpPieces() = default;
24
26 std::string gen(const mlir::tblgen::Operator &op);
27
28protected:
30 virtual void genHeader(llvm::raw_ostream &os) {}
31
33 virtual void genResult(
34 llvm::raw_ostream &os, const mlir::tblgen::NamedTypeConstraint &result,
35 const std::string &resultName
36 ) = 0;
37
39 virtual void genResultInferred(llvm::raw_ostream &os) {}
40
42 virtual void
43 genOperand(llvm::raw_ostream &os, const mlir::tblgen::NamedTypeConstraint &operand) = 0;
44
46 virtual void genAttributesPrefix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op) {}
47
49 virtual void genAttribute(llvm::raw_ostream &os, const mlir::tblgen::NamedAttribute &attr) = 0;
50
52 virtual void genAttributesSuffix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op) {}
53
55 virtual void genRegionsPrefix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op) {}
56
58 virtual void genRegion(llvm::raw_ostream &os, const mlir::tblgen::NamedRegion &region) = 0;
59
61 virtual void genRegionsSuffix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op) {}
62};
Helper struct to generate a string from operation operand, attribute, and result pieces.
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 &region)=0
Generate code for region to os.
virtual ~GenStringFromOpPieces()=default
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.