Nick Lewycky | 028700f | 2011-12-15 22:58:58 +0000 | [diff] [blame] | 1 | //===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==// |
Nick Lewycky | b3ffe10 | 2011-12-10 22:34:41 +0000 | [diff] [blame] | 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 | //===----------------------------------------------------------------------===// |
| 13 | |
Bill Wendling | f245ae5 | 2013-07-25 00:34:29 +0000 | [diff] [blame] | 14 | #include "llvm/IR/Function.h" |
Nick Lewycky | b3ffe10 | 2011-12-10 22:34:41 +0000 | [diff] [blame] | 15 | #include "llvm/CodeGen/MachineFunction.h" |
| 16 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 17 | #include "llvm/Target/TargetOptions.h" |
| 18 | using namespace llvm; |
| 19 | |
| 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 we should eliminate non-leaf frame pointers and then |
| 24 | // check to see if we should eliminate all frame pointers. |
Bill Wendling | 062cd94 | 2013-08-22 21:16:14 +0000 | [diff] [blame] | 25 | if (MF.getFunction()->hasFnAttribute("no-frame-pointer-elim-non-leaf") && |
| 26 | !NoFramePointerElim) { |
Nick Lewycky | b3ffe10 | 2011-12-10 22:34:41 +0000 | [diff] [blame] | 27 | const MachineFrameInfo *MFI = MF.getFrameInfo(); |
| 28 | return MFI->hasCalls(); |
| 29 | } |
| 30 | |
| 31 | return NoFramePointerElim; |
| 32 | } |
| 33 | |
| 34 | /// LessPreciseFPMAD - This flag return true when -enable-fp-mad option |
| 35 | /// is specified on the command line. When this flag is off(default), the |
| 36 | /// code generator is not allowed to generate mad (multiply add) if the |
| 37 | /// result is "less precise" than doing those operations individually. |
| 38 | bool TargetOptions::LessPreciseFPMAD() const { |
| 39 | return UnsafeFPMath || LessPreciseFPMADOption; |
| 40 | } |
| 41 | |
| 42 | /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume |
| 43 | /// that the rounding mode of the FPU can change from its default. |
| 44 | bool TargetOptions::HonorSignDependentRoundingFPMath() const { |
| 45 | return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption; |
| 46 | } |
| 47 | |
| 48 | /// getTrapFunctionName - If this returns a non-empty string, this means isel |
| 49 | /// should lower Intrinsic::trap to a call to the specified function name |
| 50 | /// instead of an ISD::TRAP node. |
| 51 | StringRef TargetOptions::getTrapFunctionName() const { |
| 52 | return TrapFuncName; |
| 53 | } |