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;
31 Reloc::Model RelocationModel;
32 CodeModel::Model CMModel;
35 cl::opt<bool, true> PrintCode("print-machineinstrs",
36 cl::desc("Print generated machine code"),
37 cl::location(PrintMachineCode), cl::init(false));
40 DisableFPElim("disable-fp-elim",
41 cl::desc("Disable frame pointer elimination optimization"),
42 cl::location(NoFramePointerElim),
45 DisableExcessPrecision("disable-excess-fp-precision",
46 cl::desc("Disable optimizations that may increase FP precision"),
47 cl::location(NoExcessFPPrecision),
50 EnableUnsafeFPMath("enable-unsafe-fp-math",
51 cl::desc("Enable optimizations that may decrease FP precision"),
52 cl::location(UnsafeFPMath),
55 EnableFiniteOnltFPMath("enable-finite-only-fp-math",
56 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
57 cl::location(FiniteOnlyFPMathOption),
60 GenerateSoftFloatCalls("soft-float",
61 cl::desc("Generate software floating point library calls"),
62 cl::location(UseSoftFloat),
65 cl::opt<llvm::Reloc::Model, true>
68 cl::desc("Choose relocation model"),
69 cl::location(RelocationModel),
70 cl::init(Reloc::Default),
72 clEnumValN(Reloc::Default, "default",
73 " Target default relocation model"),
74 clEnumValN(Reloc::Static, "static",
75 " Non-relocatable code"),
76 clEnumValN(Reloc::PIC_, "pic",
77 " Fully relocatable, position independent code"),
78 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
79 " Relocatable external references, non-relocatable code"),
81 cl::opt<llvm::CodeModel::Model, true>
84 cl::desc("Choose relocation model"),
85 cl::location(CMModel),
86 cl::init(CodeModel::Default),
88 clEnumValN(CodeModel::Default, "default",
89 " Target default code model"),
90 clEnumValN(CodeModel::Small, "small",
92 clEnumValN(CodeModel::Kernel, "kernel",
93 " Kernel code model"),
94 clEnumValN(CodeModel::Medium, "medium",
95 " Medium code model"),
96 clEnumValN(CodeModel::Large, "large",
101 //---------------------------------------------------------------------------
102 // TargetMachine Class
105 TargetMachine::~TargetMachine() {
109 /// getRelocationModel - Returns the code generation relocation model. The
110 /// choices are static, PIC, and dynamic-no-pic, and target default.
111 Reloc::Model TargetMachine::getRelocationModel() {
112 return RelocationModel;
115 /// setRelocationModel - Sets the code generation relocation model.
116 void TargetMachine::setRelocationModel(Reloc::Model Model) {
117 RelocationModel = Model;
120 /// getCodeModel - Returns the code model. The choices are small, kernel,
121 /// medium, large, and target default.
122 CodeModel::Model TargetMachine::getCodeModel() {
126 /// setCodeModel - Sets the code model.
127 void TargetMachine::setCodeModel(CodeModel::Model Model) {
132 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
133 /// option is specified on the command line. If this returns false (default),
134 /// the code generator is not allowed to assume that FP arithmetic arguments
135 /// and results are never NaNs or +-Infs.
136 bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }