brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 1c5e067 Raw
97 lines · plain
1// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s2 3// CHECK: CXXRecordDecl {{.*}} struct EmptyStruct definition4struct EmptyStruct {5};6 7// CHECK: NamespaceDecl {{.*}} NS18namespace NS1 {9  // CHECK: CXXRecordDecl {{.*}} struct Foo definition10  struct Foo {11    float a;12    EmptyStruct es;13  };14 15  // CHECK: CXXRecordDecl {{.*}} struct Bar definition16  struct Bar {17    // CHECK: CXXRecordDecl {{.*}} struct Foo definition18    struct Foo {19      int b;20      EmptyStruct es;21    };22    // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition23    // CHECK: FieldDecl {{.*}} b 'int'24  };25  // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition26  // CHECK: FieldDecl {{.*}} a 'float'27}28 29struct Foo {30  double c;31  EmptyStruct es;32};33 34// CHECK: HLSLBufferDecl {{.*}}  line:[[# @LINE + 2]]:9 cbuffer CB135// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer36cbuffer CB1 {37  // CHECK: VarDecl {{.*}} foo1 'hlsl_constant Foo'38  Foo foo1;39  // CHECK: VarDecl {{.*}} foo2 'hlsl_constant NS1::Foo'40  NS1::Foo foo2;41  // CHECK: VarDecl {{.*}} foo3 'hlsl_constant NS1::Bar::Foo'42  NS1::Bar::Foo foo3;43  // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB1 definition44  // CHECK: FieldDecl {{.*}} foo1 '__cblayout_Foo'45  // CHECK: FieldDecl {{.*}} foo2 'NS1::__cblayout_Foo'46  // CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__cblayout_Foo'47}48// CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition49// CHECK: FieldDecl {{.*}} c 'double'50 51struct CB1ExpectedShape {52    double a1;53    float a2;54    int a;55};56_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB1ExpectedShape, __cblayout_CB1), "");57 58namespace NS2 {59  struct Foo {60    float d[4];61    EmptyStruct es;62  };63  // CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 2]]:11 cbuffer CB264  // CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer65  cbuffer CB2 {66    // CHECK: VarDecl {{.*}} foo0 'hlsl_constant ::Foo'67    ::Foo foo0;68    // CHECK: VarDecl {{.*}} foo1 'hlsl_constant Foo'69    Foo foo1;70    // CHECK: VarDecl {{.*}} foo2 'hlsl_constant NS1::Foo'71    NS1::Foo foo2;72    // CHECK: VarDecl {{.*}} foo3 'hlsl_constant NS1::Bar::Foo'73    NS1::Bar::Foo foo3;74    // CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB2 definition75    // CHECK: FieldDecl {{.*}} foo0 '__cblayout_Foo'76    // CHECK: FieldDecl {{.*}} foo1 'NS2::__cblayout_Foo'77    // CHECK: FieldDecl {{.*}} foo2 'NS1::__cblayout_Foo'78    // CHECK: FieldDecl {{.*}} foo3 'NS1::Bar::__cblayout_Foo'79  }80  // CHECK: CXXRecordDecl {{.*}} implicit struct __cblayout_Foo definition81  // CHECK: FieldDecl {{.*}} d 'float[4]'82}83 84struct CB2ExpectedShape {85    double a1;86    float d[4];87    float a2;88    int a;89};90_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB2ExpectedShape, NS2::__cblayout_CB2), "");91 92// Add uses for the constant buffer declarations so they are not optimized away93// CHECK: ExportDecl94export float f() {95  return foo2.a + NS2::foo2.a;96}97