1 //===-- TestEnumDefs.td - Test dialect enum definitions ----*- 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 // TableGen enum definitions for Test dialect.
11 //===----------------------------------------------------------------------===//
16 include "mlir/IR/EnumAttr.td"
18 def I32Case5: I32EnumAttrCase<"case5", 5>;
19 def I32Case10: I32EnumAttrCase<"case10", 10>;
21 def SomeI32Enum: I32EnumAttr<
22 "SomeI32Enum", "", [I32Case5, I32Case10]>;
24 def I64Case5: I64EnumAttrCase<"case5", 5>;
25 def I64Case10: I64EnumAttrCase<"case10", 10>;
27 def SomeI64Enum: I64EnumAttr<
28 "SomeI64Enum", "", [I64Case5, I64Case10]>;
30 //===----------------------------------------------------------------------===//
32 //===----------------------------------------------------------------------===//
34 // Define the C++ enum.
36 : I32EnumAttr<"TestEnum", "a test enum", [
37 I32EnumAttrCase<"First", 0, "first">,
38 I32EnumAttrCase<"Second", 1, "second">,
39 I32EnumAttrCase<"Third", 2, "third">,
41 let genSpecializedAttr = 0;
42 let cppNamespace = "test";
45 def TestSimpleEnum : I32EnumAttr<"SimpleEnum", "", [
46 I32EnumAttrCase<"a", 0>,
47 I32EnumAttrCase<"b", 1>
49 let genSpecializedAttr = 0;
50 let cppNamespace = "::test";
53 //===----------------------------------------------------------------------===//
55 //===----------------------------------------------------------------------===//
57 // Define the C++ enum.
59 : I32BitEnumAttr<"TestBitEnum", "a test bit enum", [
60 I32BitEnumAttrCaseBit<"Read", 0, "read">,
61 I32BitEnumAttrCaseBit<"Write", 1, "write">,
62 I32BitEnumAttrCaseBit<"Execute", 2, "execute">,
64 let genSpecializedAttr = 0;
65 let cppNamespace = "test";
69 // Define an enum with a different separator
70 def TestBitEnumVerticalBar
71 : I32BitEnumAttr<"TestBitEnumVerticalBar", "another test bit enum", [
72 I32BitEnumAttrCaseBit<"User", 0, "user">,
73 I32BitEnumAttrCaseBit<"Group", 1, "group">,
74 I32BitEnumAttrCaseBit<"Other", 2, "other">,
76 let genSpecializedAttr = 0;
77 let cppNamespace = "test";
78 let separator = " | ";
81 //===----------------------------------------------------------------------===//
82 // Test Patterns (Multi-result Ops)
84 def MultiResultOpKind1: I64EnumAttrCase<"kind1", 1>;
85 def MultiResultOpKind2: I64EnumAttrCase<"kind2", 2>;
86 def MultiResultOpKind3: I64EnumAttrCase<"kind3", 3>;
87 def MultiResultOpKind4: I64EnumAttrCase<"kind4", 4>;
88 def MultiResultOpKind5: I64EnumAttrCase<"kind5", 5>;
89 def MultiResultOpKind6: I64EnumAttrCase<"kind6", 6>;
91 def MultiResultOpEnum: I64EnumAttr<
92 "MultiResultOpEnum", "Multi-result op kinds", [
93 MultiResultOpKind1, MultiResultOpKind2, MultiResultOpKind3,
94 MultiResultOpKind4, MultiResultOpKind5, MultiResultOpKind6
97 #endif // TEST_ENUMDEFS