LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
OpCAPIParamHelper.cpp
Go to the documentation of this file.
1
//===- OpCAPIParamHelper.cpp ----------------------------------------------===//
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
#include "
OpCAPIParamHelper.h
"
11
12
#include "
CommonCAPIGen.h
"
13
14
#include <mlir/TableGen/Operator.h>
15
16
#include <llvm/Support/FormatVariadic.h>
17
18
std::string
GenStringFromOpPieces::gen
(
const
mlir::tblgen::Operator &op) {
19
std::string params;
20
llvm::raw_string_ostream oss(params);
21
genHeader
(oss);
22
if
(!op.allResultTypesKnown()) {
23
// If result types are not inferred, call handler for each result
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());
27
}
28
}
else
{
29
// Otherewise, call inferred result handler
30
genResultInferred
(oss);
31
}
32
for
(
const
mlir::tblgen::NamedTypeConstraint &operand : op.getOperands()) {
33
genOperand
(oss, operand);
34
}
35
{
36
auto
attrs = op.getAttributes();
37
if
(!attrs.empty()) {
38
genAttributesPrefix
(oss, op);
39
for
(
const
mlir::tblgen::NamedAttribute &namedAttr : attrs) {
40
genAttribute
(oss, namedAttr);
41
}
42
genAttributesSuffix
(oss, op);
43
}
44
}
45
{
46
auto
regions = op.getRegions();
47
if
(!regions.empty()) {
48
genRegionsPrefix
(oss, op);
49
for
(
const
mlir::tblgen::NamedRegion ®ion : regions) {
50
genRegion
(oss, region);
51
}
52
genRegionsSuffix
(oss, op);
53
}
54
}
55
return
params;
56
}
CommonCAPIGen.h
OpCAPIParamHelper.h
GenStringFromOpPieces::genRegionsSuffix
virtual void genRegionsSuffix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate region section suffix code to os. Default does nothing.
Definition
OpCAPIParamHelper.h:61
GenStringFromOpPieces::genOperand
virtual void genOperand(llvm::raw_ostream &os, const mlir::tblgen::NamedTypeConstraint &operand)=0
Generate code for operand to os.
GenStringFromOpPieces::gen
std::string gen(const mlir::tblgen::Operator &op)
Generate string from the operation pieces.
Definition
OpCAPIParamHelper.cpp:18
GenStringFromOpPieces::genAttributesSuffix
virtual void genAttributesSuffix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate attribute section suffix code to os. Default does nothing.
Definition
OpCAPIParamHelper.h:52
GenStringFromOpPieces::genResultInferred
virtual void genResultInferred(llvm::raw_ostream &os)
Generate code to os when result type is inferred. Default does nothing.
Definition
OpCAPIParamHelper.h:39
GenStringFromOpPieces::genHeader
virtual void genHeader(llvm::raw_ostream &os)
Generate header code to os. Default does nothing.
Definition
OpCAPIParamHelper.h:30
GenStringFromOpPieces::genRegion
virtual void genRegion(llvm::raw_ostream &os, const mlir::tblgen::NamedRegion ®ion)=0
Generate code for region to os.
GenStringFromOpPieces::genAttributesPrefix
virtual void genAttributesPrefix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate attribute section prefix code to os. Default does nothing.
Definition
OpCAPIParamHelper.h:46
GenStringFromOpPieces::genResult
virtual void genResult(llvm::raw_ostream &os, const mlir::tblgen::NamedTypeConstraint &result, const std::string &resultName)=0
Generate code for result to os.
GenStringFromOpPieces::genAttribute
virtual void genAttribute(llvm::raw_ostream &os, const mlir::tblgen::NamedAttribute &attr)=0
Generate code for attr to os.
GenStringFromOpPieces::genRegionsPrefix
virtual void genRegionsPrefix(llvm::raw_ostream &os, const mlir::tblgen::Operator &op)
Generate region section prefix code to os. Default does nothing.
Definition
OpCAPIParamHelper.h:55
tools
llzk-tblgen
OpCAPIParamHelper.cpp
Generated by
1.17.0
Copyright 2025 Veridise Inc. under the Apache License v2.0. Copyright 2026 Project LLZK under the Apache License v2.0.