remove #include
[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/Support/CommandLine.h"
17 using namespace llvm;
18
19 //---------------------------------------------------------------------------
20 // Command-line options that tend to be useful on more than one back-end.
21 //
22
23 namespace llvm {
24   bool PrintMachineCode;
25   bool NoFramePointerElim;
26   bool NoExcessFPPrecision;
27   bool UnsafeFPMath;
28   bool FiniteOnlyFPMathOption;
29   Reloc::Model RelocationModel;
30   CodeModel::Model CMModel;
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(FiniteOnlyFPMathOption),
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   cl::opt<llvm::CodeModel::Model, true>
74   DefCodeModel(
75     "code-model",
76     cl::desc("Choose relocation model"),
77     cl::location(CMModel),
78     cl::init(CodeModel::Default),
79     cl::values(
80       clEnumValN(CodeModel::Default, "default",
81                  "  Target default code model"),
82       clEnumValN(CodeModel::Small, "small",
83                  "  Small code model"),
84       clEnumValN(CodeModel::Kernel, "kernel",
85                  "  Kernel code model"),
86       clEnumValN(CodeModel::Medium, "medium",
87                  "  Medium code model"),
88       clEnumValN(CodeModel::Large, "large",
89                  "  Large code model"),
90       clEnumValEnd));
91 }
92
93 //---------------------------------------------------------------------------
94 // TargetMachine Class
95 //
96
97 TargetMachine::~TargetMachine() {
98 }
99
100 /// getRelocationModel - Returns the code generation relocation model. The
101 /// choices are static, PIC, and dynamic-no-pic, and target default.
102 Reloc::Model TargetMachine::getRelocationModel() {
103   return RelocationModel;
104 }
105
106 /// setRelocationModel - Sets the code generation relocation model.
107 void TargetMachine::setRelocationModel(Reloc::Model Model) {
108   RelocationModel = Model;
109 }
110
111 /// getCodeModel - Returns the code model. The choices are small, kernel,
112 /// medium, large, and target default.
113 CodeModel::Model TargetMachine::getCodeModel() {
114   return CMModel;
115 }
116
117 /// setCodeModel - Sets the code model.
118 void TargetMachine::setCodeModel(CodeModel::Model Model) {
119   CMModel = Model;
120 }
121
122 namespace llvm {
123   /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
124   /// option is specified on the command line. If this returns false (default),
125   /// the code generator is not allowed to assume that FP arithmetic arguments
126   /// and results are never NaNs or +-Infs.
127   bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }
128 }
129