1*9880d681SAndroid Build Coastguard Worker //===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file implements the methods in the TargetOptions. 11*9880d681SAndroid Build Coastguard Worker // 12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Function.h" 15*9880d681SAndroid Build Coastguard Worker #include "llvm/IR/Module.h" 16*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFrameInfo.h" 17*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFunction.h" 18*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetFrameLowering.h" 19*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetOptions.h" 20*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetSubtargetInfo.h" 21*9880d681SAndroid Build Coastguard Worker using namespace llvm; 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker /// DisableFramePointerElim - This returns true if frame pointer elimination 24*9880d681SAndroid Build Coastguard Worker /// optimization should be disabled for the given machine function. DisableFramePointerElim(const MachineFunction & MF) const25*9880d681SAndroid Build Coastguard Workerbool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const { 26*9880d681SAndroid Build Coastguard Worker // Check to see if we should eliminate all frame pointers. 27*9880d681SAndroid Build Coastguard Worker if (MF.getSubtarget().getFrameLowering()->noFramePointerElim(MF)) 28*9880d681SAndroid Build Coastguard Worker return true; 29*9880d681SAndroid Build Coastguard Worker 30*9880d681SAndroid Build Coastguard Worker // Check to see if we should eliminate non-leaf frame pointers. 31*9880d681SAndroid Build Coastguard Worker if (MF.getFunction()->hasFnAttribute("no-frame-pointer-elim-non-leaf")) 32*9880d681SAndroid Build Coastguard Worker return MF.getFrameInfo()->hasCalls(); 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker return false; 35*9880d681SAndroid Build Coastguard Worker } 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker /// LessPreciseFPMAD - This flag return true when -enable-fp-mad option 38*9880d681SAndroid Build Coastguard Worker /// is specified on the command line. When this flag is off(default), the 39*9880d681SAndroid Build Coastguard Worker /// code generator is not allowed to generate mad (multiply add) if the 40*9880d681SAndroid Build Coastguard Worker /// result is "less precise" than doing those operations individually. LessPreciseFPMAD() const41*9880d681SAndroid Build Coastguard Workerbool TargetOptions::LessPreciseFPMAD() const { 42*9880d681SAndroid Build Coastguard Worker return UnsafeFPMath || LessPreciseFPMADOption; 43*9880d681SAndroid Build Coastguard Worker } 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume 46*9880d681SAndroid Build Coastguard Worker /// that the rounding mode of the FPU can change from its default. HonorSignDependentRoundingFPMath() const47*9880d681SAndroid Build Coastguard Workerbool TargetOptions::HonorSignDependentRoundingFPMath() const { 48*9880d681SAndroid Build Coastguard Worker return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption; 49*9880d681SAndroid Build Coastguard Worker } 50