9#ifndef FORTRAN_COMMON_TYPE_KINDS_H_
10#define FORTRAN_COMMON_TYPE_KINDS_H_
12#include "Fortran-consts.h"
18static constexpr int maxKind{16};
23static constexpr bool IsValidKindOfIntrinsicType(
24 TypeCategory category, std::int64_t kind) {
26 case TypeCategory::Integer:
27 case TypeCategory::Unsigned:
28 return kind == 1 || kind == 2 || kind == 4 || kind == 8 || kind == 16;
29 case TypeCategory::Real:
30 case TypeCategory::Complex:
31 return kind == 2 || kind == 3 || kind == 4 || kind == 8 || kind == 10 ||
33 case TypeCategory::Character:
34 return kind == 1 || kind == 2 || kind == 4;
35 case TypeCategory::Logical:
36 return kind == 1 || kind == 2 || kind == 4 || kind == 8;
42static constexpr int TypeSizeInBytes(TypeCategory category, std::int64_t kind) {
43 if (IsValidKindOfIntrinsicType(category, kind)) {
44 if (category == TypeCategory::Real || category == TypeCategory::Complex) {
45 int precision{PrecisionOfRealKind(kind)};
46 int bits{BitsForBinaryPrecision(precision)};
50 if (category == TypeCategory::Complex) {
Definition bit-population-count.h:20