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/Target/TargetMachine.h"
18namespace Fortran::tools {
20[[maybe_unused]]
inline static void setUpTargetCharacteristics(
21 Fortran::evaluate::TargetCharacteristics &targetCharacteristics,
22 const llvm::TargetMachine &targetMachine,
23 const Fortran::frontend::TargetOptions &targetOptions,
24 const std::string &compilerVersion,
const std::string &compilerOptions) {
26 const llvm::Triple &targetTriple{targetMachine.getTargetTriple()};
28 if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
29 targetCharacteristics.set_hasSubnormalFlushingControl(3);
30 targetCharacteristics.set_hasSubnormalFlushingControl(4);
31 targetCharacteristics.set_hasSubnormalFlushingControl(8);
33 targetCharacteristics.set_hasSubnormalExceptionSupport(3);
34 targetCharacteristics.set_hasSubnormalExceptionSupport(4);
35 targetCharacteristics.set_hasSubnormalExceptionSupport(8);
38 if (targetTriple.isARM() || targetTriple.isAArch64()) {
39 targetCharacteristics.set_haltingSupportIsUnknownAtCompileTime();
40 targetCharacteristics.set_ieeeFeature(
41 evaluate::IeeeFeature::Halting,
false);
42 targetCharacteristics.set_ieeeFeature(
43 evaluate::IeeeFeature::Standard,
false);
44 targetCharacteristics.set_hasSubnormalFlushingControl(3);
45 targetCharacteristics.set_hasSubnormalFlushingControl(4);
46 targetCharacteristics.set_hasSubnormalFlushingControl(8);
49 switch (targetTriple.getArch()) {
50 case llvm::Triple::ArchType::amdgcn:
51 case llvm::Triple::ArchType::x86_64:
54 targetCharacteristics.DisableType(
55 Fortran::common::TypeCategory::Real, 10);
56 targetCharacteristics.DisableType(
57 Fortran::common::TypeCategory::Complex, 10);
63#ifdef FLANG_RUNTIME_F128_MATH_LIB
64 constexpr bool f128Support =
true;
66 constexpr bool f128Support =
true;
68 constexpr bool f128Support =
false;
71 if constexpr (!f128Support) {
72 targetCharacteristics.DisableType(Fortran::common::TypeCategory::Real, 16);
73 targetCharacteristics.DisableType(
74 Fortran::common::TypeCategory::Complex, 16);
78 targetCharacteristics.DisableType(common::TypeCategory::Real, realKind);
79 targetCharacteristics.DisableType(common::TypeCategory::Complex, realKind);
83 targetCharacteristics.DisableType(common::TypeCategory::Integer, intKind);
85 targetCharacteristics.set_compilerOptionsString(compilerOptions)
86 .set_compilerVersionString(compilerVersion);
88 if (targetTriple.isPPC())
89 targetCharacteristics.set_isPPC(
true);
91 if (targetTriple.isSPARC())
92 targetCharacteristics.set_isSPARC(
true);
94 if (targetTriple.isOSWindows())
95 targetCharacteristics.set_isOSWindows(
true);
98 targetCharacteristics.set_integerKindForPointer(
99 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