blob: 853e71d0efa514eb61f501cf62f434ab2b6e0862 [file] [log] [blame]
Nick Lewyckyc9e935c2011-12-15 22:58:58 +00001//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
Nick Lewyckyb9cda972011-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
Nick Lewyckyb9cda972011-12-10 22:34:41 +000014#include "llvm/CodeGen/MachineFrameInfo.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000015#include "llvm/CodeGen/MachineFunction.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000016#include "llvm/CodeGen/TargetFrameLowering.h"
17#include "llvm/CodeGen/TargetSubtargetInfo.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000018#include "llvm/IR/Function.h"
19#include "llvm/IR/Module.h"
Nick Lewyckyb9cda972011-12-10 22:34:41 +000020#include "llvm/Target/TargetOptions.h"
21using namespace llvm;
22
23/// DisableFramePointerElim - This returns true if frame pointer elimination
24/// optimization should be disabled for the given machine function.
25bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
Akira Hatanakaddf76aa2015-05-23 01:14:08 +000026 // Check to see if we should eliminate all frame pointers.
27 if (MF.getSubtarget().getFrameLowering()->noFramePointerElim(MF))
28 return true;
Nick Lewyckyb9cda972011-12-10 22:34:41 +000029
Akira Hatanakaddf76aa2015-05-23 01:14:08 +000030 // Check to see if we should eliminate non-leaf frame pointers.
Matthias Braunf1caa282017-12-15 22:22:58 +000031 if (MF.getFunction().hasFnAttribute("no-frame-pointer-elim-non-leaf"))
Matthias Braun941a7052016-07-28 18:40:00 +000032 return MF.getFrameInfo().hasCalls();
Akira Hatanakaddf76aa2015-05-23 01:14:08 +000033
34 return false;
Nick Lewyckyb9cda972011-12-10 22:34:41 +000035}
36
Nick Lewyckyb9cda972011-12-10 22:34:41 +000037/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
38/// that the rounding mode of the FPU can change from its default.
39bool TargetOptions::HonorSignDependentRoundingFPMath() const {
40 return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
41}