9#ifndef FORTRAN_EVALUATE_TYPEKINDTRAITS_H_
10#define FORTRAN_EVALUATE_TYPEKINDTRAITS_H_
12#include "flang/Common/Fortran-consts.h"
13#include "flang/Evaluate/common.h"
14#include "flang/Evaluate/complex-value.h"
15#include "flang/Evaluate/integer-value.h"
16#include "flang/Evaluate/logical-value.h"
17#include "flang/Evaluate/real-value.h"
18#include "flang/Evaluate/type.h"
20namespace Fortran::evaluate::value {
46template <common::TypeCategory CAT,
int KIND>
struct TypeKind;
49 static constexpr common::TypeCategory category{common::TypeCategory::Integer};
50 static constexpr int kind{KIND};
51 static constexpr int bits{value::IntegerValue::bits(KIND)};
53 using UnsignedT = common::HostUnsignedIntType<bits>;
54 using SignedT = common::HostSignedIntType<bits>;
55 using HostT = SignedT;
61using IntegerKindTypes = std::tuple<TypeKind<TypeCategory::Integer, 1>,
66 static constexpr common::TypeCategory category{
67 common::TypeCategory::Unsigned};
68 static constexpr int kind{KIND};
69 static constexpr int bits{value::IntegerValue::bits(KIND)};
71 using UnsignedT = common::HostUnsignedIntType<bits>;
72 using SignedT = common::HostSignedIntType<bits>;
73 using HostT = UnsignedT;
79using UnsignedKindTypes = std::tuple<TypeKind<TypeCategory::Unsigned, 1>,
84 static constexpr common::TypeCategory category{common::TypeCategory::Logical};
85 static constexpr int kind{KIND};
86 static constexpr int bits{value::LogicalValue::bits(KIND)};
88 using UnsignedT = common::HostUnsignedIntType<bits>;
89 using SignedT = common::HostSignedIntType<bits>;
90 using HostT = UnsignedT;
96using LogicalKindTypes = std::tuple<TypeKind<TypeCategory::Logical, 1>,
114template <
int KIND>
struct TypeKind<
common::TypeCategory::Real, KIND> {
115 static constexpr common::TypeCategory category{common::TypeCategory::Real};
116 static constexpr int kind{KIND};
117 static constexpr int bits{value::RealValue::bits(KIND)};
119 using UnsignedT = common::HostUnsignedIntType<bits>;
120 using SignedT = common::HostSignedIntType<bits>;
121 using HostT =
typename detail::RealHostType<bits>::type;
122 using Scalar = value::RealValue;
123 using FortranType = Fortran::evaluate::Type<common::TypeCategory::Real>;
124 static constexpr DynamicType GetType() {
return DynamicType{category, kind}; }
133 static constexpr common::TypeCategory category{common::TypeCategory::Complex};
134 static constexpr int kind{KIND};
142using ComplexKindTypes = std::tuple<TypeKind<TypeCategory::Complex, 2>,
148 static constexpr common::TypeCategory category{
149 common::TypeCategory::Character};
150 static constexpr int kind{1};
152 using StringT = std::basic_string<CharT>;
160 static constexpr common::TypeCategory category{
161 common::TypeCategory::Character};
162 static constexpr int kind{2};
163 using CharT = char16_t;
164 using StringT = std::basic_string<CharT>;
172 static constexpr common::TypeCategory category{
173 common::TypeCategory::Character};
174 static constexpr int kind{4};
175 using CharT = char32_t;
176 using StringT = std::basic_string<CharT>;
183using CharacterKindTypes = std::tuple<TypeKind<TypeCategory::Character, 1>,
186using AllIntrinsicKindTypes =
187 common::CombineTuples<IntegerKindTypes, UnsignedKindTypes, LogicalKindTypes,
188 RealKindTypes, ComplexKindTypes, CharacterKindTypes>;
Definition character-value.h:34
Definition complex-value.h:28
std::size_t bytesStored() const
Number of bytes accessed by FromRawBytes/StoreRawBytes.
Definition complex-value.h:87
Definition integer-value.h:34
std::size_t bytesStored() const
Number of bytes accessed by FromRawBytes/StoreRawBytes.
Definition integer-value.h:101
Definition logical-value.h:25
std::size_t bytesStored() const
Number of bytes accessed by FromRawBytes/StoreRawBytes.
Definition logical-value.h:69
std::size_t bytesStored() const
Number of bytes accessed by FromRawBytes/StoreRawBytes.
Definition real-value.h:84
Definition bit-population-count.h:20
Definition typekind-traits.h:46
Definition typekind-traits.h:103