1 // RUN: %clang_cc1 -triple le32-unknown-nacl %s -emit-llvm -o - | FileCheck %s 2 3 #define FASTCALL __attribute__((regparm(2))) 4 5 typedef struct { 6 int aaa; 7 double bbbb; 8 int ccc[200]; 9 } foo; 10 11 // 2 inreg arguments are supported. 12 void FASTCALL f1(int i, int j, int k); 13 // CHECK: define void @f1(i32 inreg %i, i32 inreg %j, i32 %k) 14 void f1(int i, int j, int k) { } 15 16 // inreg structs are not supported. 17 // CHECK: define void @f2(%struct.foo* inreg %a) 18 void __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) 23 void __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) 27 void __attribute__((regparm(2))) f4(long long g, int h) {} 28 29 typedef void (*FType)(int, int) __attribute ((regparm (2))); 30 FType bar; 31 extern void FASTCALL reduced(char b, double c, foo* d, double e, int f); 32 33 int 34 main(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 inreg signext 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 } 42