Added option -enable-finite-only-fp-math. When on, the codegen can assume that
[oota-llvm.git] / lib / Target / TargetMachine.cpp
1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the general parts of a Target machine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetMachine.h"
15 #include "llvm/Target/TargetOptions.h"
16 #include "llvm/Type.h"
17 #include "llvm/Support/CommandLine.h"
18 using namespace llvm;
19
20 //---------------------------------------------------------------------------
21 // Command-line options that tend to be useful on more than one back-end.
22 //
23
24 namespace llvm {
25   bool PrintMachineCode;
26   bool NoFramePointerElim;
27   bool NoExcessFPPrecision;
28   bool UnsafeFPMath;
29   bool FiniteOnlyFPMath;
30   Reloc::Model RelocationModel;
31 };
32 namespace {
33   cl::opt<bool, true> PrintCode("print-machineinstrs",
34     cl::desc("Print generated machine code"),
35     cl::location(PrintMachineCode), cl::init(false));
36
37   cl::opt<bool, true>
38     DisableFPElim("disable-fp-elim",
39                   cl::desc("Disable frame pointer elimination optimization"),
40                   cl::location(NoFramePointerElim),
41                   cl::init(false));
42   cl::opt<bool, true>
43   DisableExcessPrecision("disable-excess-fp-precision",
44                cl::desc("Disable optimizations that may increase FP precision"),
45                cl::location(NoExcessFPPrecision),
46                cl::init(false));
47   cl::opt<bool, true>
48   EnableUnsafeFPMath("enable-unsafe-fp-math",
49                cl::desc("Enable optimizations that may decrease FP precision"),
50                cl::location(UnsafeFPMath),
51                cl::init(false));
52   cl::opt<bool, true>
53   EnableFiniteOnltFPMath("enable-finite-only-fp-math",
54                cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
55                cl::location(FiniteOnlyFPMath),
56                cl::init(false));
57   cl::opt<llvm::Reloc::Model, true>
58   DefRelocationModel(
59     "relocation-model",
60     cl::desc("Choose relocation model"),
61     cl::location(RelocationModel),
62     cl::init(Reloc::Default),
63     cl::values(
64       clEnumValN(Reloc::Default, "default",
65                  "Target default relocation model"),
66       clEnumValN(Reloc::Static, "static",
67                  "Non-relocatable code"),
68       clEnumValN(Reloc::PIC, "pic",
69                  "Fully relocatable, position independent code"),
70       clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
71                  "Relocatable external references, non-relocatable code"),
72       clEnumValEnd));
73 };
74
75 //---------------------------------------------------------------------------
76 // TargetMachine Class
77 //
78
79 TargetMachine::TargetMachine(const std::string &name, const Module &M)
80   : Name(name) {
81 }
82
83 TargetMachine::~TargetMachine() {
84 }
85
86 /// getRelocationModel - Returns the code generation relocation model. The
87 /// choices are static, PIC, and dynamic-no-pic, and target default.
88 Reloc::Model TargetMachine::getRelocationModel() {
89   return RelocationModel;
90 }
91
92 /// setRelocationModel - Sets the code generation relocation model.
93 void TargetMachine::setRelocationModel(Reloc::Model Model) {
94   RelocationModel = Model;
95 }