ToolChains.h revision 00577ada44c889fbe311d61c51a8da89e65c7c9a
183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//
383b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//                     The LLVM Compiler Infrastructure
483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//
583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar// This file is distributed under the University of Illinois Open Source
683b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar// License. See LICENSE.TXT for details.
783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//
883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar//===----------------------------------------------------------------------===//
983b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
1083b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_
1183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#define CLANG_LIB_DRIVER_TOOLCHAINS_H_
1283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
13670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar#include "clang/Driver/Action.h"
1483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#include "clang/Driver/ToolChain.h"
1583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
16670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar#include "llvm/ADT/DenseMap.h"
1783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#include "llvm/Support/Compiler.h"
1883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
19670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar#include "Tools.h"
20670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar
2183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbarnamespace clang {
2283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbarnamespace driver {
23985b825eea7387be10478de0430815ed6a673326Daniel Dunbarnamespace toolchains {
2483b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
251d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// Generic_GCC - A tool chain using the 'gcc' command to perform
261d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// all subcommands; this relies on gcc translating the majority of
271d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// command line options.
2892dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
2975358d267256022475371416654b056ad8531cb3Daniel Dunbarprotected:
30670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar  mutable llvm::DenseMap<unsigned, Tool*> Tools;
31670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar
3283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbarpublic:
33cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
343917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  ~Generic_GCC();
3583b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
363917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
37670b7f4fe6720e91520ec5a993b33c00058ed77aDaniel Dunbar
383917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual bool IsUnwindTablesDefault() const;
393917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual const char *GetDefaultRelocationModel() const;
403917608370583fa30c466b6c3893448229aea9adDaniel Dunbar  virtual const char *GetForcedPicModel() const;
4183b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar};
4283b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
431d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// Darwin - The base Darwin tool chain.
4492dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
4525b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbarpublic:
4625b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar  /// The host version.
4725b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar  unsigned DarwinVersion[3];
4825b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar
4925b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbarprivate:
508eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  mutable llvm::DenseMap<unsigned, Tool*> Tools;
518eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
522603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  /// Whether the information on the target has been initialized.
532603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  //
542603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  // FIXME: This should be eliminated. What we want to do is make this part of
552603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  // the "default target for arguments" selection process, once we get out of
562603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  // the argument translation business.
572603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  mutable bool TargetInitialized;
582603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar
592603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  /// Whether we are targetting iPhoneOS target.
602603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  mutable bool TargetIsIPhoneOS;
61eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar
622603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  /// The OS version we are targetting.
632603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  mutable unsigned TargetVersion[3];
642603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar
6502633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  /// The default macosx-version-min of this tool chain; empty until
6602633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar  /// initialized.
67816bc31ed45002de2547d6679b44f31eb85ec491Daniel Dunbar  std::string MacosxVersionMin;
6802633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
69c0e665eb705762f95cd4f722ad7ecbdcde3f4527Daniel Dunbarprivate:
7060baf0f6d54376805168d49fa68628f801f95ef9Daniel Dunbar  void AddDeploymentTarget(DerivedArgList &Args) const;
71c0e665eb705762f95cd4f722ad7ecbdcde3f4527Daniel Dunbar
728eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarpublic:
7325b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar  Darwin(const HostInfo &Host, const llvm::Triple& Triple);
74f395528158379e7ea9f6ff4bbb791abadca15aabDaniel Dunbar  ~Darwin();
758eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
7600577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  std::string ComputeEffectiveClangTriple(const ArgList &Args) const;
7700577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar
786b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// @name Darwin Specific Toolchain API
796b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// {
806b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar
812603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  // FIXME: Eliminate these ...Target functions and derive separate tool chains
822603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  // for these targets and put version in constructor.
832603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  void setTarget(bool isIPhoneOS, unsigned Major, unsigned Minor,
842603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar                 unsigned Micro) const {
852603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    // FIXME: For now, allow reinitialization as long as values don't
862603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    // change. This will go away when we move away from argument translation.
872603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    if (TargetInitialized && TargetIsIPhoneOS == isIPhoneOS &&
882603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar        TargetVersion[0] == Major && TargetVersion[1] == Minor &&
892603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar        TargetVersion[2] == Micro)
902603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar      return;
912603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar
922603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    assert(!TargetInitialized && "Target already initialized!");
932603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    TargetInitialized = true;
942603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    TargetIsIPhoneOS = isIPhoneOS;
952603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    TargetVersion[0] = Major;
962603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    TargetVersion[1] = Minor;
972603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    TargetVersion[2] = Micro;
982603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  }
992603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar
1002603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  bool isTargetIPhoneOS() const {
1012603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    assert(TargetInitialized && "Target not initialized!");
1022603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    return TargetIsIPhoneOS;
1032603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  }
1042603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar
10503d87ee556f9e11ab83f6d2f80c9ee92e3667301Daniel Dunbar  bool isTargetInitialized() const { return TargetInitialized; }
10603d87ee556f9e11ab83f6d2f80c9ee92e3667301Daniel Dunbar
1072603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  void getTargetVersion(unsigned (&Res)[3]) const {
1082603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    assert(TargetInitialized && "Target not initialized!");
1092603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    Res[0] = TargetVersion[0];
1102603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    Res[1] = TargetVersion[1];
1112603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar    Res[2] = TargetVersion[2];
1122603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar  }
1132603137cb91e1d143b36fb71a72189884fbde5b5Daniel Dunbar
114eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar  /// getDarwinArchName - Get the "Darwin" arch name for a particular compiler
115eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar  /// invocation. For example, Darwin treats different ARM variations as
116eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar  /// distinct architectures.
117eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar  llvm::StringRef getDarwinArchName(const ArgList &Args) const;
118eeff406730f50afd973f005a8d501a19af4785e5Daniel Dunbar
119ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar  static bool isVersionLT(unsigned (&A)[3], unsigned (&B)[3]) {
120608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar    for (unsigned i=0; i < 3; ++i) {
121608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar      if (A[i] > B[i]) return false;
122608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar      if (A[i] < B[i]) return true;
123608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar    }
124608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar    return false;
125608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar  }
126608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar
127ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar  bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
128ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar    assert(isTargetIPhoneOS() && "Unexpected call for OS X target!");
129608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar    unsigned B[3] = { V0, V1, V2 };
130ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar    return isVersionLT(TargetVersion, B);
131608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar  }
132608d04cb7bee2db28c8689f6626bf9e0b114c473Daniel Dunbar
133ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar  bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
134ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar    assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!");
135cacb0f007001f7463d44ebd5dde7bfaecf876a71Daniel Dunbar    unsigned B[3] = { V0, V1, V2 };
136ce3fdf233353b10f20d74dceda3d77a82285de17Daniel Dunbar    return isVersionLT(TargetVersion, B);
137cacb0f007001f7463d44ebd5dde7bfaecf876a71Daniel Dunbar  }
138cacb0f007001f7463d44ebd5dde7bfaecf876a71Daniel Dunbar
1396b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.
1406b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  ///
1416b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// \param Args - The input argument list.
1426b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// \param CmdArgs [out] - The command argument list to append the paths
1436b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// (prefixed by -L) to.
1441d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  virtual void AddLinkSearchPathArgs(const ArgList &Args,
1451d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar                                     ArgStringList &CmdArgs) const = 0;
14602633b541b04ad5ffc1c70f4c2feeeb13e607057Daniel Dunbar
1476cd4154b9088fa18ae05d11c0f3140fafd76c734Daniel Dunbar  /// AddLinkRuntimeLibArgs - Add the linker arguments to link the compiler
1486cd4154b9088fa18ae05d11c0f3140fafd76c734Daniel Dunbar  /// runtime library.
1491d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
1501d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar                                     ArgStringList &CmdArgs) const = 0;
1516cd4154b9088fa18ae05d11c0f3140fafd76c734Daniel Dunbar
1526b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// }
1536b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// @name ToolChain Implementation
1546b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// {
1556b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar
1564180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar  virtual types::ID LookupTypeForExtension(const char *Ext) const;
1574180011fb8cef06adec04d30486b1bf3b99aa8b8Daniel Dunbar
158279c1dbebf37cd128f3c73c70741a6b8c35ad025Daniel Dunbar  virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args,
1590dcb9a3705743ec972af37f48ead81a0939e3958Daniel Dunbar                                        const char *BoundArch) const;
1608eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
1618eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
1628eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
1639e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  virtual bool IsBlocksDefault() const {
164ef44a5d65c48b92802aac02126d36c03d818e847Daniel Dunbar    // Always allow blocks on Darwin; users interested in versioning are
165ef44a5d65c48b92802aac02126d36c03d818e847Daniel Dunbar    // expected to use /usr/include/Blocks.h.
166ef44a5d65c48b92802aac02126d36c03d818e847Daniel Dunbar    return true;
1679e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  }
168eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar  virtual bool IsIntegratedAssemblerDefault() const {
16971a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar#ifdef DISABLE_DEFAULT_INTEGRATED_ASSEMBLER
17071a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar    return false;
17171a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar#else
172eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar    // Default integrated assembler to on for x86.
173eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar    return (getTriple().getArch() == llvm::Triple::x86 ||
174eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar            getTriple().getArch() == llvm::Triple::x86_64);
17571a6cbc5a101899f54e0a76aece82c01b48ad089Daniel Dunbar#endif
176eb840bd0e473ee11622e084a0d6ff276ee7aa5c6Daniel Dunbar  }
1779e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  virtual bool IsObjCNonFragileABIDefault() const {
178f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    // Non-fragile ABI is default for everything but i386.
179f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    return getTriple().getArch() != llvm::Triple::x86;
1809e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  }
181609508ce95732e7e7010f79c5207613eced7c9cbDaniel Dunbar  virtual bool IsObjCLegacyDispatchDefault() const {
182609508ce95732e7e7010f79c5207613eced7c9cbDaniel Dunbar    // This is only used with the non-fragile ABI.
183f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar
184f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    // Legacy dispatch is used everywhere except on x86_64.
185f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    return getTriple().getArch() != llvm::Triple::x86_64;
186609508ce95732e7e7010f79c5207613eced7c9cbDaniel Dunbar  }
187f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar  virtual bool UseObjCMixedDispatch() const {
188f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    // This is only used with the non-fragile ABI and non-legacy dispatch.
189f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar
190f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    // Mixed dispatch is used everywhere except OS X before 10.6.
191f645aaaf274c2f32c9ace457b9e69f041b565c17Daniel Dunbar    return !(!isTargetIPhoneOS() && isMacosxVersionLT(10, 6));
192f643b9b338b797a824447207d7eab5f1187f4f34Daniel Dunbar  }
1938eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual bool IsUnwindTablesDefault() const;
1949e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  virtual unsigned GetDefaultStackProtectorLevel() const {
1955435fc9739e9ac4baede460cf5e7489886948af5Daniel Dunbar    // Stack protectors default to on for 10.6 and beyond.
1965435fc9739e9ac4baede460cf5e7489886948af5Daniel Dunbar    return !isTargetIPhoneOS() && !isMacosxVersionLT(10, 6);
1979e5cc6b703b2d0013f13800c2ffbeb3cf85fcfadDaniel Dunbar  }
1988eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual const char *GetDefaultRelocationModel() const;
1998eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual const char *GetForcedPicModel() const;
2006b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar
20143a9b3263cb0bcb050cc75c15b3e6a8951e6b97aDaniel Dunbar  virtual bool SupportsObjCGC() const;
20243a9b3263cb0bcb050cc75c15b3e6a8951e6b97aDaniel Dunbar
203f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar  virtual bool UseDwarfDebugFlags() const;
204f2d8b9f967a1ab53ee9fdbcc3ac0a4ee0a83a26eDaniel Dunbar
205b2987d159a88ab0ee2e40c884eb4d77b42ab89b6Daniel Dunbar  virtual bool UseSjLjExceptions() const;
206b2987d159a88ab0ee2e40c884eb4d77b42ab89b6Daniel Dunbar
2076b200b2b698b6ac9e310f2225c69c85d28ae4fb0Daniel Dunbar  /// }
2088eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar};
2098eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
2101d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// DarwinClang - The Darwin toolchain used by Clang.
21192dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
2121d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbarpublic:
21325b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar  DarwinClang(const HostInfo &Host, const llvm::Triple& Triple);
2141d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2151d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// @name Darwin ToolChain Implementation
2161d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// {
2171d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2181d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  virtual void AddLinkSearchPathArgs(const ArgList &Args,
2191d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar                                    ArgStringList &CmdArgs) const;
2201d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2211d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
2221d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar                                     ArgStringList &CmdArgs) const;
2231d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2241d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// }
2251d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar};
2261d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2271d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// DarwinGCC - The Darwin toolchain used by GCC.
22892dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY DarwinGCC : public Darwin {
2291d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// GCC version to use.
23055bac5339154cedc7541b5648f9c3486e547b45cTed Kremenek  unsigned GCCVersion[3];
2311d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2321d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// The directory suffix for this tool chain.
2331d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  std::string ToolChainDir;
2341d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2351d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbarpublic:
23625b58eb7998ed947bc1c07e70de0b5d8f6aff857Daniel Dunbar  DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple);
2371d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2381d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// @name Darwin ToolChain Implementation
2391d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// {
2401d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2411d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  virtual void AddLinkSearchPathArgs(const ArgList &Args,
2421d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar                                    ArgStringList &CmdArgs) const;
2431d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2441d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  virtual void AddLinkRuntimeLibArgs(const ArgList &Args,
2451d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar                                     ArgStringList &CmdArgs) const;
2461d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2471d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  /// }
2481d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar};
2491d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar
2501d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar/// Darwin_Generic_GCC - Generic Darwin tool chain using gcc.
25192dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC {
2528eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbarpublic:
2531d4612b829500cbe04a2eafca74afac703e34934Daniel Dunbar  Darwin_Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
254cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar    : Generic_GCC(Host, Triple) {}
2558eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
25600577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar  std::string ComputeEffectiveClangTriple(const ArgList &Args) const;
25700577ada44c889fbe311d61c51a8da89e65c7c9aDaniel Dunbar
2588eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar  virtual const char *GetDefaultRelocationModel() const { return "pic"; }
2598eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar};
2608eddb3fb6ff3dd20e3920380e1ce56df105b8a98Daniel Dunbar
26192dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC {
262e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghanpublic:
263e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan  AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
264e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan
265e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
266e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan};
267e7925a075f110ab21afeae084670a155dea568e3Edward O'Callaghan
26892dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_GCC {
269f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbarpublic:
270f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar  OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
271f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar
272f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
273f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar};
274f7b8eec37c8c8012fa525c71fb29a58c9f29beefDaniel Dunbar
27592dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_GCC {
27675358d267256022475371416654b056ad8531cb3Daniel Dunbarpublic:
277214afe96b4210ca36d99621dd930225e6bf5b9b3Daniel Dunbar  FreeBSD(const HostInfo &Host, const llvm::Triple& Triple);
27875358d267256022475371416654b056ad8531cb3Daniel Dunbar
27975358d267256022475371416654b056ad8531cb3Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
28075358d267256022475371416654b056ad8531cb3Daniel Dunbar};
28175358d267256022475371416654b056ad8531cb3Daniel Dunbar
28238e317d6dce161b249508686cc67eb7176958762Chris Lattnerclass LLVM_LIBRARY_VISIBILITY Minix : public Generic_GCC {
28338e317d6dce161b249508686cc67eb7176958762Chris Lattnerpublic:
28438e317d6dce161b249508686cc67eb7176958762Chris Lattner  Minix(const HostInfo &Host, const llvm::Triple& Triple);
28538e317d6dce161b249508686cc67eb7176958762Chris Lattner
28638e317d6dce161b249508686cc67eb7176958762Chris Lattner  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
28738e317d6dce161b249508686cc67eb7176958762Chris Lattner};
28838e317d6dce161b249508686cc67eb7176958762Chris Lattner
28992dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_GCC {
29011e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbarpublic:
291cb8ab23f7c800b041aeb6fc38c341d1aa0da86bfDaniel Dunbar  DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
29211e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar
29311e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
29411e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar};
29511e1b40d759a643086f590f6ffbd9d68360bad46Daniel Dunbar
29692dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY Linux : public Generic_GCC {
2976b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedmanpublic:
2986b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman  Linux(const HostInfo &Host, const llvm::Triple& Triple);
299ba30bbe4e36a30a274da809a11a42f9cdc168e92Rafael Espindola
300ba30bbe4e36a30a274da809a11a42f9cdc168e92Rafael Espindola  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
3016b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman};
3026b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman
3036b3454a219cee5ef36c4668961f93a5c32deab61Eli Friedman
3043a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
3053a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
30692dd1915842410005c68d32c43bb3b3cf5a4a702Duncan Sandsclass LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
3073a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattnerpublic:
3083a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple);
3093a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  ~TCEToolChain();
3103a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner
3113a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
3123a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  bool IsMathErrnoDefault() const;
3133a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  bool IsUnwindTablesDefault() const;
3143a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  const char* GetDefaultRelocationModel() const;
3153a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  const char* GetForcedPicModel() const;
3163a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner
3173a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattnerprivate:
3183a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner  mutable llvm::DenseMap<unsigned, Tool*> Tools;
3193a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner
3203a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner};
3213a47c4e0a3e8d13ee4fb06cc3a98f9cfa9982400Chris Lattner
322ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencerclass LLVM_LIBRARY_VISIBILITY Windows : public ToolChain {
323ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  mutable llvm::DenseMap<unsigned, Tool*> Tools;
324ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer
325ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencerpublic:
326ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  Windows(const HostInfo &Host, const llvm::Triple& Triple);
327ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer
328ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
329ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer
330ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  virtual bool IsIntegratedAssemblerDefault() const;
331ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  virtual bool IsUnwindTablesDefault() const;
332ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  virtual const char *GetDefaultRelocationModel() const;
333ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer  virtual const char *GetForcedPicModel() const;
334ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer};
335ff58e3610f4e12094def69eb2d6dcb4330378d8fMichael J. Spencer
33683b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace toolchains
33783b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace driver
33883b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar} // end namespace clang
33983b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar
34083b08eb6d2a7f71328db51baa79c654bb9dcc55dDaniel Dunbar#endif
341