TargetOptionsImpl.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include "llvm/CodeGen/MachineFrameInfo.h"
  13. #include "llvm/CodeGen/MachineFunction.h"
  14. #include "llvm/CodeGen/TargetFrameLowering.h"
  15. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  16. #include "llvm/IR/Function.h"
  17. #include "llvm/IR/Module.h"
  18. #include "llvm/Target/TargetOptions.h"
  19. using namespace llvm;
  20. /// DisableFramePointerElim - This returns true if frame pointer elimination
  21. /// optimization should be disabled for the given machine function.
  22. bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
  23. // Check to see if the target want to forcably keep frame pointer.
  24. if (MF.getSubtarget().getFrameLowering()->keepFramePointer(MF))
  25. return true;
  26. const Function &F = MF.getFunction();
  27. if (!F.hasFnAttribute("frame-pointer"))
  28. return false;
  29. StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString();
  30. if (FP == "all")
  31. return true;
  32. if (FP == "non-leaf")
  33. return MF.getFrameInfo().hasCalls();
  34. if (FP == "none")
  35. return false;
  36. llvm_unreachable("unknown frame pointer flag");
  37. }
  38. /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
  39. /// that the rounding mode of the FPU can change from its default.
  40. bool TargetOptions::HonorSignDependentRoundingFPMath() const {
  41. return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
  42. }
  43. /// NOTE: There are targets that still do not support the debug entry values
  44. /// production and that is being controlled with the SupportsDebugEntryValues.
  45. /// In addition, SCE debugger does not have the feature implemented, so prefer
  46. /// not to emit the debug entry values in that case.
  47. /// The EnableDebugEntryValues can be used for the testing purposes.
  48. bool TargetOptions::ShouldEmitDebugEntryValues() const {
  49. return (SupportsDebugEntryValues && DebuggerTuning != DebuggerKind::SCE) ||
  50. EnableDebugEntryValues;
  51. }