File: group_shared.hlsl

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (107 lines) | stat: -rw-r--r-- 4,021 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify

 groupshared float a[10];

 [numthreads(8,8,1)]
 void main() {
   a[0] = 1;
   // expected-error@+1 {{automatic variable qualified with an address space}}
   groupshared float b;
 }

// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
 groupshared float foo() {
  static groupshared float foo0;
    return 1;
 }
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
  groupshared void bar() {
    extern groupshared float bar0;
  }
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
  groupshared float decl() {
      return 1;
  }

  class C {
      // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
      // expected-error@+1 {{return type cannot be qualified with address space}}
      groupshared void foo() {}
      // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
      // expected-error@+1 {{return type cannot be qualified with address space}}
      groupshared void bar();
      // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
      // expected-error@+1 {{return type cannot be qualified with address space}}
      friend groupshared void friend_def() {}
      // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
      // expected-error@+1 {{return type cannot be qualified with address space}}
      friend groupshared void friend_decl();
  };

  struct S {
    // expected-warning@+2 {{'groupshared' attribute only applies to variables}}
    // expected-error@+1 {{field may not be qualified with an address space}}
    groupshared float f;
    static groupshared float g;
  };

  // expected-error@+1 {{parameter may not be qualified with an address space}}
  float foo2(groupshared float a) {
    return a;
  }

// expected-note@+2 {{parameter may not be qualified with an address space}}
template<typename T>
  T tfoo(T t) {
     return t;
  }
  // expected-warning@+1 {{alias declarations are a C++11 extension}}
 using GSF = groupshared float;
 GSF gs;
 // expected-error@+1 {{no matching function for call to 'tfoo'}}
 GSF gs2 = tfoo<GSF>(gs);

// NOTE:This one didn't report error on the groupshared return type,
// it is caused by return type check is after pointer check which is acceptable.
// expected-error@+1 {{pointers are unsupported in HLSL}}
groupshared void (*fp)();
// expected-error@+2 {{pointers are unsupported in HLSL}}
// expected-error@+1 {{parameter may not be qualified with an address space}}
void (*fp2)(groupshared float);
// NOTE: HLSL not support trailing return types.
// expected-warning@+2 {{'auto' type specifier is a C++11 extension}}
// expected-error@+1 {{expected function body after function declarator}}
auto func() -> groupshared void;
// expected-warning@+2 {{'groupshared' attribute only applies to variables}}
// expected-error@+1 {{return type cannot be qualified with address space}}
void groupshared f();

struct S2 {
  // Do we reject it as a function qualifier on a member function?
  void f() groupshared;
};

// Does it impact size or alignment?
_Static_assert(sizeof(float) == sizeof(groupshared float), "");
_Static_assert(_Alignof(double) == _Alignof(groupshared double),"");

// Does it impact type identity for templates?
template <typename Ty>
struct S3 {
  static const bool value = false;
};

template <>
struct S3<groupshared float> {
  static const bool value = true;
};
_Static_assert(!S3<float>::value, "");
_Static_assert(S3<groupshared float>::value, "");

// Can you overload based on the qualifier?
void func(float f) {}
// expected-error@+1 {{parameter may not be qualified with an address space}}
void func(groupshared float f) {}