Debian Codegraph @

clang/test/AST/HLSL/matrix-single-subscript-setter.hlsl

raw
1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -o - %s | FileCheck %s
2
3 typedef float float4x4 __attribute__((matrix_type(4,4)));
4 typedef int int4x4 __attribute__((matrix_type(4,4)));
5
6 typedef float float4 __attribute__((ext_vector_type(4)));
7 typedef int int4 __attribute__((ext_vector_type(4)));
8
9 export void setMatrix(out float4x4 M, int index, float4 V) {
10 // CHECK: BinaryOperator{{.*}} 'vector<float, 4>' lvalue matrixcomponent '='
11 // CHECK-NEXT: MatrixSingleSubscriptExpr {{.*}} 'vector<float, 4>' lvalue matrixcomponent
12 // CHECK-NEXT: DeclRefExpr {{.*}} 'float4x4':'matrix<float, 4, 4>' lvalue ParmVar {{.*}} 'M' 'float4x4 &__restrict'
13 // CHECK-NEXT: DeclRefExpr {{.*}} 'int' lvalue ParmVar {{.*}} 'index' 'int'
14 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'float4':'vector<float, 4>' <LValueToRValue>
15 // CHECK-NEXT: DeclRefExpr {{.*}} 'float4':'vector<float, 4>' lvalue ParmVar {{.*}} 'V' 'float4':'vector<float, 4>'
16 M[index] = V;
17 }
18
19 export void setMatrixConstIndex(out int4x4 M, int4x4 N ) {
20 // CHECK: BinaryOperator {{.*}} 'vector<int, 4>' lvalue matrixcomponent '='
21 // CHECK: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
22 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'M' 'int4x4 &__restrict'
23 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0
24 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<int, 4>' <LValueToRValue>
25 // CHECK-NEXT: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
26 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'N' 'int4x4':'matrix<int, 4, 4>'
27 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
28 M[0] = N[3];
29
30 // CHECK: BinaryOperator {{.*}} 'vector<int, 4>' lvalue matrixcomponent '='
31 // CHECK: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
32 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'M' 'int4x4 &__restrict'
33 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1
34 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<int, 4>' <LValueToRValue>
35 // CHECK-NEXT: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
36 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'N' 'int4x4':'matrix<int, 4, 4>'
37 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 2
38 M[1] = N[2];
39
40 // CHECK: BinaryOperator {{.*}} 'vector<int, 4>' lvalue matrixcomponent '='
41 // CHECK: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
42 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'M' 'int4x4 &__restrict'
43 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 2
44 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<int, 4>' <LValueToRValue>
45 // CHECK-NEXT: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
46 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'N' 'int4x4':'matrix<int, 4, 4>'
47 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1
48 M[2] = N[1];
49
50 // CHECK: BinaryOperator {{.*}} 'vector<int, 4>' lvalue matrixcomponent '='
51 // CHECK: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
52 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'M' 'int4x4 &__restrict'
53 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 3
54 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'vector<int, 4>' <LValueToRValue>
55 // CHECK-NEXT: MatrixSingleSubscriptExpr {{.*}} 'vector<int, 4>' lvalue matrixcomponent
56 // CHECK-NEXT: DeclRefExpr {{.*}} 'int4x4':'matrix<int, 4, 4>' lvalue ParmVar {{.*}} 'N' 'int4x4':'matrix<int, 4, 4>'
57 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0
58 M[3] = N[0];
59 }