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