2020-02-25 23:11:52 +08:00
|
|
|
//===-- lib/Common/default-kinds.cpp --------------------------------------===//
|
2018-10-16 06:28:47 +08:00
|
|
|
//
|
2019-12-21 04:52:07 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-10-16 06:28:47 +08:00
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-10-16 06:28:47 +08:00
|
|
|
|
2020-02-25 23:11:52 +08:00
|
|
|
#include "flang/Common/default-kinds.h"
|
|
|
|
#include "flang/Common/idioms.h"
|
2018-10-16 06:28:47 +08:00
|
|
|
|
2019-01-19 04:40:47 +08:00
|
|
|
namespace Fortran::common {
|
2018-10-16 06:28:47 +08:00
|
|
|
|
2018-10-17 05:42:22 +08:00
|
|
|
IntrinsicTypeDefaultKinds::IntrinsicTypeDefaultKinds() {
|
|
|
|
#if __x86_64__
|
|
|
|
quadPrecisionKind_ = 10;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultIntegerKind(
|
|
|
|
int k) {
|
|
|
|
defaultIntegerKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-12-24 09:12:53 +08:00
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_subscriptIntegerKind(
|
|
|
|
int k) {
|
|
|
|
subscriptIntegerKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-01-04 08:32:23 +08:00
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_sizeIntegerKind(
|
|
|
|
int k) {
|
|
|
|
sizeIntegerKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-10-17 05:42:22 +08:00
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultRealKind(
|
|
|
|
int k) {
|
|
|
|
defaultRealKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_doublePrecisionKind(
|
|
|
|
int k) {
|
|
|
|
doublePrecisionKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_quadPrecisionKind(
|
|
|
|
int k) {
|
|
|
|
quadPrecisionKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultCharacterKind(
|
|
|
|
int k) {
|
|
|
|
defaultCharacterKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntrinsicTypeDefaultKinds &IntrinsicTypeDefaultKinds::set_defaultLogicalKind(
|
|
|
|
int k) {
|
|
|
|
defaultLogicalKind_ = k;
|
|
|
|
return *this;
|
|
|
|
}
|
2018-10-16 06:28:47 +08:00
|
|
|
|
|
|
|
int IntrinsicTypeDefaultKinds::GetDefaultKind(TypeCategory category) const {
|
|
|
|
switch (category) {
|
2020-03-29 12:00:16 +08:00
|
|
|
case TypeCategory::Integer:
|
|
|
|
return defaultIntegerKind_;
|
2018-10-16 06:28:47 +08:00
|
|
|
case TypeCategory::Real:
|
2020-03-29 12:00:16 +08:00
|
|
|
case TypeCategory::Complex:
|
|
|
|
return defaultRealKind_;
|
|
|
|
case TypeCategory::Character:
|
|
|
|
return defaultCharacterKind_;
|
|
|
|
case TypeCategory::Logical:
|
|
|
|
return defaultLogicalKind_;
|
|
|
|
default:
|
|
|
|
CRASH_NO_CASE;
|
|
|
|
return 0;
|
2018-10-16 06:28:47 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-29 12:00:16 +08:00
|
|
|
} // namespace Fortran::common
|