Reverse sense of unwind-tables option. This means
[oota-llvm.git] / lib / Target / TargetMachine.cpp
1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
2 //
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 describes the general parts of a Target machine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetAsmInfo.h"
15 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Target/TargetOptions.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 FiniteOnlyFPMathOption;
30   bool HonorSignDependentRoundingFPMathOption;
31   bool UseSoftFloat;
32   bool NoZerosInBSS;
33   bool ExceptionHandling;
34   bool UnwindTablesMandatory;
35   Reloc::Model RelocationModel;
36   CodeModel::Model CMModel;
37   bool PerformTailCallOpt;
38   bool OptimizeForSize;
39 }
40 namespace {
41   cl::opt<bool, true> PrintCode("print-machineinstrs",
42     cl::desc("Print generated machine code"),
43     cl::location(PrintMachineCode), cl::init(false));
44
45   cl::opt<bool, true>
46     DisableFPElim("disable-fp-elim",
47                   cl::desc("Disable frame pointer elimination optimization"),
48                   cl::location(NoFramePointerElim),
49                   cl::init(false));
50   cl::opt<bool, true>
51   DisableExcessPrecision("disable-excess-fp-precision",
52                cl::desc("Disable optimizations that may increase FP precision"),
53                cl::location(NoExcessFPPrecision),
54                cl::init(false));
55   cl::opt<bool, true>
56   EnableUnsafeFPMath("enable-unsafe-fp-math",
57                cl::desc("Enable optimizations that may decrease FP precision"),
58                cl::location(UnsafeFPMath),
59                cl::init(false));
60   cl::opt<bool, true>
61   EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
62                cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
63                cl::location(FiniteOnlyFPMathOption),
64                cl::init(false));
65   cl::opt<bool, true>
66   EnableHonorSignDependentRoundingFPMath(cl::Hidden,
67                "enable-sign-dependent-rounding-fp-math",
68        cl::desc("Force codegen to assume rounding mode can change dynamically"),
69                cl::location(HonorSignDependentRoundingFPMathOption),
70                cl::init(false));
71
72   cl::opt<bool, true>
73   GenerateSoftFloatCalls("soft-float",
74                cl::desc("Generate software floating point library calls"),
75                cl::location(UseSoftFloat),
76                cl::init(false));
77   cl::opt<bool, true>
78   DontPlaceZerosInBSS("nozero-initialized-in-bss",
79               cl::desc("Don't place zero-initialized symbols into bss section"),
80               cl::location(NoZerosInBSS),
81               cl::init(false));
82   cl::opt<bool, true>
83   EnableExceptionHandling("enable-eh",
84                cl::desc("Emit DWARF exception handling (default if target supports)"),
85                cl::location(ExceptionHandling),
86                cl::init(false));
87   cl::opt<bool, true>
88   EnableUnwindTables("unwind-tables",
89                cl::desc("Generate unwinding tables for all functions"),
90                cl::location(UnwindTablesMandatory),
91                cl::init(false));
92
93   cl::opt<llvm::Reloc::Model, true>
94   DefRelocationModel(
95     "relocation-model",
96     cl::desc("Choose relocation model"),
97     cl::location(RelocationModel),
98     cl::init(Reloc::Default),
99     cl::values(
100       clEnumValN(Reloc::Default, "default",
101                  "  Target default relocation model"),
102       clEnumValN(Reloc::Static, "static",
103                  "  Non-relocatable code"),
104       clEnumValN(Reloc::PIC_, "pic",
105                  "  Fully relocatable, position independent code"),
106       clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
107                  "  Relocatable external references, non-relocatable code"),
108       clEnumValEnd));
109   cl::opt<llvm::CodeModel::Model, true>
110   DefCodeModel(
111     "code-model",
112     cl::desc("Choose code model"),
113     cl::location(CMModel),
114     cl::init(CodeModel::Default),
115     cl::values(
116       clEnumValN(CodeModel::Default, "default",
117                  "  Target default code model"),
118       clEnumValN(CodeModel::Small, "small",
119                  "  Small code model"),
120       clEnumValN(CodeModel::Kernel, "kernel",
121                  "  Kernel code model"),
122       clEnumValN(CodeModel::Medium, "medium",
123                  "  Medium code model"),
124       clEnumValN(CodeModel::Large, "large",
125                  "  Large code model"),
126       clEnumValEnd));
127
128   cl::opt<bool, true>
129   EnablePerformTailCallOpt("tailcallopt",
130                            cl::desc("Turn on tail call optimization."),
131                            cl::location(PerformTailCallOpt),
132                            cl::init(false));
133   cl::opt<bool, true>
134   EnableOptimizeForSize("optimize-size",
135                         cl::desc("Optimize for size."),
136                            cl::location(OptimizeForSize),
137                            cl::init(false));
138 }
139
140 //---------------------------------------------------------------------------
141 // TargetMachine Class
142 //
143
144 TargetMachine::~TargetMachine() {
145   delete AsmInfo;
146 }
147
148 /// getRelocationModel - Returns the code generation relocation model. The
149 /// choices are static, PIC, and dynamic-no-pic, and target default.
150 Reloc::Model TargetMachine::getRelocationModel() {
151   return RelocationModel;
152 }
153
154 /// setRelocationModel - Sets the code generation relocation model.
155 void TargetMachine::setRelocationModel(Reloc::Model Model) {
156   RelocationModel = Model;
157 }
158
159 /// getCodeModel - Returns the code model. The choices are small, kernel,
160 /// medium, large, and target default.
161 CodeModel::Model TargetMachine::getCodeModel() {
162   return CMModel;
163 }
164
165 /// setCodeModel - Sets the code model.
166 void TargetMachine::setCodeModel(CodeModel::Model Model) {
167   CMModel = Model;
168 }
169
170 namespace llvm {
171   /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
172   /// option is specified on the command line. If this returns false (default),
173   /// the code generator is not allowed to assume that FP arithmetic arguments
174   /// and results are never NaNs or +-Infs.
175   bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }
176   
177   /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
178   /// that the rounding mode of the FPU can change from its default.
179   bool HonorSignDependentRoundingFPMath() {
180     return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;
181   }
182 }
183