Alex Bradbury | c0e8231 | 2019-04-09 10:12:49 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - | FileCheck %s |
| 2 | |
| 3 | // This file contains test cases that will have different output for ilp32 vs |
| 4 | // the other 32-bit ABIs. |
| 5 | |
| 6 | #include <stddef.h> |
| 7 | #include <stdint.h> |
| 8 | |
| 9 | struct tiny { |
| 10 | uint8_t a, b, c, d; |
| 11 | }; |
| 12 | |
| 13 | struct small { |
| 14 | int32_t a, *b; |
| 15 | }; |
| 16 | |
| 17 | struct small_aligned { |
| 18 | int64_t a; |
| 19 | }; |
| 20 | |
| 21 | struct large { |
| 22 | int32_t a, b, c, d; |
| 23 | }; |
| 24 | |
| 25 | // Scalars passed on the stack should not have signext/zeroext attributes |
| 26 | // (they are anyext). |
| 27 | |
| 28 | // 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) |
| 29 | int f_scalar_stack_1(int32_t a, int64_t b, float c, double d, long double e, |
| 30 | uint8_t f, int8_t g, uint8_t h) { |
| 31 | return g + h; |
| 32 | } |
| 33 | |
| 34 | // Ensure that scalars passed on the stack are still determined correctly in |
| 35 | // the presence of large return values that consume a register due to the need |
| 36 | // to pass a pointer. |
| 37 | |
| 38 | // 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) |
| 39 | struct large f_scalar_stack_2(float a, int64_t b, double c, long double d, |
| 40 | uint8_t e, int8_t f, uint8_t g) { |
| 41 | return (struct large){a, e, f, g}; |
| 42 | } |
| 43 | |
| 44 | // Aggregates and >=XLen scalars passed on the stack should be lowered just as |
| 45 | // they would be if passed via registers. |
| 46 | |
| 47 | // 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) |
| 48 | void f_scalar_stack_3(double a, int64_t b, double c, int64_t d, int e, |
| 49 | int64_t f, float g, double h, long double i) {} |
| 50 | |
| 51 | // 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) |
| 52 | void f_agg_stack(double a, int64_t b, double c, int64_t d, struct tiny e, |
| 53 | struct small f, struct small_aligned g, struct large h) {} |