1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file describes the general parts of a Target machine.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetAsmInfo.h"
15 #include "llvm/Target/TargetMachine.h"
16 #include "llvm/Target/TargetOptions.h"
17 #include "llvm/Support/CommandLine.h"
20 //---------------------------------------------------------------------------
21 // Command-line options that tend to be useful on more than one back-end.
25 bool PrintMachineCode;
26 bool NoFramePointerElim;
27 bool NoExcessFPPrecision;
29 bool FiniteOnlyFPMathOption;
30 bool HonorSignDependentRoundingFPMathOption;
33 bool ExceptionHandling;
34 Reloc::Model RelocationModel;
35 CodeModel::Model CMModel;
38 cl::opt<bool, true> PrintCode("print-machineinstrs",
39 cl::desc("Print generated machine code"),
40 cl::location(PrintMachineCode), cl::init(false));
43 DisableFPElim("disable-fp-elim",
44 cl::desc("Disable frame pointer elimination optimization"),
45 cl::location(NoFramePointerElim),
48 DisableExcessPrecision("disable-excess-fp-precision",
49 cl::desc("Disable optimizations that may increase FP precision"),
50 cl::location(NoExcessFPPrecision),
53 EnableUnsafeFPMath("enable-unsafe-fp-math",
54 cl::desc("Enable optimizations that may decrease FP precision"),
55 cl::location(UnsafeFPMath),
58 EnableFiniteOnlyFPMath("enable-finite-only-fp-math",
59 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
60 cl::location(FiniteOnlyFPMathOption),
63 EnableHonorSignDependentRoundingFPMath(cl::Hidden,
64 "enable-sign-dependent-rounding-fp-math",
65 cl::desc("Force codegen to assume rounding mode can change dynamically"),
66 cl::location(HonorSignDependentRoundingFPMathOption),
70 GenerateSoftFloatCalls("soft-float",
71 cl::desc("Generate software floating point library calls"),
72 cl::location(UseSoftFloat),
75 DontPlaceZerosInBSS("nozero-initialized-in-bss",
76 cl::desc("Don't place zero-initialized symbols into bss section"),
77 cl::location(NoZerosInBSS),
80 EnableExceptionHandling("enable-eh",
81 cl::desc("Exception handling should be emitted."),
82 cl::location(ExceptionHandling),
85 cl::opt<llvm::Reloc::Model, true>
88 cl::desc("Choose relocation model"),
89 cl::location(RelocationModel),
90 cl::init(Reloc::Default),
92 clEnumValN(Reloc::Default, "default",
93 " Target default relocation model"),
94 clEnumValN(Reloc::Static, "static",
95 " Non-relocatable code"),
96 clEnumValN(Reloc::PIC_, "pic",
97 " Fully relocatable, position independent code"),
98 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
99 " Relocatable external references, non-relocatable code"),
101 cl::opt<llvm::CodeModel::Model, true>
104 cl::desc("Choose code model"),
105 cl::location(CMModel),
106 cl::init(CodeModel::Default),
108 clEnumValN(CodeModel::Default, "default",
109 " Target default code model"),
110 clEnumValN(CodeModel::Small, "small",
111 " Small code model"),
112 clEnumValN(CodeModel::Kernel, "kernel",
113 " Kernel code model"),
114 clEnumValN(CodeModel::Medium, "medium",
115 " Medium code model"),
116 clEnumValN(CodeModel::Large, "large",
117 " Large code model"),
121 //---------------------------------------------------------------------------
122 // TargetMachine Class
125 TargetMachine::~TargetMachine() {
129 /// getRelocationModel - Returns the code generation relocation model. The
130 /// choices are static, PIC, and dynamic-no-pic, and target default.
131 Reloc::Model TargetMachine::getRelocationModel() {
132 return RelocationModel;
135 /// setRelocationModel - Sets the code generation relocation model.
136 void TargetMachine::setRelocationModel(Reloc::Model Model) {
137 RelocationModel = Model;
140 /// getCodeModel - Returns the code model. The choices are small, kernel,
141 /// medium, large, and target default.
142 CodeModel::Model TargetMachine::getCodeModel() {
146 /// setCodeModel - Sets the code model.
147 void TargetMachine::setCodeModel(CodeModel::Model Model) {
152 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
153 /// option is specified on the command line. If this returns false (default),
154 /// the code generator is not allowed to assume that FP arithmetic arguments
155 /// and results are never NaNs or +-Infs.
156 bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }
158 /// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
159 /// that the rounding mode of the FPU can change from its default.
160 bool HonorSignDependentRoundingFPMath() {
161 return !UnsafeFPMath && HonorSignDependentRoundingFPMathOption;