142 lines · plain
1// RUN: %clang_cc1 -finclude-default-header -fnative-int16-type -triple spirv-unknown-vulkan-compute -x hlsl -ast-dump -o - %s | FileCheck %s2 3// CHECK: VarDecl {{.*}} bool_const 'const hlsl_private bool' static cinit4// 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' 19// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true10[[vk::constant_id(1)]]11const bool bool_const = true;12 13// CHECK: VarDecl {{.*}} short_const 'const hlsl_private short' static cinit14// 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' 219// CHECK-NEXT: ImplicitCastExpr {{.*}} 'short' <IntegralCast>20// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 421[[vk::constant_id(2)]]22const short short_const = 4;23 24// CHECK: VarDecl {{.*}} int_const 'const hlsl_private int' static cinit25// 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' 330// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 531[[vk::constant_id(3)]]32const int int_const = 5;33 34// CHECK: VarDecl {{.*}} long_const 'const hlsl_private long long' static cinit35// 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' 440// CHECK-NEXT: ImplicitCastExpr {{.*}} 'long long' <IntegralCast>41// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 842[[vk::constant_id(4)]]43const long long long_const = 8;44 45// CHECK: VarDecl {{.*}} ushort_const 'const hlsl_private unsigned short' static cinit46// 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' 551// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned short' <IntegralCast>52// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1053[[vk::constant_id(5)]]54const unsigned short ushort_const = 10;55 56// CHECK: VarDecl {{.*}} uint_const 'const hlsl_private unsigned int' static cinit57// 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' 662// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>63// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1264[[vk::constant_id(6)]]65const unsigned int uint_const = 12;66 67// CHECK: VarDecl {{.*}} uint_const_2 'const hlsl_private uint':'const hlsl_private unsigned int' static cinit68// 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' 673// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned int' <IntegralCast>74// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1275[[vk::constant_id(6)]]76const uint uint_const_2 = 12;77 78 79// CHECK: VarDecl {{.*}} ulong_const 'const hlsl_private unsigned long long' static cinit80// 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' 785// CHECK-NEXT: ImplicitCastExpr {{.*}} 'unsigned long long' <IntegralCast>86// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 2587[[vk::constant_id(7)]]88const unsigned long long ulong_const = 25;89 90// CHECK: VarDecl {{.*}} half_const 'const hlsl_private half' static cinit91// 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' 896// CHECK-NEXT: ImplicitCastExpr {{.*}} 'half' <FloatingCast>97// CHECK-NEXT: FloatingLiteral {{.*}} 'float' 4.040000e+0198[[vk::constant_id(8)]]99const half half_const = 40.4;100 101// CHECK: VarDecl {{.*}} float_const 'const hlsl_private float' static cinit102// 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' 8107// CHECK-NEXT: ImplicitCastExpr {{.*}} 'float' <IntegralToFloating>108// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 50109[[vk::constant_id(8)]]110const float float_const = 50;111 112// CHECK: VarDecl {{.*}} double_const 'const hlsl_private double' static cinit113// 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' 9118// CHECK-NEXT: ImplicitCastExpr {{.*}} 'double' <IntegralToFloating>119// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 100120[[vk::constant_id(9)]]121const double double_const = 100;122 123// CHECK: VarDecl {{.*}} enum_const 'const hlsl_private E' static cinit124// 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' 132enum E {133 e0 = 10,134 e1 = 20,135 e2 = 30136};137 138[[vk::constant_id(10)]]139const E enum_const = e2;140 141// CHECK-NOT: CXXRecordDecl {{.*}} implicit struct __cblayout_$Globals definition142