2011-12-16 06:58:58 +08:00
|
|
|
//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
|
2011-12-11 06:34:41 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-12-11 06:34:41 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the methods in the TargetOptions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetFrameLowering.h"
|
|
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/Module.h"
|
2011-12-11 06:34:41 +08:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
/// DisableFramePointerElim - This returns true if frame pointer elimination
|
|
|
|
/// optimization should be disabled for the given machine function.
|
|
|
|
bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
|
2019-01-14 18:55:55 +08:00
|
|
|
// Check to see if the target want to forcably keep frame pointer.
|
|
|
|
if (MF.getSubtarget().getFrameLowering()->keepFramePointer(MF))
|
2015-05-23 09:14:08 +08:00
|
|
|
return true;
|
|
|
|
|
2019-01-14 18:55:55 +08:00
|
|
|
const Function &F = MF.getFunction();
|
|
|
|
|
2019-12-25 10:12:15 +08:00
|
|
|
if (!F.hasFnAttribute("frame-pointer"))
|
2019-01-14 18:55:55 +08:00
|
|
|
return false;
|
|
|
|
StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString();
|
|
|
|
if (FP == "all")
|
|
|
|
return true;
|
|
|
|
if (FP == "non-leaf")
|
|
|
|
return MF.getFrameInfo().hasCalls();
|
|
|
|
if (FP == "none")
|
|
|
|
return false;
|
|
|
|
llvm_unreachable("unknown frame pointer flag");
|
2011-12-11 06:34:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
|
|
|
|
/// that the rounding mode of the FPU can change from its default.
|
|
|
|
bool TargetOptions::HonorSignDependentRoundingFPMath() const {
|
|
|
|
return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
|
|
|
|
}
|
2020-03-19 19:13:18 +08:00
|
|
|
|
|
|
|
/// NOTE: There are targets that still do not support the debug entry values
|
2020-07-24 19:31:36 +08:00
|
|
|
/// production and that is being controlled with the SupportsDebugEntryValues.
|
|
|
|
/// In addition, SCE debugger does not have the feature implemented, so prefer
|
|
|
|
/// not to emit the debug entry values in that case.
|
|
|
|
/// The EnableDebugEntryValues can be used for the testing purposes.
|
2020-03-19 19:13:18 +08:00
|
|
|
bool TargetOptions::ShouldEmitDebugEntryValues() const {
|
2020-07-24 19:31:36 +08:00
|
|
|
return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) ||
|
|
|
|
EnableDebugEntryValues;
|
2020-03-19 19:13:18 +08:00
|
|
|
}
|