Author: Henrich Lauko Date: 2025-07-15T16:18:57+02:00 New Revision: 9f7937401b62d95f2ebe86072d6f277eb9745cd0
URL: https://github.com/llvm/llvm-project/commit/9f7937401b62d95f2ebe86072d6f277eb9745cd0 DIFF: https://github.com/llvm/llvm-project/commit/9f7937401b62d95f2ebe86072d6f277eb9745cd0.diff LOG: [CIR] Separate CIR EnumAttr definitions to be includable without the rest of attributes (#148850) 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 https://github.com/llvm/clangir/pull/1733 Added: clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td Modified: clang/include/clang/CIR/Dialect/IR/CIRAttrs.td Removed: ################################################################################ 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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits