"conjf", "conj", benefit);
patterns.add<ScalarOpToLibmCall<complex::AbsOp, FloatTypeResolver>>(
patterns.getContext(), "cabsf", "cabs", benefit);
+ patterns.add<ScalarOpToLibmCall<complex::AngleOp, FloatTypeResolver>>(
+ patterns.getContext(), "cargf", "carg", benefit);
}
namespace {
ConversionTarget target(getContext());
target.addLegalDialect<func::FuncDialect>();
target.addIllegalOp<complex::PowOp, complex::SqrtOp, complex::TanhOp,
- complex::AbsOp>();
+ complex::AbsOp, complex::AngleOp>();
if (failed(applyPartialConversion(module, target, std::move(patterns))))
signalPassFailure();
}
%double_result = complex.abs %double : complex<f64>
// CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]]
return %float_result, %double_result : f32, f64
+}
+
+// CHECK-LABEL: func @carg_caller
+// CHECK-SAME: %[[FLOAT:.*]]: complex<f32>
+// CHECK-SAME: %[[DOUBLE:.*]]: complex<f64>
+func.func @carg_caller(%float: complex<f32>, %double: complex<f64>) -> (f32, f64) {
+ // CHECK: %[[FLOAT_RESULT:.*]] = call @cargf(%[[FLOAT]])
+ %float_result = complex.angle %float : complex<f32>
+ // CHECK: %[[DOUBLE_RESULT:.*]] = call @carg(%[[DOUBLE]])
+ %double_result = complex.angle %double : complex<f64>
+ // CHECK: return %[[FLOAT_RESULT]], %[[DOUBLE_RESULT]]
+ return %float_result, %double_result : f32, f64
}
\ No newline at end of file