LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Ops.cpp
Go to the documentation of this file.
1//===-- Ops.cpp - LLZK operation implementations ----------------*- 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
11
13
14#include <mlir/IR/PatternMatch.h>
15
16// TableGen'd implementation files
17#define GET_OP_CLASSES
19
20using namespace mlir;
21
22namespace llzk {
23
24namespace {
25
26struct RemoveUnusedNonDetPattern : public OpRewritePattern<NonDetOp> {
27 using OpRewritePattern::OpRewritePattern;
28
29 LogicalResult matchAndRewrite(NonDetOp op, PatternRewriter &rewriter) const override {
30 if (!op.getResult().use_empty()) {
31 return failure();
32 }
33 rewriter.eraseOp(op);
34 return success();
35 }
36};
37
38} // namespace
39
40//===------------------------------------------------------------------===//
41// NonDetOp
42//===------------------------------------------------------------------===//
43
44void NonDetOp::getAsmResultNames(OpAsmSetValueNameFn setNameFn) {
45 setNameFn(getResult(), "nondet");
46}
47
48void NonDetOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) {
49 results.add<RemoveUnusedNonDetPattern>(context);
50}
51
52} // namespace llzk
static void getCanonicalizationPatterns(::mlir::RewritePatternSet &results, ::mlir::MLIRContext *context)
Definition Ops.cpp:48
void getAsmResultNames(::mlir::OpAsmSetValueNameFn setNameFn)
Definition Ops.cpp:44