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/TargetObjInfo.h"
17 #include "llvm/Target/TargetOptions.h"
18 #include "llvm/Support/CommandLine.h"
21 //---------------------------------------------------------------------------
22 // Command-line options that tend to be useful on more than one back-end.
26 bool PrintMachineCode;
27 bool NoFramePointerElim;
28 bool NoExcessFPPrecision;
30 bool FiniteOnlyFPMathOption;
32 Reloc::Model RelocationModel;
33 CodeModel::Model CMModel;
36 cl::opt<bool, true> PrintCode("print-machineinstrs",
37 cl::desc("Print generated machine code"),
38 cl::location(PrintMachineCode), cl::init(false));
41 DisableFPElim("disable-fp-elim",
42 cl::desc("Disable frame pointer elimination optimization"),
43 cl::location(NoFramePointerElim),
46 DisableExcessPrecision("disable-excess-fp-precision",
47 cl::desc("Disable optimizations that may increase FP precision"),
48 cl::location(NoExcessFPPrecision),
51 EnableUnsafeFPMath("enable-unsafe-fp-math",
52 cl::desc("Enable optimizations that may decrease FP precision"),
53 cl::location(UnsafeFPMath),
56 EnableFiniteOnltFPMath("enable-finite-only-fp-math",
57 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
58 cl::location(FiniteOnlyFPMathOption),
61 GenerateSoftFloatCalls("soft-float",
62 cl::desc("Generate software floating point library calls"),
63 cl::location(UseSoftFloat),
66 cl::opt<llvm::Reloc::Model, true>
69 cl::desc("Choose relocation model"),
70 cl::location(RelocationModel),
71 cl::init(Reloc::Default),
73 clEnumValN(Reloc::Default, "default",
74 " Target default relocation model"),
75 clEnumValN(Reloc::Static, "static",
76 " Non-relocatable code"),
77 clEnumValN(Reloc::PIC_, "pic",
78 " Fully relocatable, position independent code"),
79 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
80 " Relocatable external references, non-relocatable code"),
82 cl::opt<llvm::CodeModel::Model, true>
85 cl::desc("Choose relocation model"),
86 cl::location(CMModel),
87 cl::init(CodeModel::Default),
89 clEnumValN(CodeModel::Default, "default",
90 " Target default code model"),
91 clEnumValN(CodeModel::Small, "small",
93 clEnumValN(CodeModel::Kernel, "kernel",
94 " Kernel code model"),
95 clEnumValN(CodeModel::Medium, "medium",
96 " Medium code model"),
97 clEnumValN(CodeModel::Large, "large",
102 //---------------------------------------------------------------------------
103 // TargetMachine Class
106 TargetMachine::~TargetMachine() {
111 /// getRelocationModel - Returns the code generation relocation model. The
112 /// choices are static, PIC, and dynamic-no-pic, and target default.
113 Reloc::Model TargetMachine::getRelocationModel() {
114 return RelocationModel;
117 /// setRelocationModel - Sets the code generation relocation model.
118 void TargetMachine::setRelocationModel(Reloc::Model Model) {
119 RelocationModel = Model;
122 /// getCodeModel - Returns the code model. The choices are small, kernel,
123 /// medium, large, and target default.
124 CodeModel::Model TargetMachine::getCodeModel() {
128 /// setCodeModel - Sets the code model.
129 void TargetMachine::setCodeModel(CodeModel::Model Model) {
134 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
135 /// option is specified on the command line. If this returns false (default),
136 /// the code generator is not allowed to assume that FP arithmetic arguments
137 /// and results are never NaNs or +-Infs.
138 bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }