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"
17namespace Fortran::tools {
19[[maybe_unused]]
inline static void setUpTargetCharacteristics(
20 Fortran::evaluate::TargetCharacteristics &targetCharacteristics,
21 const llvm::TargetMachine &targetMachine,
22 const Fortran::frontend::TargetOptions &targetOptions,
23 const std::string &compilerVersion,
const std::string &compilerOptions) {
25 const llvm::Triple &targetTriple{targetMachine.getTargetTriple()};
27 if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
28 targetCharacteristics.set_hasSubnormalFlushingControl(3);
29 targetCharacteristics.set_hasSubnormalFlushingControl(4);
30 targetCharacteristics.set_hasSubnormalFlushingControl(8);
32 targetCharacteristics.set_hasSubnormalExceptionSupport(3);
33 targetCharacteristics.set_hasSubnormalExceptionSupport(4);
34 targetCharacteristics.set_hasSubnormalExceptionSupport(8);
37 if (targetTriple.isARM() || targetTriple.isAArch64()) {
38 targetCharacteristics.set_haltingSupportIsUnknownAtCompileTime();
39 targetCharacteristics.set_ieeeFeature(
40 evaluate::IeeeFeature::Halting,
false);
41 targetCharacteristics.set_ieeeFeature(
42 evaluate::IeeeFeature::Standard,
false);
43 targetCharacteristics.set_hasSubnormalFlushingControl(3);
44 targetCharacteristics.set_hasSubnormalFlushingControl(4);
45 targetCharacteristics.set_hasSubnormalFlushingControl(8);
48 switch (targetTriple.getArch()) {
49 case llvm::Triple::ArchType::amdgpu:
50 case llvm::Triple::ArchType::x86_64:
53 targetCharacteristics.DisableType(
54 Fortran::common::TypeCategory::Real, 10);
55 targetCharacteristics.DisableType(
56 Fortran::common::TypeCategory::Complex, 10);
62#ifdef FLANG_RUNTIME_F128_MATH_LIB
63 constexpr bool f128Support =
true;
65 constexpr bool f128Support =
true;
67 constexpr bool f128Support =
false;
70 if constexpr (!f128Support) {
71 targetCharacteristics.DisableType(Fortran::common::TypeCategory::Real, 16);
72 targetCharacteristics.DisableType(
73 Fortran::common::TypeCategory::Complex, 16);
77 targetCharacteristics.DisableType(common::TypeCategory::Real, realKind);
78 targetCharacteristics.DisableType(common::TypeCategory::Complex, realKind);
82 targetCharacteristics.DisableType(common::TypeCategory::Integer, intKind);
84 targetCharacteristics.set_compilerOptionsString(compilerOptions)
85 .set_compilerVersionString(compilerVersion);
87 if (targetTriple.isPPC())
88 targetCharacteristics.set_isPPC(
true);
90 if (targetTriple.isSPARC())
91 targetCharacteristics.set_isSPARC(
true);
93 if (targetTriple.isOSWindows())
94 targetCharacteristics.set_isOSWindows(
true);
97 targetCharacteristics.set_integerKindForPointer(
98 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