[RISCV][NFC] Refactor RISC-V ABI lowering tests in preparation for hard float patches
authorAlex Bradbury <asb@lowrisc.org>
Tue, 9 Apr 2019 10:12:49 +0000 (10:12 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Tue, 9 Apr 2019 10:12:49 +0000 (10:12 +0000)
Split tests in to files representing the subset of RISC-V ABIs they should
have identical output for.

llvm-svn: 357989

clang/test/CodeGen/riscv32-ilp32-abi.c [new file with mode: 0644]
clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c [new file with mode: 0644]
clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c [moved from clang/test/CodeGen/riscv32-abi.c with 96% similarity]
clang/test/CodeGen/riscv64-lp64-abi.c [new file with mode: 0644]
clang/test/CodeGen/riscv64-lp64-lp64f-abi.c [new file with mode: 0644]
clang/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c [moved from clang/test/CodeGen/riscv64-abi.c with 98% similarity]

diff --git a/clang/test/CodeGen/riscv32-ilp32-abi.c b/clang/test/CodeGen/riscv32-ilp32-abi.c
new file mode 100644 (file)
index 0000000..59f0bb5
--- /dev/null
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+
+// This file contains test cases that will have different output for ilp32 vs
+// the other 32-bit ABIs.
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct tiny {
+  uint8_t a, b, c, d;
+};
+
+struct small {
+  int32_t a, *b;
+};
+
+struct small_aligned {
+  int64_t a;
+};
+
+struct large {
+  int32_t a, b, c, d;
+};
+
+// Scalars passed on the stack should not have signext/zeroext attributes
+// (they are anyext).
+
+// CHECK-LABEL: define i32 @f_scalar_stack_1(i32 %a, i64 %b, float %c, double %d, fp128 %e, i8 zeroext %f, i8 %g, i8 %h)
+int f_scalar_stack_1(int32_t a, int64_t b, float c, double d, long double e,
+                     uint8_t f, int8_t g, uint8_t h) {
+  return g + h;
+}
+
+// Ensure that scalars passed on the stack are still determined correctly in
+// the presence of large return values that consume a register due to the need
+// to pass a pointer.
+
+// CHECK-LABEL: define void @f_scalar_stack_2(%struct.large* noalias sret %agg.result, float %a, i64 %b, double %c, fp128 %d, i8 zeroext %e, i8 %f, i8 %g)
+struct large f_scalar_stack_2(float a, int64_t b, double c, long double d,
+                              uint8_t e, int8_t f, uint8_t g) {
+  return (struct large){a, e, f, g};
+}
+
+// Aggregates and >=XLen scalars passed on the stack should be lowered just as
+// they would be if passed via registers.
+
+// CHECK-LABEL: define void @f_scalar_stack_3(double %a, i64 %b, double %c, i64 %d, i32 %e, i64 %f, float %g, double %h, fp128 %i)
+void f_scalar_stack_3(double a, int64_t b, double c, int64_t d, int e,
+                      int64_t f, float g, double h, long double i) {}
+
+// CHECK-LABEL: define void @f_agg_stack(double %a, i64 %b, double %c, i64 %d, i32 %e.coerce, [2 x i32] %f.coerce, i64 %g.coerce, %struct.large* %h)
+void f_agg_stack(double a, int64_t b, double c, int64_t d, struct tiny e,
+                 struct small f, struct small_aligned g, struct large h) {}
diff --git a/clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c b/clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
new file mode 100644 (file)
index 0000000..7639226
--- /dev/null
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
+
+// This file contains test cases that will have the same output for the ilp32
+// and ilp32f ABIs.
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct tiny {
+  uint8_t a, b, c, d;
+};
+
+struct small {
+  int32_t a, *b;
+};
+
+struct small_aligned {
+  int64_t a;
+};
+
+struct large {
+  int32_t a, b, c, d;
+};
+
+// Scalars passed on the stack should not have signext/zeroext attributes
+// (they are anyext).
+
+// CHECK-LABEL: define i32 @f_scalar_stack_1(i32 %a, i64 %b, i32 %c, double %d, fp128 %e, i8 zeroext %f, i8 %g, i8 %h)
+int f_scalar_stack_1(int32_t a, int64_t b, int32_t c, double d, long double e,
+                     uint8_t f, int8_t g, uint8_t h) {
+  return g + h;
+}
+
+// Ensure that scalars passed on the stack are still determined correctly in
+// the presence of large return values that consume a register due to the need
+// to pass a pointer.
+
+// CHECK-LABEL: define void @f_scalar_stack_2(%struct.large* noalias sret %agg.result, int32_t %a, i64 %b, i64 %c, fp128 %d, i8 zeroext %e, i8 %f, i8 %g)
+struct large f_scalar_stack_2(int32_t a, int64_t b, double c, long double d,
+                              uint8_t e, int8_t f, uint8_t g) {
+  return (struct large){a, e, f, g};
+}
+
+// Aggregates and >=XLen scalars passed on the stack should be lowered just as
+// they would be if passed via registers.
+
+// CHECK-LABEL: define void @f_scalar_stack_3(double %a, i64 %b, double %c, i64 %d, i32 %e, i64 %f, int32_t %g, double %h, fp128 %i)
+void f_scalar_stack_3(double a, int64_t b, double c, int64_t d, int e,
+                      int64_t f, int32_t g, double h, long double i) {}
+
+// CHECK-LABEL: define void @f_agg_stack(double %a, i64 %b, double %c, i64 %d, i32 %e.coerce, [2 x i32] %f.coerce, i64 %g.coerce, %struct.large* %h)
+void f_agg_stack(double a, int64_t b, double c, int64_t d, struct tiny e,
+                 struct small f, struct small_aligned g, struct large h) {}
similarity index 96%
rename from clang/test/CodeGen/riscv32-abi.c
rename to clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
index 04eceb3..3d7ee6e 100644 (file)
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -triple riscv32 -emit-llvm -fforce-enable-int128 %s -o - \
-// RUN: | FileCheck %s -check-prefixes=CHECK,CHECK-FORCEINT128
+// RUN:   | FileCheck %s -check-prefixes=CHECK,CHECK-FORCEINT128
+
+// This file contains test cases that will have the same output for the ilp32,
+// ilp32f, and ilp32d ABIs.
 
 #include <stddef.h>
 #include <stdint.h>
@@ -187,8 +190,8 @@ v16i8 f_vec_large_v16i8_ret() {
   return (v16i8){1, 2, 3, 4, 5, 6, 7, 8};
 }
 
-// Scalars passed on the stack should have signext/zeroext attributes (they
-// are anyext).
+// Scalars passed on the stack should not have signext/zeroext attributes
+// (they are anyext).
 
 // CHECK-LABEL: define i32 @f_scalar_stack_1(i32 %a.coerce, [2 x i32] %b.coerce, i64 %c.coerce, %struct.large* %d, i8 zeroext %e, i8 signext %f, i8 %g, i8 %h)
 int f_scalar_stack_1(struct tiny a, struct small b, struct small_aligned c,
@@ -196,24 +199,18 @@ int f_scalar_stack_1(struct tiny a, struct small b, struct small_aligned c,
   return g + h;
 }
 
-// CHECK-LABEL: define i32 @f_scalar_stack_2(i32 %a, i64 %b, float %c, double %d, fp128 %e, i8 zeroext %f, i8 %g, i8 %h)
-int f_scalar_stack_2(int32_t a, int64_t b, float c, double d, long double e,
-                     uint8_t f, int8_t g, uint8_t h) {
-  return g + h;
-}
-
 // Ensure that scalars passed on the stack are still determined correctly in
 // the presence of large return values that consume a register due to the need
 // to pass a pointer.
 
-// CHECK-LABEL: define void @f_scalar_stack_3(%struct.large* noalias sret %agg.result, i32 %a, i64 %b, double %c, fp128 %d, i8 zeroext %e, i8 %f, i8 %g)
-struct large f_scalar_stack_3(int32_t a, int64_t b, double c, long double d,
+// CHECK-LABEL: define void @f_scalar_stack_2(%struct.large* noalias sret %agg.result, i32 %a, i64 %b, double %c, fp128 %d, i8 zeroext %e, i8 %f, i8 %g)
+struct large f_scalar_stack_2(int32_t a, int64_t b, int64_t c, long double d,
                               uint8_t e, int8_t f, uint8_t g) {
   return (struct large){a, e, f, g};
 }
 
 // CHECK-LABEL: define fp128 @f_scalar_stack_4(i32 %a, i64 %b, double %c, fp128 %d, i8 zeroext %e, i8 %f, i8 %g)
-long double f_scalar_stack_4(int32_t a, int64_t b, double c, long double d,
+long double f_scalar_stack_4(int32_t a, int64_t b, int64_t c, long double d,
                              uint8_t e, int8_t f, uint8_t g) {
   return d;
 }
diff --git a/clang/test/CodeGen/riscv64-lp64-abi.c b/clang/test/CodeGen/riscv64-lp64-abi.c
new file mode 100644 (file)
index 0000000..3720315
--- /dev/null
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s
+
+// This file contains test cases that will have different output for lp64 vs
+// the other 64-bit ABIs.
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct large {
+  int64_t a, b, c, d;
+};
+
+typedef unsigned char v32i8 __attribute__((vector_size(32)));
+
+// Scalars passed on the stack should not have signext/zeroext attributes
+// (they are anyext).
+
+// CHECK-LABEL: define signext i32 @f_scalar_stack_1(i32 signext %a, i128 %b, float %c, fp128 %d, <32 x i8>*, i8 zeroext %f, i8 %g, i8 %h)
+int f_scalar_stack_1(int32_t a, __int128_t b, float c, long double d, v32i8 e,
+                     uint8_t f, int8_t g, uint8_t h) {
+  return g + h;
+}
+
+// Ensure that scalars passed on the stack are still determined correctly in
+// the presence of large return values that consume a register due to the need
+// to pass a pointer.
+
+// CHECK-LABEL: define void @f_scalar_stack_2(%struct.large* noalias sret %agg.result, double %a, i128 %b, fp128 %c, <32 x i8>*, i8 zeroext %e, i8 %f, i8 %g)
+struct large f_scalar_stack_2(double a, __int128_t b, long double c, v32i8 d,
+                              uint8_t e, int8_t f, uint8_t g) {
+  return (struct large){a, e, f, g};
+}
diff --git a/clang/test/CodeGen/riscv64-lp64-lp64f-abi.c b/clang/test/CodeGen/riscv64-lp64-lp64f-abi.c
new file mode 100644 (file)
index 0000000..3b944e7
--- /dev/null
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s
+
+// This file contains test cases that will have the same output for the lp64
+// and lp64f ABIs.
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct large {
+  int64_t a, b, c, d;
+};
+
+typedef unsigned char v32i8 __attribute__((vector_size(32)));
+
+// Scalars passed on the stack should not have signext/zeroext attributes
+// (they are anyext).
+
+// CHECK-LABEL: define signext i32 @f_scalar_stack_1(i32 signext %a, i128 %b, double %c, fp128 %d, <32 x i8>*, i8 zeroext %f, i8 %g, i8 %h)
+int f_scalar_stack_1(int32_t a, __int128_t b, double c, long double d, v32i8 e,
+                     uint8_t f, int8_t g, uint8_t h) {
+  return g + h;
+}
+
+// Ensure that scalars passed on the stack are still determined correctly in
+// the presence of large return values that consume a register due to the need
+// to pass a pointer.
+
+// CHECK-LABEL: define void @f_scalar_stack_2(%struct.large* noalias sret %agg.result, double %a, i128 %b, fp128 %c, <32 x i8>*, i8 zeroext %e, i8 %f, i8 %g)
+struct large f_scalar_stack_2(double a, __int128_t b, long double c, v32i8 d,
+                              uint8_t e, int8_t f, uint8_t g) {
+  return (struct large){a, e, f, g};
+}
similarity index 98%
rename from clang/test/CodeGen/riscv64-abi.c
rename to clang/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c
index 7a0f065..792117d 100644 (file)
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - | FileCheck %s
 
+// This file contains test cases that will have the same output for the lp64,
+// lp64f, and lp64d ABIs.
+
 #include <stddef.h>
 #include <stdint.h>
 
@@ -176,8 +179,8 @@ v32i8 f_vec_large_v32i8_ret() {
   return (v32i8){1, 2, 3, 4, 5, 6, 7, 8};
 }
 
-// Scalars passed on the stack should have signext/zeroext attributes (they
-// are anyext).
+// Scalars passed on the stack should not have signext/zeroext attributes
+// (they are anyext).
 
 // CHECK-LABEL: define signext i32 @f_scalar_stack_1(i64 %a.coerce, [2 x i64] %b.coerce, i128 %c.coerce, %struct.large* %d, i8 zeroext %e, i8 signext %f, i8 %g, i8 %h)
 int f_scalar_stack_1(struct tiny a, struct small b, struct small_aligned c,