Skip to content

Commit

Permalink
[SYCL] Make Intel attributes consistent with clang attributes. (#3022)
Browse files Browse the repository at this point in the history
Clang allows attributes to be specified via a special pragma named
`#pragma clang attribute` and many of the Intel-specified attributes
were opting out of this support for no real reason.

This changes allows Intel attributes to be specified via this pragma,
similar to how almost all other Clang attributes are.
  • Loading branch information
AaronBallman authored Jan 14, 2021
1 parent 4dc3b35 commit aeb4de7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
15 changes: 0 additions & 15 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,6 @@ def SYCLDevice : InheritableAttr {
let Subjects = SubjectList<[Function]>;
let LangOpts = [SYCLIsDevice];
let Documentation = [SYCLDeviceDocs];
let PragmaAttributeSupport = 0;
}

def SYCLKernel : InheritableAttr {
Expand All @@ -1167,7 +1166,6 @@ def SYCLSimd : InheritableAttr {
let Subjects = SubjectList<[Function]>;
let LangOpts = [SYCLExplicitSIMD];
let Documentation = [SYCLSimdDocs];
let PragmaAttributeSupport = 0;
}

// Available in SYCL explicit SIMD extension. Binds a file scope private
Expand All @@ -1180,7 +1178,6 @@ def SYCLRegisterNum : InheritableAttr {
// for the host device as well
let LangOpts = [SYCLExplicitSIMD];
let Documentation = [SYCLRegisterNumDocs];
let PragmaAttributeSupport = 0;
}

// Used to mark ESIMD kernel pointer parameters originating from accessors.
Expand All @@ -1190,7 +1187,6 @@ def SYCLSimdAccessorPtr : InheritableAttr {
let Subjects = SubjectList<[ParmVar]>;
let LangOpts = [SYCLExplicitSIMD];
let Documentation = [SYCLSimdAccessorPtrDocs];
let PragmaAttributeSupport = 0;
}

def SYCLScope : Attr {
Expand Down Expand Up @@ -1219,7 +1215,6 @@ def SYCLDeviceIndirectlyCallable : InheritableAttr {
let Subjects = SubjectList<[Function]>;
let LangOpts = [SYCLIsDevice];
let Documentation = [SYCLDeviceIndirectlyCallableDocs];
let PragmaAttributeSupport = 0;
}

def SYCLIntelBufferLocation : InheritableAttr {
Expand All @@ -1244,7 +1239,6 @@ def SYCLIntelKernelArgsRestrict : InheritableAttr {
let LangOpts = [ SYCLIsDevice, SYCLIsHost ];
let Documentation = [ SYCLIntelKernelArgsRestrictDocs ];
let SimpleHandler = 1;
let PragmaAttributeSupport = 0;
}

def SYCLIntelNumSimdWorkItems : InheritableAttr {
Expand All @@ -1254,7 +1248,6 @@ def SYCLIntelNumSimdWorkItems : InheritableAttr {
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [SYCLIntelNumSimdWorkItemsAttrDocs];
let PragmaAttributeSupport = 0;
}

def SYCLIntelUseStallEnableClusters : InheritableAttr {
Expand All @@ -1267,7 +1260,6 @@ def SYCLIntelUseStallEnableClusters : InheritableAttr {
}
}];
let Documentation = [SYCLIntelUseStallEnableClustersAttrDocs];
let PragmaAttributeSupport = 0;
}

def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
Expand All @@ -1277,7 +1269,6 @@ def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [SYCLIntelSchedulerTargetFmaxMhzAttrDocs];
let PragmaAttributeSupport = 0;
let AdditionalMembers = [{
static unsigned getMinValue() {
return 0;
Expand All @@ -1286,7 +1277,6 @@ def SYCLIntelSchedulerTargetFmaxMhz : InheritableAttr {
return 1024*1024;
}
}];

}

def SYCLIntelMaxWorkGroupSize : InheritableAttr {
Expand All @@ -1297,7 +1287,6 @@ def SYCLIntelMaxWorkGroupSize : InheritableAttr {
ExprArgument<"ZDim">];
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Function], ErrorDiag>;
let PragmaAttributeSupport = 0;
let AdditionalMembers = [{
ArrayRef<const Expr *> dimensions() const {
return {getXDim(), getYDim(), getZDim()};
Expand All @@ -1322,7 +1311,6 @@ def SYCLIntelMaxGlobalWorkDim : InheritableAttr {
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [SYCLIntelMaxGlobalWorkDimAttrDocs];
let PragmaAttributeSupport = 0;
}

def SYCLIntelNoGlobalWorkOffset : InheritableAttr {
Expand All @@ -1332,7 +1320,6 @@ def SYCLIntelNoGlobalWorkOffset : InheritableAttr {
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [SYCLIntelNoGlobalWorkOffsetAttrDocs];
let PragmaAttributeSupport = 0;
}

def SYCLIntelLoopFuse : InheritableAttr {
Expand Down Expand Up @@ -1413,7 +1400,6 @@ def IntelReqdSubGroupSize: InheritableAttr {
let Subjects = SubjectList<[Function, CXXMethod], ErrorDiag>;
let Documentation = [IntelReqdSubGroupSizeDocs];
let LangOpts = [OpenCL, SYCLIsDevice, SYCLIsHost];
let PragmaAttributeSupport = 0;
}

// This attribute is both a type attribute, and a declaration attribute (for
Expand Down Expand Up @@ -2133,7 +2119,6 @@ def SYCLIntelPipeIO : Attr {
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let Subjects = SubjectList<[Var]>;
let Documentation = [SYCLIntelPipeIOAttrDocs];
let PragmaAttributeSupport = 0;
}

// Variadic integral arguments.
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Misc/pragma-attribute-supported-attributes-list.test
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
// CHECK-NEXT: IBAction (SubjectMatchRule_objc_method_is_instance)
// CHECK-NEXT: IFunc (SubjectMatchRule_function)
// CHECK-NEXT: InitPriority (SubjectMatchRule_variable)
// CHECK-NEXT: IntelReqdSubGroupSize (SubjectMatchRule_function, SubjectMatchRule_function_is_member)
// CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
// CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
// CHECK-NEXT: Leaf (SubjectMatchRule_function)
Expand Down Expand Up @@ -145,7 +146,19 @@
// CHECK-NEXT: ReturnTypestate (SubjectMatchRule_function, SubjectMatchRule_variable_is_parameter)
// CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
// CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
// CHECK-NEXT: SYCLDevice (SubjectMatchRule_function)
// CHECK-NEXT: SYCLDeviceIndirectlyCallable (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelKernelArgsRestrict (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelLoopFuse (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelMaxGlobalWorkDim (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelMaxWorkGroupSize (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelNoGlobalWorkOffset (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelNumSimdWorkItems (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelPipeIO (SubjectMatchRule_variable)
// CHECK-NEXT: SYCLIntelSchedulerTargetFmaxMhz (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelUseStallEnableClusters (SubjectMatchRule_function)
// CHECK-NEXT: SYCLRegisterNum (SubjectMatchRule_variable_is_global)
// CHECK-NEXT: SYCLSimd (SubjectMatchRule_function)
// CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
// CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
// CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Expand Down

0 comments on commit aeb4de7

Please sign in to comment.