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(
22 const llvm::TargetMachine &targetMachine,
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.DisableType(
30 Fortran::common::TypeCategory::Real, 10);
32 if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
33 targetCharacteristics.set_hasSubnormalFlushingControl(3);
34 targetCharacteristics.set_hasSubnormalFlushingControl(4);
35 targetCharacteristics.set_hasSubnormalFlushingControl(8);
37 if (targetTriple.isARM() || targetTriple.isAArch64()) {
38 targetCharacteristics.set_haltingSupportIsUnknownAtCompileTime();
39 targetCharacteristics.set_ieeeFeature(
40 evaluate::IeeeFeature::Halting,
false);
42 targetCharacteristics.set_ieeeFeature(evaluate::IeeeFeature::Halting);
49#ifdef FLANG_RUNTIME_F128_MATH_LIB
51 constexpr bool f128Support =
true;
54 constexpr bool f128Support =
true;
56 constexpr bool f128Support =
false;
59 if constexpr (!f128Support)
60 targetCharacteristics.DisableType(Fortran::common::TypeCategory::Real, 16);
63 targetCharacteristics.DisableType(common::TypeCategory::Real, realKind);
66 targetCharacteristics.DisableType(common::TypeCategory::Integer, intKind);
68 targetCharacteristics.set_compilerOptionsString(compilerOptions)
69 .set_compilerVersionString(compilerVersion);
71 if (targetTriple.isPPC())
72 targetCharacteristics.set_isPPC(
true);
74 if (targetTriple.isSPARC())
75 targetCharacteristics.set_isSPARC(
true);
77 if (targetTriple.isOSWindows())
78 targetCharacteristics.set_isOSWindows(
true);
Options for controlling the target.
Definition: TargetOptions.h:27
std::vector< int > disabledRealKinds
The real KINDs disabled for this target.
Definition: TargetOptions.h:43
std::vector< int > disabledIntegerKinds
The integer KINDs disabled for this target.
Definition: TargetOptions.h:46