10b57cec5SDimitry Andric //===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file implements the methods in the TargetOptions. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFrameInfo.h" 140b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunction.h" 150b57cec5SDimitry Andric #include "llvm/CodeGen/TargetFrameLowering.h" 160b57cec5SDimitry Andric #include "llvm/CodeGen/TargetSubtargetInfo.h" 170b57cec5SDimitry Andric #include "llvm/IR/Function.h" 180b57cec5SDimitry Andric #include "llvm/IR/Module.h" 190b57cec5SDimitry Andric #include "llvm/Target/TargetOptions.h" 200b57cec5SDimitry Andric using namespace llvm; 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric /// DisableFramePointerElim - This returns true if frame pointer elimination 230b57cec5SDimitry Andric /// optimization should be disabled for the given machine function. DisableFramePointerElim(const MachineFunction & MF) const240b57cec5SDimitry Andricbool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const { 250b57cec5SDimitry Andric // Check to see if the target want to forcably keep frame pointer. 260b57cec5SDimitry Andric if (MF.getSubtarget().getFrameLowering()->keepFramePointer(MF)) 270b57cec5SDimitry Andric return true; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric const Function &F = MF.getFunction(); 300b57cec5SDimitry Andric 31480093f4SDimitry Andric if (!F.hasFnAttribute("frame-pointer")) 320b57cec5SDimitry Andric return false; 330b57cec5SDimitry Andric StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString(); 340b57cec5SDimitry Andric if (FP == "all") 350b57cec5SDimitry Andric return true; 360b57cec5SDimitry Andric if (FP == "non-leaf") 370b57cec5SDimitry Andric return MF.getFrameInfo().hasCalls(); 380b57cec5SDimitry Andric if (FP == "none") 390b57cec5SDimitry Andric return false; 400b57cec5SDimitry Andric llvm_unreachable("unknown frame pointer flag"); 410b57cec5SDimitry Andric } 420b57cec5SDimitry Andric 430b57cec5SDimitry Andric /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume 440b57cec5SDimitry Andric /// that the rounding mode of the FPU can change from its default. HonorSignDependentRoundingFPMath() const450b57cec5SDimitry Andricbool TargetOptions::HonorSignDependentRoundingFPMath() const { 460b57cec5SDimitry Andric return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption; 470b57cec5SDimitry Andric } 485ffd83dbSDimitry Andric 495ffd83dbSDimitry Andric /// NOTE: There are targets that still do not support the debug entry values 50*af732203SDimitry Andric /// production and that is being controlled with the SupportsDebugEntryValues. 51*af732203SDimitry Andric /// In addition, SCE debugger does not have the feature implemented, so prefer 52*af732203SDimitry Andric /// not to emit the debug entry values in that case. 53*af732203SDimitry Andric /// The EnableDebugEntryValues can be used for the testing purposes. ShouldEmitDebugEntryValues() const545ffd83dbSDimitry Andricbool TargetOptions::ShouldEmitDebugEntryValues() const { 55*af732203SDimitry Andric return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) || 56*af732203SDimitry Andric EnableDebugEntryValues; 575ffd83dbSDimitry Andric } 58