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 MemberRefOpInterface : OpInterface<"MemberRefOpInterface"> {
17 Common interface for operations that read or write from a struct member.
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 MemberRefOp.}],
25 "::mlir::Value", "getVal", (ins)>,
26 // Requires implementors to have a '$component' argument.
28 [{Gets the SSA value with the target component from the MemberRefOp.}],
29 "::mlir::TypedValue<::llzk::component::StructType>", "getComponent",
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.
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)>,
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.
48 [{Gets the struct type of the target component.}],
49 "::llzk::component::StructType", "getStructType", (ins),
50 /*methodBody=*/[{ return $_op.getComponent().getType(); }]>,
52 [{Return `true` if the op is a read, `false` if it's a write.}],
53 "bool", "isRead", (ins)>,
56 let extraClassDeclaration = [{
57 /// Gets the definition for the `member` referenced in this op.
58 ::mlir::FailureOr<SymbolLookupResult<MemberDefOp>> getMemberDefOp(::mlir::SymbolTableCollection &tables);
62#endif // LLZK_STRUCT_OP_INTERFACES