1//===-- TestAttrDefs.td - Test dialect attr definitions ----*- 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// TableGen data attribute definitions for Test dialect. 10// 11//===----------------------------------------------------------------------===// 12 13#ifndef TEST_ATTRDEFS 14#define TEST_ATTRDEFS 15 16// To get the test dialect definition. 17include "TestOps.td" 18 19// All of the attributes will extend this class. 20class Test_Attr<string name> : AttrDef<Test_Dialect, name>; 21 22def SimpleAttrA : Test_Attr<"SimpleA"> { 23 let mnemonic = "smpla"; 24} 25 26// A more complex parameterized attribute. 27def CompoundAttrA : Test_Attr<"CompoundA"> { 28 let mnemonic = "cmpnd_a"; 29 30 // List of type parameters. 31 let parameters = ( 32 ins 33 "int":$widthOfSomething, 34 "::mlir::Type":$oneType, 35 // This is special syntax since ArrayRefs require allocation in the 36 // constructor. 37 ArrayRefParameter< 38 "int", // The parameter C++ type. 39 "An example of an array of ints" // Parameter description. 40 >: $arrayOfInts 41 ); 42} 43 44// An attribute testing AttributeSelfTypeParameter. 45def AttrWithSelfTypeParam : Test_Attr<"AttrWithSelfTypeParam"> { 46 let mnemonic = "attr_with_self_type_param"; 47 let parameters = (ins AttributeSelfTypeParameter<"">:$type); 48} 49 50// An attribute testing AttributeSelfTypeParameter. 51def AttrWithTypeBuilder : Test_Attr<"AttrWithTypeBuilder"> { 52 let mnemonic = "attr_with_type_builder"; 53 let parameters = (ins "::mlir::IntegerAttr":$attr); 54 let typeBuilder = "$_attr.getType()"; 55} 56 57#endif // TEST_ATTRDEFS 58