LLVM  9.0.0svn
Go to the documentation of this file.
1 //===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the methods in the TargetOptions.
11 //
12 //===----------------------------------------------------------------------===//
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/Module.h"
21 using namespace llvm;
23 /// DisableFramePointerElim - This returns true if frame pointer elimination
24 /// optimization should be disabled for the given machine function.
26  // Check to see if the target want to forcably keep frame pointer.
28  return true;
30  const Function &F = MF.getFunction();
32  // TODO: Remove support for old `fp elim` function attributes after fully
33  // migrate to use "frame-pointer"
34  if (!F.hasFnAttribute("frame-pointer")) {
35  // Check to see if we should eliminate all frame pointers.
36  if (F.getFnAttribute("no-frame-pointer-elim").getValueAsString() == "true")
37  return true;
39  // Check to see if we should eliminate non-leaf frame pointers.
40  if (F.hasFnAttribute("no-frame-pointer-elim-non-leaf"))
41  return MF.getFrameInfo().hasCalls();
43  return false;
44  }
46  StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString();
47  if (FP == "all")
48  return true;
49  if (FP == "non-leaf")
50  return MF.getFrameInfo().hasCalls();
51  if (FP == "none")
52  return false;
53  llvm_unreachable("unknown frame pointer flag");
54 }
56 /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
57 /// that the rounding mode of the FPU can change from its default.
60 }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
virtual bool keepFramePointer(const MachineFunction &MF) const
Return true if the target wants to keep the frame pointer regardless of the function attribute "frame...
bool HonorSignDependentRoundingFPMath() const
HonorSignDependentRoundingFPMath - Return true if the codegen must assume that the rounding mode of t...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.h:321
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Module.h This file contains the declarations for the Module class.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
StringRef getValueAsString() const
Return the attribute's value as a string.
Definition: Attributes.cpp:195
virtual const TargetFrameLowering * getFrameLowering() const
unsigned HonorSignDependentRoundingFPMathOption
HonorSignDependentRoundingFPMath - This returns true when the -enable-sign-dependent-rounding-fp-math...
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
Definition: Function.h:331
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool hasCalls() const
Return true if the current function has any function calls.