1//===-- DialectBase.td - Base Dialect definition file ------*- 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 contains the base set of constructs for defining Dialect classes.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef DIALECTBASE_TD
14#define DIALECTBASE_TD
15
16//===----------------------------------------------------------------------===//
17// Dialect definitions
18//===----------------------------------------------------------------------===//
19
20// "Enum" values for emitAccessorPrefix of Dialect.
21defvar kEmitAccessorPrefix_Raw = 0;      // Don't emit any getter/setter prefix.
22defvar kEmitAccessorPrefix_Prefixed = 1; // Only emit with getter/setter prefix.
23defvar kEmitAccessorPrefix_Both = 2;     // Emit without and with prefix.
24
25class Dialect {
26  // The name of the dialect.
27  string name = ?;
28
29  // Short summary of the dialect.
30  string summary = ?;
31
32  // The description of the dialect.
33  string description = ?;
34
35  // A list of dialects this dialect will load on construction as dependencies.
36  // These are dialects that this dialect may involve in canonicalization
37  // pattern or interfaces.
38  list<string> dependentDialects = [];
39
40  // The C++ namespace that ops of this dialect should be placed into.
41  //
42  // By default, uses the name of the dialect as the only namespace. To avoid
43  // placing in any namespace, use "". To specify nested namespaces, use "::"
44  // as the delimiter, e.g., given "A::B", ops will be placed in
45  // `namespace A { namespace B { <ops> } }`.
46  //
47  // Note that this works in conjunction with dialect C++ code. Depending on how
48  // the generated files are included into the dialect, you may want to specify
49  // a full namespace path or a partial one.
50  string cppNamespace = name;
51
52  // An optional code block containing extra declarations to place in the
53  // dialect declaration.
54  code extraClassDeclaration = "";
55
56  // If this dialect overrides the hook for materializing constants.
57  bit hasConstantMaterializer = 0;
58
59  /// If the dialect definition provides a non-default destructor.
60  /// If false, a default destructor implementation will be generated.
61  bit hasNonDefaultDestructor = 0;
62
63  // If this dialect overrides the hook for verifying operation attributes.
64  bit hasOperationAttrVerify = 0;
65
66  // If this dialect overrides the hook for verifying region argument
67  // attributes.
68  bit hasRegionArgAttrVerify = 0;
69
70  // If this dialect overrides the hook for verifying region result attributes.
71  bit hasRegionResultAttrVerify = 0;
72
73  // If this dialect overrides the hook for op interface fallback.
74  bit hasOperationInterfaceFallback = 0;
75
76  // If this dialect should use default generated attribute parser boilerplate.
77  // When set, ODS will generate declarations for the attribute parsing and
78  // printing hooks in the dialect and default implementations that dispatch to
79  // each individual attribute directly.
80  bit useDefaultAttributePrinterParser = 0;
81
82  // If this dialect should use default generated type parser boilerplate:
83  // When set, ODS will generate declarations for the type parsing and printing
84  // hooks in the dialect and default implementations that dispatch to each
85  // individual type directly.
86  bit useDefaultTypePrinterParser = 0;
87
88  // If this dialect overrides the hook for canonicalization patterns.
89  bit hasCanonicalizer = 0;
90
91  // Whether to emit raw/with no prefix or format changes, or emit with
92  // accessor with prefix only and UpperCamel suffix or to emit accessors with
93  // both.
94  //
95  // If emitting with prefix is specified then the attribute/operand's
96  // name is converted to UpperCamel from snake_case (which would result in
97  // leaving UpperCamel unchanged while also converting lowerCamel to
98  // UpperCamel) and prefixed with `get` or `set` depending on if it is a getter
99  // or setter.
100  int emitAccessorPrefix = kEmitAccessorPrefix_Raw;
101
102  // If this dialect can be extended at runtime with new operations or types.
103  bit isExtensible = 0;
104}
105
106#endif // DIALECTBASE_TD
107