blob: 7a39a4c27374c9e8180c969860c43b9b8d6791f3 [file] [log] [blame]
Nick Lewycky028700f2011-12-15 22:58:58 +00001//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
Nick Lewyckyb3ffe102011-12-10 22:34:41 +00002//
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 Wendlingf245ae52013-07-25 00:34:29 +000014#include "llvm/IR/Function.h"
Nick Lewyckyb3ffe102011-12-10 22:34:41 +000015#include "llvm/CodeGen/MachineFunction.h"
16#include "llvm/CodeGen/MachineFrameInfo.h"
17#include "llvm/Target/TargetOptions.h"
18using namespace llvm;
19
20/// DisableFramePointerElim - This returns true if frame pointer elimination
21/// optimization should be disabled for the given machine function.
22bool 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 Wendlingf245ae52013-07-25 00:34:29 +000025 bool NoFramePointerElimNonLeaf =
26 MF.getFunction()->getFnAttribute("no-frame-pointer-elim-non-leaf")
27 .getValueAsString() == "true";
Nick Lewyckyb3ffe102011-12-10 22:34:41 +000028 if (NoFramePointerElimNonLeaf && !NoFramePointerElim) {
29 const MachineFrameInfo *MFI = MF.getFrameInfo();
30 return MFI->hasCalls();
31 }
32
33 return NoFramePointerElim;
34}
35
36/// LessPreciseFPMAD - This flag return true when -enable-fp-mad option
37/// is specified on the command line. When this flag is off(default), the
38/// code generator is not allowed to generate mad (multiply add) if the
39/// result is "less precise" than doing those operations individually.
40bool TargetOptions::LessPreciseFPMAD() const {
41 return UnsafeFPMath || LessPreciseFPMADOption;
42}
43
44/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
45/// that the rounding mode of the FPU can change from its default.
46bool TargetOptions::HonorSignDependentRoundingFPMath() const {
47 return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
48}
49
50/// getTrapFunctionName - If this returns a non-empty string, this means isel
51/// should lower Intrinsic::trap to a call to the specified function name
52/// instead of an ISD::TRAP node.
53StringRef TargetOptions::getTrapFunctionName() const {
54 return TrapFuncName;
55}