Skip to content

Commit 77682f7

Browse files
committed
Address review comments
- remove the wrapper files - simplify code
1 parent 2215134 commit 77682f7

File tree

3 files changed

+22
-36
lines changed

3 files changed

+22
-36
lines changed

flang/lib/Evaluate/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ add_flang_library(FortranEvaluate
5858
tools.cpp
5959
type.cpp
6060
variable.cpp
61-
wrappers.c
6261

6362
LINK_LIBS
6463
FortranCommon

flang/lib/Evaluate/intrinsics-library.cpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,25 +278,37 @@ static std::complex<HostT> StdPowF2B(
278278
}
279279

280280
#ifdef _AIX
281+
#ifdef __clang_major__
282+
#pragma clang diagnostic ignored "-Wc99-extensions"
283+
#endif
284+
281285
extern "C" {
282-
void csqrtf_wrapper(const float[], float[]);
283-
void csqrt_wrapper(const double[], double[]);
284-
} // extern "C"
286+
float _Complex csqrtf(float _Complex);
287+
double _Complex csqrt(double _Complex);
288+
}
285289
#endif
286290

287291
template <typename HostT>
288292
static std::complex<HostT> CSqrt(const std::complex<HostT> &x) {
289293
std::complex<HostT> res;
290-
#if _AIX
291-
HostT y[2]{x.real(), x.imag()};
292-
HostT r[2];
294+
#ifdef _AIX
293295
if constexpr (std::is_same_v<HostT, float>) {
294-
csqrtf_wrapper(y, r);
296+
float _Complex c;
297+
reinterpret_cast<HostT(&)[2]>(c)[0] = x.real();
298+
reinterpret_cast<HostT(&)[2]>(c)[1] = x.imag();
299+
float _Complex r{csqrtf(c)};
300+
res.real(reinterpret_cast<HostT(&)[2]>(r)[0]);
301+
res.imag(reinterpret_cast<HostT(&)[2]>(r)[1]);
295302
} else if constexpr (std::is_same_v<HostT, double>) {
296-
csqrt_wrapper(y, r);
303+
double _Complex c;
304+
reinterpret_cast<HostT(&)[2]>(c)[0] = x.real();
305+
reinterpret_cast<HostT(&)[2]>(c)[1] = x.imag();
306+
double _Complex r{csqrt(c)};
307+
res.real(reinterpret_cast<HostT(&)[2]>(r)[0]);
308+
res.imag(reinterpret_cast<HostT(&)[2]>(r)[1]);
309+
} else {
310+
assert("bad complex component type");
297311
}
298-
res.real(r[0]);
299-
res.imag(r[1]);
300312
#else
301313
res = std::sqrt(x);
302314
#endif

flang/lib/Evaluate/wrappers.c

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)