Skip to content

Commit 53d598b

Browse files
authored
Merge pull request #1028 from flang-compiler/jpr-cherry-picking
Cherry pick all flang commits from LLVM since last cherry-picking
2 parents 2a40e62 + 2eb81ad commit 53d598b

20 files changed

+553
-36
lines changed

flang/include/flang/Evaluate/tools.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,23 @@ class ScalarConstantExpander {
992992
std::optional<ConstantSubscripts> lbounds_;
993993
};
994994

995+
// Given a collection of element values, package them as a Constant.
996+
// If the type is Character or a derived type, take the length or type
997+
// (resp.) from a another Constant.
998+
template <typename T>
999+
Constant<T> PackageConstant(std::vector<Scalar<T>> &&elements,
1000+
const Constant<T> &reference, const ConstantSubscripts &shape) {
1001+
if constexpr (T::category == TypeCategory::Character) {
1002+
return Constant<T>{
1003+
reference.LEN(), std::move(elements), ConstantSubscripts{shape}};
1004+
} else if constexpr (T::category == TypeCategory::Derived) {
1005+
return Constant<T>{reference.GetType().GetDerivedTypeSpec(),
1006+
std::move(elements), ConstantSubscripts{shape}};
1007+
} else {
1008+
return Constant<T>{std::move(elements), ConstantSubscripts{shape}};
1009+
}
1010+
}
1011+
9951012
} // namespace Fortran::evaluate
9961013

9971014
namespace Fortran::semantics {

flang/lib/Evaluate/fold-character.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ Expr<Type<TypeCategory::Character, KIND>> FoldIntrinsicFunction(
102102
CharacterUtils<KIND>::TRIM(std::get<Scalar<T>>(*scalar))}};
103103
}
104104
}
105-
// TODO: cshift, eoshift, maxloc, minloc, pack, spread, transfer,
106-
// transpose, unpack
105+
// TODO: findloc, maxloc, minloc, transfer
107106
return Expr<T>{std::move(funcRef)};
108107
}
109108

flang/lib/Evaluate/fold-complex.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ Expr<Type<TypeCategory::Complex, KIND>> FoldIntrinsicFunction(
6060
} else if (name == "sum") {
6161
return FoldSum<T>(context, std::move(funcRef));
6262
}
63-
// TODO: cshift, dot_product, eoshift, matmul, pack, spread, transfer,
64-
// transpose, unpack
63+
// TODO: dot_product, matmul, transfer
6564
return Expr<T>{std::move(funcRef)};
6665
}
6766

0 commit comments

Comments
 (0)