brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.1 KiB · bf3751b Raw
96 lines · c
1// REQUIRES: arm-registered-target,aarch64-registered-target,powerpc-registered-target2// RUN: %clang_cc1 -triple thumbv7-none-none -mfloat-abi hard -x c -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS3// RUN: %clang_cc1 -triple thumbv7-none-none -mfloat-abi hard -x c++ -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS4// RUN: %clang_cc1 -triple thumbv7-none-none -mfloat-abi hard -x c++ -DEXTERN_C -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS5// RUN: %clang_cc1 -triple aarch64-none-none -mfloat-abi hard -x c -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS6// RUN: %clang_cc1 -triple aarch64-none-none -mfloat-abi hard -x c++ -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS7// RUN: %clang_cc1 -triple aarch64-none-none -mfloat-abi hard -x c++ -DEXTERN_C -emit-llvm -o - %s | FileCheck %s --check-prefix=AAPCS8// RUN: %clang_cc1 -triple powerpc64le-none-none -mfloat-abi hard -x c -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC --check-prefix=PPC-C9// RUN: %clang_cc1 -triple powerpc64le-none-none -mfloat-abi hard -x c++ -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC --check-prefix=PPC-CXX10// RUN: %clang_cc1 -triple powerpc64le-none-none -mfloat-abi hard -x c++ -DEXTERN_C -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC --check-prefix=PPC-CXX11 12// The aim here is to test whether each of these structure types is13// regarded as a homogeneous aggregate of a single kind of14// floating-point item, because in all of these ABIs, that changes the15// calling convention.16//17// We expect that 'Floats' and 'Doubles' are homogeneous, and 'Mixed'18// is not. But the next two structures, with separating zero-size19// bitfields, are more interesting.20//21// For the Arm architecture, AAPCS says that the homogeneity rule is22// applied _after_ data layout is completed, so that it's unaffected23// by anything that was completely discarded during data layout. So we24// expect that FloatsBF and DoublesBF still count as homogeneous.25//26// But on PowerPC, it depends on whether the source language is C or27// C++, because that's consistent with the decisions gcc makes.28 29struct Floats {30    float a;31    float b;32};33 34struct Doubles {35    double a;36    double b;37};38 39struct Mixed {40    double a;41    float b;42};43 44struct FloatsBF {45    float a;46    int : 0;47    float b;48};49 50struct DoublesBF {51    double a;52    int : 0;53    double b;54};55 56// In C++ mode, we test both with and without extern "C", to ensure57// that doesn't make a difference.58#ifdef EXTERN_C59#define LINKAGE extern "C"60#else61#define LINKAGE62#endif63 64// For Arm backends, the IR emitted for the homogeneous-aggregate65// return convention uses the actual structure type, so that66// HandleFloats returns a %struct.Floats, and so on. To check that67// 'Mixed' is not treated as homogeneous, it's enough to check that68// its return type is _not_ %struct.Mixed. (The fallback handling69// varies between AArch32 and AArch64.)70//71// For PowerPC, homogeneous structure types are lowered to an IR array72// types like [2 x float], and the non-homogeneous Mixed is lowered to73// a pair of i64.74 75// AAPCS: define{{.*}} %struct.Floats @{{.*HandleFloats.*}}76// PPC: define{{.*}} [2 x float] @{{.*HandleFloats.*}}77LINKAGE struct Floats HandleFloats(struct Floats x) { return x; }78 79// AAPCS: define{{.*}} %struct.Doubles @{{.*HandleDoubles.*}}80// PPC: define{{.*}} [2 x double] @{{.*HandleDoubles.*}}81LINKAGE struct Doubles HandleDoubles(struct Doubles x) { return x; }82 83// AAPCS-NOT: define{{.*}} %struct.Mixed @{{.*HandleMixed.*}}84// PPC: define{{.*}} { i64, i64 } @{{.*HandleMixed.*}}85LINKAGE struct Mixed HandleMixed(struct Mixed x) { return x; }86 87// AAPCS: define{{.*}} %struct.FloatsBF @{{.*HandleFloatsBF.*}}88// PPC-C-NOT: define{{.*}} [2 x float] @{{.*HandleFloatsBF.*}}89// PPC-CXX: define{{.*}} [2 x float] @{{.*HandleFloatsBF.*}}90LINKAGE struct FloatsBF HandleFloatsBF(struct FloatsBF x) { return x; }91 92// AAPCS: define{{.*}} %struct.DoublesBF @{{.*HandleDoublesBF.*}}93// PPC-C-NOT: define{{.*}} [2 x double] @{{.*HandleDoublesBF.*}}94// PPC-CXX: define{{.*}} [2 x double] @{{.*HandleDoublesBF.*}}95LINKAGE struct DoublesBF HandleDoublesBF(struct DoublesBF x) { return x; }96