[complex] Use the much more powerful EmitCall routine to call libcalls
for complex math. This should fix the windows build bots that started having trouble here and generally fix complex libcall emission on targets which use sret for complex data types. It also makes the code a bit simpler (despite calling into a much more complex bucket of code). llvm-svn: 219565
This commit is contained in:
parent
ec8e838baa
commit
686de24128
|
@ -584,23 +584,7 @@ ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
|
|||
llvm::FunctionType *FTy = CGF.CGM.getTypes().GetFunctionType(FuncInfo);
|
||||
llvm::Constant *Func = CGF.CGM.CreateRuntimeFunction(FTy, LibCallName);
|
||||
|
||||
llvm::Value *ArgVals[] = {Op.LHS.first, Op.LHS.second, Op.RHS.first,
|
||||
Op.RHS.second};
|
||||
llvm::Value *Result = CGF.EmitRuntimeCall(Func, ArgVals);
|
||||
|
||||
llvm::Value *ResR, *ResI;
|
||||
if (Result->getType()->isVectorTy()) {
|
||||
ResR = CGF.Builder.CreateExtractElement(Result, CGF.Builder.getInt32(0));
|
||||
ResI = CGF.Builder.CreateExtractElement(Result, CGF.Builder.getInt32(1));
|
||||
} else {
|
||||
assert(Result->getType()->isAggregateType() &&
|
||||
"Only vector and aggregate libcall returns are supported!");
|
||||
unsigned ResRIndices[] = {0};
|
||||
ResR = CGF.Builder.CreateExtractValue(Result, ResRIndices);
|
||||
unsigned ResIIndices[] = {1};
|
||||
ResI = CGF.Builder.CreateExtractValue(Result, ResIIndices);
|
||||
}
|
||||
return ComplexPairTy(ResR, ResI);
|
||||
return CGF.EmitCall(FuncInfo, Func, ReturnValueSlot(), Args).getComplexVal();
|
||||
}
|
||||
|
||||
// See C11 Annex G.5.1 for the semantics of multiplicative operators on complex
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
|
||||
// RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
|
||||
// RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
|
||||
|
||||
float _Complex add_float_rr(float a, float b) {
|
||||
// X86-LABEL: @add_float_rr(
|
||||
|
@ -87,7 +89,7 @@ float _Complex mul_float_rc(float a, float _Complex b) {
|
|||
float _Complex mul_float_cc(float _Complex a, float _Complex b) {
|
||||
// X86-LABEL: @mul_float_cc(
|
||||
// X86-NOT: fmul
|
||||
// X86: call <2 x float> @__mulsc3(
|
||||
// X86: call {{.*}} @__mulsc3(
|
||||
// X86: ret
|
||||
return a * b;
|
||||
}
|
||||
|
@ -110,14 +112,14 @@ float _Complex div_float_cr(float _Complex a, float b) {
|
|||
float _Complex div_float_rc(float a, float _Complex b) {
|
||||
// X86-LABEL: @div_float_rc(
|
||||
// X86-NOT: fdiv
|
||||
// X86: call <2 x float> @__divsc3(
|
||||
// X86: call {{.*}} @__divsc3(
|
||||
// X86: ret
|
||||
return a / b;
|
||||
}
|
||||
float _Complex div_float_cc(float _Complex a, float _Complex b) {
|
||||
// X86-LABEL: @div_float_cc(
|
||||
// X86-NOT: fdiv
|
||||
// X86: call <2 x float> @__divsc3(
|
||||
// X86: call {{.*}} @__divsc3(
|
||||
// X86: ret
|
||||
return a / b;
|
||||
}
|
||||
|
@ -209,7 +211,7 @@ double _Complex mul_double_rc(double a, double _Complex b) {
|
|||
double _Complex mul_double_cc(double _Complex a, double _Complex b) {
|
||||
// X86-LABEL: @mul_double_cc(
|
||||
// X86-NOT: fmul
|
||||
// X86: call { double, double } @__muldc3(
|
||||
// X86: call {{.*}} @__muldc3(
|
||||
// X86: ret
|
||||
return a * b;
|
||||
}
|
||||
|
@ -232,14 +234,14 @@ double _Complex div_double_cr(double _Complex a, double b) {
|
|||
double _Complex div_double_rc(double a, double _Complex b) {
|
||||
// X86-LABEL: @div_double_rc(
|
||||
// X86-NOT: fdiv
|
||||
// X86: call { double, double } @__divdc3(
|
||||
// X86: call {{.*}} @__divdc3(
|
||||
// X86: ret
|
||||
return a / b;
|
||||
}
|
||||
double _Complex div_double_cc(double _Complex a, double _Complex b) {
|
||||
// X86-LABEL: @div_double_cc(
|
||||
// X86-NOT: fdiv
|
||||
// X86: call { double, double } @__divdc3(
|
||||
// X86: call {{.*}} @__divdc3(
|
||||
// X86: ret
|
||||
return a / b;
|
||||
}
|
||||
|
@ -331,7 +333,7 @@ long double _Complex mul_long_double_rc(long double a, long double _Complex b) {
|
|||
long double _Complex mul_long_double_cc(long double _Complex a, long double _Complex b) {
|
||||
// X86-LABEL: @mul_long_double_cc(
|
||||
// X86-NOT: fmul
|
||||
// X86: call { x86_fp80, x86_fp80 } @__mulxc3(
|
||||
// X86: call {{.*}} @__mulxc3(
|
||||
// X86: ret
|
||||
return a * b;
|
||||
}
|
||||
|
@ -354,14 +356,14 @@ long double _Complex div_long_double_cr(long double _Complex a, long double b) {
|
|||
long double _Complex div_long_double_rc(long double a, long double _Complex b) {
|
||||
// X86-LABEL: @div_long_double_rc(
|
||||
// X86-NOT: fdiv
|
||||
// X86: call { x86_fp80, x86_fp80 } @__divxc3(
|
||||
// X86: call {{.*}} @__divxc3(
|
||||
// X86: ret
|
||||
return a / b;
|
||||
}
|
||||
long double _Complex div_long_double_cc(long double _Complex a, long double _Complex b) {
|
||||
// X86-LABEL: @div_long_double_cc(
|
||||
// X86-NOT: fdiv
|
||||
// X86: call { x86_fp80, x86_fp80 } @__divxc3(
|
||||
// X86: call {{.*}} @__divxc3(
|
||||
// X86: ret
|
||||
return a / b;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue