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