blob: 6ab5a11106b172bd389c2f0a4da07e91d7727c74 [file] [log] [blame]
Derek Schuff9ed63f82012-09-06 17:37:28 +00001// RUN: %clang_cc1 -triple le32-unknown-nacl %s -emit-llvm -o - | FileCheck %s
2
3#define FASTCALL __attribute__((regparm(2)))
4
5typedef struct {
6 int aaa;
7 double bbbb;
8 int ccc[200];
9} foo;
10
11// 2 inreg arguments are supported.
12void FASTCALL f1(int i, int j, int k);
13// CHECK: define void @f1(i32 inreg %i, i32 inreg %j, i32 %k)
14void f1(int i, int j, int k) { }
15
16// inreg structs are not supported.
17// CHECK: define void @f2(%struct.foo* inreg %a)
18void __attribute__((regparm(1))) f2(foo* a) {}
19
20// Only the first 2 arguments can be passed inreg, and the first
21// non-integral type consumes remaining available registers.
22// CHECK: define void @f3(%struct.foo* byval %a, i32 %b)
23void __attribute__((regparm(2))) f3(foo a, int b) {}
24
25// Only 64 total bits are supported
26// CHECK: define void @f4(i64 inreg %g, i32 %h)
27void __attribute__((regparm(2))) f4(long long g, int h) {}
28
29typedef void (*FType)(int, int) __attribute ((regparm (2)));
30FType bar;
31extern void FASTCALL reduced(char b, double c, foo* d, double e, int f);
32
33int
34main(void) {
35 // The presence of double c means that foo* d is not passed inreg. This
36 // behavior is different from current x86-32 behavior
37 // CHECK: call void @reduced(i8 signext inreg 0, {{.*}} %struct.foo* null
38 reduced(0, 0.0, 0, 0.0, 0);
39 // CHECK: call void {{.*}}(i32 inreg 1, i32 inreg 2)
40 bar(1,2);
41}