1//===- IRDLAttributes.td - IR Definition Language Dialect --*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file declares the attributes used in IRDL. 10// 11//===----------------------------------------------------------------------===// 12 13#ifndef MLIR_DIALECT_IRDL_IR_IRDLATTRIBUTES 14#define MLIR_DIALECT_IRDL_IR_IRDLATTRIBUTES 15 16include "IRDL.td" 17include "mlir/IR/AttrTypeBase.td" 18include "mlir/IR/EnumAttr.td" 19 20def Variadicity : I32EnumAttr< 21 "Variadicity", "variadicity kind", 22 [ 23 I32EnumAttrCase<"single", 0>, 24 I32EnumAttrCase<"optional", 1>, 25 I32EnumAttrCase<"variadic", 2>, 26 ]> { 27 let cppNamespace = "::mlir::irdl"; 28 let genSpecializedAttr = 0; 29} 30 31def VariadicityAttr : EnumAttr<IRDL_Dialect, Variadicity, "variadicity"> { 32 let summary = 33 "A variadicity kind. Can be either 'single', 'optional', or 'variadic'"; 34 let description = [{ 35 A `irdl.variadicity` attribute specifies that the associated operand or 36 result definition is either a single definition (the default), an 37 optional definition, or a variadic definition. 38 39 For instance: 40 ```mlir 41 irdl.operands (%arg1, single %arg2, optional %arg3, variadic %arg4) 42 ``` 43 44 In this example, both %arg1 and %arg2 are single operands, %arg3 is an 45 optional operand, and %arg4 is a variadic operand. 46 }]; 47} 48 49def VariadicityArrayAttr : ArrayOfAttr<IRDL_Dialect, "VariadicityArray", "variadicity_array", 50 VariadicityAttr.cppClassName> {} 51 52#endif // MLIR_DIALECT_IRDL_IR_IRDLATTRIBUTES 53