67 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file implements the methods in the TargetOptions.10//11//===----------------------------------------------------------------------===//12 13#include "llvm/ADT/StringSwitch.h"14#include "llvm/CodeGen/MachineFrameInfo.h"15#include "llvm/CodeGen/MachineFunction.h"16#include "llvm/CodeGen/TargetFrameLowering.h"17#include "llvm/CodeGen/TargetSubtargetInfo.h"18#include "llvm/IR/Function.h"19#include "llvm/Target/TargetOptions.h"20using namespace llvm;21 22/// DisableFramePointerElim - This returns true if frame pointer elimination23/// optimization should be disabled for the given machine function.24bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {25 const Function &F = MF.getFunction();26 27 Attribute FPAttr = F.getFnAttribute("frame-pointer");28 if (!FPAttr.isValid())29 return false;30 StringRef FP = FPAttr.getValueAsString();31 if (FP == "all")32 return true;33 if (FP == "non-leaf" || FP == "non-leaf-no-reserve")34 return MF.getFrameInfo().hasCalls();35 if (FP == "none" || FP == "reserved")36 return false;37 llvm_unreachable("unknown frame pointer flag");38}39 40bool TargetOptions::FramePointerIsReserved(const MachineFunction &MF) const {41 const Function &F = MF.getFunction();42 Attribute FPAttr = F.getFnAttribute("frame-pointer");43 if (!FPAttr.isValid())44 return false;45 46 return StringSwitch<bool>(FPAttr.getValueAsString())47 .Cases({"all", "non-leaf", "reserved"}, true)48 .Case(("non-leaf-no-reserve"), MF.getFrameInfo().hasCalls())49 .Case("none", false);50}51 52/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume53/// 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 values59/// production and that is being controlled with the SupportsDebugEntryValues.60/// In addition, SCE debugger does not have the feature implemented, so prefer61/// 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