Prune some includes and forward declarations.
[oota-llvm.git] / lib / Target / TargetMachine.cpp
1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the general parts of a Target machine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/MC/MCAsmInfo.h"
15 #include "llvm/MC/MCCodeGenInfo.h"
16 #include "llvm/Target/TargetMachine.h"
17 #include "llvm/Target/TargetOptions.h"
18 #include "llvm/Support/CommandLine.h"
19 using namespace llvm;
20
21 //---------------------------------------------------------------------------
22 // Command-line options that tend to be useful on more than one back-end.
23 //
24
25 namespace llvm {
26   bool HasDivModLibcall;
27   bool AsmVerbosityDefault(false);
28 }
29
30 static cl::opt<bool>
31 DataSections("fdata-sections",
32   cl::desc("Emit data into separate sections"),
33   cl::init(false));
34 static cl::opt<bool>
35 FunctionSections("ffunction-sections",
36   cl::desc("Emit functions into separate sections"),
37   cl::init(false));
38
39 //---------------------------------------------------------------------------
40 // TargetMachine Class
41 //
42
43 TargetMachine::TargetMachine(const Target &T,
44                              StringRef TT, StringRef CPU, StringRef FS,
45                              const TargetOptions &Options)
46   : TheTarget(T), TargetTriple(TT), TargetCPU(CPU), TargetFS(FS),
47     CodeGenInfo(0), AsmInfo(0),
48     MCRelaxAll(false),
49     MCNoExecStack(false),
50     MCSaveTempLabels(false),
51     MCUseLoc(true),
52     MCUseCFI(true),
53     MCUseDwarfDirectory(false),
54     Options(Options) {
55 }
56
57 TargetMachine::~TargetMachine() {
58   delete CodeGenInfo;
59   delete AsmInfo;
60 }
61
62 /// getRelocationModel - Returns the code generation relocation model. The
63 /// choices are static, PIC, and dynamic-no-pic, and target default.
64 Reloc::Model TargetMachine::getRelocationModel() const {
65   if (!CodeGenInfo)
66     return Reloc::Default;
67   return CodeGenInfo->getRelocationModel();
68 }
69
70 /// getCodeModel - Returns the code model. The choices are small, kernel,
71 /// medium, large, and target default.
72 CodeModel::Model TargetMachine::getCodeModel() const {
73   if (!CodeGenInfo)
74     return CodeModel::Default;
75   return CodeGenInfo->getCodeModel();
76 }
77
78 /// getOptLevel - Returns the optimization level: None, Less,
79 /// Default, or Aggressive.
80 CodeGenOpt::Level TargetMachine::getOptLevel() const {
81   if (!CodeGenInfo)
82     return CodeGenOpt::Default;
83   return CodeGenInfo->getOptLevel();
84 }
85
86 bool TargetMachine::getAsmVerbosityDefault() {
87   return AsmVerbosityDefault;
88 }
89
90 void TargetMachine::setAsmVerbosityDefault(bool V) {
91   AsmVerbosityDefault = V;
92 }
93
94 bool TargetMachine::getFunctionSections() {
95   return FunctionSections;
96 }
97
98 bool TargetMachine::getDataSections() {
99   return DataSections;
100 }
101
102 void TargetMachine::setFunctionSections(bool V) {
103   FunctionSections = V;
104 }
105
106 void TargetMachine::setDataSections(bool V) {
107   DataSections = V;
108 }
109