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 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 DontPlaceZerosInBSS("nozero-initialized-in-bss",
67 cl::desc("Don't place zero-initialized symbols into bss section"),
68 cl::location(NoZerosInBSS),
71 cl::opt<llvm::Reloc::Model, true>
74 cl::desc("Choose relocation model"),
75 cl::location(RelocationModel),
76 cl::init(Reloc::Default),
78 clEnumValN(Reloc::Default, "default",
79 " Target default relocation model"),
80 clEnumValN(Reloc::Static, "static",
81 " Non-relocatable code"),
82 clEnumValN(Reloc::PIC_, "pic",
83 " Fully relocatable, position independent code"),
84 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
85 " Relocatable external references, non-relocatable code"),
87 cl::opt<llvm::CodeModel::Model, true>
90 cl::desc("Choose relocation model"),
91 cl::location(CMModel),
92 cl::init(CodeModel::Default),
94 clEnumValN(CodeModel::Default, "default",
95 " Target default code model"),
96 clEnumValN(CodeModel::Small, "small",
98 clEnumValN(CodeModel::Kernel, "kernel",
99 " Kernel code model"),
100 clEnumValN(CodeModel::Medium, "medium",
101 " Medium code model"),
102 clEnumValN(CodeModel::Large, "large",
103 " Large code model"),
107 //---------------------------------------------------------------------------
108 // TargetMachine Class
111 TargetMachine::~TargetMachine() {
115 /// getRelocationModel - Returns the code generation relocation model. The
116 /// choices are static, PIC, and dynamic-no-pic, and target default.
117 Reloc::Model TargetMachine::getRelocationModel() {
118 return RelocationModel;
121 /// setRelocationModel - Sets the code generation relocation model.
122 void TargetMachine::setRelocationModel(Reloc::Model Model) {
123 RelocationModel = Model;
126 /// getCodeModel - Returns the code model. The choices are small, kernel,
127 /// medium, large, and target default.
128 CodeModel::Model TargetMachine::getCodeModel() {
132 /// setCodeModel - Sets the code model.
133 void TargetMachine::setCodeModel(CodeModel::Model Model) {
138 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
139 /// option is specified on the command line. If this returns false (default),
140 /// the code generator is not allowed to assume that FP arithmetic arguments
141 /// and results are never NaNs or +-Infs.
142 bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }