[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)
Kishan Parmar via cfe-commits
cfe-commits at lists.llvm.org
Mon May 6 02:51:07 PDT 2024
================
@@ -0,0 +1,286 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-DEF
+// RUN: %clang_cc1 -msoft-float -mfloat-abi soft -triple powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-SOFT-FLOAT
+
+// CHECK-GNU-DEF-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-DEF-SAME: (float noundef [[F:%.*]], [8 x i32] noundef [[X_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-GNU-DEF-NEXT: entry:
+// CHECK-GNU-DEF-NEXT: [[RETVAL:%.*]] = alloca { ppc_fp128, ppc_fp128 }, align 16
+// CHECK-GNU-DEF-NEXT: [[X:%.*]] = alloca { ppc_fp128, ppc_fp128 }, align 16
+// CHECK-GNU-DEF-NEXT: [[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-GNU-DEF-NEXT: store [8 x i32] [[X_COERCE]], ptr [[X]], align 16
+// CHECK-GNU-DEF-NEXT: store float [[F]], ptr [[F_ADDR]], align 4
+// CHECK-GNU-DEF-NEXT: [[X_REALP:%.*]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT: [[X_REAL:%.*]] = load ppc_fp128, ptr [[X_REALP]], align 16
+// CHECK-GNU-DEF-NEXT: [[X_IMAGP:%.*]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT: [[X_IMAG:%.*]] = load ppc_fp128, ptr [[X_IMAGP]], align 16
+// CHECK-GNU-DEF-NEXT: [[RETVAL_REALP:%.*]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT: [[RETVAL_IMAGP:%.*]] = getelementptr inbounds { ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT: store ppc_fp128 [[X_REAL]], ptr [[RETVAL_REALP]], align 16
+// CHECK-GNU-DEF-NEXT: store ppc_fp128 [[X_IMAG]], ptr [[RETVAL_IMAGP]], align 16
+// CHECK-GNU-DEF-NEXT: [[TMP0:%.*]] = load [8 x i32], ptr [[RETVAL]], align 16
+// CHECK-GNU-DEF-NEXT: ret [8 x i32] [[TMP0]]
+//
+// CHECK-GNU-SOFT-FLOAT-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-SOFT-FLOAT-SAME: (float noundef [[F:%.*]], ptr noundef byval({ ppc_fp128, ppc_fp128 }) align 16 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
----------------
Long5hot wrote:
Below assembly's generated with -fcomplex-ppc-gnu-abi -O1 --target=ppc32 -S -msoft-float
"use-soft-float"="true" get's passed in IR in attributes
```
_Complex double testComplexDouble(float w, _Complex float x, _Complex double z)
{
return z;
}
testComplexDouble: # @testComplexDouble
.Lfunc_begin2:
.cfi_startproc
# %bb.0:
mr 6, 10
mr 5, 9
mr 4, 8
mr 3, 7
blr
.Lfunc_end2:
.size testComplexDouble, .Lfunc_end2-.Lfunc_begin2
.cfi_endproc
# -- End function
```
```
_Complex double checkComplexDoubleOnStack(float x1, _Complex float cf, float x2, _Complex double cd)
{
return testComplexDouble(x2, cf, cd);
}
.globl checkComplexDoubleOnStack # -- Begin function checkComplexDoubleOnStack
.p2align 2
.type checkComplexDoubleOnStack, at function
checkComplexDoubleOnStack: # @checkComplexDoubleOnStack
.Lfunc_begin3:
.cfi_startproc
# %bb.0:
lwz 3, 0(8)
lwz 4, 4(8)
lwz 5, 8(8)
lwz 6, 12(8)
blr
```
https://github.com/llvm/llvm-project/pull/77732
More information about the cfe-commits
mailing list