LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
Ops.h
Go to the documentation of this file.
1
//===-- Ops.h ---------------------------------------------------*- C++ -*-===//
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
#pragma once
11
12
#include "
llzk/Dialect/Function/IR/OpTraits.h
"
13
#include "
llzk/Dialect/LLZK/IR/Attrs.h
"
14
#include "
llzk/Dialect/Polymorphic/IR/Ops.h
"
15
#include "
llzk/Dialect/Shared/OpHelpers.h
"
16
#include "
llzk/Dialect/Struct/IR/Types.h
"
17
#include "
llzk/Dialect/Verif/IR/OpInterfaces.h
"
18
19
namespace
llzk
{
20
21
namespace
component
{
22
25
template
<
typename
TypeClass>
26
// Suppress false positive from `clang-tidy`
27
// NOLINTNEXTLINE(bugprone-crtp-constructor-accessibility)
28
class
SetFuncAllowAttrs
:
public
mlir::OpTrait::TraitBase<TypeClass, SetFuncAllowAttrs> {
29
public
:
30
static
mlir::LogicalResult
verifyTrait
(mlir::Operation *op);
31
};
32
33
}
// namespace component
34
35
namespace
function
{
36
class
FuncDefOp
;
37
}
// namespace function
38
39
}
// namespace llzk
40
41
// Include TableGen'd declarations
42
#include "
llzk/Dialect/Struct/IR/OpInterfaces.h.inc
"
43
44
// Include TableGen'd declarations
45
#define GET_OP_CLASSES
46
#include "
llzk/Dialect/Struct/IR/Ops.h.inc
"
47
48
namespace
llzk::component
{
49
50
mlir::InFlightDiagnostic
51
genCompareErr
(
StructDefOp
expected, mlir::Operation *origin,
const
char
*aspect);
52
53
mlir::LogicalResult
checkSelfType
(
54
mlir::SymbolTableCollection &symbolTable,
StructDefOp
expectedStruct, mlir::Type actualType,
55
mlir::Operation *origin,
const
char
*aspect
56
);
57
59
bool
isInStruct
(mlir::Operation *op);
60
63
mlir::FailureOr<StructDefOp>
verifyInStruct
(mlir::Operation *op);
64
67
bool
isInStructFunctionNamed
(mlir::Operation *op,
char
const
*funcName);
68
71
template
<
char
const *FuncName,
unsigned
PrefixLen>
72
mlir::LogicalResult
verifyInStructFunctionNamed
(
73
mlir::Operation *op, llvm::function_ref<llvm::SmallString<PrefixLen>()> prefix
74
) {
75
return
isInStructFunctionNamed
(op, FuncName)
76
? mlir::success()
77
: op->emitOpError(prefix())
78
<<
"only valid within a '"
<<
getOperationName<function::FuncDefOp>
()
79
<<
"' named \"@"
<< FuncName <<
"\" within a '"
80
<<
getOperationName<StructDefOp>
() <<
"' definition"
;
81
}
82
85
template
<
char
const *FuncName>
struct
InStructFunctionNamed
{
86
template
<
typename
TypeClass>
class
Impl
:
public
mlir::OpTrait::TraitBase<TypeClass, Impl> {
87
public
:
88
static
mlir::LogicalResult
verifyTrait
(mlir::Operation *op) {
89
return
verifyInStructFunctionNamed<FuncName, 0>
(op, [] {
return
llvm::SmallString<0>(); });
90
}
91
};
92
};
93
94
}
// namespace llzk::component
Attrs.h
OpHelpers.h
OpTraits.h
Ops.h
OpInterfaces.h.inc
Ops.h.inc
Types.h
OpInterfaces.h
llzk::component::InStructFunctionNamed::Impl
Definition
Ops.h:86
llzk::component::InStructFunctionNamed::Impl::verifyTrait
static mlir::LogicalResult verifyTrait(mlir::Operation *op)
Definition
Ops.h:88
llzk::component::SetFuncAllowAttrs
Only valid/implemented for StructDefOp.
Definition
Ops.h:28
llzk::component::SetFuncAllowAttrs::verifyTrait
static mlir::LogicalResult verifyTrait(mlir::Operation *op)
llzk::component::StructDefOp
Definition
Ops.h.inc:1148
llzk::function::FuncDefOp
Definition
Ops.h.inc:633
llzk::component
Definition
Dialect.cpp:209
llzk::component::isInStruct
bool isInStruct(Operation *op)
Definition
Ops.cpp:57
llzk::component::genCompareErr
InFlightDiagnostic genCompareErr(StructDefOp expected, Operation *origin, const char *aspect)
Definition
Ops.cpp:99
llzk::component::checkSelfType
LogicalResult checkSelfType(SymbolTableCollection &tables, StructDefOp expectedStruct, Type actualType, Operation *origin, const char *aspect)
Verifies that the given actualType matches the StructDefOp given (i.e., for the "self" type parameter...
Definition
Ops.cpp:121
llzk::component::verifyInStruct
FailureOr< StructDefOp > verifyInStruct(Operation *op)
Definition
Ops.cpp:59
llzk::component::verifyInStructFunctionNamed
mlir::LogicalResult verifyInStructFunctionNamed(mlir::Operation *op, llvm::function_ref< llvm::SmallString< PrefixLen >()> prefix)
Checks if the given Operation is contained within a FuncDefOp with the given name that is itself cont...
Definition
Ops.h:72
llzk::component::isInStructFunctionNamed
bool isInStructFunctionNamed(Operation *op, char const *funcName)
Definition
Ops.cpp:67
llzk::function
Definition
Ops.cpp:50
llzk
Definition
AnalysisPassEnums.cpp:19
llzk::getOperationName
llvm::StringLiteral getOperationName()
Get the operation name, like "constrain.eq" for the given OpClass.
Definition
OpHelpers.h:34
llzk::component::InStructFunctionNamed
This class provides a verifier for ops that are expecting to have an ancestor FuncDefOp with the give...
Definition
Ops.h:85
include
llzk
Dialect
Struct
IR
Ops.h
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.