-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[CIR] Separate CIR EnumAttr definitions to be includable without the rest of attributes #148850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Henrich Lauko (xlauko) ChangesThis mirrors incubator change from llvm/clangir#1733 Full diff: https://github.com/llvm/llvm-project/pull/148850.diff 2 Files Affected:
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index e85a6ec1950ec..29d8aea8d08e7 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -14,10 +14,10 @@
#define CLANG_CIR_DIALECT_IR_CIRATTRS_TD
include "mlir/IR/BuiltinAttributeInterfaces.td"
-include "mlir/IR/EnumAttr.td"
-include "clang/CIR/Dialect/IR/CIRDialect.td"
include "clang/CIR/Dialect/IR/CIRAttrConstraints.td"
+include "clang/CIR/Dialect/IR/CIRDialect.td"
+include "clang/CIR/Dialect/IR/CIREnumAttr.td"
//===----------------------------------------------------------------------===//
// CIR Attrs
@@ -42,21 +42,6 @@ class CIR_TypedAttr<string name, string attrMnemonic, list<Trait> traits = []>
let assemblyFormat = [{}];
}
-class CIR_I32EnumAttr<string name, string summary, list<I32EnumAttrCase> cases>
- : I32EnumAttr<name, summary, cases> {
- let cppNamespace = "::cir";
-}
-
-class CIR_I64EnumAttr<string name, string summary, list<I64EnumAttrCase> cases>
- : I64EnumAttr<name, summary, cases> {
- let cppNamespace = "::cir";
-}
-
-class CIR_EnumAttr<EnumAttrInfo info, string name = "", list<Trait> traits = []>
- : EnumAttr<CIR_Dialect, info, name, traits> {
- let assemblyFormat = "`<` $value `>`";
-}
-
class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
: CIR_Attr<name, attrMnemonic, traits> {
let returnType = "bool";
diff --git a/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td b/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td
new file mode 100644
index 0000000000000..98b8a31d2a18a
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the CIR dialect enum base classes
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef CLANG_CIR_DIALECT_IR_CIRENUMATTR_TD
+#define CLANG_CIR_DIALECT_IR_CIRENUMATTR_TD
+
+include "mlir/IR/EnumAttr.td"
+
+class CIR_I32EnumAttr<string name, string summary, list<I32EnumAttrCase> cases>
+ : I32EnumAttr<name, summary, cases> {
+ let cppNamespace = "::cir";
+}
+
+class CIR_I64EnumAttr<string name, string summary, list<I64EnumAttrCase> cases>
+ : I64EnumAttr<name, summary, cases> {
+ let cppNamespace = "::cir";
+}
+
+class CIR_EnumAttr<EnumAttrInfo info, string name = "", list<Trait> traits = []>
+ : EnumAttr<CIR_Dialect, info, name, traits> {
+ let assemblyFormat = "`<` $value `>`";
+}
+
+class CIR_DefaultValuedEnumParameter<EnumAttrInfo info, string value = "">
+ : EnumParameter<info> {
+ let defaultValue = value;
+}
+
+#endif // CLANG_CIR_DIALECT_IR_CIRENUMATTR_TD
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the commit message/topic of this to say WHY we are doing this? The patch seems fine to me, I just don't understand why we are doing it.
Is it clear now? |
961c62a
to
9dbdad1
Compare
…rest of attributes This mirrors incubator change from llvm/clangir#1733
b4f0b27
to
af05c66
Compare
This change allows enum definition classes to be included in type definitions without creating cyclic dependencies between CIRTypes.td and CIRAttrs.td, since attributes already include CIRTypes.td. In the pull request mentioned below, this is used to define the AddressSpace enum alongside PointerType.
Additionally, this introduces
DefaultValuedEnumParameter
.This mirrors some parts of incubator change from llvm/clangir#1733