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/Type.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 Reloc::Model RelocationModel;
32 cl::opt<bool, true> PrintCode("print-machineinstrs",
33 cl::desc("Print generated machine code"),
34 cl::location(PrintMachineCode), cl::init(false));
37 DisableFPElim("disable-fp-elim",
38 cl::desc("Disable frame pointer elimination optimization"),
39 cl::location(NoFramePointerElim),
42 DisableExcessPrecision("disable-excess-fp-precision",
43 cl::desc("Disable optimizations that may increase FP precision"),
44 cl::location(NoExcessFPPrecision),
47 EnableUnsafeFPMath("enable-unsafe-fp-math",
48 cl::desc("Enable optimizations that may decrease FP precision"),
49 cl::location(UnsafeFPMath),
51 cl::opt<llvm::Reloc::Model, true>
54 cl::desc("Choose relocation model"),
55 cl::location(RelocationModel),
56 cl::init(Reloc::Default),
58 clEnumValN(Reloc::Default, "default",
59 "Target default relocation model"),
60 clEnumValN(Reloc::Static, "static",
61 "Non-relocatable code"),
62 clEnumValN(Reloc::PIC, "pic",
63 "Fully relocatable, position independent code"),
64 clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
65 "Relocatable external references, non-relocatable code"),
69 //---------------------------------------------------------------------------
70 // TargetMachine Class
73 TargetMachine::TargetMachine(const std::string &name, const Module &M)
77 TargetMachine::~TargetMachine() {
80 /// getRelocationModel - Returns the code generation relocation model. The
81 /// choices are static, PIC, and dynamic-no-pic, and target default.
82 Reloc::Model TargetMachine::getRelocationModel() {
83 return RelocationModel;
86 /// setRelocationModel - Sets the code generation relocation model.
87 void TargetMachine::setRelocationModel(Reloc::Model Model) {
88 RelocationModel = Model;