LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
ScalarEvaluation.h
Go to the documentation of this file.
1
//===-- ScalarEvaluation.h -------------------------------------*- 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 "
llzk/Dialect/Cast/IR/Ops.h
"
13
#include "
llzk/Dialect/Felt/IR/Attrs.h
"
14
#include "
llzk/Dialect/LLZK/IR/AttributeHelper.h
"
15
#include "
llzk/Util/DynamicAPIntHelper.h
"
16
17
#include <mlir/IR/Builders.h>
18
#include <mlir/Interfaces/SideEffectInterfaces.h>
19
20
namespace
llzk::polymorphic::detail
{
21
26
inline
mlir::LogicalResult
evaluateScalarOperation
(
27
mlir::Operation *op, llvm::ArrayRef<mlir::Attribute> operands,
28
llvm::SmallVectorImpl<mlir::OpFoldResult> &results
29
) {
30
// Assert casts fold only when their range checks are satisfied.
31
if
(op->getNumRegions() || (!mlir::isMemoryEffectFree(op) &&
32
!llvm::isa<llzk::cast::FeltToIndexOp, llzk::cast::IntToFeltOp>(op))) {
33
return
mlir::failure();
34
}
35
mlir::Operation *temporary = op->clone();
36
auto
status = temporary->fold(operands, results);
37
temporary->destroy();
38
return
mlir::success(mlir::succeeded(status) && results.size() == op->getNumResults());
39
}
40
41
}
// namespace llzk::polymorphic::detail
AttributeHelper.h
Ops.h
DynamicAPIntHelper.h
This file implements helpers for DynamicAPInt operations and conversions that LLVM does not provide.
Attrs.h
llzk::polymorphic::detail
Common interface for constant parameter-like symbol operations that can be defined within a TemplateO...
Definition
ConstraintBindings.h:24
llzk::polymorphic::detail::evaluateScalarOperation
mlir::LogicalResult evaluateScalarOperation(mlir::Operation *op, llvm::ArrayRef< mlir::Attribute > operands, llvm::SmallVectorImpl< mlir::OpFoldResult > &results)
Evaluate a scalar operation using caller-supplied operand constants.
Definition
ScalarEvaluation.h:26
lib
Dialect
Polymorphic
Transforms
ScalarEvaluation.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.