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/TargetMachine.h"
15 #include "llvm/Target/TargetOptions.h"
16 #include "llvm/Support/CommandLine.h"
19 //---------------------------------------------------------------------------
20 // Command-line options that tend to be useful on more than one back-end.
24 bool PrintMachineCode;
25 bool NoFramePointerElim;
26 bool NoExcessFPPrecision;
28 bool FiniteOnlyFPMathOption;
29 Reloc::Model RelocationModel;
30 CodeModel::Model CMModel;
33 cl::opt<bool, true> PrintCode("print-machineinstrs",
34 cl::desc("Print generated machine code"),
35 cl::location(PrintMachineCode), cl::init(false));
38 DisableFPElim("disable-fp-elim",
39 cl::desc("Disable frame pointer elimination optimization"),
40 cl::location(NoFramePointerElim),
43 DisableExcessPrecision("disable-excess-fp-precision",
44 cl::desc("Disable optimizations that may increase FP precision"),
45 cl::location(NoExcessFPPrecision),
48 EnableUnsafeFPMath("enable-unsafe-fp-math",
49 cl::desc("Enable optimizations that may decrease FP precision"),
50 cl::location(UnsafeFPMath),
53 EnableFiniteOnltFPMath("enable-finite-only-fp-math",
54 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
55 cl::location(FiniteOnlyFPMathOption),
57 cl::opt<llvm::Reloc::Model, true>
60 cl::desc("Choose relocation model"),
61 cl::location(RelocationModel),
62 cl::init(Reloc::Default),
64 clEnumValN(Reloc::Default, "default",
65 " Target default relocation model"),
66 clEnumValN(Reloc::Static, "static",
67 " Non-relocatable code"),
68 clEnumValN(Reloc::PIC_, "pic",
69 " Fully relocatable, position independent code"),
70 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
71 " Relocatable external references, non-relocatable code"),
73 cl::opt<llvm::CodeModel::Model, true>
76 cl::desc("Choose relocation model"),
77 cl::location(CMModel),
78 cl::init(CodeModel::Default),
80 clEnumValN(CodeModel::Default, "default",
81 " Target default code model"),
82 clEnumValN(CodeModel::Small, "small",
84 clEnumValN(CodeModel::Kernel, "kernel",
85 " Kernel code model"),
86 clEnumValN(CodeModel::Medium, "medium",
87 " Medium code model"),
88 clEnumValN(CodeModel::Large, "large",
93 //---------------------------------------------------------------------------
94 // TargetMachine Class
97 TargetMachine::~TargetMachine() {
100 /// getRelocationModel - Returns the code generation relocation model. The
101 /// choices are static, PIC, and dynamic-no-pic, and target default.
102 Reloc::Model TargetMachine::getRelocationModel() {
103 return RelocationModel;
106 /// setRelocationModel - Sets the code generation relocation model.
107 void TargetMachine::setRelocationModel(Reloc::Model Model) {
108 RelocationModel = Model;
111 /// getCodeModel - Returns the code model. The choices are small, kernel,
112 /// medium, large, and target default.
113 CodeModel::Model TargetMachine::getCodeModel() {
117 /// setCodeModel - Sets the code model.
118 void TargetMachine::setCodeModel(CodeModel::Model Model) {
123 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
124 /// option is specified on the command line. If this returns false (default),
125 /// the code generator is not allowed to assume that FP arithmetic arguments
126 /// and results are never NaNs or +-Infs.
127 bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }