| 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/IR/Function.h" |
| 18 | #include "llvm/Target/TargetOptions.h" |
| 19 | using namespace llvm; |
| 20 | |
| 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 | FramePointerKind FP = MF.getFrameInfo().getFramePointerPolicy(); |
| 25 | switch (FP) { |
| 26 | case FramePointerKind::All: |
| 27 | return true; |
| 28 | case FramePointerKind::NonLeaf: |
| 29 | case FramePointerKind::NonLeafNoReserve: |
| 30 | return MF.getFrameInfo().hasCalls(); |
| 31 | case FramePointerKind::None: |
| 32 | case FramePointerKind::Reserved: |
| 33 | return false; |
| 34 | } |
| 35 | llvm_unreachable("unknown frame pointer flag"); |
| 36 | } |
| 37 | |
| 38 | bool TargetOptions::FramePointerIsReserved(const MachineFunction &MF) const { |
| 39 | FramePointerKind FP = MF.getFrameInfo().getFramePointerPolicy(); |
| 40 | switch (FP) { |
| 41 | case FramePointerKind::All: |
| 42 | case FramePointerKind::NonLeaf: |
| 43 | case FramePointerKind::Reserved: |
| 44 | return true; |
| 45 | case FramePointerKind::NonLeafNoReserve: |
| 46 | return MF.getFrameInfo().hasCalls(); |
| 47 | case FramePointerKind::None: |
| 48 | return false; |
| 49 | } |
| 50 | llvm_unreachable("unknown frame pointer flag"); |
| 51 | } |
| 52 | |
| 53 | /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume |
| 54 | /// that the rounding mode of the FPU can change from its default. |
| 55 | bool TargetOptions::HonorSignDependentRoundingFPMath() const { |
| 56 | return HonorSignDependentRoundingFPMathOption; |
| 57 | } |
| 58 | |
| 59 | /// NOTE: There are targets that still do not support the debug entry values |
| 60 | /// production and that is being controlled with the SupportsDebugEntryValues. |
| 61 | /// In addition, SCE debugger does not have the feature implemented, so prefer |
| 62 | /// not to emit the debug entry values in that case. |
| 63 | /// The EnableDebugEntryValues can be used for the testing purposes. |
| 64 | bool TargetOptions::ShouldEmitDebugEntryValues() const { |
| 65 | return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) || |
| 66 | EnableDebugEntryValues; |
| 67 | } |
| 68 |