TargetOptionsImpl.cpp revision 251662
10Sduke//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
22362Sohair//
30Sduke//                     The LLVM Compiler Infrastructure
40Sduke//
50Sduke// This file is distributed under the University of Illinois Open Source
60Sduke// License. See LICENSE.TXT for details.
70Sduke//
80Sduke//===----------------------------------------------------------------------===//
90Sduke//
100Sduke// This file implements the methods in the TargetOptions.
110Sduke//
120Sduke//===----------------------------------------------------------------------===//
130Sduke
140Sduke#include "llvm/CodeGen/MachineFunction.h"
150Sduke#include "llvm/CodeGen/MachineFrameInfo.h"
160Sduke#include "llvm/Target/TargetOptions.h"
170Sdukeusing namespace llvm;
180Sduke
192362Sohair/// DisableFramePointerElim - This returns true if frame pointer elimination
202362Sohair/// optimization should be disabled for the given machine function.
212362Sohairbool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
220Sduke  // Check to see if we should eliminate non-leaf frame pointers and then
230Sduke  // check to see if we should eliminate all frame pointers.
240Sduke  if (NoFramePointerElimNonLeaf && !NoFramePointerElim) {
250Sduke    const MachineFrameInfo *MFI = MF.getFrameInfo();
260Sduke    return MFI->hasCalls();
270Sduke  }
280Sduke
290Sduke  return NoFramePointerElim;
300Sduke}
310Sduke
320Sduke/// LessPreciseFPMAD - This flag return true when -enable-fp-mad option
330Sduke/// is specified on the command line.  When this flag is off(default), the
340Sduke/// code generator is not allowed to generate mad (multiply add) if the
350Sduke/// result is "less precise" than doing those operations individually.
360Sdukebool TargetOptions::LessPreciseFPMAD() const {
370Sduke  return UnsafeFPMath || LessPreciseFPMADOption;
380Sduke}
390Sduke
400Sduke/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
410Sduke/// that the rounding mode of the FPU can change from its default.
420Sdukebool TargetOptions::HonorSignDependentRoundingFPMath() const {
430Sduke  return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
440Sduke}
450Sduke
460Sduke/// getTrapFunctionName - If this returns a non-empty string, this means isel
470Sduke/// should lower Intrinsic::trap to a call to the specified function name
480Sduke/// instead of an ISD::TRAP node.
490SdukeStringRef TargetOptions::getTrapFunctionName() const {
500Sduke  return TrapFuncName;
510Sduke}
520Sduke
530Sdukebool TargetOptions::operator==(const TargetOptions &TO) {
540Sduke#define ARE_EQUAL(X) X == TO.X
550Sduke  return
560Sduke    ARE_EQUAL(UnsafeFPMath) &&
570Sduke    ARE_EQUAL(NoInfsFPMath) &&
580Sduke    ARE_EQUAL(NoNaNsFPMath) &&
590Sduke    ARE_EQUAL(HonorSignDependentRoundingFPMathOption) &&
600Sduke    ARE_EQUAL(UseSoftFloat) &&
610Sduke    ARE_EQUAL(NoZerosInBSS) &&
620Sduke    ARE_EQUAL(JITExceptionHandling) &&
630Sduke    ARE_EQUAL(JITEmitDebugInfo) &&
640Sduke    ARE_EQUAL(JITEmitDebugInfoToDisk) &&
650Sduke    ARE_EQUAL(GuaranteedTailCallOpt) &&
660Sduke    ARE_EQUAL(DisableTailCalls) &&
670Sduke    ARE_EQUAL(StackAlignmentOverride) &&
680Sduke    ARE_EQUAL(RealignStack) &&
690Sduke    ARE_EQUAL(SSPBufferSize) &&
700Sduke    ARE_EQUAL(EnableFastISel) &&
710Sduke    ARE_EQUAL(PositionIndependentExecutable) &&
720Sduke    ARE_EQUAL(EnableSegmentedStacks) &&
730Sduke    ARE_EQUAL(UseInitArray) &&
740Sduke    ARE_EQUAL(TrapFuncName) &&
750Sduke    ARE_EQUAL(FloatABIType) &&
760Sduke    ARE_EQUAL(AllowFPOpFusion);
770Sduke#undef ARE_EQUAL
780Sduke}
790Sduke