Debian Codegraph @

clang/test/AST/HLSL/vk.spec-constant.usage.hlsl

raw
1 // RUN: %clang_cc1 -finclude-default-header -fnative-int16-type -triple spirv-unknown-vulkan-compute -x hlsl -ast-dump -o - %s | FileCheck %s
2
3 // CHECK: VarDecl {{.*}} bool_const 'const hlsl_private bool' static cinit
4 // CHECK-NEXT: CallExpr {{.*}} 'bool'
5 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'bool (*)(unsigned int, bool) noexcept' <FunctionToPointerDecay>
6 // CHECK-NEXT: DeclRefExpr {{.*}} 'bool (unsigned int, bool) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_bool' 'bool (unsigned int, bool) noexcept'
7 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
8 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1
9 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true
10 [[vk::constant_id(1)]]
11 const bool bool_const = true;
12
13 // CHECK: VarDecl {{.*}} short_const 'const hlsl_private short' static cinit
14 // CHECK-NEXT: CallExpr {{.*}} 'short'
15 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'short (*)(unsigned int, short) noexcept' <FunctionToPointerDecay>
16 // CHECK-NEXT: DeclRefExpr {{.*}} 'short (unsigned int, short) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_short' 'short (unsigned int, short) noexcept'
17 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
18 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 2
19 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'short' <IntegralCast>
20 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 4
21 [[vk::constant_id(2)]]
22 const short short_const = 4;
23
24 // CHECK: VarDecl {{.*}} int_const 'const hlsl_private int' static cinit
25 // CHECK-NEXT: CallExpr {{.*}} 'int'
26 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int (*)(unsigned int, int) noexcept' <FunctionToPointerDecay>
27 // CHECK-NEXT: DeclRefExpr {{.*}} 'int (unsigned int, int) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_int' 'int (unsigned int, int) noexcept'
28 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
29 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
30 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 5
31 [[vk::constant_id(3)]]
32 const int int_const = 5;
33
34 // CHECK: VarDecl {{.*}} long_const 'const hlsl_private long long' static cinit
35 // CHECK-NEXT: CallExpr {{.*}} 'long long'
36 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'long long (*)(unsigned int, long long) noexcept' <FunctionToPointerDecay>
37 // CHECK-NEXT: DeclRefExpr {{.*}} 'long long (unsigned int, long long) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_longlong' 'long long (unsigned int, long long) noexcept'
38 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
39 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 4
40 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'long long' <IntegralCast>
41 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 8
42 [[vk::constant_id(4)]]
43 const long long long_const = 8;
44
45 // CHECK: VarDecl {{.*}} ushort_const 'const hlsl_private unsigned short' static cinit
46 // CHECK-NEXT: CallExpr {{.*}} 'unsigned short'
47 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned short (*)(unsigned int, unsigned short) noexcept' <FunctionToPointerDecay>
48 // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned short (unsigned int, unsigned short) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_ushort' 'unsigned short (unsigned int, unsigned short) noexcept'
49 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
50 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 5
51 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned short' <IntegralCast>
52 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 10
53 [[vk::constant_id(5)]]
54 const unsigned short ushort_const = 10;
55
56 // CHECK: VarDecl {{.*}} uint_const 'const hlsl_private unsigned int' static cinit
57 // CHECK-NEXT: CallExpr {{.*}} 'unsigned int'
58 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int (*)(unsigned int, unsigned int) noexcept' <FunctionToPointerDecay>
59 // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int (unsigned int, unsigned int) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_uint' 'unsigned int (unsigned int, unsigned int) noexcept'
60 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
61 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 6
62 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
63 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 12
64 [[vk::constant_id(6)]]
65 const unsigned int uint_const = 12;
66
67 // CHECK: VarDecl {{.*}} uint_const_2 'const hlsl_private uint':'const hlsl_private unsigned int' static cinit
68 // CHECK-NEXT: CallExpr {{.*}} 'unsigned int'
69 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int (*)(unsigned int, unsigned int) noexcept' <FunctionToPointerDecay>
70 // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int (unsigned int, unsigned int) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_uint' 'unsigned int (unsigned int, unsigned int) noexcept'
71 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
72 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 6
73 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
74 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 12
75 [[vk::constant_id(6)]]
76 const uint uint_const_2 = 12;
77
78
79 // CHECK: VarDecl {{.*}} ulong_const 'const hlsl_private unsigned long long' static cinit
80 // CHECK-NEXT: CallExpr {{.*}} 'unsigned long long'
81 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned long long (*)(unsigned int, unsigned long long) noexcept' <FunctionToPointerDecay>
82 // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned long long (unsigned int, unsigned long long) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_ulonglong' 'unsigned long long (unsigned int, unsigned long long) noexcept'
83 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
84 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 7
85 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned long long' <IntegralCast>
86 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 25
87 [[vk::constant_id(7)]]
88 const unsigned long long ulong_const = 25;
89
90 // CHECK: VarDecl {{.*}} half_const 'const hlsl_private half' static cinit
91 // CHECK-NEXT: CallExpr {{.*}} 'half'
92 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'half (*)(unsigned int, half) noexcept' <FunctionToPointerDecay>
93 // CHECK-NEXT: DeclRefExpr {{.*}} 'half (unsigned int, half) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_half' 'half (unsigned int, half) noexcept'
94 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
95 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 8
96 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'half' <FloatingCast>
97 // CHECK-NEXT: FloatingLiteral {{.*}} 'float' 4.040000e+01
98 [[vk::constant_id(8)]]
99 const half half_const = 40.4;
100
101 // CHECK: VarDecl {{.*}} float_const 'const hlsl_private float' static cinit
102 // CHECK-NEXT: CallExpr {{.*}} 'float'
103 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'float (*)(unsigned int, float) noexcept' <FunctionToPointerDecay>
104 // CHECK-NEXT: DeclRefExpr {{.*}} 'float (unsigned int, float) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_float' 'float (unsigned int, float) noexcept'
105 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
106 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 8
107 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'float' <IntegralToFloating>
108 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 50
109 [[vk::constant_id(8)]]
110 const float float_const = 50;
111
112 // CHECK: VarDecl {{.*}} double_const 'const hlsl_private double' static cinit
113 // CHECK-NEXT: CallExpr {{.*}} 'double'
114 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'double (*)(unsigned int, double) noexcept' <FunctionToPointerDecay>
115 // CHECK-NEXT: DeclRefExpr {{.*}} 'double (unsigned int, double) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_double' 'double (unsigned int, double) noexcept'
116 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
117 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 9
118 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'double' <IntegralToFloating>
119 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 100
120 [[vk::constant_id(9)]]
121 const double double_const = 100;
122
123 // CHECK: VarDecl {{.*}} enum_const 'const hlsl_private E' static cinit
124 // CHECK-NEXT: CStyleCastExpr {{.*}} 'E' <IntegralCast>
125 // CHECK-NEXT: CallExpr {{.*}} 'int'
126 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int (*)(unsigned int, int) noexcept' <FunctionToPointerDecay>
127 // CHECK-NEXT: DeclRefExpr {{.*}} 'int (unsigned int, int) noexcept' lvalue Function {{.*}} '__builtin_get_spirv_spec_constant_int' 'int (unsigned int, int) noexcept'
128 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>
129 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 10
130 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'int' <IntegralCast>
131 // CHECK-NEXT: DeclRefExpr {{.*}} 'E' EnumConstant {{.*}} 'e2' 'E'
132 enum E {
133 e0 = 10,
134 e1 = 20,
135 e2 = 30
136 };
137
138 [[vk::constant_id(10)]]
139 const E enum_const = e2;
140
141 // CHECK-NOT: CXXRecordDecl {{.*}} implicit struct __cblayout_$Globals definition