Add NaCl (a target where long double = double) to long double ABI test

A test was recently (r244468) added to cover long double calling convention
codegen, distinguishing between Android and GNU conventions (where long doubles
are fp128 and x86_fp80, respectively). Native Client is a target where long
doubles are the same as doubles. This change augments the test to cover
that case.

Also rename the test to test/codeGen/X86_64-longdouble.c

Differential Revision: http://reviews.llvm.org/D11921

llvm-svn: 244524
This commit is contained in:
Derek Schuff 2015-08-10 23:02:37 +00:00
parent 652b0dabe6
commit 4044f6197a
1 changed files with 24 additions and 4 deletions

View File

@ -4,6 +4,9 @@
// RUN: | FileCheck %s --check-prefix=GNU --check-prefix=CHECK // RUN: | FileCheck %s --check-prefix=GNU --check-prefix=CHECK
// RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \ // RUN: %clang_cc1 -triple x86_64 -emit-llvm -O -o - %s \
// RUN: | FileCheck %s --check-prefix=GNU --check-prefix=CHECK // RUN: | FileCheck %s --check-prefix=GNU --check-prefix=CHECK
// NaCl is an example of a target for which long double is the same as double.
// RUN: %clang_cc1 -triple x86_64-nacl -emit-llvm -O -o - %s \
// RUN: | FileCheck %s --check-prefix=NACL --check-prefix=CHECK
// Android uses fp128 for long double but other x86_64 targets use x86_fp80. // Android uses fp128 for long double but other x86_64 targets use x86_fp80.
@ -19,12 +22,14 @@ long double TestLD(long double x) {
return x * x; return x * x;
// ANDROID: define fp128 @TestLD(fp128 %x) // ANDROID: define fp128 @TestLD(fp128 %x)
// GNU: define x86_fp80 @TestLD(x86_fp80 %x) // GNU: define x86_fp80 @TestLD(x86_fp80 %x)
// NACL: define double @TestLD(double %x)
} }
long double _Complex TestLDC(long double _Complex x) { long double _Complex TestLDC(long double _Complex x) {
return x * x; return x * x;
// ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x) // ANDROID: define void @TestLDC({ fp128, fp128 }* {{.*}}, { fp128, fp128 }* {{.*}} %x)
// GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) // GNU: define { x86_fp80, x86_fp80 } @TestLDC({ x86_fp80, x86_fp80 }* {{.*}} %x)
// NACL: define { double, double } @TestLDC(double %x{{.*}}, double %x{{.*}})
} }
typedef __builtin_va_list va_list; typedef __builtin_va_list va_list;
@ -51,14 +56,18 @@ double TestGetVarDouble(va_list ap) {
long double TestGetVarLD(va_list ap) { long double TestGetVarLD(va_list ap) {
return __builtin_va_arg(ap, long double); return __builtin_va_arg(ap, long double);
// fp128 can be passed in memory or in register, but x86_fp80 is in memory. // fp128 and double can be passed in memory or in register, but x86_fp80 is in
// memory.
// ANDROID: define fp128 @TestGetVarLD( // ANDROID: define fp128 @TestGetVarLD(
// GNU: define x86_fp80 @TestGetVarLD( // GNU: define x86_fp80 @TestGetVarLD(
// NACL: define double @TestGetVarLD(
// ANDROID: br label // ANDROID: br label
// ANDROID: br label // ANDROID: br label
// NACL: br
// ANDROID: = phi // ANDROID: = phi
// GNU-NOT: br // GNU-NOT: br
// GNU-NOT: = phi // GNU-NOT: = phi
// NACL: = phi
// ANDROID: ret fp128 // ANDROID: ret fp128
// GNU: ret x86_fp80 // GNU: ret x86_fp80
} }
@ -68,10 +77,17 @@ long double _Complex TestGetVarLDC(va_list ap) {
// Pair of fp128 or x86_fp80 are passed as struct in memory. // Pair of fp128 or x86_fp80 are passed as struct in memory.
// ANDROID: define void @TestGetVarLDC({ fp128, fp128 }* {{.*}}, %struct.__va_list_tag* // ANDROID: define void @TestGetVarLDC({ fp128, fp128 }* {{.*}}, %struct.__va_list_tag*
// GNU: define { x86_fp80, x86_fp80 } @TestGetVarLDC( // GNU: define { x86_fp80, x86_fp80 } @TestGetVarLDC(
// CHECK-NOT: br // Pair of double can go in SSE registers or memory
// CHECK-NOT: phi // NACL: define { double, double } @TestGetVarLDC(
// ANDROID-NOT: br
// GNU-NOT: br
// NACL: br
// ANDROID-NOT: phi
// GNU-NOT: phi
// NACL: phi
// ANDROID: ret void // ANDROID: ret void
// GNU: ret { x86_fp80, x86_fp80 } // GNU: ret { x86_fp80, x86_fp80 }
// NACL: ret { double, double }
} }
void TestVarArg(const char *s, ...); void TestVarArg(const char *s, ...);
@ -100,6 +116,8 @@ void TestPassVarLD(long double x) {
// ANDROID: call {{.*}} @TestVarArg(i8* {{.*}}, fp128 %x // ANDROID: call {{.*}} @TestVarArg(i8* {{.*}}, fp128 %x
// GNU: define void @TestPassVarLD(x86_fp80 %x) // GNU: define void @TestPassVarLD(x86_fp80 %x)
// GNU: call {{.*}} @TestVarArg(i8* {{.*}}, x86_fp80 %x // GNU: call {{.*}} @TestVarArg(i8* {{.*}}, x86_fp80 %x
// NACL: define void @TestPassVarLD(double %x)
// NACL: call {{.*}} @TestVarArg(i8* {{.*}}, double %x
} }
void TestPassVarLDC(long double _Complex x) { void TestPassVarLDC(long double _Complex x) {
@ -111,5 +129,7 @@ void TestPassVarLDC(long double _Complex x) {
// GNU: define void @TestPassVarLDC({ x86_fp80, x86_fp80 }* {{.*}} %x) // GNU: define void @TestPassVarLDC({ x86_fp80, x86_fp80 }* {{.*}} %x)
// GNU: store x86_fp80 %{{.*}}, x86_fp80* % // GNU: store x86_fp80 %{{.*}}, x86_fp80* %
// GNU-NEXT: store x86_fp80 %{{.*}}, x86_fp80* % // GNU-NEXT: store x86_fp80 %{{.*}}, x86_fp80* %
// GNGNU-NEXT: call {{.*}} @TestVarArg(i8* {{.*}}, { x86_fp80, x86_fp80 }* {{.*}} % // GNU-NEXT: call {{.*}} @TestVarArg(i8* {{.*}}, { x86_fp80, x86_fp80 }* {{.*}} %
// NACL: define void @TestPassVarLDC(double %x{{.*}}, double %x{{.*}})
// NACL: call {{.*}} @TestVarArg(i8* {{.*}}, double %x{{.*}}, double %x{{.*}})
} }