1234285Sdim//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
2234285Sdim//
3234285Sdim//                     The LLVM Compiler Infrastructure
4234285Sdim//
5234285Sdim// This file is distributed under the University of Illinois Open Source
6234285Sdim// License. See LICENSE.TXT for details.
7234285Sdim//
8234285Sdim//===----------------------------------------------------------------------===//
9234285Sdim//
10234285Sdim// This file implements the methods in the TargetOptions.
11234285Sdim//
12234285Sdim//===----------------------------------------------------------------------===//
13234285Sdim
14263508Sdim#include "llvm/IR/Function.h"
15234285Sdim#include "llvm/CodeGen/MachineFunction.h"
16234285Sdim#include "llvm/CodeGen/MachineFrameInfo.h"
17234285Sdim#include "llvm/Target/TargetOptions.h"
18234285Sdimusing namespace llvm;
19234285Sdim
20234285Sdim/// DisableFramePointerElim - This returns true if frame pointer elimination
21234285Sdim/// optimization should be disabled for the given machine function.
22234285Sdimbool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
23234285Sdim  // Check to see if we should eliminate non-leaf frame pointers and then
24234285Sdim  // check to see if we should eliminate all frame pointers.
25263508Sdim  if (MF.getFunction()->hasFnAttribute("no-frame-pointer-elim-non-leaf") &&
26263508Sdim      !NoFramePointerElim) {
27234285Sdim    const MachineFrameInfo *MFI = MF.getFrameInfo();
28234285Sdim    return MFI->hasCalls();
29234285Sdim  }
30234285Sdim
31234285Sdim  return NoFramePointerElim;
32234285Sdim}
33234285Sdim
34234285Sdim/// LessPreciseFPMAD - This flag return true when -enable-fp-mad option
35234285Sdim/// is specified on the command line.  When this flag is off(default), the
36234285Sdim/// code generator is not allowed to generate mad (multiply add) if the
37234285Sdim/// result is "less precise" than doing those operations individually.
38234285Sdimbool TargetOptions::LessPreciseFPMAD() const {
39234285Sdim  return UnsafeFPMath || LessPreciseFPMADOption;
40234285Sdim}
41234285Sdim
42234285Sdim/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
43234285Sdim/// that the rounding mode of the FPU can change from its default.
44234285Sdimbool TargetOptions::HonorSignDependentRoundingFPMath() const {
45234285Sdim  return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
46234285Sdim}
47234285Sdim
48234285Sdim/// getTrapFunctionName - If this returns a non-empty string, this means isel
49234285Sdim/// should lower Intrinsic::trap to a call to the specified function name
50234285Sdim/// instead of an ISD::TRAP node.
51234285SdimStringRef TargetOptions::getTrapFunctionName() const {
52234285Sdim  return TrapFuncName;
53234285Sdim}
54