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;
32 bool ExceptionHandling;
33 Reloc::Model RelocationModel;
34 CodeModel::Model CMModel;
37 cl::opt<bool, true> PrintCode("print-machineinstrs",
38 cl::desc("Print generated machine code"),
39 cl::location(PrintMachineCode), cl::init(false));
42 DisableFPElim("disable-fp-elim",
43 cl::desc("Disable frame pointer elimination optimization"),
44 cl::location(NoFramePointerElim),
47 DisableExcessPrecision("disable-excess-fp-precision",
48 cl::desc("Disable optimizations that may increase FP precision"),
49 cl::location(NoExcessFPPrecision),
52 EnableUnsafeFPMath("enable-unsafe-fp-math",
53 cl::desc("Enable optimizations that may decrease FP precision"),
54 cl::location(UnsafeFPMath),
57 EnableFiniteOnltFPMath("enable-finite-only-fp-math",
58 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
59 cl::location(FiniteOnlyFPMathOption),
62 GenerateSoftFloatCalls("soft-float",
63 cl::desc("Generate software floating point library calls"),
64 cl::location(UseSoftFloat),
67 DontPlaceZerosInBSS("nozero-initialized-in-bss",
68 cl::desc("Don't place zero-initialized symbols into bss section"),
69 cl::location(NoZerosInBSS),
72 EnableExceptionHandling("enable-eh",
73 cl::desc("Exception handling should be emitted."),
74 cl::location(ExceptionHandling),
77 cl::opt<llvm::Reloc::Model, true>
80 cl::desc("Choose relocation model"),
81 cl::location(RelocationModel),
82 cl::init(Reloc::Default),
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"),
93 cl::opt<llvm::CodeModel::Model, true>
96 cl::desc("Choose relocation model"),
97 cl::location(CMModel),
98 cl::init(CodeModel::Default),
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"),
113 //---------------------------------------------------------------------------
114 // TargetMachine Class
117 TargetMachine::~TargetMachine() {
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;
127 /// setRelocationModel - Sets the code generation relocation model.
128 void TargetMachine::setRelocationModel(Reloc::Model Model) {
129 RelocationModel = Model;
132 /// getCodeModel - Returns the code model. The choices are small, kernel,
133 /// medium, large, and target default.
134 CodeModel::Model TargetMachine::getCodeModel() {
138 /// setCodeModel - Sets the code model.
139 void TargetMachine::setCodeModel(CodeModel::Model Model) {
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; }