1//===-- OpInterfaces.td ------------------------------------*- tablegen -*-===//
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
8//===----------------------------------------------------------------------===//
10#ifndef LLZK_STRUCT_OP_INTERFACES
11#define LLZK_STRUCT_OP_INTERFACES
13include "llzk/Dialect/Struct/IR/Types.td"
15def FieldRefOpInterface : OpInterface<"FieldRefOpInterface"> {
17 Common interface for operations that read or write from a field.
19 let cppNamespace = "::llzk::component";
22 // Requires implementors to have a '$val' argument.
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.
28 [{Gets the SSA value with the target component from the FieldRefOp.}],
29 "::mlir::TypedValue<::llzk::component::StructType>", "getComponent",
31 // Requires implementors to have a '$field_name' argument.
33 [{Gets the field name attribute value from the FieldRefOp.}],
34 "::llvm::StringRef", "getFieldName", (ins)>,
35 InterfaceMethod<[{Gets the field name attribute from the FieldRefOp.}],
36 "::mlir::FlatSymbolRefAttr", "getFieldNameAttr", (ins)>,
37 // Requires the '$component' argument type to be LLZK_StructType.
39 [{Gets the struct type of the target component.}],
40 "::llzk::component::StructType", "getStructType", (ins),
41 /*methodBody=*/[{ return $_op.getComponent().getType(); }]>,
43 [{Return `true` if the op is a read, `false` if it's a write.}],
44 "bool", "isRead", (ins)>,
47 let extraClassDeclaration = [{
48 /// Gets the definition for the `field` referenced in this op.
49 ::mlir::FailureOr<SymbolLookupResult<FieldDefOp>> getFieldDefOp(::mlir::SymbolTableCollection &tables);
53#endif // LLZK_STRUCT_OP_INTERFACES