LLZK 0.1.0
Veridise's ZK Language IR
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 FieldRefOpInterface : OpInterface<"FieldRefOpInterface"> {
16 let description = [{
17 Common interface for operations that read or write from a field.
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 FieldRefOp.}],
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 FieldRefOp.}],
29 "::mlir::TypedValue<::llzk::component::StructType>", "getComponent",
30 (ins)>,
31 InterfaceMethod<
32 [{Gets the SSA value with the target component from the FieldRefOp.}],
33 "::mlir::OpOperand &", "getComponentMutable", (ins)>,
34 // Requires implementors to have a '$field_name' argument.
35 InterfaceMethod<
36 [{Gets the field name attribute value from the FieldRefOp.}],
37 "::llvm::StringRef", "getFieldName", (ins)>,
38 InterfaceMethod<[{Gets the field name attribute from the FieldRefOp.}],
39 "::mlir::FlatSymbolRefAttr", "getFieldNameAttr", (ins)>,
40 InterfaceMethod<
41 [{Sets the field name attribute value in the FieldRefOp.}], "void",
42 "setFieldName", (ins "::llvm::StringRef":$attrValue)>,
43 InterfaceMethod<[{Sets the field name attribute in the FieldRefOp.}],
44 "void", "setFieldNameAttr",
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 `field` referenced in this op.
58 ::mlir::FailureOr<SymbolLookupResult<FieldDefOp>> getFieldDefOp(::mlir::SymbolTableCollection &tables);
59 }];
60}
61
62#endif // LLZK_STRUCT_OP_INTERFACES