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;
30 Reloc::Model RelocationModel;
31 CodeModel::Model CMModel;
34 cl::opt<bool, true> PrintCode("print-machineinstrs",
35 cl::desc("Print generated machine code"),
36 cl::location(PrintMachineCode), cl::init(false));
39 DisableFPElim("disable-fp-elim",
40 cl::desc("Disable frame pointer elimination optimization"),
41 cl::location(NoFramePointerElim),
44 DisableExcessPrecision("disable-excess-fp-precision",
45 cl::desc("Disable optimizations that may increase FP precision"),
46 cl::location(NoExcessFPPrecision),
49 EnableUnsafeFPMath("enable-unsafe-fp-math",
50 cl::desc("Enable optimizations that may decrease FP precision"),
51 cl::location(UnsafeFPMath),
54 EnableFiniteOnltFPMath("enable-finite-only-fp-math",
55 cl::desc("Enable optimizations that assumes non- NaNs / +-Infs"),
56 cl::location(FiniteOnlyFPMathOption),
58 cl::opt<llvm::Reloc::Model, true>
61 cl::desc("Choose relocation model"),
62 cl::location(RelocationModel),
63 cl::init(Reloc::Default),
65 clEnumValN(Reloc::Default, "default",
66 " Target default relocation model"),
67 clEnumValN(Reloc::Static, "static",
68 " Non-relocatable code"),
69 clEnumValN(Reloc::PIC_, "pic",
70 " Fully relocatable, position independent code"),
71 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
72 " Relocatable external references, non-relocatable code"),
74 cl::opt<llvm::CodeModel::Model, true>
77 cl::desc("Choose relocation model"),
78 cl::location(CMModel),
79 cl::init(CodeModel::Default),
81 clEnumValN(CodeModel::Default, "default",
82 " Target default code model"),
83 clEnumValN(CodeModel::Small, "small",
85 clEnumValN(CodeModel::Kernel, "kernel",
86 " Kernel code model"),
87 clEnumValN(CodeModel::Medium, "medium",
88 " Medium code model"),
89 clEnumValN(CodeModel::Large, "large",
94 //---------------------------------------------------------------------------
95 // TargetMachine Class
98 TargetMachine::~TargetMachine() {
102 /// getRelocationModel - Returns the code generation relocation model. The
103 /// choices are static, PIC, and dynamic-no-pic, and target default.
104 Reloc::Model TargetMachine::getRelocationModel() {
105 return RelocationModel;
108 /// setRelocationModel - Sets the code generation relocation model.
109 void TargetMachine::setRelocationModel(Reloc::Model Model) {
110 RelocationModel = Model;
113 /// getCodeModel - Returns the code model. The choices are small, kernel,
114 /// medium, large, and target default.
115 CodeModel::Model TargetMachine::getCodeModel() {
119 /// setCodeModel - Sets the code model.
120 void TargetMachine::setCodeModel(CodeModel::Model Model) {
125 /// FiniteOnlyFPMath - This returns true when the -enable-finite-only-fp-math
126 /// option is specified on the command line. If this returns false (default),
127 /// the code generator is not allowed to assume that FP arithmetic arguments
128 /// and results are never NaNs or +-Infs.
129 bool FiniteOnlyFPMath() { return UnsafeFPMath || FiniteOnlyFPMathOption; }