Skip to content

Commit 9f40e86

Browse files
committed
[clang][RISCV][NFC][test] Move riscv-abi.cpp and riscv{32,64}-*abi.c tests to use update_cc_test_checks.py
This patch implements an initial step towards refactoring our ABI tests (moving them to update_cc_test_checks.py). Future patches combine them. Differential Revision: https://reviews.llvm.org/D134050
1 parent 5cb8381 commit 9f40e86

14 files changed

+1847
-683
lines changed

clang/test/CodeGen/RISCV/riscv-abi.cpp

Lines changed: 84 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --filter "^define |^entry:" --version 2
12
// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - \
2-
// RUN: | FileCheck -check-prefixes=ILP32,ILP32-ILP32F,ILP32-ILP32F-ILP32D %s
3+
// RUN: | FileCheck -check-prefixes=ILP32-ILP32F-ILP32D,ILP32-ILP32F,ILP32 %s
34
// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm %s -o - \
4-
// RUN: | FileCheck -check-prefixes=ILP32F,ILP32-ILP32F,ILP32F-ILP32D,ILP32-ILP32F-ILP32D %s
5+
// RUN: | FileCheck -check-prefixes=ILP32-ILP32F-ILP32D,ILP32F-ILP32D,ILP32-ILP32F,ILP32F %s
56
// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d -target-abi ilp32d -emit-llvm %s -o - \
6-
// RUN: | FileCheck -check-prefixes=ILP32D,ILP32F-ILP32D,ILP32-ILP32F-ILP32D %s
7+
// RUN: | FileCheck -check-prefixes=ILP32-ILP32F-ILP32D,ILP32F-ILP32D,ILP32D %s
78

89
// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
9-
// RUN: | FileCheck -check-prefixes=LP64,LP64-LP64F,LP64-LP64F-LP64D %s
10+
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64-LP64F,LP64 %s
1011
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm %s -o - \
11-
// RUN: | FileCheck -check-prefixes=LP64F,LP64-LP64F,LP64F-LP64D,LP64-LP64F-LP64D %s
12+
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64F-LP64D,LP64-LP64F,LP64F %s
1213
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -o - \
13-
// RUN: | FileCheck -check-prefixes=LP64D,LP64F-LP64D,LP64-LP64F-LP64D %s
14+
// RUN: | FileCheck -check-prefixes=LP64-LP64F-LP64D,LP64F-LP64D,LP64D %s
1415

1516
#include <stdint.h>
1617

@@ -25,8 +26,14 @@ struct child1_int32_s : parent1_int32_s {
2526
int32_t i2;
2627
};
2728

28-
// ILP32-ILP32F-ILP32D-LABEL: define{{.*}} [2 x i32] @_Z30int32_int32_struct_inheritance14child1_int32_s([2 x i32] %a.coerce)
29-
// LP64-LP64F-LP64D-LABEL: define{{.*}} i64 @_Z30int32_int32_struct_inheritance14child1_int32_s(i64 %a.coerce)
29+
// ILP32-ILP32F-ILP32D-LABEL: define dso_local [2 x i32] @_Z30int32_int32_struct_inheritance14child1_int32_s
30+
// ILP32-ILP32F-ILP32D-SAME: ([2 x i32] [[A_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
31+
// ILP32-ILP32F-ILP32D: entry:
32+
//
33+
// LP64-LP64F-LP64D-LABEL: define dso_local i64 @_Z30int32_int32_struct_inheritance14child1_int32_s
34+
// LP64-LP64F-LP64D-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
35+
// LP64-LP64F-LP64D: entry:
36+
//
3037
struct child1_int32_s int32_int32_struct_inheritance(struct child1_int32_s a) {
3138
return a;
3239
}
@@ -39,10 +46,22 @@ struct child2_float_s : parent2_int32_s {
3946
float f1;
4047
};
4148

42-
// ILP32: define{{.*}} [2 x i32] @_Z30int32_float_struct_inheritance14child2_float_s([2 x i32] %a.coerce)
43-
// ILP32F-ILP32D: define{{.*}} { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s(i32 %0, float %1)
44-
// LP64: define{{.*}} i64 @_Z30int32_float_struct_inheritance14child2_float_s(i64 %a.coerce)
45-
// LP64F-LP64D: define{{.*}} { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s(i32 %0, float %1)
49+
// ILP32-LABEL: define dso_local [2 x i32] @_Z30int32_float_struct_inheritance14child2_float_s
50+
// ILP32-SAME: ([2 x i32] [[A_COERCE:%.*]]) #[[ATTR0]] {
51+
// ILP32: entry:
52+
//
53+
// ILP32F-ILP32D-LABEL: define dso_local { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s
54+
// ILP32F-ILP32D-SAME: (i32 [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
55+
// ILP32F-ILP32D: entry:
56+
//
57+
// LP64-LABEL: define dso_local i64 @_Z30int32_float_struct_inheritance14child2_float_s
58+
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
59+
// LP64: entry:
60+
//
61+
// LP64F-LP64D-LABEL: define dso_local { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s
62+
// LP64F-LP64D-SAME: (i32 [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
63+
// LP64F-LP64D: entry:
64+
//
4665
struct child2_float_s int32_float_struct_inheritance(struct child2_float_s a) {
4766
return a;
4867
}
@@ -55,9 +74,18 @@ struct child3_int64_s : parent3_float_s {
5574
int64_t i1;
5675
};
5776

58-
// ILP32-ILP32F-ILP32D-LABEL: define{{.*}} void @_Z30float_int64_struct_inheritance14child3_int64_s(ptr noalias sret(%struct.child3_int64_s)
59-
// LP64-LABEL: define{{.*}} [2 x i64] @_Z30float_int64_struct_inheritance14child3_int64_s([2 x i64] %a.coerce)
60-
// LP64F-LP64D-LABEL: define{{.*}} { float, i64 } @_Z30float_int64_struct_inheritance14child3_int64_s(float %0, i64 %1)
77+
// ILP32-ILP32F-ILP32D-LABEL: define dso_local void @_Z30float_int64_struct_inheritance14child3_int64_s
78+
// ILP32-ILP32F-ILP32D-SAME: (ptr noalias sret([[STRUCT_CHILD3_INT64_S:%.*]]) align 8 [[AGG_RESULT:%.*]], ptr noundef [[A:%.*]]) #[[ATTR0]] {
79+
// ILP32-ILP32F-ILP32D: entry:
80+
//
81+
// LP64-LABEL: define dso_local [2 x i64] @_Z30float_int64_struct_inheritance14child3_int64_s
82+
// LP64-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
83+
// LP64: entry:
84+
//
85+
// LP64F-LP64D-LABEL: define dso_local { float, i64 } @_Z30float_int64_struct_inheritance14child3_int64_s
86+
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], i64 [[TMP1:%.*]]) #[[ATTR0]] {
87+
// LP64F-LP64D: entry:
88+
//
6189
struct child3_int64_s float_int64_struct_inheritance(struct child3_int64_s a) {
6290
return a;
6391
}
@@ -70,10 +98,22 @@ struct child4_double_s : parent4_double_s {
7098
double d1;
7199
};
72100

73-
// ILP32-ILP32F-LABEL: define{{.*}} void @_Z32double_double_struct_inheritance15child4_double_s(ptr noalias sret(%struct.child4_double_s)
74-
// ILP32D-LABEL: define{{.*}} { double, double } @_Z32double_double_struct_inheritance15child4_double_s(double %0, double %1)
75-
// LP64-LP64F-LABEL: define{{.*}} [2 x i64] @_Z32double_double_struct_inheritance15child4_double_s([2 x i64] %a.coerce)
76-
// LP64D-LABEL: define{{.*}} { double, double } @_Z32double_double_struct_inheritance15child4_double_s(double %0, double %1)
101+
// ILP32-ILP32F-LABEL: define dso_local void @_Z32double_double_struct_inheritance15child4_double_s
102+
// ILP32-ILP32F-SAME: (ptr noalias sret([[STRUCT_CHILD4_DOUBLE_S:%.*]]) align 8 [[AGG_RESULT:%.*]], ptr noundef [[A:%.*]]) #[[ATTR0]] {
103+
// ILP32-ILP32F: entry:
104+
//
105+
// ILP32D-LABEL: define dso_local { double, double } @_Z32double_double_struct_inheritance15child4_double_s
106+
// ILP32D-SAME: (double [[TMP0:%.*]], double [[TMP1:%.*]]) #[[ATTR0]] {
107+
// ILP32D: entry:
108+
//
109+
// LP64-LP64F-LABEL: define dso_local [2 x i64] @_Z32double_double_struct_inheritance15child4_double_s
110+
// LP64-LP64F-SAME: ([2 x i64] [[A_COERCE:%.*]]) #[[ATTR0]] {
111+
// LP64-LP64F: entry:
112+
//
113+
// LP64D-LABEL: define dso_local { double, double } @_Z32double_double_struct_inheritance15child4_double_s
114+
// LP64D-SAME: (double [[TMP0:%.*]], double [[TMP1:%.*]]) #[[ATTR0]] {
115+
// LP64D: entry:
116+
//
77117
struct child4_double_s double_double_struct_inheritance(struct child4_double_s a) {
78118
return a;
79119
}
@@ -89,8 +129,14 @@ struct child5_virtual_s : virtual parent5_virtual_s {
89129
float f1;
90130
};
91131

92-
// ILP32-ILP32F-ILP32D-LABEL: define{{.*}} void @_ZN16child5_virtual_sC1EOS_(ptr noundef nonnull align 4 dereferenceable(8) %this, ptr noundef nonnull align 4 dereferenceable(8) %0)
93-
// LP64-LP64F-LP64D-LABEL: define{{.*}} void @_ZN16child5_virtual_sC1EOS_(ptr noundef nonnull align 8 dereferenceable(12) %this, ptr noundef nonnull align 8 dereferenceable(12) %0)
132+
// ILP32-ILP32F-ILP32D-LABEL: define dso_local void @_Z38int32_float_virtual_struct_inheritance16child5_virtual_s
133+
// ILP32-ILP32F-ILP32D-SAME: (ptr noalias sret([[STRUCT_CHILD5_VIRTUAL_S:%.*]]) align 4 [[AGG_RESULT:%.*]], ptr noundef [[A:%.*]]) #[[ATTR0]] {
134+
// ILP32-ILP32F-ILP32D: entry:
135+
//
136+
// LP64-LP64F-LP64D-LABEL: define dso_local void @_Z38int32_float_virtual_struct_inheritance16child5_virtual_s
137+
// LP64-LP64F-LP64D-SAME: (ptr noalias sret([[STRUCT_CHILD5_VIRTUAL_S:%.*]]) align 8 [[AGG_RESULT:%.*]], ptr noundef [[A:%.*]]) #[[ATTR0]] {
138+
// LP64-LP64F-LP64D: entry:
139+
//
94140
struct child5_virtual_s int32_float_virtual_struct_inheritance(struct child5_virtual_s a) {
95141
return a;
96142
}
@@ -110,14 +156,28 @@ struct child6b_s : parent6_float_s {
110156
struct grandchild_6_s : child6a_s, child6b_s {
111157
};
112158

113-
// ILP32: define{{.*}} [2 x i32] @_Z38float_float_diamond_struct_inheritance14grandchild_6_s([2 x i32] %a.coerce)
114159
// ILP32F-ILP64D: define{{.*}} { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s(float %0, float %1)
115-
// LP64: define{{.*}} i64 @_Z38float_float_diamond_struct_inheritance14grandchild_6_s(i64 %a.coerce)
116-
// LP64F-LP64D: define{{.*}} { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s(float %0, float %1)
160+
// ILP32-LABEL: define dso_local [2 x i32] @_Z38float_float_diamond_struct_inheritance14grandchild_6_s
161+
// ILP32-SAME: ([2 x i32] [[A_COERCE:%.*]]) #[[ATTR0]] {
162+
// ILP32: entry:
163+
//
164+
// ILP32F-ILP32D-LABEL: define dso_local { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s
165+
// ILP32F-ILP32D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
166+
// ILP32F-ILP32D: entry:
167+
//
168+
// LP64-LABEL: define dso_local i64 @_Z38float_float_diamond_struct_inheritance14grandchild_6_s
169+
// LP64-SAME: (i64 [[A_COERCE:%.*]]) #[[ATTR0]] {
170+
// LP64: entry:
171+
//
172+
// LP64F-LP64D-LABEL: define dso_local { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s
173+
// LP64F-LP64D-SAME: (float [[TMP0:%.*]], float [[TMP1:%.*]]) #[[ATTR0]] {
174+
// LP64F-LP64D: entry:
175+
//
117176
struct grandchild_6_s float_float_diamond_struct_inheritance(struct grandchild_6_s a) {
118177
return a;
119178
}
120179

121180
// NOTE: These prefixes are unused. Do not add tests below this line:
181+
//// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
122182
// ILP32F: {{.*}}
123183
// LP64F: {{.*}}

clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "^define |^entry:" --version 2
12
// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
23

34
// This file contains test cases that will have different output for ilp32 vs
@@ -25,13 +26,19 @@ struct large {
2526
// Scalars passed on the stack should have signext/zeroext attributes, just as
2627
// if they were passed in registers.
2728

28-
// CHECK-LABEL: define{{.*}} i32 @f_scalar_stack_1(i32 noundef %a, i64 noundef %b, float noundef %c, double noundef %d, fp128 noundef %e, i8 noundef zeroext %f, i8 noundef signext %g, i8 noundef zeroext %h)
29+
// CHECK-LABEL: define dso_local i32 @f_scalar_stack_1
30+
// CHECK-SAME: (i32 noundef [[A:%.*]], i64 noundef [[B:%.*]], float noundef [[C:%.*]], double noundef [[D:%.*]], fp128 noundef [[E:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]]) #[[ATTR0:[0-9]+]] {
31+
// CHECK: entry:
32+
//
2933
int f_scalar_stack_1(int32_t a, int64_t b, float c, double d, long double e,
3034
uint8_t f, int8_t g, uint8_t h) {
3135
return g + h;
3236
}
3337

34-
// CHECK-LABEL: define{{.*}} void @f_scalar_stack_2(ptr noalias sret(%struct.large) align 4 %agg.result, float noundef %a, i64 noundef %b, double noundef %c, fp128 noundef %d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef zeroext %g)
38+
// CHECK-LABEL: define dso_local void @f_scalar_stack_2
39+
// CHECK-SAME: (ptr noalias sret([[STRUCT_LARGE:%.*]]) align 4 [[AGG_RESULT:%.*]], float noundef [[A:%.*]], i64 noundef [[B:%.*]], double noundef [[C:%.*]], fp128 noundef [[D:%.*]], i8 noundef zeroext [[E:%.*]], i8 noundef signext [[F:%.*]], i8 noundef zeroext [[G:%.*]]) #[[ATTR0]] {
40+
// CHECK: entry:
41+
//
3542
struct large f_scalar_stack_2(float a, int64_t b, double c, long double d,
3643
uint8_t e, int8_t f, uint8_t g) {
3744
return (struct large){a, e, f, g};
@@ -40,10 +47,16 @@ struct large f_scalar_stack_2(float a, int64_t b, double c, long double d,
4047
// Aggregates and >=XLen scalars passed on the stack should be lowered just as
4148
// they would be if passed via registers.
4249

43-
// CHECK-LABEL: define{{.*}} void @f_scalar_stack_3(double noundef %a, i64 noundef %b, double noundef %c, i64 noundef %d, i32 noundef %e, i64 noundef %f, float noundef %g, double noundef %h, fp128 noundef %i)
50+
// CHECK-LABEL: define dso_local void @f_scalar_stack_3
51+
// CHECK-SAME: (double noundef [[A:%.*]], i64 noundef [[B:%.*]], double noundef [[C:%.*]], i64 noundef [[D:%.*]], i32 noundef [[E:%.*]], i64 noundef [[F:%.*]], float noundef [[G:%.*]], double noundef [[H:%.*]], fp128 noundef [[I:%.*]]) #[[ATTR0]] {
52+
// CHECK: entry:
53+
//
4454
void f_scalar_stack_3(double a, int64_t b, double c, int64_t d, int e,
4555
int64_t f, float g, double h, long double i) {}
4656

47-
// CHECK-LABEL: define{{.*}} void @f_agg_stack(double noundef %a, i64 noundef %b, double noundef %c, i64 noundef %d, i32 %e.coerce, [2 x i32] %f.coerce, i64 %g.coerce, ptr noundef %h)
57+
// CHECK-LABEL: define dso_local void @f_agg_stack
58+
// CHECK-SAME: (double noundef [[A:%.*]], i64 noundef [[B:%.*]], double noundef [[C:%.*]], i64 noundef [[D:%.*]], i32 [[E_COERCE:%.*]], [2 x i32] [[F_COERCE:%.*]], i64 [[G_COERCE:%.*]], ptr noundef [[H:%.*]]) #[[ATTR0]] {
59+
// CHECK: entry:
60+
//
4861
void f_agg_stack(double a, int64_t b, double c, int64_t d, struct tiny e,
4962
struct small f, struct small_aligned g, struct large h) {}

clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --filter "^define |^entry:" --version 2
12
// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
23
// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm %s -o - \
34
// RUN: | FileCheck %s
@@ -27,13 +28,19 @@ struct large {
2728
// Scalars passed on the stack should have signext/zeroext attributes, just as
2829
// if they were passed in registers.
2930

30-
// CHECK-LABEL: define{{.*}} i32 @f_scalar_stack_1(i32 noundef %a, i64 noundef %b, i32 noundef %c, double noundef %d, fp128 noundef %e, i8 noundef zeroext %f, i8 noundef signext %g, i8 noundef zeroext %h)
31+
// CHECK-LABEL: define dso_local i32 @f_scalar_stack_1
32+
// CHECK-SAME: (i32 noundef [[A:%.*]], i64 noundef [[B:%.*]], i32 noundef [[C:%.*]], double noundef [[D:%.*]], fp128 noundef [[E:%.*]], i8 noundef zeroext [[F:%.*]], i8 noundef signext [[G:%.*]], i8 noundef zeroext [[H:%.*]]) #[[ATTR0:[0-9]+]] {
33+
// CHECK: entry:
34+
//
3135
int f_scalar_stack_1(int32_t a, int64_t b, int32_t c, double d, long double e,
3236
uint8_t f, int8_t g, uint8_t h) {
3337
return g + h;
3438
}
3539

36-
// CHECK-LABEL: define{{.*}} void @f_scalar_stack_2(ptr noalias sret(%struct.large) align 4 %agg.result, i32 noundef %a, i64 noundef %b, double noundef %c, fp128 noundef %d, i8 noundef zeroext %e, i8 noundef signext %f, i8 noundef zeroext %g)
40+
// CHECK-LABEL: define dso_local void @f_scalar_stack_2
41+
// CHECK-SAME: (ptr noalias sret([[STRUCT_LARGE:%.*]]) align 4 [[AGG_RESULT:%.*]], i32 noundef [[A:%.*]], i64 noundef [[B:%.*]], double noundef [[C:%.*]], fp128 noundef [[D:%.*]], i8 noundef zeroext [[E:%.*]], i8 noundef signext [[F:%.*]], i8 noundef zeroext [[G:%.*]]) #[[ATTR0]] {
42+
// CHECK: entry:
43+
//
3744
struct large f_scalar_stack_2(int32_t a, int64_t b, double c, long double d,
3845
uint8_t e, int8_t f, uint8_t g) {
3946
return (struct large){a, e, f, g};
@@ -42,10 +49,16 @@ struct large f_scalar_stack_2(int32_t a, int64_t b, double c, long double d,
4249
// Aggregates and >=XLen scalars passed on the stack should be lowered just as
4350
// they would be if passed via registers.
4451

45-
// CHECK-LABEL: define{{.*}} void @f_scalar_stack_3(double noundef %a, i64 noundef %b, double noundef %c, i64 noundef %d, i32 noundef %e, i64 noundef %f, i32 noundef %g, double noundef %h, fp128 noundef %i)
52+
// CHECK-LABEL: define dso_local void @f_scalar_stack_3
53+
// CHECK-SAME: (double noundef [[A:%.*]], i64 noundef [[B:%.*]], double noundef [[C:%.*]], i64 noundef [[D:%.*]], i32 noundef [[E:%.*]], i64 noundef [[F:%.*]], i32 noundef [[G:%.*]], double noundef [[H:%.*]], fp128 noundef [[I:%.*]]) #[[ATTR0]] {
54+
// CHECK: entry:
55+
//
4656
void f_scalar_stack_3(double a, int64_t b, double c, int64_t d, int e,
4757
int64_t f, int32_t g, double h, long double i) {}
4858

49-
// CHECK-LABEL: define{{.*}} void @f_agg_stack(double noundef %a, i64 noundef %b, double noundef %c, i64 noundef %d, i32 %e.coerce, [2 x i32] %f.coerce, i64 %g.coerce, ptr noundef %h)
59+
// CHECK-LABEL: define dso_local void @f_agg_stack
60+
// CHECK-SAME: (double noundef [[A:%.*]], i64 noundef [[B:%.*]], double noundef [[C:%.*]], i64 noundef [[D:%.*]], i32 [[E_COERCE:%.*]], [2 x i32] [[F_COERCE:%.*]], i64 [[G_COERCE:%.*]], ptr noundef [[H:%.*]]) #[[ATTR0]] {
61+
// CHECK: entry:
62+
//
5063
void f_agg_stack(double a, int64_t b, double c, int64_t d, struct tiny e,
5164
struct small f, struct small_aligned g, struct large h) {}

0 commit comments

Comments
 (0)