LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
ValueCopy.h
Go to the documentation of this file.
1//===-- ValueCopy.h - Mutable value-copy materialization --------*- C++ -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2026 Project LLZK
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9
10#pragma once
11
12#include <mlir/IR/Builders.h>
13#include <mlir/IR/DialectInterface.h>
14#include <mlir/Support/LLVM.h>
15
16#include <string>
17
18namespace llzk {
19
25class ValueCopyDialectInterface : public mlir::DialectInterface::Base<ValueCopyDialectInterface> {
26public:
27 using Base::Base;
28
34 virtual bool canMaterializeValueCopy(mlir::Type type) const = 0;
35
37 virtual std::string getValueCopyFailureReason(mlir::Type type) const;
38
43 virtual mlir::FailureOr<mlir::Value>
44 materializeValueCopy(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value source) const = 0;
45};
46
50bool requiresValueCopy(mlir::Type type);
51
55bool canMaterializeValueCopy(mlir::Type type);
56
58inline bool requiresUnsupportedValueCopy(mlir::Type type) {
59 return requiresValueCopy(type) && !canMaterializeValueCopy(type);
60}
61
64std::string getValueCopyFailureReason(mlir::Type type);
65
70mlir::FailureOr<mlir::Value>
71materializeValueCopy(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value source);
72
73} // namespace llzk
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation source
Definition LICENSE.txt:28
Dialect hook for materializing independent storage for mutable value types.
Definition ValueCopy.h:25
virtual mlir::FailureOr< mlir::Value > materializeValueCopy(mlir::OpBuilder &builder, mlir::Location loc, mlir::Value source) const =0
Preserve the value-copy semantics of source at the builder's insertion point.
virtual std::string getValueCopyFailureReason(mlir::Type type) const
Explain why this dialect cannot copy type. Called only after support is rejected.
Definition ValueCopy.cpp:50
virtual bool canMaterializeValueCopy(mlir::Type type) const =0
Return whether the value semantics of type can be preserved by either reusing the same SSA value or m...
std::string getValueCopyFailureReason(Type type)
Definition ValueCopy.cpp:56
bool requiresUnsupportedValueCopy(mlir::Type type)
Return whether type requires a value copy that cannot currently be materialized.
Definition ValueCopy.h:58
FailureOr< Value > materializeValueCopy(OpBuilder &builder, Location loc, Value source)
Definition ValueCopy.cpp:68
bool requiresValueCopy(Type type)
Definition ValueCopy.cpp:38
bool canMaterializeValueCopy(Type type)
Definition ValueCopy.cpp:40