blob: 8e1c7d55626a32fec5b0329706e75246f568418c [file] [log] [blame]
Daniel Dunbar39176082009-03-20 00:20:03 +00001//===--- ToolChains.cpp - ToolChain Implementations ---------------------*-===//
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#include "ToolChains.h"
11
12using namespace clang::driver;
13using namespace clang::driver::toolchains;
14
15/// Generic_GCC - A tool chain using the 'gcc' command to perform
16/// all subcommands; this relies on gcc translating the majority of
17/// command line options.
18
19Generic_GCC::~Generic_GCC() {
20 // Free tool implementations.
21 for (llvm::DenseMap<unsigned, Tool*>::iterator
22 it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
23 delete it->second;
24}
25
26Tool &Generic_GCC::SelectTool(const Compilation &C,
27 const JobAction &JA) const {
28 Action::ActionClass Key;
29 if (ShouldUseClangCompiler(C, JA))
30 Key = Action::AnalyzeJobClass;
31 else
32 Key = JA.getKind();
33
34 Tool *&T = Tools[Key];
35 if (!T) {
36 switch (Key) {
37 default:
38 assert(0 && "Invalid tool kind.");
39 case Action::PreprocessJobClass:
40 T = new tools::gcc::Preprocess(*this); break;
41 case Action::PrecompileJobClass:
42 T = new tools::gcc::Precompile(*this); break;
43 case Action::AnalyzeJobClass:
44 T = new tools::Clang(*this); break;
45 case Action::CompileJobClass:
46 T = new tools::gcc::Compile(*this); break;
47 case Action::AssembleJobClass:
48 T = new tools::gcc::Assemble(*this); break;
49 case Action::LinkJobClass:
50 T = new tools::gcc::Link(*this); break;
51 }
52 }
53
54 return *T;
55}
56
57bool Generic_GCC::IsMathErrnoDefault() const {
58 return true;
59}
60
61bool Generic_GCC::IsUnwindTablesDefault() const {
62 // FIXME: Gross; we should probably have some separate target definition,
63 // possibly even reusing the one in clang.
64 return getArchName() == "x86_64";
65}
66
67const char *Generic_GCC::GetDefaultRelocationModel() const {
68 return "static";
69}
70
71const char *Generic_GCC::GetForcedPicModel() const {
72 return 0;
73}
74
75