TargetOptionsImpl.cpp 2.3 KB

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