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 targetCharacteristics.set_ieeeFeature(evaluate::IeeeFeature::Halting,
true);
30 if (targetTriple.getArch() == llvm::Triple::ArchType::x86_64) {
31 targetCharacteristics.set_hasSubnormalFlushingControl(3);
32 targetCharacteristics.set_hasSubnormalFlushingControl(4);
33 targetCharacteristics.set_hasSubnormalFlushingControl(8);
36 if (targetTriple.isARM() || targetTriple.isAArch64()) {
37 targetCharacteristics.set_haltingSupportIsUnknownAtCompileTime();
38 targetCharacteristics.set_ieeeFeature(
39 evaluate::IeeeFeature::Halting,
false);
40 targetCharacteristics.set_hasSubnormalFlushingControl(3);
41 targetCharacteristics.set_hasSubnormalFlushingControl(4);
42 targetCharacteristics.set_hasSubnormalFlushingControl(8);
45 if (targetTriple.getArch() != llvm::Triple::ArchType::x86_64) {
46 targetCharacteristics.DisableType(
47 Fortran::common::TypeCategory::Real, 10);
52#ifdef FLANG_RUNTIME_F128_MATH_LIB
53 constexpr bool f128Support =
true;
55 constexpr bool f128Support =
true;
57 constexpr bool f128Support =
false;
60 if constexpr (!f128Support)
61 targetCharacteristics.DisableType(Fortran::common::TypeCategory::Real, 16);
64 targetCharacteristics.DisableType(common::TypeCategory::Real, realKind);
67 targetCharacteristics.DisableType(common::TypeCategory::Integer, intKind);
69 targetCharacteristics.set_compilerOptionsString(compilerOptions)
70 .set_compilerVersionString(compilerVersion);
72 if (targetTriple.isPPC())
73 targetCharacteristics.set_isPPC(
true);
75 if (targetTriple.isSPARC())
76 targetCharacteristics.set_isSPARC(
true);
78 if (targetTriple.isOSWindows())
79 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