2525#include " flang/Common/idioms.h"
2626#include " flang/Common/real.h"
2727#include " flang/Common/template.h"
28+ #include " flang/Common/type-kinds.h"
2829#include " flang/Support/Fortran-features.h"
2930#include " flang/Support/Fortran.h"
3031#include < cinttypes>
@@ -62,28 +63,6 @@ using LogicalResult = Type<TypeCategory::Logical, 4>;
6263using LargestReal = Type<TypeCategory::Real, 16 >;
6364using Ascii = Type<TypeCategory::Character, 1 >;
6465
65- // A predicate that is true when a kind value is a kind that could possibly
66- // be supported for an intrinsic type category on some target instruction
67- // set architecture.
68- static constexpr bool IsValidKindOfIntrinsicType (
69- TypeCategory category, std::int64_t kind) {
70- switch (category) {
71- case TypeCategory::Integer:
72- case TypeCategory::Unsigned:
73- return kind == 1 || kind == 2 || kind == 4 || kind == 8 || kind == 16 ;
74- case TypeCategory::Real:
75- case TypeCategory::Complex:
76- return kind == 2 || kind == 3 || kind == 4 || kind == 8 || kind == 10 ||
77- kind == 16 ;
78- case TypeCategory::Character:
79- return kind == 1 || kind == 2 || kind == 4 ;
80- case TypeCategory::Logical:
81- return kind == 1 || kind == 2 || kind == 4 || kind == 8 ;
82- default :
83- return false ;
84- }
85- }
86-
8766// DynamicType is meant to be suitable for use as the result type for
8867// GetType() functions and member functions; consequently, it must be
8968// capable of being used in a constexpr context. So it does *not*
@@ -95,15 +74,15 @@ static constexpr bool IsValidKindOfIntrinsicType(
9574class DynamicType {
9675public:
9776 constexpr DynamicType (TypeCategory cat, int k) : category_{cat}, kind_{k} {
98- CHECK (IsValidKindOfIntrinsicType (category_, kind_));
77+ CHECK (common:: IsValidKindOfIntrinsicType (category_, kind_));
9978 }
10079 DynamicType (int charKind, const semantics::ParamValue &len);
10180 // When a known length is presented, resolve it to its effective
10281 // length of zero if it is negative.
10382 constexpr DynamicType (int k, std::int64_t len)
10483 : category_{TypeCategory::Character}, kind_{k}, knownLength_{
10584 len >= 0 ? len : 0 } {
106- CHECK (IsValidKindOfIntrinsicType (category_, kind_));
85+ CHECK (common:: IsValidKindOfIntrinsicType (category_, kind_));
10786 }
10887 explicit constexpr DynamicType (
10988 const semantics::DerivedTypeSpec &dt, bool poly = false )
@@ -360,7 +339,7 @@ using IndirectSubscriptIntegerExpr =
360339// category that could possibly be supported on any target.
361340template <TypeCategory CATEGORY, int KIND>
362341using CategoryKindTuple =
363- std::conditional_t <IsValidKindOfIntrinsicType(CATEGORY, KIND),
342+ std::conditional_t <common:: IsValidKindOfIntrinsicType(CATEGORY, KIND),
364343 std::tuple<Type<CATEGORY, KIND>>, std::tuple<>>;
365344
366345template <TypeCategory CATEGORY, int ... KINDS>
0 commit comments