diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index a0ae93ce75a2..869eb54ec9e8 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -10,8 +10,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_CIR_DIALECT_CIR_ATTRS -#define MLIR_CIR_DIALECT_CIR_ATTRS +#ifndef CLANG_CIR_DIALECT_IR_CIRATTRS_TD +#define CLANG_CIR_DIALECT_IR_CIRATTRS_TD include "mlir/IR/BuiltinAttributeInterfaces.td" include "clang/CIR/Dialect/IR/CIREnumAttr.td" @@ -45,7 +45,7 @@ class CIR_TypedAttr traits = []> let assemblyFormat = [{}]; } -class CIRUnitAttr traits = []> +class CIR_UnitAttr traits = []> : CIR_Attr { let returnType = "bool"; let defaultValue = "false"; @@ -68,7 +68,6 @@ def CIR_SourceLanguage : CIR_I32EnumAttr<"SourceLanguage", "source language", [ } def CIR_SourceLanguageAttr : CIR_EnumAttr { - let summary = "Module source language"; let description = [{ Represents the source language used to generate the module. @@ -252,7 +251,7 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> { // ZeroAttr //===----------------------------------------------------------------------===// -def ZeroAttr : CIR_TypedAttr<"Zero", "zero"> { +def CIR_ZeroAttr : CIR_TypedAttr<"Zero", "zero"> { let summary = "Attribute to represent zero initialization"; let description = [{ The ZeroAttr is used to indicate zero initialization on structs. @@ -263,7 +262,7 @@ def ZeroAttr : CIR_TypedAttr<"Zero", "zero"> { // UndefAttr //===----------------------------------------------------------------------===// -def UndefAttr : CIR_TypedAttr<"Undef", "undef"> { +def CIR_UndefAttr : CIR_TypedAttr<"Undef", "undef"> { let summary = "Represent an undef constant"; let description = [{ The UndefAttr represents an undef constant, corresponding to LLVM's notion @@ -275,7 +274,7 @@ def UndefAttr : CIR_TypedAttr<"Undef", "undef"> { // PoisonAttr //===----------------------------------------------------------------------===// -def PoisonAttr : CIR_TypedAttr<"Poison", "poison"> { +def CIR_PoisonAttr : CIR_TypedAttr<"Poison", "poison"> { let summary = "Represent a typed poison constant"; let description = [{ The PoisonAttr represents a typed poison constant, corresponding to LLVM's @@ -287,7 +286,9 @@ def PoisonAttr : CIR_TypedAttr<"Poison", "poison"> { // ConstArrayAttr //===----------------------------------------------------------------------===// -def ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", [TypedAttrInterface]> { +def CIR_ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", [ + TypedAttrInterface +]> { let summary = "A constant array from ArrayAttr or StringRefAttr"; let description = [{ An CIR array attribute is an array of literals of the specified attr types. @@ -333,8 +334,9 @@ def ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", [TypedAttrInterface]> // ConstVectorAttr //===----------------------------------------------------------------------===// -def ConstVectorAttr : CIR_Attr<"ConstVector", "const_vector", - [TypedAttrInterface]> { +def CIR_ConstVectorAttr : CIR_Attr<"ConstVector", "const_vector", [ + TypedAttrInterface +]> { let summary = "A constant vector from ArrayAttr"; let description = [{ A CIR vector attribute is an array of literals of the specified attribute @@ -364,8 +366,9 @@ def ConstVectorAttr : CIR_Attr<"ConstVector", "const_vector", // ConstRecordAttr //===----------------------------------------------------------------------===// -def ConstRecordAttr : CIR_Attr<"ConstRecord", "const_record", - [TypedAttrInterface]> { +def CIR_ConstRecordAttr : CIR_Attr<"ConstRecord", "const_record", [ + TypedAttrInterface +]> { let summary = "Represents a constant record"; let description = [{ Effectively supports "struct-like" constants. It's must be built from @@ -506,7 +509,7 @@ def CIR_FPAttr : CIR_Attr<"FP", "fp", [TypedAttrInterface]> { // ComplexAttr //===----------------------------------------------------------------------===// -def ComplexAttr : CIR_Attr<"Complex", "complex", [TypedAttrInterface]> { +def CIR_ComplexAttr : CIR_Attr<"Complex", "complex", [TypedAttrInterface]> { let summary = "An attribute that contains a constant complex value"; let description = [{ The `#cir.complex` attribute contains a constant value of complex number @@ -540,7 +543,7 @@ def ComplexAttr : CIR_Attr<"Complex", "complex", [TypedAttrInterface]> { // ConstPointerAttr //===----------------------------------------------------------------------===// -def ConstPtrAttr : CIR_Attr<"ConstPtr", "ptr", [TypedAttrInterface]> { +def CIR_ConstPtrAttr : CIR_Attr<"ConstPtr", "ptr", [TypedAttrInterface]> { let summary = "Holds a constant pointer value"; let parameters = (ins AttributeSelfTypeParameter<"", "::cir::PointerType">:$type, @@ -575,7 +578,7 @@ def CIR_CmpOrdering : CIR_I32EnumAttr< let genSpecializedAttr = 0; } -def CmpThreeWayInfoAttr : CIR_Attr<"CmpThreeWayInfo", "cmp3way_info"> { +def CIR_CmpThreeWayInfoAttr : CIR_Attr<"CmpThreeWayInfo", "cmp3way_info"> { let summary = "Holds information about a three-way comparison operation"; let description = [{ The `#cmp3way_info` attribute contains information about a three-way @@ -629,8 +632,9 @@ def CmpThreeWayInfoAttr : CIR_Attr<"CmpThreeWayInfo", "cmp3way_info"> { // DataMemberAttr //===----------------------------------------------------------------------===// -def DataMemberAttr : CIR_Attr<"DataMember", "data_member", - [TypedAttrInterface]> { +def CIR_DataMemberAttr : CIR_Attr<"DataMember", "data_member", [ + TypedAttrInterface +]> { let summary = "Holds a constant data member pointer value"; let parameters = (ins AttributeSelfTypeParameter< "", "cir::DataMemberType">:$type, @@ -679,7 +683,7 @@ def DataMemberAttr : CIR_Attr<"DataMember", "data_member", // MethodAttr //===----------------------------------------------------------------------===// -def MethodAttr : CIR_Attr<"Method", "method", [TypedAttrInterface]> { +def CIR_MethodAttr : CIR_Attr<"Method", "method", [TypedAttrInterface]> { let summary = "Holds a constant pointer-to-member-function value"; let description = [{ A method attribute is a literal attribute that represents a constant @@ -737,7 +741,9 @@ def MethodAttr : CIR_Attr<"Method", "method", [TypedAttrInterface]> { // GlobalViewAttr //===----------------------------------------------------------------------===// -def GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [TypedAttrInterface]> { +def CIR_GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [ + TypedAttrInterface +]> { let summary = "Provides constant access to a global address"; let description = [{ Get constant address of global `symbol` and optionally apply offsets to @@ -820,7 +826,7 @@ def GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [TypedAttrInterface]> // TypeInfoAttr //===----------------------------------------------------------------------===// -def TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> { +def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> { let summary = "Represents a typeinfo used for RTTI"; let description = [{ The typeinfo data for a given class is stored into an ArrayAttr. The @@ -905,8 +911,7 @@ def VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> { // DynamicCastInfoAttr //===----------------------------------------------------------------------===// -def DynamicCastInfoAttr - : CIR_Attr<"DynamicCastInfo", "dyn_cast_info"> { +def CIR_DynamicCastInfoAttr : CIR_Attr<"DynamicCastInfo", "dyn_cast_info"> { let summary = "ABI specific information about a dynamic cast"; let description = [{ Provide ABI specific information about a dynamic cast operation. @@ -922,11 +927,13 @@ def DynamicCastInfoAttr `__dynamic_cast` runtime function. }]; - let parameters = (ins GlobalViewAttr:$srcRtti, - GlobalViewAttr:$destRtti, - "mlir::FlatSymbolRefAttr":$runtimeFunc, - "mlir::FlatSymbolRefAttr":$badCastFunc, - CIR_IntAttr:$offsetHint); + let parameters = (ins + CIR_GlobalViewAttr:$srcRtti, + CIR_GlobalViewAttr:$destRtti, + "mlir::FlatSymbolRefAttr":$runtimeFunc, + "mlir::FlatSymbolRefAttr":$badCastFunc, + CIR_IntAttr:$offsetHint + ); let builders = [ AttrBuilderWithInferredContext<(ins "GlobalViewAttr":$srcRtti, @@ -1000,8 +1007,8 @@ def CIR_AddressSpaceAttr : CIR_EnumAttr { // AST Wrappers //===----------------------------------------------------------------------===// -class AST traits = []> - : CIR_Attr { +class CIR_AST traits = []> + : CIR_Attr { string clang_name = !strconcat("const clang::", name, " *"); let summary = !strconcat("Wraps a '", clang_name, "' AST node."); @@ -1040,40 +1047,54 @@ class AST traits = []> }]; } -def ASTDeclAttr : AST<"Decl", "decl", [ASTDeclInterface]>; +def CIR_ASTDeclAttr : CIR_AST<"Decl", "decl", [ASTDeclInterface]>; -def ASTFunctionDeclAttr : AST<"FunctionDecl", "function.decl", - [ASTFunctionDeclInterface]>; +def CIR_ASTFunctionDeclAttr : CIR_AST<"FunctionDecl", "function.decl",[ + ASTFunctionDeclInterface +]>; -def ASTCXXMethodDeclAttr : AST<"CXXMethodDecl", "cxxmethod.decl", - [ASTCXXMethodDeclInterface]>; +def CIR_ASTCXXMethodDeclAttr : CIR_AST<"CXXMethodDecl", "cxxmethod.decl", [ + ASTCXXMethodDeclInterface +]>; -def ASTCXXConstructorDeclAttr : AST<"CXXConstructorDecl", - "cxxconstructor.decl", [ASTCXXConstructorDeclInterface]>; +def CIR_ASTCXXConstructorDeclAttr + : CIR_AST<"CXXConstructorDecl","cxxconstructor.decl", [ + ASTCXXConstructorDeclInterface + ]>; -def ASTCXXConversionDeclAttr : AST<"CXXConversionDecl", - "cxxconversion.decl", [ASTCXXConversionDeclInterface]>; +def CIR_ASTCXXConversionDeclAttr + : CIR_AST<"CXXConversionDecl", "cxxconversion.decl", [ + ASTCXXConversionDeclInterface + ]>; -def ASTCXXDestructorDeclAttr : AST<"CXXDestructorDecl", - "cxxdestructor.decl", [ASTCXXDestructorDeclInterface]>; +def CIR_ASTCXXDestructorDeclAttr + : CIR_AST<"CXXDestructorDecl", "cxxdestructor.decl", [ + ASTCXXDestructorDeclInterface + ]>; -def ASTVarDeclAttr : AST<"VarDecl", "var.decl", - [ASTVarDeclInterface]>; +def CIR_ASTVarDeclAttr : CIR_AST<"VarDecl", "var.decl", [ + ASTVarDeclInterface +]>; -def ASTTypeDeclAttr: AST<"TypeDecl", "type.decl", - [ASTTypeDeclInterface]>; +def CIR_ASTTypeDeclAttr : CIR_AST<"TypeDecl", "type.decl", [ + ASTTypeDeclInterface +]>; -def ASTTagDeclAttr : AST<"TagDecl", "tag.decl", - [ASTTagDeclInterface]>; +def CIR_ASTTagDeclAttr : CIR_AST<"TagDecl", "tag.decl", [ + ASTTagDeclInterface +]>; -def ASTRecordDeclAttr : AST<"RecordDecl", "record.decl", - [ASTRecordDeclInterface]>; +def CIR_ASTRecordDeclAttr : CIR_AST<"RecordDecl", "record.decl", [ + ASTRecordDeclInterface +]>; -def ASTExprAttr : AST<"Expr", "expr", - [ASTExprInterface]>; +def CIR_ASTExprAttr : CIR_AST<"Expr", "expr", [ + ASTExprInterface +]>; -def ASTCallExprAttr : AST<"CallExpr", "call.expr", - [ASTCallExprInterface]>; +def CIR_ASTCallExprAttr : CIR_AST<"CallExpr", "call.expr", [ + ASTCallExprInterface +]>; //===----------------------------------------------------------------------===// @@ -1119,7 +1140,7 @@ def CIR_VisibilityAttr : CIR_EnumAttr { // ExtraFuncAttr //===----------------------------------------------------------------------===// -def ExtraFuncAttr : CIR_Attr<"ExtraFuncAttributes", "extra"> { +def CIR_ExtraFuncAttr : CIR_Attr<"ExtraFuncAttributes", "extra"> { let summary = "Represents aggregated attributes for a function"; let description = [{ This is a wrapper of attribute dictionary that contains extra attributes of @@ -1135,8 +1156,6 @@ def ExtraFuncAttr : CIR_Attr<"ExtraFuncAttributes", "extra"> { ]; let assemblyFormat = [{ `(` $elements `)` }]; - - // Printing and parsing also available in CIRDialect.cpp } //===----------------------------------------------------------------------===// @@ -1170,15 +1189,15 @@ def CIR_InlineAttr : CIR_EnumAttr { // Unit Function Attributes //===----------------------------------------------------------------------===// -def OptNoneAttr : CIRUnitAttr<"OptNone", "optnone"> { +def CIR_OptNoneAttr : CIR_UnitAttr<"OptNone", "optnone"> { let storageType = [{ OptNoneAttr }]; } -def NoThrowAttr : CIRUnitAttr<"NoThrow", "nothrow"> { +def CIR_NoThrowAttr : CIR_UnitAttr<"NoThrow", "nothrow"> { let storageType = [{ NoThrowAttr }]; } -def ConvergentAttr : CIRUnitAttr<"Convergent", "convergent"> { +def CIR_ConvergentAttr : CIR_UnitAttr<"Convergent", "convergent"> { let storageType = [{ ConvergentAttr }]; } @@ -1236,7 +1255,7 @@ class CIR_GlobalCtorDtor }]; } -def GlobalCtorAttr : CIR_GlobalCtorDtor<"Ctor", "ctor"> { +def CIR_GlobalCtorAttr : CIR_GlobalCtorDtor<"Ctor", "ctor"> { let summary = "Marks a function as a global constructor"; let description = [{ Marks the function as a global constructor in the module's constructor list. @@ -1244,7 +1263,7 @@ def GlobalCtorAttr : CIR_GlobalCtorDtor<"Ctor", "ctor"> { }]; } -def GlobalDtorAttr : CIR_GlobalCtorDtor<"Dtor", "dtor"> { +def CIR_GlobalDtorAttr : CIR_GlobalCtorDtor<"Dtor", "dtor"> { let summary = "Marks a function as a global destructor"; let description = [{ Marks a function as a global destructor in the module dtors list. @@ -1252,7 +1271,7 @@ def GlobalDtorAttr : CIR_GlobalCtorDtor<"Dtor", "dtor"> { }]; } -def BitfieldInfoAttr : CIR_Attr<"BitfieldInfo", "bitfield_info"> { +def CIR_BitfieldInfoAttr : CIR_Attr<"BitfieldInfo", "bitfield_info"> { let summary = "Represents a bit field info"; let description = [{ Holds the next information about bitfields: name, storage type, a bitfield size @@ -1282,7 +1301,7 @@ def BitfieldInfoAttr : CIR_Attr<"BitfieldInfo", "bitfield_info"> { // AnnotationAttr //===----------------------------------------------------------------------===// -def AnnotationAttr : CIR_Attr<"Annotation", "annotation"> { +def CIR_AnnotationAttr : CIR_Attr<"Annotation", "annotation"> { let summary = "Annotation attribute for global variables and functions"; let description = [{ Represent C/C++ attribute of annotate in CIR. @@ -1321,8 +1340,9 @@ def AnnotationAttr : CIR_Attr<"Annotation", "annotation"> { // GlobalAnnotationValuesAttr //===----------------------------------------------------------------------===// -def GlobalAnnotationValuesAttr : CIR_Attr<"GlobalAnnotationValues", - "global_annotations"> { +def CIR_GlobalAnnotationValuesAttr : CIR_Attr<"GlobalAnnotationValues", + "global_annotations" +> { let summary = "Array of annotations, each element consists of name of" "a global var or func and one of its annotations"; let description = [{ @@ -1366,7 +1386,7 @@ def GlobalAnnotationValuesAttr : CIR_Attr<"GlobalAnnotationValues", // AddressPointAttr //===----------------------------------------------------------------------===// -def AddressPointAttr : CIR_Attr<"AddressPoint", "address_point"> { +def CIR_AddressPointAttr : CIR_Attr<"AddressPoint", "address_point"> { let summary = "Address point attribute"; let description = [{ @@ -1397,4 +1417,4 @@ include "clang/CIR/Dialect/IR/CIRTBAAAttrs.td" include "clang/CIR/Dialect/IR/CIROpenCLAttrs.td" include "clang/CIR/Dialect/IR/CIRCUDAAttrs.td" -#endif // MLIR_CIR_DIALECT_CIR_ATTRS +#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIRCUDAAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRCUDAAttrs.td index 34d563ed898f..504eb35c8357 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRCUDAAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRCUDAAttrs.td @@ -10,15 +10,14 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_CIR_DIALECT_CIR_CUDA_ATTRS -#define MLIR_CIR_DIALECT_CIR_CUDA_ATTRS +#ifndef CLANG_CIR_DIALECT_IR_CIRCUDAATTRS_TD +#define CLANG_CIR_DIALECT_IR_CIRCUDAATTRS_TD //===----------------------------------------------------------------------===// // CUDAKernelNameAttr //===----------------------------------------------------------------------===// -def CUDAKernelNameAttr : CIR_Attr<"CUDAKernelName", - "cu.kernel_name"> { +def CIR_CUDAKernelNameAttr : CIR_Attr<"CUDAKernelName", "cu.kernel_name"> { let summary = "Device-side function name for this stub."; let description = [{ @@ -35,15 +34,14 @@ def CUDAKernelNameAttr : CIR_Attr<"CUDAKernelName", let assemblyFormat = "`<` $kernel_name `>`"; } -def CUDAShadowNameAttr : CIR_Attr<"CUDAShadowName", - "cu.shadow_name"> { +def CIR_CUDAShadowNameAttr : CIR_Attr<"CUDAShadowName", "cu.shadow_name"> { let summary = "Device-side global variable name for this shadow."; let description = [{ This attribute is attached to global variable definitions and records the mangled name of the global variable used on the device. - In CUDA, __device__, __constant__ and __shared__ variables, as well as + In CUDA, __device__, __constant__ and __shared__ variables, as well as surface and texture variables, will generate a shadow symbol on host. We must preserve the correspodence in order to generate registration functions. @@ -53,8 +51,9 @@ def CUDAShadowNameAttr : CIR_Attr<"CUDAShadowName", let assemblyFormat = "`<` $device_side_name `>`"; } -def CUDABinaryHandleAttr : CIR_Attr<"CUDABinaryHandle", - "cu.binary_handle"> { +def CIR_CUDABinaryHandleAttr : CIR_Attr< + "CUDABinaryHandle", "cu.binary_handle" +> { let summary = "Fat binary handle for device code."; let description = [{ @@ -70,8 +69,9 @@ def CUDABinaryHandleAttr : CIR_Attr<"CUDABinaryHandle", let assemblyFormat = "`<` $name `>`"; } -def CUDAExternallyInitializedAttr : CIR_Attr<"CUDAExternallyInitialized", - "cu.externally_initialized"> { +def CIR_CUDAExternallyInitializedAttr : CIR_Attr< + "CUDAExternallyInitialized", "cu.externally_initialized" +> { let summary = "The marked variable is externally initialized."; let description = [{ @@ -83,4 +83,4 @@ def CUDAExternallyInitializedAttr : CIR_Attr<"CUDAExternallyInitialized", }]; } -#endif // MLIR_CIR_DIALECT_CIR_CUDA_ATTRS +#endif // CLANG_CIR_DIALECT_IR_CIRCUDAATTRS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td index 8d3970f4394b..41ed85a35c22 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROpenCLAttrs.td @@ -10,16 +10,16 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_CIR_DIALECT_CIR_OPENCL_ATTRS -#define MLIR_CIR_DIALECT_CIR_OPENCL_ATTRS +#ifndef CLANG_CIR_DIALECT_IR_CIROPENCLATTRS_TD +#define CLANG_CIR_DIALECT_IR_CIROPENCLATTRS_TD //===----------------------------------------------------------------------===// // OpenCLKernelMetadataAttr //===----------------------------------------------------------------------===// -def OpenCLKernelMetadataAttr - : CIR_Attr<"OpenCLKernelMetadata", "cl.kernel_metadata"> { - +def CIR_OpenCLKernelMetadataAttr : CIR_Attr< + "OpenCLKernelMetadata", "cl.kernel_metadata" +> { let summary = "OpenCL kernel metadata"; let description = [{ Provide the required information of an OpenCL kernel for the SPIR-V backend. @@ -78,7 +78,7 @@ def OpenCLKernelMetadataAttr // Only types in CIR carry signedness if (!mlir::isa(hintQTy.getDialect())) return std::nullopt; - + // See also clang::CodeGen::CodeGenFunction::EmitKernelMetadata auto hintEltQTy = mlir::dyn_cast(hintQTy); auto isCIRSignedIntType = [](mlir::Type t) { @@ -96,9 +96,9 @@ def OpenCLKernelMetadataAttr // OpenCLKernelArgMetadataAttr //===----------------------------------------------------------------------===// -def OpenCLKernelArgMetadataAttr - : CIR_Attr<"OpenCLKernelArgMetadata", "cl.kernel_arg_metadata"> { - +def CIR_OpenCLKernelArgMetadataAttr : CIR_Attr< + "OpenCLKernelArgMetadata", "cl.kernel_arg_metadata" +> { let summary = "OpenCL kernel argument metadata"; let description = [{ Provide the required information of an OpenCL kernel argument for the SPIR-V @@ -175,22 +175,20 @@ def OpenCLVersionAttr : CIR_Attr<"OpenCLVersion", "cl.version"> { // TODO: It might be worthwhile to introduce a generic attribute applicable to // all offloading languages. -def OpenCLKernelAttr : CIRUnitAttr< - "OpenCLKernel", "cl.kernel"> { +def CIR_OpenCLKernelAttr : CIR_UnitAttr<"OpenCLKernel", "cl.kernel"> { let summary = "OpenCL kernel"; let description = [{ Indicate the function is a OpenCL kernel. }]; - - let storageType = [{ OpenCLKernelAttr }]; } //===----------------------------------------------------------------------===// // OpenCLKernelUniformWorkGroupSizeAttr //===----------------------------------------------------------------------===// -def OpenCLKernelUniformWorkGroupSizeAttr : CIRUnitAttr< - "OpenCLKernelUniformWorkGroupSize", "cl.uniform_work_group_size"> { +def CIR_OpenCLKernelUniformWorkGroupSizeAttr : CIR_UnitAttr< + "OpenCLKernelUniformWorkGroupSize", "cl.uniform_work_group_size" +> { let summary = "OpenCL kernel work-group uniformity"; let description = [{ In OpenCL v2.0, work groups can either be uniform or non-uniform. @@ -206,4 +204,4 @@ def OpenCLKernelUniformWorkGroupSizeAttr : CIRUnitAttr< let storageType = [{ OpenCLKernelUniformWorkGroupSizeAttr }]; } -#endif // MLIR_CIR_DIALECT_CIR_OPENCL_ATTRS +#endif // CLANG_CIR_DIALECT_IR_CIROPENCLATTRS_TD diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td index a277366f75e6..c0401b254eff 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIROps.td +++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td @@ -293,7 +293,7 @@ def CIR_DynamicCastOp : CIR_Op<"dyn_cast"> { let arguments = (ins CIR_DynamicCastKind:$kind, CIR_PtrToRecordType:$src, - OptionalAttr:$info, + OptionalAttr:$info, UnitAttr:$relative_layout ); @@ -1911,9 +1911,13 @@ def CIR_CmpThreeWayOp : CIR_Op<"cmp3way", [Pure, SameTypeOperands]> { ``` }]; + let arguments = (ins + CIR_AnyType:$lhs, + CIR_AnyType:$rhs, + CIR_CmpThreeWayInfoAttr:$info + ); + let results = (outs CIR_AnySIntType:$result); - let arguments = (ins CIR_AnyType:$lhs, CIR_AnyType:$rhs, - CmpThreeWayInfoAttr:$info); let assemblyFormat = [{ `(` $lhs `:` type($lhs) `,` $rhs `,` qualified($info) `)` @@ -2606,9 +2610,12 @@ def CIR_VTableAddrPointOp : CIR_Op<"vtable.address_point",[ ``` }]; - let arguments = (ins OptionalAttr:$name, - Optional:$sym_addr, - AddressPointAttr:$address_point); + let arguments = (ins + OptionalAttr:$name, + Optional:$sym_addr, + CIR_AddressPointAttr:$address_point + ); + let results = (outs Res:$addr); let assemblyFormat = [{ @@ -2735,7 +2742,7 @@ def CIR_SetBitfieldOp : CIR_Op<"set_bitfield"> { let arguments = (ins Arg:$addr, CIR_AnyType:$src, - BitfieldInfoAttr:$bitfield_info, + CIR_BitfieldInfoAttr:$bitfield_info, UnitAttr:$is_volatile ); @@ -2813,9 +2820,9 @@ def CIR_GetBitfieldOp : CIR_Op<"get_bitfield"> { let arguments = (ins Arg:$addr, - BitfieldInfoAttr:$bitfield_info, + CIR_BitfieldInfoAttr:$bitfield_info, UnitAttr:$is_volatile - ); + ); let results = (outs CIR_IntType:$result); @@ -3715,7 +3722,7 @@ def FuncOp : CIR_Op<"func", [ DefaultValuedAttr< CIR_CallingConv, "CallingConv::C" >:$calling_conv, - ExtraFuncAttr:$extra_attrs, + CIR_ExtraFuncAttr:$extra_attrs, OptionalAttr:$sym_visibility, UnitAttr:$comdat, OptionalAttr:$arg_attrs, @@ -3989,7 +3996,7 @@ class CIR_CallOp extra_traits = []> Variadic:$arg_ops, DefaultValuedAttr:$calling_conv, DefaultValuedAttr:$side_effect, - ExtraFuncAttr:$extra_attrs, + CIR_ExtraFuncAttr:$extra_attrs, OptionalAttr:$ast ); } @@ -4278,12 +4285,12 @@ def CIR_AwaitOp : CIR_Op<"await",[ // Represents the unwind region where unwind continues or // the program std::terminate's. -def CIR_CatchUnwind : CIRUnitAttr<"CatchUnwind", "unwind"> { +def CIR_CatchUnwind : CIR_UnitAttr<"CatchUnwind", "unwind"> { let storageType = [{ CatchUnwind }]; } // Represents the catch_all region. -def CIR_CatchAll : CIRUnitAttr<"CatchAll", "all"> { +def CIR_CatchAll : CIR_UnitAttr<"CatchAll", "all"> { let storageType = [{ CatchAllAttr }]; } diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td index 4f6c0352a378..ac7806d2ac93 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTBAAAttrs.td @@ -10,6 +10,9 @@ // //===----------------------------------------------------------------------===// +#ifndef CLANG_CIR_DIALECT_IR_CIRTBAAATTRS_TD +#define CLANG_CIR_DIALECT_IR_CIRTBAAATTRS_TD + include "clang/CIR/Dialect/IR/CIRTypes.td" //===----------------------------------------------------------------------===// @@ -20,12 +23,16 @@ def CIR_TBAAAttr : CIR_Attr<"TBAA", "tbaa", []> { let summary = "CIR dialect TBAA base attribute"; } +class CIR_TBAAAttrCase + : CIR_Attr; + //===----------------------------------------------------------------------===// // TBAAOmnipotentCharAttr //===----------------------------------------------------------------------===// -def CIR_TBAAOmnipotentChar - : CIR_Attr<"TBAAOmnipotentChar", "tbaa_omnipotent_char", [], "TBAAAttr"> { +def CIR_TBAAOmnipotentCharAttr : CIR_TBAAAttrCase< + "TBAAOmnipotentChar", "tbaa_omnipotent_char" +> { let summary = "Describes a special scalar type, the omnipotent char type."; } @@ -33,8 +40,9 @@ def CIR_TBAAOmnipotentChar // TBAAVTablePointerAttr //===----------------------------------------------------------------------===// -def CIR_TBAAVTablePointerAttr - : CIR_Attr<"TBAAVTablePointer", "tbaa_vptr", [], "TBAAAttr"> { +def CIR_TBAAVTablePointerAttr : CIR_TBAAAttrCase< + "TBAAVTablePointer", "tbaa_vptr" +> { let summary = "Describes a special scalar type, the vtable pointer type."; let parameters = (ins CIR_AnyType:$type); let assemblyFormat = "`<` struct(params) `>`"; @@ -44,17 +52,17 @@ def CIR_TBAAVTablePointerAttr // TBAAScalarAttr //===----------------------------------------------------------------------===// -def CIR_TBAAScalarAttr : CIR_Attr<"TBAAScalar", "tbaa_scalar", [], "TBAAAttr"> { +def CIR_TBAAScalarAttr : CIR_TBAAAttrCase< "TBAAScalar", "tbaa_scalar"> { let summary = "Describes a scalar type in TBAA with an identifier."; - let parameters = (ins StringRefParameter<>:$id, - CIR_AnyType:$type, + let parameters = (ins StringRefParameter<>:$id, + CIR_AnyType:$type, OptionalParameter<"cir::TBAAScalarAttr">:$parent); let description = [{ Define a TBAA scalar attribute. - The optional `parent` attribute is used to describe the parent type of the - scalar type. If the `parent` is null or omitted, the parent type is the + The optional `parent` attribute is used to describe the parent type of the + scalar type. If the `parent` is null or omitted, the parent type is the `omnipotent char` type. Example: @@ -64,16 +72,16 @@ def CIR_TBAAScalarAttr : CIR_Attr<"TBAAScalar", "tbaa_scalar", [], "TBAAAttr"> { #tbaa_scalar1 = #cir.tbaa_scalar #tbaa_scalar2 = #cir.tbaa_scalar> - #tbaa_scalar3 = #cir.tbaa_scalar, + #tbaa_scalar3 = #cir.tbaa_scalar, parent = #tbaa_scalar2> ``` - + See the following link for more details: https://llvm.org/docs/LangRef.html#tbaa-metadata }]; let builders = [ - AttrBuilder<(ins "llvm::StringRef":$id, + AttrBuilder<(ins "llvm::StringRef":$id, "mlir::Type":$type), [{ return $_get($_ctxt, id, type, /*parent =*/ nullptr); }]> @@ -82,7 +90,7 @@ def CIR_TBAAScalarAttr : CIR_Attr<"TBAAScalar", "tbaa_scalar", [], "TBAAAttr"> { let assemblyFormat = "`<` struct(params) `>`"; } -def CIR_TBAATagAttr : CIR_Attr<"TBAATag", "tbaa_tag", [], "TBAAAttr"> { +def CIR_TBAATagAttr : CIR_TBAAAttrCase<"TBAATag", "tbaa_tag"> { let parameters = (ins CIR_TBAAAttr : $base, CIR_TBAAAttr : $access, "int64_t" @@ -91,7 +99,7 @@ def CIR_TBAATagAttr : CIR_Attr<"TBAATag", "tbaa_tag", [], "TBAAAttr"> { let assemblyFormat = "`<` struct(params) `>`"; } -def CIR_TBAAMemberAttr : CIR_Attr<"TBAAMember", "tbaa_member", []> { +def CIR_TBAAMemberAttr : CIR_Attr<"TBAAMember", "tbaa_member"> { let summary = "Attribute representing a member of a TBAA structured type."; let parameters = (ins "TBAAAttr":$type_desc, "int64_t":$offset); @@ -137,8 +145,7 @@ def CIR_TBAAMemberAttrArray : ArrayRefParameter<"TBAAMemberAttr"> { }]; } -def CIR_TBAAStructAttr : CIR_Attr<"TBAAStruct", - "tbaa_struct", [], "TBAAAttr"> { +def CIR_TBAAStructAttr : CIR_TBAAAttrCase<"TBAAStruct", "tbaa_struct"> { let summary = "Describes a struct type in TBAA"; let parameters = (ins StringRefParameter<> : $id, @@ -164,10 +171,12 @@ def CIR_TBAAStructAttr : CIR_Attr<"TBAAStruct", } def CIR_AnyTBAAAttr : AnyAttrOf<[ - CIR_TBAAAttr, - CIR_TBAAOmnipotentChar, + CIR_TBAAAttr, + CIR_TBAAOmnipotentCharAttr, CIR_TBAAVTablePointerAttr, CIR_TBAAScalarAttr, CIR_TBAAStructAttr, CIR_TBAATagAttr ]>; + +#endif // CLANG_CIR_DIALECT_IR_CIRTBAAATTRS_TD diff --git a/clang/test/CIR/IR/invalid-annotations.cir b/clang/test/CIR/IR/invalid-annotations.cir index d7c76b221c52..0c3b56f75839 100644 --- a/clang/test/CIR/IR/invalid-annotations.cir +++ b/clang/test/CIR/IR/invalid-annotations.cir @@ -3,7 +3,7 @@ // expected-error @below {{invalid kind of attribute specified}} -// expected-error @below {{failed to parse AnnotationAttr parameter 'name' which is to be a `mlir::StringAttr`}} +// expected-error @below {{failed to parse CIR_AnnotationAttr parameter 'name' which is to be a `mlir::StringAttr`}} cir.global external @a = #cir.ptr : !cir.ptr [#cir.annotation] // -----