blob: be476d78ed6c8bcdf1abd2d716aa52b0d8d25ab9 [file] [log] [blame]
Daniel Dunbar83b08eb2009-03-17 21:38:00 +00001//===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
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#ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_
11#define CLANG_LIB_DRIVER_TOOLCHAINS_H_
12
Daniel Dunbar670b7f42009-03-17 22:07:31 +000013#include "clang/Driver/Action.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000014#include "clang/Driver/ToolChain.h"
15
Daniel Dunbar670b7f42009-03-17 22:07:31 +000016#include "llvm/ADT/DenseMap.h"
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000017#include "llvm/Support/Compiler.h"
18
Daniel Dunbar670b7f42009-03-17 22:07:31 +000019#include "Tools.h"
20
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000021namespace clang {
22namespace driver {
23namespace toolchains VISIBILITY_HIDDEN {
24
Daniel Dunbar670b7f42009-03-17 22:07:31 +000025 /// Generic_GCC - A tool chain using the 'gcc' command to perform
26 /// all subcommands; this relies on gcc translating the majority of
27 /// command line options.
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000028class Generic_GCC : public ToolChain {
Daniel Dunbar670b7f42009-03-17 22:07:31 +000029 mutable llvm::DenseMap<unsigned, Tool*> Tools;
30
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000031public:
32 Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform,
Daniel Dunbar670b7f42009-03-17 22:07:31 +000033 const char *OS) : ToolChain(Host, Arch, Platform, OS) {}
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000034
35 virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; }
36
37 virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const {
Daniel Dunbar670b7f42009-03-17 22:07:31 +000038 Action::ActionClass Key;
39 if (ShouldUseClangCompiler(C, JA))
40 Key = Action::AnalyzeJobClass;
41 else
42 Key = JA.getKind();
43
44 Tool *&T = Tools[Key];
45 if (!T) {
46 switch (Key) {
47 default:
48 assert(0 && "Invalid tool kind.");
49 case Action::PreprocessJobClass:
50 T = new tools::GCC_Preprocess(*this); break;
51 case Action::PrecompileJobClass:
52 T = new tools::GCC_Precompile(*this); break;
53 case Action::AnalyzeJobClass:
54 T = new tools::Clang(*this); break;
55 case Action::CompileJobClass:
56 T = new tools::GCC_Compile(*this); break;
57 case Action::AssembleJobClass:
58 T = new tools::GCC_Assemble(*this); break;
59 case Action::LinkJobClass:
60 T = new tools::GCC_Assemble(*this); break;
61 }
62 }
63
64 return *T;
Daniel Dunbar83b08eb2009-03-17 21:38:00 +000065 }
66
67 virtual bool IsMathErrnoDefault() const { return true; }
68
69 virtual bool IsUnwindTablesDefault() const {
70 // FIXME: Gross; we should probably have some separate target definition,
71 // possibly even reusing the one in clang.
72 return getArchName() == "x86_64";
73 }
74
75 virtual const char *GetDefaultRelocationModel() const {
76 return "static";
77 }
78
79 virtual const char *GetForcedPicModel() const {
80 return 0;
81 }
82};
83
84} // end namespace toolchains
85} // end namespace driver
86} // end namespace clang
87
88#endif