From d08e04fb77bbe4a4fbdf875deff4d5628016bd2e Mon Sep 17 00:00:00 2001 From: Alex Bradbury Date: Tue, 9 Apr 2019 10:12:49 +0000 Subject: [PATCH] [RISCV][NFC] Refactor RISC-V ABI lowering tests in preparation for hard float patches Split tests in to files representing the subset of RISC-V ABIs they should have identical output for. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357989 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/riscv32-ilp32-abi.c | 53 +++++++++++++++++++ test/CodeGen/riscv32-ilp32-ilp32f-abi.c | 53 +++++++++++++++++++ ...bi.c => riscv32-ilp32-ilp32f-ilp32d-abi.c} | 21 ++++---- test/CodeGen/riscv64-lp64-abi.c | 32 +++++++++++ test/CodeGen/riscv64-lp64-lp64f-abi.c | 32 +++++++++++ ...4-abi.c => riscv64-lp64-lp64f-lp64d-abi.c} | 7 ++- 6 files changed, 184 insertions(+), 14 deletions(-) create mode 100644 test/CodeGen/riscv32-ilp32-abi.c create mode 100644 test/CodeGen/riscv32-ilp32-ilp32f-abi.c rename test/CodeGen/{riscv32-abi.c => riscv32-ilp32-ilp32f-ilp32d-abi.c} (96%) create mode 100644 test/CodeGen/riscv64-lp64-abi.c create mode 100644 test/CodeGen/riscv64-lp64-lp64f-abi.c rename test/CodeGen/{riscv64-abi.c => riscv64-lp64-lp64f-lp64d-abi.c} (98%) diff --git a/test/CodeGen/riscv32-ilp32-abi.c b/test/CodeGen/riscv32-ilp32-abi.c new file mode 100644 index 0000000000..59f0bb5683 --- /dev/null +++ b/test/CodeGen/riscv32-ilp32-abi.c @@ -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 +#include + +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/test/CodeGen/riscv32-ilp32-ilp32f-abi.c b/test/CodeGen/riscv32-ilp32-ilp32f-abi.c new file mode 100644 index 0000000000..7639226ff6 --- /dev/null +++ b/test/CodeGen/riscv32-ilp32-ilp32f-abi.c @@ -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 +#include + +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) {} diff --git a/test/CodeGen/riscv32-abi.c b/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c similarity index 96% rename from test/CodeGen/riscv32-abi.c rename to test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c index 04eceb3a81..3d7ee6e073 100644 --- a/test/CodeGen/riscv32-abi.c +++ b/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c @@ -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 #include @@ -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/test/CodeGen/riscv64-lp64-abi.c b/test/CodeGen/riscv64-lp64-abi.c new file mode 100644 index 0000000000..3720315208 --- /dev/null +++ b/test/CodeGen/riscv64-lp64-abi.c @@ -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 +#include + +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/test/CodeGen/riscv64-lp64-lp64f-abi.c b/test/CodeGen/riscv64-lp64-lp64f-abi.c new file mode 100644 index 0000000000..3b944e716a --- /dev/null +++ b/test/CodeGen/riscv64-lp64-lp64f-abi.c @@ -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 +#include + +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}; +} diff --git a/test/CodeGen/riscv64-abi.c b/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c similarity index 98% rename from test/CodeGen/riscv64-abi.c rename to test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c index 7a0f065fb4..792117d9e3 100644 --- a/test/CodeGen/riscv64-abi.c +++ b/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c @@ -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 #include @@ -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, -- 2.40.0