1*0b57cec5SDimitry Andric //===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==// 2*0b57cec5SDimitry Andric // 3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0b57cec5SDimitry Andric // 7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 8*0b57cec5SDimitry Andric // 9*0b57cec5SDimitry Andric // This file implements the methods in the TargetOptions. 10*0b57cec5SDimitry Andric // 11*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFrameInfo.h" 14*0b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h" 15*0b57cec5SDimitry Andric #include "llvm/CodeGen/TargetFrameLowering.h" 16*0b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h" 17*0b57cec5SDimitry Andric #include "llvm/IR/Function.h" 18*0b57cec5SDimitry Andric #include "llvm/Target/TargetOptions.h" 19*0b57cec5SDimitry Andric using namespace llvm; 20*0b57cec5SDimitry Andric 21*0b57cec5SDimitry Andric /// DisableFramePointerElim - This returns true if frame pointer elimination 22*0b57cec5SDimitry Andric /// optimization should be disabled for the given machine function. DisableFramePointerElim(const MachineFunction & MF) const23*0b57cec5SDimitry Andricbool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const { 24*0b57cec5SDimitry Andric // Check to see if the target want to forcably keep frame pointer. 25*0b57cec5SDimitry Andric if (MF.getSubtarget().getFrameLowering()->keepFramePointer(MF)) 26*0b57cec5SDimitry Andric return true; 27*0b57cec5SDimitry Andric 28*0b57cec5SDimitry Andric const Function &F = MF.getFunction(); 29*0b57cec5SDimitry Andric 30*0b57cec5SDimitry Andric if (!F.hasFnAttribute("frame-pointer")) 31*0b57cec5SDimitry Andric return false; 32*0b57cec5SDimitry Andric StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString(); 33*0b57cec5SDimitry Andric if (FP == "all") 34*0b57cec5SDimitry Andric return true; 35*0b57cec5SDimitry Andric if (FP == "non-leaf") 36*0b57cec5SDimitry Andric return MF.getFrameInfo().hasCalls(); 37*0b57cec5SDimitry Andric if (FP == "none") 38*0b57cec5SDimitry Andric return false; 39*0b57cec5SDimitry Andric llvm_unreachable("unknown frame pointer flag"); 40*0b57cec5SDimitry Andric } 41*0b57cec5SDimitry Andric 42*0b57cec5SDimitry Andric /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume 43*0b57cec5SDimitry Andric /// that the rounding mode of the FPU can change from its default. HonorSignDependentRoundingFPMath() const44*0b57cec5SDimitry Andricbool TargetOptions::HonorSignDependentRoundingFPMath() const { 45*0b57cec5SDimitry Andric return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption; 46*0b57cec5SDimitry Andric } 47*0b57cec5SDimitry Andric 48*0b57cec5SDimitry Andric /// NOTE: There are targets that still do not support the debug entry values 49*0b57cec5SDimitry Andric /// production and that is being controlled with the SupportsDebugEntryValues. 50*0b57cec5SDimitry Andric /// In addition, SCE debugger does not have the feature implemented, so prefer 51*0b57cec5SDimitry Andric /// not to emit the debug entry values in that case. 52*0b57cec5SDimitry Andric /// The EnableDebugEntryValues can be used for the testing purposes. ShouldEmitDebugEntryValues() const53*0b57cec5SDimitry Andricbool TargetOptions::ShouldEmitDebugEntryValues() const { 54*0b57cec5SDimitry Andric return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) || 55*0b57cec5SDimitry Andric EnableDebugEntryValues; 56*0b57cec5SDimitry Andric } 57*0b57cec5SDimitry Andric