clang API Documentation

HostInfo.h
Go to the documentation of this file.
00001 //===--- HostInfo.h - Host specific information -----------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef CLANG_DRIVER_HOSTINFO_H_
00011 #define CLANG_DRIVER_HOSTINFO_H_
00012 
00013 #include "llvm/ADT/Triple.h"
00014 #include <string>
00015 
00016 namespace clang {
00017 namespace driver {
00018   class ArgList;
00019   class Driver;
00020   class ToolChain;
00021 
00022 /// HostInfo - Config information about a particular host which may interact
00023 /// with driver behavior.
00024 ///
00025 /// The host information is used for controlling the parts of the driver which
00026 /// interact with the platform the driver is ostensibly being run from. For
00027 /// testing purposes, the HostInfo used by the driver may differ from the actual
00028 /// host.
00029 class HostInfo {
00030 protected:
00031   const Driver &TheDriver;
00032   const llvm::Triple Triple;
00033 
00034   HostInfo(const Driver &D, const llvm::Triple &_Triple);
00035 
00036 public:
00037   virtual ~HostInfo();
00038 
00039   const Driver &getDriver() const { return TheDriver; }
00040 
00041   const llvm::Triple& getTriple() const { return Triple; }
00042   std::string getArchName() const { return Triple.getArchName(); }
00043   std::string getPlatformName() const { return Triple.getVendorName(); }
00044   std::string getOSName() const { return Triple.getOSName(); }
00045 
00046   /// CreateToolChain - Construct the toolchain to use for this host (which the
00047   /// host retains ownership of).
00048   ///
00049   /// \param Args - The argument list, which may be used to alter the default
00050   /// toolchain, for example in the presence of -m32 or -m64.
00051   ///
00052   /// \param ArchName - The architecture to return a toolchain for, or 0 if
00053   /// unspecified. This will only ever be non-zero for hosts which support a
00054   /// driver driver.
00055 
00056   // FIXME: Pin down exactly what the HostInfo is allowed to use Args
00057   // for here. Currently this is for -m32 / -m64 defaulting.
00058   virtual ToolChain *CreateToolChain(const ArgList &Args,
00059                                      const char *ArchName=0) const = 0;
00060 };
00061 
00062 const HostInfo *createAuroraUXHostInfo(const Driver &D,
00063                                        const llvm::Triple& Triple);
00064 const HostInfo *createDarwinHostInfo(const Driver &D,
00065                                      const llvm::Triple& Triple);
00066 const HostInfo *createOpenBSDHostInfo(const Driver &D,
00067                                       const llvm::Triple& Triple);
00068 const HostInfo *createFreeBSDHostInfo(const Driver &D,
00069                                       const llvm::Triple& Triple);
00070 const HostInfo *createNetBSDHostInfo(const Driver &D,
00071                                       const llvm::Triple& Triple);
00072 const HostInfo *createMinixHostInfo(const Driver &D,
00073                                       const llvm::Triple& Triple);
00074 const HostInfo *createDragonFlyHostInfo(const Driver &D,
00075                                         const llvm::Triple& Triple);
00076 const HostInfo *createLinuxHostInfo(const Driver &D,
00077                                     const llvm::Triple& Triple);
00078 const HostInfo *createTCEHostInfo(const Driver &D, 
00079                                   const llvm::Triple& Triple);
00080 const HostInfo *createWindowsHostInfo(const Driver &D,
00081                                       const llvm::Triple &Triple);
00082 const HostInfo *createMinGWHostInfo(const Driver &D,
00083                                     const llvm::Triple &Triple);
00084 const HostInfo *createUnknownHostInfo(const Driver &D,
00085                                       const llvm::Triple& Triple);
00086 
00087 } // end namespace driver
00088 } // end namespace clang
00089 
00090 #endif