1//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the methods in the TargetOptions.
10//
11//===----------------------------------------------------------------------===//
12
13#include "llvm/CodeGen/MachineFrameInfo.h"
14#include "llvm/CodeGen/MachineFunction.h"
15#include "llvm/CodeGen/TargetFrameLowering.h"
16#include "llvm/CodeGen/TargetSubtargetInfo.h"
17#include "llvm/Target/TargetOptions.h"
18using namespace llvm;
19
20/// DisableFramePointerElim - This returns true if frame pointer elimination
21/// optimization should be disabled for the given machine function.
22bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
23 FramePointerKind FP = MF.getFrameInfo().getFramePointerPolicy();
24 switch (FP) {
25 case FramePointerKind::All:
26 return true;
27 case FramePointerKind::NonLeaf:
28 case FramePointerKind::NonLeafNoReserve:
29 return MF.getFrameInfo().hasCalls();
30 case FramePointerKind::None:
31 case FramePointerKind::Reserved:
32 return false;
33 }
34 llvm_unreachable("unknown frame pointer flag");
35}
36
37bool TargetOptions::FramePointerIsReserved(const MachineFunction &MF) const {
38 FramePointerKind FP = MF.getFrameInfo().getFramePointerPolicy();
39 switch (FP) {
40 case FramePointerKind::All:
41 case FramePointerKind::NonLeaf:
42 case FramePointerKind::Reserved:
43 return true;
44 case FramePointerKind::NonLeafNoReserve:
45 return MF.getFrameInfo().hasCalls();
46 case FramePointerKind::None:
47 return false;
48 }
49 llvm_unreachable("unknown frame pointer flag");
50}
51
52/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
53/// that the rounding mode of the FPU can change from its default.
54bool TargetOptions::HonorSignDependentRoundingFPMath() const {
55 return HonorSignDependentRoundingFPMathOption;
56}
57
58/// NOTE: There are targets that still do not support the debug entry values
59/// production and that is being controlled with the SupportsDebugEntryValues.
60/// In addition, SCE debugger does not have the feature implemented, so prefer
61/// not to emit the debug entry values in that case.
62/// The EnableDebugEntryValues can be used for the testing purposes.
63bool TargetOptions::ShouldEmitDebugEntryValues() const {
64 return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) ||
65 EnableDebugEntryValues;
66}
67