1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the general parts of a Target machine.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/MC/MCAsmInfo.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.
26 bool EnableMachineSched;
27 bool HasDivModLibcall;
28 bool AsmVerbosityDefault(false);
32 DataSections("fdata-sections",
33 cl::desc("Emit data into separate sections"),
36 FunctionSections("ffunction-sections",
37 cl::desc("Emit functions into separate sections"),
40 /// EnableMachineSched - temporary flag to enable the machine scheduling pass
41 /// until we complete the register allocation pass configuration cleanup.
42 static cl::opt<bool, true>
43 MachineSchedOpt("enable-misched",
44 cl::desc("Enable the machine instruction scheduling pass."),
45 cl::location(EnableMachineSched),
46 cl::init(false), cl::Hidden);
48 //---------------------------------------------------------------------------
49 // TargetMachine Class
52 TargetMachine::TargetMachine(const Target &T,
53 StringRef TT, StringRef CPU, StringRef FS,
54 const TargetOptions &Options)
55 : TheTarget(T), TargetTriple(TT), TargetCPU(CPU), TargetFS(FS),
56 CodeGenInfo(0), AsmInfo(0),
59 MCSaveTempLabels(false),
62 MCUseDwarfDirectory(false),
66 TargetMachine::~TargetMachine() {
71 /// getRelocationModel - Returns the code generation relocation model. The
72 /// choices are static, PIC, and dynamic-no-pic, and target default.
73 Reloc::Model TargetMachine::getRelocationModel() const {
75 return Reloc::Default;
76 return CodeGenInfo->getRelocationModel();
79 /// getCodeModel - Returns the code model. The choices are small, kernel,
80 /// medium, large, and target default.
81 CodeModel::Model TargetMachine::getCodeModel() const {
83 return CodeModel::Default;
84 return CodeGenInfo->getCodeModel();
87 /// getOptLevel - Returns the optimization level: None, Less,
88 /// Default, or Aggressive.
89 CodeGenOpt::Level TargetMachine::getOptLevel() const {
91 return CodeGenOpt::Default;
92 return CodeGenInfo->getOptLevel();
95 bool TargetMachine::getAsmVerbosityDefault() {
96 return AsmVerbosityDefault;
99 void TargetMachine::setAsmVerbosityDefault(bool V) {
100 AsmVerbosityDefault = V;
103 bool TargetMachine::getFunctionSections() {
104 return FunctionSections;
107 bool TargetMachine::getDataSections() {
111 void TargetMachine::setFunctionSections(bool V) {
112 FunctionSections = V;
115 void TargetMachine::setDataSections(bool V) {