//===--- ToolChains.cpp - ToolChain Implementations ---------------------*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ToolChains.h"
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/HostInfo.h"
#include "clang/Driver/OptTable.h"
#include "clang/Driver/Option.h"
#include "clang/Driver/Options.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
#include <cstdlib> // ::getenv
using namespace clang::driver;
using namespace clang::driver::toolchains;
/// Darwin - Darwin tool chain for i386 and x86_64.
Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple)
: ToolChain(Host, Triple), TargetInitialized(false)
{
// Compute the initial Darwin version based on the host.
bool HadExtra;
std::string OSName = Triple.getOSName();
if (!Driver::GetReleaseVersion(&OSName[6],
DarwinVersion[0], DarwinVersion[1],
DarwinVersion[2], HadExtra))
getDriver().Diag(clang::diag::err_drv_invalid_darwin_version) << OSName;
llvm::raw_string_ostream(MacosxVersionMin)
<< "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
<< DarwinVersion[1];
}
types::ID Darwin::LookupTypeForExtension(const char *Ext) const {
types::ID Ty = types::lookupTypeForExtension(Ext);
// Darwin always preprocesses assembly files (unless -x is used explicitly).
if (Ty == types::TY_PP_Asm)
return types::TY_Asm;
return Ty;
}
// FIXME: Can we tablegen this?
static const char *GetArmArchForMArch(llvm::StringRef Value) {
if (Value == "armv6k")
return "armv6";
if (Value == "armv5tej")
return "armv5";
if (Value == "xscale")
return "xscale";
if (Value == "armv4t")
return "armv4t";
if (Value == "armv7" || Value == "armv7-a" || Value == "armv7-r" ||
Value == "armv7-m" || Value == "armv7a" || Value == "armv7r" ||
Value == "armv7m")
return "armv7";
return 0;
}
// FIXME: Can we tablegen this?
static const char *GetArmArchForMCpu(llvm::StringRef Value) {
if (Value == "arm10tdmi" || Value == "arm1020t" || Value == "arm9e" ||
Value == "arm946e-s" || Value == "arm966e-s" ||
Value == "arm968e-s" || Value == "arm10e" ||
Value == "arm1020e" || Value == "arm1022e" || Value == "arm926ej-s" ||
Value == "arm1026ej-s")
return "armv5";
if (Value == "xscale")
return "xscale";
if (Value == "arm1136j-s" || Value == "arm1136jf-s" ||