Skip to content

Commit 803afb7

Browse files
committed
[flang][rt] Attempt to support some complex pow on the device
1 parent 061f87f commit 803afb7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

flang-rt/lib/runtime/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(supported_sources
2323
assign.cpp
2424
buffer.cpp
2525
character.cpp
26+
complex-powi.cpp
2627
connection.cpp
2728
copy.cpp
2829
derived-api.cpp

flang-rt/lib/runtime/complex-powi.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "flang/Common/api-attrs.h"
910
#include "flang/Common/float128.h"
1011
#include "flang/Runtime/cpp-type.h"
1112
#include "flang/Runtime/entry-names.h"
@@ -18,7 +19,7 @@ namespace Fortran::runtime {
1819
#pragma clang diagnostic ignored "-Wc99-extensions"
1920
#endif
2021

21-
template <typename C, typename I> C tgpowi(C base, I exp) {
22+
template <typename C, typename I> inline RT_API_ATTRS C tgpowi(C base, I exp) {
2223
if (exp == 0) {
2324
return C{1};
2425
}
@@ -65,21 +66,23 @@ template <typename C, typename I> C tgpowi(C base, I exp) {
6566
#ifndef _MSC_VER
6667
// With most compilers, C complex is implemented as a builtin type that may have
6768
// specific ABI requirements
68-
extern "C" float _Complex RTNAME(cpowi)(float _Complex base, std::int32_t exp) {
69+
extern "C" RT_API_ATTRS CppTypeFor<TypeCategory::Complex, 4> RTNAME(cpowi)(
70+
CppTypeFor<TypeCategory::Complex, 4> base, std::int32_t exp) {
6971
return tgpowi(base, exp);
7072
}
7173

72-
extern "C" double _Complex RTNAME(zpowi)(
73-
double _Complex base, std::int32_t exp) {
74+
extern "C" RT_API_ATTRS CppTypeFor<TypeCategory::Complex, 8> RTNAME(zpowi)(
75+
CppTypeFor<TypeCategory::Complex, 8> base, std::int32_t exp) {
7476
return tgpowi(base, exp);
7577
}
7678

77-
extern "C" float _Complex RTNAME(cpowk)(float _Complex base, std::int64_t exp) {
79+
extern "C" RT_API_ATTRS CppTypeFor<TypeCategory::Complex, 4> RTNAME(cpowk)(
80+
CppTypeFor<TypeCategory::Complex, 4> base, std::int64_t exp) {
7881
return tgpowi(base, exp);
7982
}
8083

81-
extern "C" double _Complex RTNAME(zpowk)(
82-
double _Complex base, std::int64_t exp) {
84+
extern "C" RT_API_ATTRS CppTypeFor<TypeCategory::Complex, 8> RTNAME(zpowk)(
85+
CppTypeFor<TypeCategory::Complex, 8> base, std::int64_t exp) {
8386
return tgpowi(base, exp);
8487
}
8588

0 commit comments

Comments
 (0)