|
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -std=gnu++11 -ast-dump %s | FileCheck %s |
| 2 | + |
| 3 | +// add_ir_attributes_function attribute used to represent compile-time SYCL |
| 4 | +// properties and some of those properties are intended to be turned into |
| 5 | +// attributes to enable various diagnostics. |
| 6 | +// |
| 7 | +// This test is intended to check one (and only, at least for now) of such |
| 8 | +// tranformations: property with "indirectly-callable" key should have the same |
| 9 | +// effect as applying sycl_device attribute and the test checks that we do add |
| 10 | +// that attribute implicitly. |
| 11 | + |
| 12 | +// CHECK-LABEL: ToBeTurnedIntoDeviceFunction 'void ()' |
| 13 | +// CHECK: SYCLAddIRAttributesFunctionAttr |
| 14 | +// CHECK: SYCLDeviceAttr {{.*}} Implicit |
| 15 | +[[__sycl_detail__::add_ir_attributes_function("indirectly-callable", "void")]] |
| 16 | +void ToBeTurnedIntoDeviceFunction(); |
| 17 | + |
| 18 | +// CHECK-LABEL: NotToBeTurnedIntoDeviceFunction 'void ()' |
| 19 | +// CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 20 | +// CHECK: SYCLAddIRAttributesFunctionAttr |
| 21 | +// CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 22 | +[[__sycl_detail__::add_ir_attributes_function("not-indirectly-callable", "void")]] |
| 23 | +void NotToBeTurnedIntoDeviceFunction(); |
| 24 | + |
| 25 | +template <int V> |
| 26 | +struct Metadata { |
| 27 | + static constexpr const char *name = "not-indirectly-callable"; |
| 28 | + static constexpr const char *value = "void"; |
| 29 | +}; |
| 30 | + |
| 31 | +template <> |
| 32 | +struct Metadata<42> { |
| 33 | + static constexpr const char *name = "indirectly-callable"; |
| 34 | + static constexpr const char *value = "void"; |
| 35 | +}; |
| 36 | + |
| 37 | +// CHECK-LABEL: ToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 38 | +// CHECK: SYCLAddIRAttributesFunctionAttr |
| 39 | +// CHECK: SYCLDeviceAttr {{.*}} Implicit |
| 40 | +[[__sycl_detail__::add_ir_attributes_function(Metadata<42>::name, Metadata<42>::value)]] |
| 41 | +void ToBeTurnedIntoDeviceFunctionAttrTemplateArgs(); |
| 42 | + |
| 43 | +// CHECK-LABEL: NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 44 | +// CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 45 | +// CHECK: SYCLAddIRAttributesFunctionAttr |
| 46 | +// CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 47 | +[[__sycl_detail__::add_ir_attributes_function(Metadata<1>::name, Metadata<1>::value)]] |
| 48 | +void NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs(); |
| 49 | + |
| 50 | +// CHECK-LABEL: class Base definition |
| 51 | +class Base { |
| 52 | + // CHECK-LABEL: ToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 53 | + // CHECK: SYCLAddIRAttributesFunctionAttr |
| 54 | + // CHECK: SYCLDeviceAttr {{.*}} Implicit |
| 55 | + [[__sycl_detail__::add_ir_attributes_function(Metadata<42>::name, Metadata<42>::value)]] |
| 56 | + virtual void ToBeTurnedIntoDeviceFunctionAttrTemplateArgs(); |
| 57 | + |
| 58 | + // CHECK-LABEL: NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 59 | + // CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 60 | + // CHECK: SYCLAddIRAttributesFunctionAttr |
| 61 | + // CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 62 | + [[__sycl_detail__::add_ir_attributes_function(Metadata<1>::name, Metadata<1>::value)]] |
| 63 | + virtual void NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs(); |
| 64 | +}; |
| 65 | + |
| 66 | +// CHECK-LABEL: class Derived definition |
| 67 | +class Derived : public Base { |
| 68 | + // CHECK-LABEL: ToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 69 | + // CHECK: SYCLAddIRAttributesFunctionAttr |
| 70 | + // CHECK: SYCLDeviceAttr {{.*}} Implicit |
| 71 | + [[__sycl_detail__::add_ir_attributes_function(Metadata<42>::name, Metadata<42>::value)]] |
| 72 | + void ToBeTurnedIntoDeviceFunctionAttrTemplateArgs() override; |
| 73 | + |
| 74 | + // CHECK-LABEL: NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 75 | + // CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 76 | + // CHECK: SYCLAddIRAttributesFunctionAttr |
| 77 | + // CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 78 | + [[__sycl_detail__::add_ir_attributes_function(Metadata<1>::name, Metadata<1>::value)]] |
| 79 | + void NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs() override; |
| 80 | +}; |
| 81 | + |
| 82 | +// CHECK-LABEL: class SubDerived definition |
| 83 | +class SubDerived : public Derived { |
| 84 | + // CHECK-LABEL: ToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 85 | + // CHECK: SYCLAddIRAttributesFunctionAttr |
| 86 | + // CHECK: SYCLDeviceAttr {{.*}} Implicit |
| 87 | + [[__sycl_detail__::add_ir_attributes_function(Metadata<2>::name, Metadata<42>::name, Metadata<2>::value, Metadata<42>::value)]] |
| 88 | + void ToBeTurnedIntoDeviceFunctionAttrTemplateArgs() override; |
| 89 | + |
| 90 | + // CHECK-LABEL: NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs 'void ()' |
| 91 | + // CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 92 | + // CHECK: SYCLAddIRAttributesFunctionAttr |
| 93 | + // CHECK-NOT: SYCLDeviceAttr {{.*}} Implicit |
| 94 | + [[__sycl_detail__::add_ir_attributes_function(Metadata<1>::name, Metadata<2>::name, Metadata<1>::value, Metadata<2>::value)]] |
| 95 | + void NotToBeTurnedIntoDeviceFunctionAttrTemplateArgs() override; |
| 96 | +}; |
0 commit comments