|
| 1 | +// RUN: %clang_cc1 -triple riscv32 -emit-llvm -x c++ %s -o - \ |
| 2 | +// RUN: | FileCheck -check-prefixes=ILP32,ILP32-ILP32F,ILP32-ILP32F-ILP32D %s |
| 3 | +// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm -x c++ %s -o - \ |
| 4 | +// RUN: | FileCheck -check-prefixes=ILP32F,ILP32-ILP32F,ILP32F-ILP32D,ILP32-ILP32F-ILP32D %s |
| 5 | +// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d -target-abi ilp32d -emit-llvm %s -x c++ -o - \ |
| 6 | +// RUN: | FileCheck -check-prefixes=ILP32D,ILP32F-ILP32D,ILP32-ILP32F-ILP32D %s |
| 7 | + |
| 8 | +// RUN: %clang_cc1 -triple riscv64 -emit-llvm -x c++ %s -o - \ |
| 9 | +// RUN: | FileCheck -check-prefixes=LP64,LP64-LP64F,LP64-LP64F-LP64D %s |
| 10 | +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm -x c++ %s -o - \ |
| 11 | +// RUN: | FileCheck -check-prefixes=LP64F,LP64-LP64F,LP64F-LP64D,LP64-LP64F-LP64D %s |
| 12 | +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-abi lp64d -emit-llvm %s -x c++ -o - \ |
| 13 | +// RUN: | FileCheck -check-prefixes=LP64D,LP64F-LP64D,LP64-LP64F-LP64D %s |
| 14 | + |
| 15 | +#include <stdint.h> |
| 16 | + |
| 17 | +// Ensure that fields inherited from a parent struct are treated in the same |
| 18 | +// way as fields directly in the child for the purposes of RISC-V ABI rules. |
| 19 | + |
| 20 | +struct parent1_int32_s { |
| 21 | + int32_t i1; |
| 22 | +}; |
| 23 | + |
| 24 | +struct child1_int32_s : parent1_int32_s { |
| 25 | + int32_t i2; |
| 26 | +}; |
| 27 | + |
| 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) |
| 30 | +struct child1_int32_s int32_int32_struct_inheritance(struct child1_int32_s a) { |
| 31 | + return a; |
| 32 | +} |
| 33 | + |
| 34 | +struct parent2_int32_s { |
| 35 | + int32_t i1; |
| 36 | +}; |
| 37 | + |
| 38 | +struct child2_float_s : parent2_int32_s { |
| 39 | + float f1; |
| 40 | +}; |
| 41 | + |
| 42 | +// TODO: Fix incorrect lowering for hard-float ABIs. |
| 43 | + |
| 44 | +// ILP32: define{{.*}} [2 x i32] @_Z30int32_float_struct_inheritance14child2_float_s([2 x i32] %a.coerce) |
| 45 | +// ILP32F-ILP32D: define{{.*}} float @_Z30int32_float_struct_inheritance14child2_float_s(float %0) |
| 46 | +// LP64: define{{.*}} i64 @_Z30int32_float_struct_inheritance14child2_float_s(i64 %a.coerce) |
| 47 | +// LP64F-LP64D: define{{.*}} float @_Z30int32_float_struct_inheritance14child2_float_s(float %0) |
| 48 | +struct child2_float_s int32_float_struct_inheritance(struct child2_float_s a) { |
| 49 | + return a; |
| 50 | +} |
| 51 | + |
| 52 | +struct parent3_float_s { |
| 53 | + float f1; |
| 54 | +}; |
| 55 | + |
| 56 | +struct child3_int64_s : parent3_float_s { |
| 57 | + int64_t i1; |
| 58 | +}; |
| 59 | + |
| 60 | +// TODO: Fix incorrect lowering for lp64f/lp64d ABIs. |
| 61 | + |
| 62 | +// ILP32-ILP32F-ILP32D-LABEL: define{{.*}} void @_Z30float_int64_struct_inheritance14child3_int64_s(ptr noalias sret(%struct.child3_int64_s) |
| 63 | +// LP64-LP64F-LP64D-LABEL: define{{.*}} [2 x i64] @_Z30float_int64_struct_inheritance14child3_int64_s([2 x i64] %a.coerce) |
| 64 | +struct child3_int64_s float_int64_struct_inheritance(struct child3_int64_s a) { |
| 65 | + return a; |
| 66 | +} |
| 67 | + |
| 68 | +struct parent4_double_s { |
| 69 | + double d1; |
| 70 | +}; |
| 71 | + |
| 72 | +struct child4_double_s : parent4_double_s { |
| 73 | + double d1; |
| 74 | +}; |
| 75 | + |
| 76 | +// TODO: Fix incorrect lowering for ilp32d/lp64d ABIs. |
| 77 | + |
| 78 | +// ILP32-ILP32F-LABEL: define{{.*}} void @_Z32double_double_struct_inheritance15child4_double_s(ptr noalias sret(%struct.child4_double_s) |
| 79 | +// ILP32D-LABEL: define{{.*}} double @_Z32double_double_struct_inheritance15child4_double_s(double %0) |
| 80 | +// LP64-LP64F-LABEL: define{{.*}} [2 x i64] @_Z32double_double_struct_inheritance15child4_double_s([2 x i64] %a.coerce) |
| 81 | +// LP64D-LABEL: define{{.*}} double @_Z32double_double_struct_inheritance15child4_double_s(double %0) |
| 82 | +struct child4_double_s double_double_struct_inheritance(struct child4_double_s a) { |
| 83 | + return a; |
| 84 | +} |
| 85 | + |
| 86 | +// NOTE: These prefixes are unused. Do not add tests below this line: |
| 87 | +// ILP32F: {{.*}} |
| 88 | +// LP64F: {{.*}} |
0 commit comments