Skip to content

Commit 58d5186

Browse files
author
Greg Roth
committed
Revert change to how existing matrix types are printed
There is an inconsistency in how matrix and vector pointers and references are printed at present. Also back out a change that's probably better independent than as a rider
1 parent 1fa442b commit 58d5186

File tree

4 files changed

+14
-31
lines changed

4 files changed

+14
-31
lines changed

clang/lib/AST/TypePrinter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,11 @@ void TypePrinter::printConstantMatrixBefore(const ConstantMatrixType *T,
855855
if (Policy.UseHLSLTypes)
856856
OS << "matrix<";
857857
printBefore(T->getElementType(), OS);
858+
if (!Policy.UseHLSLTypes) {
859+
OS << " __attribute__((matrix_type(";
860+
OS << T->getNumRows() << ", " << T->getNumColumns();
861+
OS << ")))";
862+
}
858863
}
859864

860865
void TypePrinter::printConstantMatrixAfter(const ConstantMatrixType *T,
@@ -864,10 +869,6 @@ void TypePrinter::printConstantMatrixAfter(const ConstantMatrixType *T,
864869
OS << ", ";
865870
OS << T->getNumRows() << ", " << T->getNumColumns();
866871
OS << ">";
867-
} else {
868-
OS << " __attribute__((matrix_type(";
869-
OS << T->getNumRows() << ", " << T->getNumColumns();
870-
OS << ")))";
871872
}
872873
}
873874

clang/test/CodeGenHLSL/basic_types.hlsl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,30 @@
1111
// CHECK:"?uint_Val@@3IA" = global i32 0, align 4
1212
// CHECK:"?uint64_t_Val@@3KA" = global i64 0, align 8
1313
// CHECK:"?int64_t_Val@@3JA" = global i64 0, align 8
14-
// CHECK:"?int16_t1_Val@@3T?$__vector@F$00@__clang@@A" = global <1 x i16> zeroinitializer, align 2
1514
// CHECK:"?int16_t2_Val@@3T?$__vector@F$01@__clang@@A" = global <2 x i16> zeroinitializer, align 4
1615
// CHECK:"?int16_t3_Val@@3T?$__vector@F$02@__clang@@A" = global <3 x i16> zeroinitializer, align 8
1716
// CHECK:"?int16_t4_Val@@3T?$__vector@F$03@__clang@@A" = global <4 x i16> zeroinitializer, align 8
18-
// CHECK:"?uint16_t1_Val@@3T?$__vector@G$00@__clang@@A" = global <1 x i16> zeroinitializer, align 2
1917
// CHECK:"?uint16_t2_Val@@3T?$__vector@G$01@__clang@@A" = global <2 x i16> zeroinitializer, align 4
2018
// CHECK:"?uint16_t3_Val@@3T?$__vector@G$02@__clang@@A" = global <3 x i16> zeroinitializer, align 8
2119
// CHECK:"?uint16_t4_Val@@3T?$__vector@G$03@__clang@@A" = global <4 x i16> zeroinitializer, align 8
22-
// CHECK:"?int1_Val@@3T?$__vector@H$00@__clang@@A" = global <1 x i32> zeroinitializer, align 4
2320
// CHECK:"?int2_Val@@3T?$__vector@H$01@__clang@@A" = global <2 x i32> zeroinitializer, align 8
2421
// CHECK:"?int3_Val@@3T?$__vector@H$02@__clang@@A" = global <3 x i32> zeroinitializer, align 16
2522
// CHECK:"?int4_Val@@3T?$__vector@H$03@__clang@@A" = global <4 x i32> zeroinitializer, align 16
26-
// CHECK:"?uint1_Val@@3T?$__vector@I$00@__clang@@A" = global <1 x i32> zeroinitializer, align 4
2723
// CHECK:"?uint2_Val@@3T?$__vector@I$01@__clang@@A" = global <2 x i32> zeroinitializer, align 8
2824
// CHECK:"?uint3_Val@@3T?$__vector@I$02@__clang@@A" = global <3 x i32> zeroinitializer, align 16
2925
// CHECK:"?uint4_Val@@3T?$__vector@I$03@__clang@@A" = global <4 x i32> zeroinitializer, align 16
30-
// CHECK:"?int64_t1_Val@@3T?$__vector@J$00@__clang@@A" = global <1 x i64> zeroinitializer, align 8
3126
// CHECK:"?int64_t2_Val@@3T?$__vector@J$01@__clang@@A" = global <2 x i64> zeroinitializer, align 16
3227
// CHECK:"?int64_t3_Val@@3T?$__vector@J$02@__clang@@A" = global <3 x i64> zeroinitializer, align 32
3328
// CHECK:"?int64_t4_Val@@3T?$__vector@J$03@__clang@@A" = global <4 x i64> zeroinitializer, align 32
34-
// CHECK:"?uint64_t1_Val@@3T?$__vector@K$00@__clang@@A" = global <1 x i64> zeroinitializer, align 8
3529
// CHECK:"?uint64_t2_Val@@3T?$__vector@K$01@__clang@@A" = global <2 x i64> zeroinitializer, align 16
3630
// CHECK:"?uint64_t3_Val@@3T?$__vector@K$02@__clang@@A" = global <3 x i64> zeroinitializer, align 32
3731
// CHECK:"?uint64_t4_Val@@3T?$__vector@K$03@__clang@@A" = global <4 x i64> zeroinitializer, align 32
38-
// CHECK:"?half1_Val@@3T?$__vector@$f16@$00@__clang@@A" = global <1 x half> zeroinitializer, align 2
3932
// CHECK:"?half2_Val@@3T?$__vector@$f16@$01@__clang@@A" = global <2 x half> zeroinitializer, align 4
4033
// CHECK:"?half3_Val@@3T?$__vector@$f16@$02@__clang@@A" = global <3 x half> zeroinitializer, align 8
4134
// CHECK:"?half4_Val@@3T?$__vector@$f16@$03@__clang@@A" = global <4 x half> zeroinitializer, align 8
42-
// CHECK:"?float1_Val@@3T?$__vector@M$00@__clang@@A" = global <1 x float> zeroinitializer, align 4
4335
// CHECK:"?float2_Val@@3T?$__vector@M$01@__clang@@A" = global <2 x float> zeroinitializer, align 8
4436
// CHECK:"?float3_Val@@3T?$__vector@M$02@__clang@@A" = global <3 x float> zeroinitializer, align 16
4537
// CHECK:"?float4_Val@@3T?$__vector@M$03@__clang@@A" = global <4 x float> zeroinitializer, align 16
46-
// CHECK:"?double1_Val@@3T?$__vector@N$00@__clang@@A" = global <1 x double> zeroinitializer, align 8
4738
// CHECK:"?double2_Val@@3T?$__vector@N$01@__clang@@A" = global <2 x double> zeroinitializer, align 16
4839
// CHECK:"?double3_Val@@3T?$__vector@N$02@__clang@@A" = global <3 x double> zeroinitializer, align 32
4940
// CHECK:"?double4_Val@@3T?$__vector@N$03@__clang@@A" = global <4 x double> zeroinitializer, align 32
@@ -69,45 +60,36 @@ TYPE_DECL(int64_t);
6960
// built-in vector data types:
7061

7162
#ifdef __HLSL_ENABLE_16_BIT
72-
TYPE_DECL(int16_t1 );
7363
TYPE_DECL(int16_t2 );
7464
TYPE_DECL(int16_t3 );
7565
TYPE_DECL(int16_t4 );
76-
TYPE_DECL( uint16_t1 );
7766
TYPE_DECL( uint16_t2 );
7867
TYPE_DECL( uint16_t3 );
7968
TYPE_DECL( uint16_t4 );
8069
#endif
8170

82-
TYPE_DECL( int1 );
8371
TYPE_DECL( int2 );
8472
TYPE_DECL( int3 );
8573
TYPE_DECL( int4 );
86-
TYPE_DECL( uint1 );
8774
TYPE_DECL( uint2 );
8875
TYPE_DECL( uint3 );
8976
TYPE_DECL( uint4 );
90-
TYPE_DECL( int64_t1 );
9177
TYPE_DECL( int64_t2 );
9278
TYPE_DECL( int64_t3 );
9379
TYPE_DECL( int64_t4 );
94-
TYPE_DECL( uint64_t1 );
9580
TYPE_DECL( uint64_t2 );
9681
TYPE_DECL( uint64_t3 );
9782
TYPE_DECL( uint64_t4 );
9883

9984
#ifdef __HLSL_ENABLE_16_BIT
100-
TYPE_DECL(half1 );
10185
TYPE_DECL(half2 );
10286
TYPE_DECL(half3 );
10387
TYPE_DECL(half4 );
10488
#endif
10589

106-
TYPE_DECL( float1 );
10790
TYPE_DECL( float2 );
10891
TYPE_DECL( float3 );
10992
TYPE_DECL( float4 );
110-
TYPE_DECL( double1 );
11193
TYPE_DECL( double2 );
11294
TYPE_DECL( double3 );
11395
TYPE_DECL( double4 );

clang/test/Sema/matrix-type-operators.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ void add(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
1717
// expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
1818

1919
a = b + &c;
20-
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))'))}}
21-
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))') to incompatible type 'float'}}
20+
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
21+
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
2222

2323
b += &c;
24-
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))'))}}
25-
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))') to incompatible type 'float'}}
24+
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
25+
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
2626
}
2727

2828
void sub(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
@@ -38,12 +38,12 @@ void sub(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
3838
// expected-error@-1 {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10)))') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))')}}
3939

4040
a = b - &c;
41-
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))'))}}
42-
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))') to incompatible type 'float'}}
41+
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
42+
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
4343

4444
b -= &c;
45-
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))'))}}
46-
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float * __attribute__((matrix_type(10, 5)))') to incompatible type 'float'}}
45+
// expected-error@-1 {{invalid operands to binary expression ('sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10)))') and 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*'))}}
46+
// expected-error@-2 {{casting 'sx10x5_t *' (aka 'float __attribute__((matrix_type(10, 5)))*') to incompatible type 'float'}}
4747
}
4848

4949
typedef int ix10x5_t __attribute__((matrix_type(10, 5)));

clang/test/SemaTemplate/matrix-type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ matrix<float, R + 1, C + 2> use_matrix_2(matrix<int, R, C> &m) {}
6464

6565
template <unsigned long R, unsigned long C>
6666
void use_matrix_2(matrix<int, R + 2, C / 2> &m1, matrix<float, R, C> &m2) {}
67-
// expected-note@-1 {{candidate function [with R = 3, C = 11] not viable: no known conversion from 'matrix<int, 5, 6>' (aka 'int __attribute__((matrix_type(5, 6)))') to 'matrix<int, 3UL + 2, 11UL / 2> &' (aka 'int & __attribute__((matrix_type(5, 5)))') for 1st argument}}
67+
// expected-note@-1 {{candidate function [with R = 3, C = 11] not viable: no known conversion from 'matrix<int, 5, 6>' (aka 'int __attribute__((matrix_type(5, 6)))') to 'matrix<int, 3UL + 2, 11UL / 2> &' (aka 'int __attribute__((matrix_type(5, 5)))&') for 1st argument}}
6868
// expected-note@-2 {{candidate template ignored: deduced type 'matrix<float, 3UL, 4UL>' of 2nd parameter does not match adjusted type 'matrix<int, 3, 4>' of argument [with R = 3, C = 4]}}
6969

7070
template <typename T, unsigned long R, unsigned long C>

0 commit comments

Comments
 (0)