rename flag
[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/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 UseSoftFloat;
31   bool NoZerosInBSS;
32   bool ExceptionHandling;
33   Reloc::Model RelocationModel;
34   CodeModel::Model CMModel;
35 }
36 namespace {
37   cl::opt<bool, true> PrintCode("print-machineinstrs",
38     cl::desc("Print generated machine code"),
39     cl::location(PrintMachineCode), cl::init(false));
40
41   cl::opt<bool, true>
42     DisableFPElim("disable-fp-elim",
43                   cl::desc("Disable frame pointer elimination optimization"),
44                   cl::location(NoFramePointerElim),
45                   cl::init(false));
46   cl::opt<bool, true>
47   DisableExcessPrecision("disable-excess-fp-precision",
48                cl::desc("Disable optimizations that may increase FP precision"),
49                cl::location(NoExcessFPPrecision),
50                cl::init(false));
51   cl::opt<bool, true>
52   EnableUnsafeFPMath("enable-unsafe-fp-math",
53                cl::desc("Enable optimizations that may decrease FP precision"),
54                cl::location(UnsafeFPMath),
55                cl::init(false));
56   cl::opt<bool, true>
57   EnableFiniteOnltFPMath("enable-finite-only-fp-math",
58                cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
59                cl::location(FiniteOnlyFPMathOption),
60                cl::init(false));
61   cl::opt<bool, true>
62   GenerateSoftFloatCalls("soft-float",
63                cl::desc("Generate software floating point library calls"),
64                cl::location(UseSoftFloat),
65                cl::init(false));
66   cl::opt<bool, true>
67   DontPlaceZerosInBSS("nozero-initialized-in-bss",
68                cl::desc("Don't place zero-initialized symbols into bss section"),
69                cl::location(NoZerosInBSS),
70                cl::init(false));
71   cl::opt<bool, true>
72   EnableExceptionHandling("enable-eh",
73                cl::desc("Exception handling should be emitted."),
74                cl::location(ExceptionHandling),
75                cl::init(false));
76
77   cl::opt<llvm::Reloc::Model, true>
78   DefRelocationModel(
79     "relocation-model",
80     cl::desc("Choose relocation model"),
81     cl::location(RelocationModel),
82     cl::init(Reloc::Default),
83     cl::values(
84       clEnumValN(Reloc::Default, "default",
85                  "  Target default relocation model"),
86       clEnumValN(Reloc::Static, "static",
87                  "  Non-relocatable code"),
88       clEnumValN(Reloc::PIC_, "pic",
89                  "  Fully relocatable, position independent code"),
90       clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
91                  "  Relocatable external references, non-relocatable code"),
92       clEnumValEnd));
93   cl::opt<llvm::CodeModel::Model, true>
94   DefCodeModel(
95     "code-model",
96     cl::desc("Choose relocation model"),
97     cl::location(CMModel),
98     cl::init(CodeModel::Default),
99     cl::values(
100       clEnumValN(CodeModel::Default, "default",
101                  "  Target default code model"),
102       clEnumValN(CodeModel::Small, "small",
103                  "  Small code model"),
104       clEnumValN(CodeModel::Kernel, "kernel",
105                  "  Kernel code model"),
106       clEnumValN(CodeModel::Medium, "medium",
107                  "  Medium code model"),
108       clEnumValN(CodeModel::Large, "large",
109                  "  Large code model"),
110       clEnumValEnd));
111 }
112
113 //---------------------------------------------------------------------------
114 // TargetMachine Class
115 //
116
117 TargetMachine::~TargetMachine() {
118   delete AsmInfo;
119 }
120
121 /// getRelocationModel - Returns the code generation relocation model. The
122 /// choices are static, PIC, and dynamic-no-pic, and target default.
123 Reloc::Model TargetMachine::getRelocationModel() {
124   return RelocationModel;
125 }
126
127 /// setRelocationModel - Sets the code generation relocation model.
128 void TargetMachine::setRelocationModel(Reloc::Model Model) {
129   RelocationModel = Model;
130 }
131
132 /// getCodeModel - Returns the code model. The choices are small, kernel,
133 /// medium, large, and target default.
134 CodeModel::Model TargetMachine::getCodeModel() {
135   return CMModel;
136 }
137
138 /// setCodeModel - Sets the code model.
139 void TargetMachine::setCodeModel(CodeModel::Model Model) {
140   CMModel = Model;
141 }
142
143 namespace llvm {
144   /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
145   /// option is specified on the command line. If this returns false (default),
146   /// the code generator is not allowed to assume that FP arithmetic arguments
147   /// and results are never NaNs or +-Infs.
148   bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }
149 }
150