-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathOpTraits.h
More file actions
52 lines (44 loc) · 1.89 KB
/
OpTraits.h
File metadata and controls
52 lines (44 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===-- OpTraits.h ----------------------------------------------*- c++ -*-===//
//
// Part of the LLZK Project, under the Apache License v2.0.
// See LICENSE.txt for license information.
// Copyright 2025 Veridise Inc.
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#pragma once
#include <mlir/IR/OpDefinition.h>
#include <mlir/IR/Operation.h>
#include <mlir/Support/LogicalResult.h>
namespace llzk::function {
mlir::LogicalResult verifyConstraintGenTraitImpl(mlir::Operation *op);
mlir::LogicalResult verifyWitnessGenTraitImpl(mlir::Operation *op);
mlir::LogicalResult verifyNotFieldNativeTraitImpl(mlir::Operation *op);
/// Marker for ops that are specific to constraint generation.
/// Verifies that the surrounding function is marked with the `AllowConstraintAttr`.
template <typename TypeClass>
class ConstraintGen : public mlir::OpTrait::TraitBase<TypeClass, ConstraintGen> {
public:
inline static mlir::LogicalResult verifyTrait(mlir::Operation *op) {
return verifyConstraintGenTraitImpl(op);
}
};
/// Marker for ops that are specific to witness generation.
/// Verifies that the surrounding function is marked with the `AllowWitnessAttr`.
template <typename TypeClass>
class WitnessGen : public mlir::OpTrait::TraitBase<TypeClass, WitnessGen> {
public:
inline static mlir::LogicalResult verifyTrait(mlir::Operation *op) {
return verifyWitnessGenTraitImpl(op);
}
};
/// Marker for ops over `llzk.felt` type operands that are not native to finite field arithmetic.
/// Verifies that the surrounding function is marked with the `AllowNonNativeFieldOpsAttr`.
template <typename TypeClass>
class NotFieldNative : public mlir::OpTrait::TraitBase<TypeClass, NotFieldNative> {
public:
inline static mlir::LogicalResult verifyTrait(mlir::Operation *op) {
return verifyNotFieldNativeTraitImpl(op);
}
};
} // namespace llzk::function