2017-05-25 04:27:09 +08:00
|
|
|
//===--- Targets.cpp - Implement target feature support -------------------===//
|
2006-10-14 15:39:34 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-10-14 15:39:34 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2009-05-03 21:42:53 +08:00
|
|
|
// This file implements construction of a TargetInfo object from a
|
2007-12-13 02:05:32 +08:00
|
|
|
// target triple.
|
2006-10-14 15:39:34 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-07-22 06:37:03 +08:00
|
|
|
#include "Targets.h"
|
|
|
|
|
|
|
|
#include "Targets/AArch64.h"
|
|
|
|
#include "Targets/AMDGPU.h"
|
|
|
|
#include "Targets/ARM.h"
|
|
|
|
#include "Targets/AVR.h"
|
|
|
|
#include "Targets/BPF.h"
|
|
|
|
#include "Targets/Hexagon.h"
|
|
|
|
#include "Targets/Lanai.h"
|
|
|
|
#include "Targets/Le64.h"
|
|
|
|
#include "Targets/MSP430.h"
|
|
|
|
#include "Targets/Mips.h"
|
|
|
|
#include "Targets/NVPTX.h"
|
|
|
|
#include "Targets/Nios2.h"
|
|
|
|
#include "Targets/OSTargets.h"
|
|
|
|
#include "Targets/PNaCl.h"
|
|
|
|
#include "Targets/PPC.h"
|
2018-01-11 21:36:56 +08:00
|
|
|
#include "Targets/RISCV.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
#include "Targets/SPIR.h"
|
|
|
|
#include "Targets/Sparc.h"
|
|
|
|
#include "Targets/SystemZ.h"
|
|
|
|
#include "Targets/TCE.h"
|
|
|
|
#include "Targets/WebAssembly.h"
|
|
|
|
#include "Targets/X86.h"
|
|
|
|
#include "Targets/XCore.h"
|
2009-11-15 14:48:46 +08:00
|
|
|
#include "clang/Basic/Diagnostic.h"
|
2018-02-09 07:14:15 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2009-08-12 14:24:27 +08:00
|
|
|
#include "llvm/ADT/Triple.h"
|
2015-09-11 01:07:54 +08:00
|
|
|
|
2007-12-04 06:06:55 +08:00
|
|
|
using namespace clang;
|
2006-10-14 15:39:34 +08:00
|
|
|
|
2017-07-22 06:37:03 +08:00
|
|
|
namespace clang {
|
|
|
|
namespace targets {
|
2006-10-14 15:39:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-10-15 02:32:12 +08:00
|
|
|
// Common code shared among targets.
|
2006-10-14 15:39:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-03-21 00:06:38 +08:00
|
|
|
/// DefineStd - Define a macro name and standard variants. For example if
|
|
|
|
/// MacroName is "unix", then this will define "__unix", "__unix__", and "unix"
|
|
|
|
/// when in GNU mode.
|
2017-07-22 06:37:03 +08:00
|
|
|
void DefineStd(MacroBuilder &Builder, StringRef MacroName,
|
|
|
|
const LangOptions &Opts) {
|
2009-03-21 00:06:38 +08:00
|
|
|
assert(MacroName[0] != '_' && "Identifier should be in the user's namespace");
|
2009-05-03 21:42:53 +08:00
|
|
|
|
2009-03-21 00:06:38 +08:00
|
|
|
// If in GNU mode (e.g. -std=gnu99 but not -std=c99) define the raw identifier
|
|
|
|
// in the user's namespace.
|
|
|
|
if (Opts.GNUMode)
|
2010-01-10 01:55:51 +08:00
|
|
|
Builder.defineMacro(MacroName);
|
2009-05-03 21:42:53 +08:00
|
|
|
|
2009-03-21 00:06:38 +08:00
|
|
|
// Define __unix.
|
2010-01-10 01:55:51 +08:00
|
|
|
Builder.defineMacro("__" + MacroName);
|
2009-05-03 21:42:53 +08:00
|
|
|
|
2009-03-21 00:06:38 +08:00
|
|
|
// Define __unix__.
|
2010-01-10 01:55:51 +08:00
|
|
|
Builder.defineMacro("__" + MacroName + "__");
|
2009-03-21 00:06:38 +08:00
|
|
|
}
|
|
|
|
|
2017-07-22 06:37:03 +08:00
|
|
|
void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName, bool Tuning) {
|
2012-01-10 19:50:09 +08:00
|
|
|
Builder.defineMacro("__" + CPUName);
|
|
|
|
Builder.defineMacro("__" + CPUName + "__");
|
|
|
|
if (Tuning)
|
|
|
|
Builder.defineMacro("__tune_" + CPUName + "__");
|
|
|
|
}
|
|
|
|
|
2017-08-01 02:17:38 +08:00
|
|
|
void addCygMingDefines(const LangOptions &Opts, MacroBuilder &Builder) {
|
|
|
|
// Mingw and cygwin define __declspec(a) to __attribute__((a)). Clang
|
|
|
|
// supports __declspec natively under -fms-extensions, but we define a no-op
|
|
|
|
// __declspec macro anyway for pre-processor compatibility.
|
|
|
|
if (Opts.MicrosoftExt)
|
|
|
|
Builder.defineMacro("__declspec", "__declspec");
|
|
|
|
else
|
|
|
|
Builder.defineMacro("__declspec(a)", "__attribute__((a))");
|
|
|
|
|
|
|
|
if (!Opts.MicrosoftExt) {
|
|
|
|
// Provide macros for all the calling convention keywords. Provide both
|
|
|
|
// single and double underscore prefixed variants. These are available on
|
|
|
|
// x64 as well as x86, even though they have no effect.
|
|
|
|
const char *CCs[] = {"cdecl", "stdcall", "fastcall", "thiscall", "pascal"};
|
|
|
|
for (const char *CC : CCs) {
|
|
|
|
std::string GCCSpelling = "__attribute__((__";
|
|
|
|
GCCSpelling += CC;
|
|
|
|
GCCSpelling += "__))";
|
|
|
|
Builder.defineMacro(Twine("_") + CC, GCCSpelling);
|
|
|
|
Builder.defineMacro(Twine("__") + CC, GCCSpelling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-21 19:28:29 +08:00
|
|
|
void addMinGWDefines(const llvm::Triple &Triple, const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) {
|
|
|
|
DefineStd(Builder, "WIN32", Opts);
|
|
|
|
DefineStd(Builder, "WINNT", Opts);
|
|
|
|
if (Triple.isArch64Bit()) {
|
|
|
|
DefineStd(Builder, "WIN64", Opts);
|
|
|
|
Builder.defineMacro("__MINGW64__");
|
|
|
|
}
|
2017-07-22 06:37:03 +08:00
|
|
|
Builder.defineMacro("__MSVCRT__");
|
|
|
|
Builder.defineMacro("__MINGW32__");
|
|
|
|
addCygMingDefines(Opts, Builder);
|
2011-08-25 04:22:22 +08:00
|
|
|
}
|
|
|
|
|
2006-10-14 15:39:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Driver code
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-07-22 06:37:03 +08:00
|
|
|
TargetInfo *AllocateTarget(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts) {
|
2009-08-18 13:47:58 +08:00
|
|
|
llvm::Triple::OSType os = Triple.getOS();
|
2008-05-20 22:21:01 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
switch (Triple.getArch()) {
|
|
|
|
default:
|
2014-05-08 14:41:40 +08:00
|
|
|
return nullptr;
|
2008-05-20 22:21:01 +08:00
|
|
|
|
2013-08-13 17:43:10 +08:00
|
|
|
case llvm::Triple::xcore:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new XCoreTargetInfo(Triple, Opts);
|
2013-08-13 17:43:10 +08:00
|
|
|
|
2011-12-13 05:14:55 +08:00
|
|
|
case llvm::Triple::hexagon:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new HexagonTargetInfo(Triple, Opts);
|
2011-12-13 05:14:55 +08:00
|
|
|
|
2016-03-29 05:02:54 +08:00
|
|
|
case llvm::Triple::lanai:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LanaiTargetInfo(Triple, Opts);
|
2016-03-29 05:02:54 +08:00
|
|
|
|
2013-01-31 20:13:10 +08:00
|
|
|
case llvm::Triple::aarch64:
|
2014-05-30 22:14:07 +08:00
|
|
|
if (Triple.isOSDarwin())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinAArch64TargetInfo(Triple, Opts);
|
2014-05-30 22:14:07 +08:00
|
|
|
|
2013-01-31 20:13:10 +08:00
|
|
|
switch (os) {
|
2015-10-15 23:07:07 +08:00
|
|
|
case llvm::Triple::CloudABI:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new CloudABITargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
2014-11-14 00:55:42 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
2016-10-25 06:55:57 +08:00
|
|
|
case llvm::Triple::Fuchsia:
|
|
|
|
return new FuchsiaTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
2013-01-31 20:13:10 +08:00
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
2014-02-25 21:51:00 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
2017-02-22 07:13:09 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
|
|
|
return new OpenBSDTargetInfo<AArch64leTargetInfo>(Triple, Opts);
|
2017-06-28 07:56:34 +08:00
|
|
|
case llvm::Triple::Win32:
|
2017-08-14 03:42:17 +08:00
|
|
|
switch (Triple.getEnvironment()) {
|
|
|
|
case llvm::Triple::GNU:
|
|
|
|
return new MinGWARM64TargetInfo(Triple, Opts);
|
|
|
|
case llvm::Triple::MSVC:
|
|
|
|
default: // Assume MSVC for unknown environments
|
|
|
|
return new MicrosoftARM64TargetInfo(Triple, Opts);
|
|
|
|
}
|
2014-02-25 21:51:00 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new AArch64leTargetInfo(Triple, Opts);
|
2014-02-25 21:51:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
case llvm::Triple::aarch64_be:
|
|
|
|
switch (os) {
|
2014-11-14 00:55:42 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
2016-10-25 06:55:57 +08:00
|
|
|
case llvm::Triple::Fuchsia:
|
|
|
|
return new FuchsiaTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
2014-02-25 21:51:00 +08:00
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
2014-01-14 02:25:15 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<AArch64beTargetInfo>(Triple, Opts);
|
2013-01-31 20:13:10 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new AArch64beTargetInfo(Triple, Opts);
|
2013-01-31 20:13:10 +08:00
|
|
|
}
|
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::arm:
|
2009-09-11 09:14:50 +08:00
|
|
|
case llvm::Triple::thumb:
|
2014-01-16 16:48:16 +08:00
|
|
|
if (Triple.isOSBinFormatMachO())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinARMTargetInfo(Triple, Opts);
|
2011-04-20 05:43:27 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
switch (os) {
|
2016-09-06 02:38:34 +08:00
|
|
|
case llvm::Triple::CloudABI:
|
|
|
|
return new CloudABITargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2010-06-10 08:46:51 +08:00
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new RTEMSTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
case llvm::Triple::NaCl:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NaClTargetInfo<ARMleTargetInfo>(Triple, Opts);
|
2014-04-05 04:31:19 +08:00
|
|
|
case llvm::Triple::Win32:
|
|
|
|
switch (Triple.getEnvironment()) {
|
2015-07-15 21:32:23 +08:00
|
|
|
case llvm::Triple::Cygnus:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new CygwinARMTargetInfo(Triple, Opts);
|
2015-07-15 21:32:23 +08:00
|
|
|
case llvm::Triple::GNU:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MinGWARMTargetInfo(Triple, Opts);
|
2014-04-05 04:31:19 +08:00
|
|
|
case llvm::Triple::Itanium:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new ItaniumWindowsARMleTargetInfo(Triple, Opts);
|
2014-04-05 04:31:19 +08:00
|
|
|
case llvm::Triple::MSVC:
|
2015-07-18 05:26:41 +08:00
|
|
|
default: // Assume MSVC for unknown environments
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MicrosoftARMleTargetInfo(Triple, Opts);
|
2014-04-05 04:31:19 +08:00
|
|
|
}
|
2014-03-28 22:40:46 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new ARMleTargetInfo(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
case llvm::Triple::armeb:
|
|
|
|
case llvm::Triple::thumbeb:
|
|
|
|
if (Triple.isOSDarwin())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinARMTargetInfo(Triple, Opts);
|
2014-03-28 22:40:46 +08:00
|
|
|
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<ARMbeTargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<ARMbeTargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<ARMbeTargetInfo>(Triple, Opts);
|
2012-08-02 21:45:48 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDTargetInfo<ARMbeTargetInfo>(Triple, Opts);
|
2011-07-02 06:41:14 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new RTEMSTargetInfo<ARMbeTargetInfo>(Triple, Opts);
|
2012-12-05 02:38:10 +08:00
|
|
|
case llvm::Triple::NaCl:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NaClTargetInfo<ARMbeTargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new ARMbeTargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
}
|
2008-04-22 02:56:49 +08:00
|
|
|
|
2017-01-05 13:20:27 +08:00
|
|
|
case llvm::Triple::avr:
|
|
|
|
return new AVRTargetInfo(Triple, Opts);
|
2015-06-11 06:59:13 +08:00
|
|
|
case llvm::Triple::bpfeb:
|
|
|
|
case llvm::Triple::bpfel:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new BPFTargetInfo(Triple, Opts);
|
2015-06-11 06:59:13 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::msp430:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MSP430TargetInfo(Triple, Opts);
|
2017-06-27 17:48:24 +08:00
|
|
|
|
|
|
|
case llvm::Triple::nios2:
|
|
|
|
return new LinuxTargetInfo<Nios2TargetInfo>(Triple, Opts);
|
2008-05-20 22:21:01 +08:00
|
|
|
|
2009-11-15 18:22:07 +08:00
|
|
|
case llvm::Triple::mips:
|
2011-07-06 02:05:54 +08:00
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new LinuxTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:05:54 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new RTEMSTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:05:54 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new FreeBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:05:54 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new NetBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:05:54 +08:00
|
|
|
default:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new MipsTargetInfo(Triple, Opts);
|
2011-07-06 02:05:54 +08:00
|
|
|
}
|
2009-11-15 18:22:07 +08:00
|
|
|
|
|
|
|
case llvm::Triple::mipsel:
|
2011-07-06 02:24:04 +08:00
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new LinuxTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:24:04 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new RTEMSTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:24:04 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new FreeBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-07-06 02:24:04 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new NetBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2013-09-21 09:27:01 +08:00
|
|
|
case llvm::Triple::NaCl:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new NaClTargetInfo<NaClMips32TargetInfo>(Triple, Opts);
|
2011-07-06 02:24:04 +08:00
|
|
|
default:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new MipsTargetInfo(Triple, Opts);
|
2011-07-06 02:24:04 +08:00
|
|
|
}
|
2009-11-15 18:22:07 +08:00
|
|
|
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::mips64:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new LinuxTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new RTEMSTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new FreeBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new NetBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2012-08-02 21:45:48 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new OpenBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
default:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new MipsTargetInfo(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
case llvm::Triple::mips64el:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new LinuxTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new RTEMSTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new FreeBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new NetBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2012-08-02 21:45:48 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new OpenBSDTargetInfo<MipsTargetInfo>(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
default:
|
2016-05-27 19:51:02 +08:00
|
|
|
return new MipsTargetInfo(Triple, Opts);
|
2011-09-21 03:21:49 +08:00
|
|
|
}
|
|
|
|
|
2011-08-25 04:22:22 +08:00
|
|
|
case llvm::Triple::le32:
|
|
|
|
switch (os) {
|
2015-05-13 05:18:10 +08:00
|
|
|
case llvm::Triple::NaCl:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NaClTargetInfo<PNaClTargetInfo>(Triple, Opts);
|
2015-05-13 05:18:10 +08:00
|
|
|
default:
|
|
|
|
return nullptr;
|
2011-08-25 04:22:22 +08:00
|
|
|
}
|
|
|
|
|
2014-09-13 01:52:47 +08:00
|
|
|
case llvm::Triple::le64:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new Le64TargetInfo(Triple, Opts);
|
2014-09-13 01:52:47 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::ppc:
|
2011-04-20 05:43:27 +08:00
|
|
|
if (Triple.isOSDarwin())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinPPC32TargetInfo(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
switch (os) {
|
2011-10-12 17:30:58 +08:00
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
2012-08-02 21:45:48 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new RTEMSTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new PPC32TargetInfo(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
}
|
2009-05-03 21:43:08 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::ppc64:
|
2011-04-20 05:43:27 +08:00
|
|
|
if (Triple.isOSDarwin())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinPPC64TargetInfo(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
switch (os) {
|
2011-10-12 17:30:58 +08:00
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::Lv2:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new PS3PPUTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new PPC64TargetInfo(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
}
|
2009-07-17 04:09:57 +08:00
|
|
|
|
2013-07-26 09:36:11 +08:00
|
|
|
case llvm::Triple::ppc64le:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2015-04-11 04:53:48 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2013-07-26 09:36:11 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new PPC64TargetInfo(Triple, Opts);
|
2013-07-26 09:36:11 +08:00
|
|
|
}
|
|
|
|
|
2012-05-21 07:28:41 +08:00
|
|
|
case llvm::Triple::nvptx:
|
2017-01-06 00:53:21 +08:00
|
|
|
return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/32);
|
2012-05-21 07:28:41 +08:00
|
|
|
case llvm::Triple::nvptx64:
|
2017-01-06 00:53:21 +08:00
|
|
|
return new NVPTXTargetInfo(Triple, Opts, /*TargetPointerWidth=*/64);
|
2012-05-21 07:28:41 +08:00
|
|
|
|
2015-01-07 04:34:47 +08:00
|
|
|
case llvm::Triple::amdgcn:
|
2012-10-13 07:32:00 +08:00
|
|
|
case llvm::Triple::r600:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new AMDGPUTargetInfo(Triple, Opts);
|
2012-10-13 07:32:00 +08:00
|
|
|
|
2018-01-11 21:36:56 +08:00
|
|
|
case llvm::Triple::riscv32:
|
2018-02-03 19:56:11 +08:00
|
|
|
// TODO: add cases for FreeBSD, NetBSD, RTEMS once tested.
|
|
|
|
if (os == llvm::Triple::Linux)
|
|
|
|
return new LinuxTargetInfo<RISCV32TargetInfo>(Triple, Opts);
|
2018-01-11 21:36:56 +08:00
|
|
|
return new RISCV32TargetInfo(Triple, Opts);
|
|
|
|
case llvm::Triple::riscv64:
|
2018-02-03 19:56:11 +08:00
|
|
|
// TODO: add cases for FreeBSD, NetBSD, RTEMS once tested.
|
|
|
|
if (os == llvm::Triple::Linux)
|
|
|
|
return new LinuxTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
2018-01-11 21:36:56 +08:00
|
|
|
return new RISCV64TargetInfo(Triple, Opts);
|
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::sparc:
|
2011-07-05 05:59:44 +08:00
|
|
|
switch (os) {
|
2011-10-12 17:30:58 +08:00
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<SparcV8TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::Solaris:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SolarisTargetInfo<SparcV8TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<SparcV8TargetInfo>(Triple, Opts);
|
2012-08-02 21:45:48 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDTargetInfo<SparcV8TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new RTEMSTargetInfo<SparcV8TargetInfo>(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SparcV8TargetInfo(Triple, Opts);
|
2011-07-05 05:59:44 +08:00
|
|
|
}
|
2009-08-18 04:08:44 +08:00
|
|
|
|
2015-05-11 23:21:44 +08:00
|
|
|
// The 'sparcel' architecture copies all the above cases except for Solaris.
|
|
|
|
case llvm::Triple::sparcel:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
|
2015-05-11 23:21:44 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
|
2015-05-11 23:21:44 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
|
2015-05-11 23:21:44 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new RTEMSTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
|
2015-05-11 23:21:44 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SparcV8elTargetInfo(Triple, Opts);
|
2015-05-11 23:21:44 +08:00
|
|
|
}
|
|
|
|
|
2013-04-16 23:17:49 +08:00
|
|
|
case llvm::Triple::sparcv9:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<SparcV9TargetInfo>(Triple, Opts);
|
2013-04-16 23:17:49 +08:00
|
|
|
case llvm::Triple::Solaris:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SolarisTargetInfo<SparcV9TargetInfo>(Triple, Opts);
|
2013-04-16 23:17:49 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<SparcV9TargetInfo>(Triple, Opts);
|
2013-04-16 23:17:49 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDTargetInfo<SparcV9TargetInfo>(Triple, Opts);
|
2013-04-16 23:17:49 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<SparcV9TargetInfo>(Triple, Opts);
|
2013-04-16 23:17:49 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SparcV9TargetInfo(Triple, Opts);
|
2013-04-16 23:17:49 +08:00
|
|
|
}
|
|
|
|
|
2013-05-07 00:26:41 +08:00
|
|
|
case llvm::Triple::systemz:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<SystemZTargetInfo>(Triple, Opts);
|
2013-05-07 00:26:41 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SystemZTargetInfo(Triple, Opts);
|
2013-05-07 00:26:41 +08:00
|
|
|
}
|
|
|
|
|
2009-08-20 04:47:07 +08:00
|
|
|
case llvm::Triple::tce:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new TCETargetInfo(Triple, Opts);
|
2009-08-20 04:47:07 +08:00
|
|
|
|
2016-11-16 23:22:31 +08:00
|
|
|
case llvm::Triple::tcele:
|
|
|
|
return new TCELETargetInfo(Triple, Opts);
|
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::x86:
|
2011-04-20 05:43:27 +08:00
|
|
|
if (Triple.isOSDarwin())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinI386TargetInfo(Triple, Opts);
|
2011-04-20 05:43:27 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
switch (os) {
|
2017-06-25 16:29:09 +08:00
|
|
|
case llvm::Triple::Ananas:
|
|
|
|
return new AnanasTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2015-06-14 05:33:49 +08:00
|
|
|
case llvm::Triple::CloudABI:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new CloudABITargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2015-03-25 18:38:50 +08:00
|
|
|
case llvm::Triple::Linux: {
|
|
|
|
switch (Triple.getEnvironment()) {
|
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2015-03-25 18:38:50 +08:00
|
|
|
case llvm::Triple::Android:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new AndroidX86_32TargetInfo(Triple, Opts);
|
2015-03-25 18:38:50 +08:00
|
|
|
}
|
|
|
|
}
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::DragonFly:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DragonFlyBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDI386TargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDI386TargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2013-09-05 21:47:07 +08:00
|
|
|
case llvm::Triple::KFreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new KFreeBSDTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2010-07-08 00:01:42 +08:00
|
|
|
case llvm::Triple::Minix:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MinixTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::Solaris:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SolarisTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
case llvm::Triple::Win32: {
|
|
|
|
switch (Triple.getEnvironment()) {
|
|
|
|
case llvm::Triple::Cygnus:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new CygwinX86_32TargetInfo(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
case llvm::Triple::GNU:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MinGWX86_32TargetInfo(Triple, Opts);
|
2014-06-29 07:34:11 +08:00
|
|
|
case llvm::Triple::Itanium:
|
2014-03-28 06:50:18 +08:00
|
|
|
case llvm::Triple::MSVC:
|
2015-07-18 05:26:41 +08:00
|
|
|
default: // Assume MSVC for unknown environments
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MicrosoftX86_32TargetInfo(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
}
|
|
|
|
}
|
2010-04-12 03:29:39 +08:00
|
|
|
case llvm::Triple::Haiku:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new HaikuX86_32TargetInfo(Triple, Opts);
|
2011-07-02 06:41:14 +08:00
|
|
|
case llvm::Triple::RTEMS:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new RTEMSX86_32TargetInfo(Triple, Opts);
|
2012-12-05 02:38:10 +08:00
|
|
|
case llvm::Triple::NaCl:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NaClTargetInfo<X86_32TargetInfo>(Triple, Opts);
|
2015-11-25 17:24:26 +08:00
|
|
|
case llvm::Triple::ELFIAMCU:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MCUX86_32TargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new X86_32TargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
}
|
2008-05-20 22:21:01 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::x86_64:
|
2014-03-28 06:50:18 +08:00
|
|
|
if (Triple.isOSDarwin() || Triple.isOSBinFormatMachO())
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DarwinX86_64TargetInfo(Triple, Opts);
|
2011-04-20 05:43:27 +08:00
|
|
|
|
2009-08-18 13:47:58 +08:00
|
|
|
switch (os) {
|
2017-06-25 16:29:09 +08:00
|
|
|
case llvm::Triple::Ananas:
|
|
|
|
return new AnanasTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2015-03-11 16:42:46 +08:00
|
|
|
case llvm::Triple::CloudABI:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new CloudABITargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2015-03-25 18:38:50 +08:00
|
|
|
case llvm::Triple::Linux: {
|
|
|
|
switch (Triple.getEnvironment()) {
|
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new LinuxTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2015-03-25 18:38:50 +08:00
|
|
|
case llvm::Triple::Android:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new AndroidX86_64TargetInfo(Triple, Opts);
|
2015-03-25 18:38:50 +08:00
|
|
|
}
|
|
|
|
}
|
2010-01-09 13:41:14 +08:00
|
|
|
case llvm::Triple::DragonFly:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new DragonFlyBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::NetBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NetBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new OpenBSDX86_64TargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new FreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2016-10-25 06:55:57 +08:00
|
|
|
case llvm::Triple::Fuchsia:
|
|
|
|
return new FuchsiaTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2013-09-05 21:47:07 +08:00
|
|
|
case llvm::Triple::KFreeBSD:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new KFreeBSDTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
case llvm::Triple::Solaris:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SolarisTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
case llvm::Triple::Win32: {
|
|
|
|
switch (Triple.getEnvironment()) {
|
2015-07-23 01:38:19 +08:00
|
|
|
case llvm::Triple::Cygnus:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new CygwinX86_64TargetInfo(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
case llvm::Triple::GNU:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MinGWX86_64TargetInfo(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
case llvm::Triple::MSVC:
|
2015-07-18 05:26:41 +08:00
|
|
|
default: // Assume MSVC for unknown environments
|
2016-04-10 03:09:25 +08:00
|
|
|
return new MicrosoftX86_64TargetInfo(Triple, Opts);
|
2014-03-28 06:50:18 +08:00
|
|
|
}
|
|
|
|
}
|
2016-05-12 00:19:05 +08:00
|
|
|
case llvm::Triple::Haiku:
|
|
|
|
return new HaikuTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2012-12-05 02:38:10 +08:00
|
|
|
case llvm::Triple::NaCl:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new NaClTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2015-01-27 22:47:44 +08:00
|
|
|
case llvm::Triple::PS4:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new PS4OSTargetInfo<X86_64TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
default:
|
2016-04-10 03:09:25 +08:00
|
|
|
return new X86_64TargetInfo(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
}
|
2012-12-12 05:38:14 +08:00
|
|
|
|
2015-05-13 05:18:10 +08:00
|
|
|
case llvm::Triple::spir: {
|
|
|
|
if (Triple.getOS() != llvm::Triple::UnknownOS ||
|
|
|
|
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
|
|
|
|
return nullptr;
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SPIR32TargetInfo(Triple, Opts);
|
2015-05-13 05:18:10 +08:00
|
|
|
}
|
|
|
|
case llvm::Triple::spir64: {
|
|
|
|
if (Triple.getOS() != llvm::Triple::UnknownOS ||
|
|
|
|
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
|
|
|
|
return nullptr;
|
2016-04-10 03:09:25 +08:00
|
|
|
return new SPIR64TargetInfo(Triple, Opts);
|
2015-05-13 05:18:10 +08:00
|
|
|
}
|
2015-09-04 06:51:53 +08:00
|
|
|
case llvm::Triple::wasm32:
|
2017-01-18 05:46:38 +08:00
|
|
|
if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
|
|
|
|
Triple.getVendor() != llvm::Triple::UnknownVendor ||
|
|
|
|
Triple.getOS() != llvm::Triple::UnknownOS ||
|
|
|
|
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment ||
|
|
|
|
!(Triple.isOSBinFormatELF() || Triple.isOSBinFormatWasm()))
|
2015-09-04 06:51:53 +08:00
|
|
|
return nullptr;
|
2016-04-10 03:09:25 +08:00
|
|
|
return new WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
|
2015-09-04 06:51:53 +08:00
|
|
|
case llvm::Triple::wasm64:
|
2017-01-18 05:46:38 +08:00
|
|
|
if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
|
|
|
|
Triple.getVendor() != llvm::Triple::UnknownVendor ||
|
|
|
|
Triple.getOS() != llvm::Triple::UnknownOS ||
|
|
|
|
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment ||
|
|
|
|
!(Triple.isOSBinFormatELF() || Triple.isOSBinFormatWasm()))
|
2015-09-04 06:51:53 +08:00
|
|
|
return nullptr;
|
2016-04-10 03:09:25 +08:00
|
|
|
return new WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
|
2016-07-02 08:05:42 +08:00
|
|
|
|
|
|
|
case llvm::Triple::renderscript32:
|
|
|
|
return new LinuxTargetInfo<RenderScript32TargetInfo>(Triple, Opts);
|
|
|
|
case llvm::Triple::renderscript64:
|
|
|
|
return new LinuxTargetInfo<RenderScript64TargetInfo>(Triple, Opts);
|
2009-08-18 13:47:58 +08:00
|
|
|
}
|
2006-10-14 15:39:34 +08:00
|
|
|
}
|
2017-07-22 06:37:03 +08:00
|
|
|
} // namespace targets
|
|
|
|
} // namespace clang
|
2009-11-15 14:48:46 +08:00
|
|
|
|
2017-07-22 06:37:03 +08:00
|
|
|
using namespace clang::targets;
|
2009-11-15 14:48:46 +08:00
|
|
|
/// CreateTargetInfo - Return the target info object for the specified target
|
2015-08-08 03:07:08 +08:00
|
|
|
/// options.
|
2014-07-06 13:26:44 +08:00
|
|
|
TargetInfo *
|
|
|
|
TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
|
2016-04-09 00:52:00 +08:00
|
|
|
const std::shared_ptr<TargetOptions> &Opts) {
|
2012-11-16 12:24:59 +08:00
|
|
|
llvm::Triple Triple(Opts->Triple);
|
2009-11-15 14:48:46 +08:00
|
|
|
|
|
|
|
// Construct the target
|
2016-04-10 03:09:25 +08:00
|
|
|
std::unique_ptr<TargetInfo> Target(AllocateTarget(Triple, *Opts));
|
2009-11-15 14:48:46 +08:00
|
|
|
if (!Target) {
|
|
|
|
Diags.Report(diag::err_target_unknown_triple) << Triple.str();
|
2014-05-08 14:41:40 +08:00
|
|
|
return nullptr;
|
2009-11-15 14:48:46 +08:00
|
|
|
}
|
2014-07-06 13:26:44 +08:00
|
|
|
Target->TargetOpts = Opts;
|
2009-11-15 14:48:46 +08:00
|
|
|
|
2009-12-19 02:42:37 +08:00
|
|
|
// Set the target CPU if specified.
|
2012-11-16 12:24:59 +08:00
|
|
|
if (!Opts->CPU.empty() && !Target->setCPU(Opts->CPU)) {
|
|
|
|
Diags.Report(diag::err_target_unknown_cpu) << Opts->CPU;
|
2018-02-09 07:14:15 +08:00
|
|
|
SmallVector<StringRef, 32> ValidList;
|
|
|
|
Target->fillValidCPUList(ValidList);
|
|
|
|
if (!ValidList.empty())
|
|
|
|
Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
|
2014-05-08 14:41:40 +08:00
|
|
|
return nullptr;
|
2009-12-19 02:42:37 +08:00
|
|
|
}
|
|
|
|
|
2009-11-15 14:48:46 +08:00
|
|
|
// Set the target ABI if specified.
|
2012-11-16 12:24:59 +08:00
|
|
|
if (!Opts->ABI.empty() && !Target->setABI(Opts->ABI)) {
|
|
|
|
Diags.Report(diag::err_target_unknown_abi) << Opts->ABI;
|
2014-05-08 14:41:40 +08:00
|
|
|
return nullptr;
|
2009-11-15 14:48:46 +08:00
|
|
|
}
|
|
|
|
|
2013-08-22 05:59:03 +08:00
|
|
|
// Set the fp math unit.
|
|
|
|
if (!Opts->FPMath.empty() && !Target->setFPMath(Opts->FPMath)) {
|
|
|
|
Diags.Report(diag::err_target_unknown_fpmath) << Opts->FPMath;
|
2014-05-08 14:41:40 +08:00
|
|
|
return nullptr;
|
2013-08-22 05:59:03 +08:00
|
|
|
}
|
|
|
|
|
2009-11-15 14:48:46 +08:00
|
|
|
// Compute the default target features, we need the target to handle this
|
|
|
|
// because features may have dependencies on one another.
|
|
|
|
llvm::StringMap<bool> Features;
|
2015-08-29 06:32:01 +08:00
|
|
|
if (!Target->initFeatureMap(Features, Diags, Opts->CPU,
|
|
|
|
Opts->FeaturesAsWritten))
|
2017-07-22 06:37:03 +08:00
|
|
|
return nullptr;
|
2009-11-15 14:48:46 +08:00
|
|
|
|
|
|
|
// Add the features to the compile options.
|
2012-11-16 12:24:59 +08:00
|
|
|
Opts->Features.clear();
|
2015-08-12 21:38:59 +08:00
|
|
|
for (const auto &F : Features)
|
|
|
|
Opts->Features.push_back((F.getValue() ? "+" : "-") + F.getKey().str());
|
2018-04-26 03:14:05 +08:00
|
|
|
// Sort here, so we handle the features in a predictable order. (This matters
|
|
|
|
// when we're dealing with features that overlap.)
|
|
|
|
llvm::sort(Opts->Features.begin(), Opts->Features.end());
|
2015-08-12 21:38:59 +08:00
|
|
|
|
2013-10-17 05:26:26 +08:00
|
|
|
if (!Target->handleTargetFeatures(Opts->Features, Diags))
|
2014-05-08 14:41:40 +08:00
|
|
|
return nullptr;
|
2009-11-15 14:48:46 +08:00
|
|
|
|
2016-05-17 01:06:34 +08:00
|
|
|
Target->setSupportedOpenCLOpts();
|
2016-11-01 23:50:52 +08:00
|
|
|
Target->setOpenCLExtensionOpts();
|
2017-09-23 00:30:00 +08:00
|
|
|
Target->setMaxAtomicWidth();
|
2016-05-17 01:06:34 +08:00
|
|
|
|
2016-06-14 16:58:50 +08:00
|
|
|
if (!Target->validateTarget(Diags))
|
|
|
|
return nullptr;
|
|
|
|
|
2014-03-08 03:33:25 +08:00
|
|
|
return Target.release();
|
2009-11-15 14:48:46 +08:00
|
|
|
}
|