9#ifndef FORTRAN_TOOLS_TARGET_SETUP_H
10#define FORTRAN_TOOLS_TARGET_SETUP_H
12#include "flang/Common/float128.h"
13#include "flang/Evaluate/target.h"
15#include "llvm/TargetParser/Triple.h"
17namespace Fortran::tools {
19[[maybe_unused]]
inline static void setUpTargetCharacteristics(
20 Fortran::evaluate::TargetCharacteristics &targetCharacteristics,
21 const llvm::Triple &targetTriple,
22 const Fortran::frontend::TargetOptions &targetOptions,
23 const std::string &compilerVersion,
const std::string &compilerOptions) {
25 if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
26 targetCharacteristics.set_hasSubnormalFlushingControl(3);
27 targetCharacteristics.set_hasSubnormalFlushingControl(4);
28 targetCharacteristics.set_hasSubnormalFlushingControl(8);
30 targetCharacteristics.set_hasSubnormalExceptionSupport(3);
31 targetCharacteristics.set_hasSubnormalExceptionSupport(4);
32 targetCharacteristics.set_hasSubnormalExceptionSupport(8);
35 if (targetTriple.isARM() || targetTriple.isAArch64()) {
36 targetCharacteristics.set_haltingSupportIsUnknownAtCompileTime();
37 targetCharacteristics.set_ieeeFeature(
38 evaluate::IeeeFeature::Halting,
false);
39 targetCharacteristics.set_ieeeFeature(
40 evaluate::IeeeFeature::Standard,
false);
41 targetCharacteristics.set_hasSubnormalFlushingControl(3);
42 targetCharacteristics.set_hasSubnormalFlushingControl(4);
43 targetCharacteristics.set_hasSubnormalFlushingControl(8);
46 switch (targetTriple.getArch()) {
47 case llvm::Triple::ArchType::amdgpu:
48 case llvm::Triple::ArchType::x86_64:
51 targetCharacteristics.DisableType(
52 Fortran::common::TypeCategory::Real, 10);
53 targetCharacteristics.DisableType(
54 Fortran::common::TypeCategory::Complex, 10);
60#ifdef FLANG_RUNTIME_F128_MATH_LIB
61 constexpr bool f128Support =
true;
63 constexpr bool f128Support =
true;
65 constexpr bool f128Support =
false;
68 if constexpr (!f128Support) {
69 targetCharacteristics.DisableType(Fortran::common::TypeCategory::Real, 16);
70 targetCharacteristics.DisableType(
71 Fortran::common::TypeCategory::Complex, 16);
75 targetCharacteristics.DisableType(common::TypeCategory::Real, realKind);
76 targetCharacteristics.DisableType(common::TypeCategory::Complex, realKind);
80 targetCharacteristics.DisableType(common::TypeCategory::Integer, intKind);
82 targetCharacteristics.set_compilerOptionsString(compilerOptions)
83 .set_compilerVersionString(compilerVersion);
85 if (targetTriple.isPPC())
86 targetCharacteristics.set_isPPC(
true);
88 if (targetTriple.isSPARC())
89 targetCharacteristics.set_isSPARC(
true);
91 if (targetTriple.isOSWindows())
92 targetCharacteristics.set_isOSWindows(
true);
95 targetCharacteristics.set_integerKindForPointer(
96 targetTriple.getArchPointerBitWidth() / 8);
std::vector< int > disabledRealKinds
The real KINDs disabled for this target.
Definition TargetOptions.h:46
std::vector< int > disabledIntegerKinds
The integer KINDs disabled for this target.
Definition TargetOptions.h:49