xref: /llvm-project/clang/test/CodeGenObjC/matrix-type-builtins.m (revision 9466b49171dc4b21f56a48594fc82b1e52f5358a)
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fenable-matrix -emit-llvm -disable-llvm-optzns -o - %s | FileCheck %s
3
4// Check that we correctly deal with placeholder expressions.
5
6typedef double double4x2 __attribute__((matrix_type(4, 2)));
7typedef double double2x4 __attribute__((matrix_type(2, 4)));
8
9__attribute__((objc_root_class))
10@interface DoubleMatrixValue
11@property double4x2 value;
12@end
13
14void test_transpose_placeholder_get(DoubleMatrixValue *m, double2x4 *r) {
15
16  *r = __builtin_matrix_transpose(m.value);
17}
18
19typedef unsigned u3x4 __attribute__((matrix_type(3, 4)));
20typedef unsigned u4x3 __attribute__((matrix_type(4, 3)));
21
22__attribute__((objc_root_class))
23@interface UnsignedMatrixValue
24@property u3x4 value;
25@end
26
27void test_transpose_placeholder_set(UnsignedMatrixValue *m, u4x3 *r) {
28
29  m.value = __builtin_matrix_transpose(*r);
30}
31
32__attribute__((objc_root_class))
33@interface PtrValue
34@property unsigned *value;
35@end
36
37__attribute__((objc_root_class))
38@interface IntValue
39@property int value;
40@end
41
42void test_column_major_load(PtrValue *Ptr, IntValue *Stride) {
43    // CHECK-LABEL: define{{.*}} void @test_column_major_load(ptr noundef %Ptr, ptr noundef %Stride) #4 {
44  // CHECK:         [[STRIDE:%.*]] = call i32 @objc_msgSend
45  // CHECK-NEXT:    [[STRIDE_EXT:%.*]] = sext i32 [[STRIDE]] to i64
46  // CHECK:         [[PTR:%.*]] = call ptr @objc_msgSend
47  // CHECK-NEXT:    call <12 x i32> @llvm.matrix.column.major.load.v12i32.i64(ptr align 4 [[PTR]], i64 [[STRIDE_EXT]], i1 false, i32 3, i32 4)
48
49  u3x4 m = __builtin_matrix_column_major_load(Ptr.value, 3, 4, Stride.value);
50}
51
52void test_column_major_store(UnsignedMatrixValue *M, PtrValue *Ptr, IntValue *Stride) {
53    // CHECK-LABEL: define{{.*}} void @test_column_major_store(ptr noundef %M, ptr noundef %Ptr, ptr noundef %Stride) #3 {
54  // CHECK:         [[M:%.*]] = call <12 x i32> @objc_msgSend
55  // CHECK:         [[PTR:%.*]] = call ptr @objc_msgSend
56  // CHECK:         [[IDX:%.*]] = call i32 @objc_msgSend
57  // CHECK-NEXT:    [[IDX_EXT:%.*]] = sext i32 [[IDX]] to i64
58  // CHECK-NEXT:    call void @llvm.matrix.column.major.store.v12i32.i64(<12 x i32> [[M]], ptr align 4 [[PTR]], i64 [[IDX_EXT]], i1 false, i32 3, i32 4)
59
60  __builtin_matrix_column_major_store(M.value, Ptr.value, Stride.value);
61}
62