sparcv9-abi.c revision fc782fbeb25ad880ec667f34997bd45d530aef86
1// RUN: %clang_cc1 -triple sparcv9-unknown-linux -emit-llvm %s -o - | FileCheck %s
2
3// CHECK: define void @f_void()
4void f_void(void) {}
5
6// Arguments and return values smaller than the word size are extended.
7
8// CHECK: define signext i32 @f_int_1(i32 signext %x)
9int f_int_1(int x) { return x; }
10
11// CHECK: define zeroext i32 @f_int_2(i32 zeroext %x)
12unsigned f_int_2(unsigned x) { return x; }
13
14// CHECK: define i64 @f_int_3(i64 %x)
15long long f_int_3(long long x) { return x; }
16
17// CHECK: define signext i8 @f_int_4(i8 signext %x)
18char f_int_4(char x) { return x; }
19
20// Small structs are passed in registers.
21struct small {
22  int *a, *b;
23};
24
25// CHECK: define %struct.small @f_small(i32* %x.coerce0, i32* %x.coerce1)
26struct small f_small(struct small x) {
27  x.a += *x.b;
28  x.b = 0;
29  return x;
30}
31
32// Medium-sized structs are passed indirectly, but can be returned in registers.
33struct medium {
34  int *a, *b;
35  int *c, *d;
36};
37
38// CHECK: define %struct.medium @f_medium(%struct.medium* %x)
39struct medium f_medium(struct medium x) {
40  x.a += *x.b;
41  x.b = 0;
42  return x;
43}
44
45// Large structs are also returned indirectly.
46struct large {
47  int *a, *b;
48  int *c, *d;
49  int x;
50};
51
52// CHECK: define void @f_large(%struct.large* noalias sret %agg.result, %struct.large* %x)
53struct large f_large(struct large x) {
54  x.a += *x.b;
55  x.b = 0;
56  return x;
57}
58
59// A 64-bit struct fits in a register.
60struct reg {
61  int a, b;
62};
63
64// CHECK: define i64 @f_reg(i64 %x.coerce)
65struct reg f_reg(struct reg x) {
66  x.a += x.b;
67  return x;
68}
69
70// Structs with mixed int and float parts require the inreg attribute.
71struct mixed {
72  int a;
73  float b;
74};
75
76// CHECK: @f_mixed(i32 inreg %x.coerce0, float inreg %x.coerce1)
77// FIXME: The return value should also be 'inreg'.
78struct mixed f_mixed(struct mixed x) {
79  x.a += 1;
80  return x;
81}
82
83// Struct with padding.
84struct mixed2 {
85  int a;
86  double b;
87};
88
89struct mixed2 f_mixed2(struct mixed2 x) {
90  x.a += 1;
91  return x;
92}
93