1 //===-- enums.td - EnumsGen test definition file -----------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 include "mlir/IR/EnumAttr.td"
10 include "mlir/IR/OpBase.td"
12 def CaseA: I32EnumAttrCase<"CaseA", 0>;
13 def CaseB: I32EnumAttrCase<"CaseB", 1>;
15 def FooEnum: I32EnumAttr<"FooEnum", "A test enum", [CaseA, CaseB]> {
16 let cppNamespace = "Outer::Inner";
17 let stringToSymbolFnName = "ConvertToEnum";
18 let symbolToStringFnName = "ConvertToString";
19 let genSpecializedAttr = 1;
22 def Case5: I32EnumAttrCase<"Case5", 5>;
23 def Case10: I32EnumAttrCase<"Case10", 10>;
25 def I32Enum: I32EnumAttr<"I32Enum", "A test enum", [Case5, Case10]>;
27 def NoBits : I32BitEnumAttrCaseNone<"None">;
28 def Bit0 : I32BitEnumAttrCaseBit<"Bit0", 0>;
29 def Bit1 : I32BitEnumAttrCaseBit<"Bit1", 1>;
30 def Bit2 : I32BitEnumAttrCaseBit<"Bit2", 2>;
31 def Bit3 : I32BitEnumAttrCaseBit<"Bit3", 3>;
32 def Bit4 : I32BitEnumAttrCaseBit<"Bit4", 4>;
33 def Bit5 : I32BitEnumAttrCaseBit<"Bit5", 5>;
35 def BitEnumWithNone : I32BitEnumAttr<"BitEnumWithNone", "A test enum",
36 [NoBits, Bit0, Bit3]> {
37 let separator = " | ";
40 def BitEnumWithoutNone : I32BitEnumAttr<"BitEnumWithoutNone", "A test enum",
43 def Bits0To3 : I32BitEnumAttrCaseGroup<"Bits0To3",
44 [Bit0, Bit1, Bit2, Bit3]>;
45 def Bits4And5 : I32BitEnumAttrCaseGroup<"Bits4And5",
47 def Bits0To5 : I32BitEnumAttrCaseGroup<"Bits0To5",
48 [Bits0To3, Bits4And5]>;
50 def BitEnumWithGroup : I32BitEnumAttr<"BitEnumWithGroup", "A test enum",
51 [Bit0, Bit1, Bit2, Bit3, Bit4, Bits0To3]> {
55 def BitEnumPrimaryGroup : I32BitEnumAttr<"BitEnumPrimaryGroup", "test enum",
56 [Bit0, Bit1, Bit2, Bit3, Bit4, Bit5,
57 Bits0To3, Bits4And5, Bits0To5]> {
59 let printBitEnumPrimaryGroups = 1;
62 def BitEnum64_None : I64BitEnumAttrCaseNone<"None">;
63 def BitEnum64_57 : I64BitEnumAttrCaseBit<"Bit57", 57>;
64 def BitEnum64_1 : I64BitEnumAttrCaseBit<"Bit1", 1>;
65 def BitEnum64_Test : I64BitEnumAttr<"BitEnum64_Test", "A 64-bit test enum",
66 [BitEnum64_None, BitEnum64_1, BitEnum64_57]>;
68 def PrettyIntEnumCase1: I32EnumAttrCase<"Case1", 1, "case_one">;
69 def PrettyIntEnumCase2: I32EnumAttrCase<"Case2", 2, "case_two">;
71 def PrettyIntEnum: I32EnumAttr<"PrettyIntEnum", "A test enum",
72 [PrettyIntEnumCase1, PrettyIntEnumCase2]>;