1 //===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
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
7 //===----------------------------------------------------------------------===//
9 // This file implements the methods in the TargetOptions.
11 //===----------------------------------------------------------------------===//
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/IR/Function.h"
18 #include "llvm/Target/TargetOptions.h"
21 /// DisableFramePointerElim - This returns true if frame pointer elimination
22 /// optimization should be disabled for the given machine function.
23 bool TargetOptions::DisableFramePointerElim(const MachineFunction
&MF
) const {
24 // Check to see if the target want to forcably keep frame pointer.
25 if (MF
.getSubtarget().getFrameLowering()->keepFramePointer(MF
))
28 const Function
&F
= MF
.getFunction();
30 if (!F
.hasFnAttribute("frame-pointer"))
32 StringRef FP
= F
.getFnAttribute("frame-pointer").getValueAsString();
36 return MF
.getFrameInfo().hasCalls();
39 llvm_unreachable("unknown frame pointer flag");
42 /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
43 /// that the rounding mode of the FPU can change from its default.
44 bool TargetOptions::HonorSignDependentRoundingFPMath() const {
45 return !UnsafeFPMath
&& HonorSignDependentRoundingFPMathOption
;
48 /// NOTE: There are targets that still do not support the debug entry values
49 /// production and that is being controlled with the SupportsDebugEntryValues.
50 /// In addition, SCE debugger does not have the feature implemented, so prefer
51 /// not to emit the debug entry values in that case.
52 /// The EnableDebugEntryValues can be used for the testing purposes.
53 bool TargetOptions::ShouldEmitDebugEntryValues() const {
54 return (SupportsDebugEntryValues
&& DebuggerTuning
!= DebuggerKind::SCE
) ||
55 EnableDebugEntryValues
;