LLZK 0.1.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
OpInterfaces.td
Go to the documentation of this file.
1//===-- OpInterfaces.td ------------------------------------*- tablegen -*-===//
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#ifndef LLZK_STRUCT_OP_INTERFACES
11#define LLZK_STRUCT_OP_INTERFACES
12
13include "llzk/Dialect/Struct/IR/Types.td"
14
15def MemberRefOpInterface : OpInterface<"MemberRefOpInterface"> {
16 let description = [{
17 Common interface for operations that read or write from a struct member.
18 }];
19 let cppNamespace = "::llzk::component";
20
21 let methods = [
22 // Requires implementors to have a '$val' argument.
23 InterfaceMethod<
24 [{Gets the SSA Value that holds the read/write data for the MemberRefOp.}],
25 "::mlir::Value", "getVal", (ins)>,
26 // Requires implementors to have a '$component' argument.
27 InterfaceMethod<
28 [{Gets the SSA value with the target component from the MemberRefOp.}],
29 "::mlir::TypedValue<::llzk::component::StructType>", "getComponent",
30 (ins)>,
31 InterfaceMethod<
32 [{Gets the SSA value with the target component from the MemberRefOp.}],
33 "::mlir::OpOperand &", "getComponentMutable", (ins)>,
34 // Requires implementors to have a '$member_name' argument.
35 InterfaceMethod<
36 [{Gets the member name attribute value from the MemberRefOp.}],
37 "::llvm::StringRef", "getMemberName", (ins)>,
38 InterfaceMethod<[{Gets the member name attribute from the MemberRefOp.}],
39 "::mlir::FlatSymbolRefAttr", "getMemberNameAttr", (ins)>,
40 InterfaceMethod<
41 [{Sets the member name attribute value in the MemberRefOp.}], "void",
42 "setMemberName", (ins "::llvm::StringRef":$attrValue)>,
43 InterfaceMethod<[{Sets the member name attribute in the MemberRefOp.}],
44 "void", "setMemberNameAttr",
45 (ins "::mlir::FlatSymbolRefAttr":$attr)>,
46 // Requires the '$component' argument type to be LLZK_StructType.
47 InterfaceMethod<
48 [{Gets the struct type of the target component.}],
49 "::llzk::component::StructType", "getStructType", (ins),
50 /*methodBody=*/[{ return $_op.getComponent().getType(); }]>,
51 InterfaceMethod<
52 [{Return `true` if the op is a read, `false` if it's a write.}],
53 "bool", "isRead", (ins)>,
54 ];
55
56 let extraClassDeclaration = [{
57 /// Gets the definition for the `member` referenced in this op.
58 ::mlir::FailureOr<SymbolLookupResult<MemberDefOp>> getMemberDefOp(::mlir::SymbolTableCollection &tables);
59 }];
60}
61
62#endif // LLZK_STRUCT_OP_INTERFACES