2017-05-25 04:27:09 +08:00
|
|
|
//===--- Targets.cpp - Implement target feature support -------------------===//
|
2006-10-14 15:39:34 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
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"
|
2018-11-28 03:52:10 +08:00
|
|
|
#include "Targets/ARC.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
#include "Targets/ARM.h"
|
|
|
|
#include "Targets/AVR.h"
|
|
|
|
#include "Targets/BPF.h"
|
2022-03-29 16:18:10 +08:00
|
|
|
#include "Targets/CSKY.h"
|
2022-03-29 02:45:41 +08:00
|
|
|
#include "Targets/DirectX.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
#include "Targets/Hexagon.h"
|
|
|
|
#include "Targets/Lanai.h"
|
2021-04-23 01:18:44 +08:00
|
|
|
#include "Targets/Le64.h"
|
2021-03-08 08:33:22 +08:00
|
|
|
#include "Targets/M68k.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
#include "Targets/MSP430.h"
|
|
|
|
#include "Targets/Mips.h"
|
|
|
|
#include "Targets/NVPTX.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"
|
2020-06-24 16:11:59 +08:00
|
|
|
#include "Targets/VE.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2018-11-28 03:52:10 +08:00
|
|
|
case llvm::Triple::arc:
|
|
|
|
return new ARCTargetInfo(Triple, Opts);
|
|
|
|
|
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:
|
2020-03-18 02:41:35 +08:00
|
|
|
if (os == llvm::Triple::Linux &&
|
|
|
|
Triple.getEnvironment() == llvm::Triple::Musl)
|
|
|
|
return new LinuxTargetInfo<HexagonTargetInfo>(Triple, Opts);
|
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
|
|
|
|
2018-09-18 17:34:39 +08:00
|
|
|
case llvm::Triple::aarch64_32:
|
|
|
|
if (Triple.isOSDarwin())
|
|
|
|
return new DarwinAArch64TargetInfo(Triple, Opts);
|
|
|
|
|
|
|
|
return nullptr;
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2021-03-08 08:33:22 +08:00
|
|
|
case llvm::Triple::m68k:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
|
|
|
return new LinuxTargetInfo<M68kTargetInfo>(Triple, Opts);
|
|
|
|
case llvm::Triple::NetBSD:
|
|
|
|
return new NetBSDTargetInfo<M68kTargetInfo>(Triple, Opts);
|
|
|
|
default:
|
|
|
|
return new M68kTargetInfo(Triple, Opts);
|
|
|
|
}
|
|
|
|
|
2021-04-23 01:18:44 +08:00
|
|
|
case llvm::Triple::le32:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::NaCl:
|
|
|
|
return new NaClTargetInfo<PNaClTargetInfo>(Triple, Opts);
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
case llvm::Triple::le64:
|
|
|
|
return new Le64TargetInfo(Triple, Opts);
|
|
|
|
|
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);
|
2019-03-15 05:54:30 +08:00
|
|
|
case llvm::Triple::AIX:
|
|
|
|
return new AIXPPC32TargetInfo(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
|
|
|
|
2021-01-03 02:17:58 +08:00
|
|
|
case llvm::Triple::ppcle:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
|
|
|
return new LinuxTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
|
|
|
case llvm::Triple::FreeBSD:
|
|
|
|
return new FreeBSDTargetInfo<PPC32TargetInfo>(Triple, Opts);
|
|
|
|
default:
|
|
|
|
return new PPC32TargetInfo(Triple, Opts);
|
|
|
|
}
|
|
|
|
|
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);
|
2020-08-09 05:51:19 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
|
|
|
return new OpenBSDTargetInfo<PPC64TargetInfo>(Triple, Opts);
|
2019-03-15 05:54:30 +08:00
|
|
|
case llvm::Triple::AIX:
|
|
|
|
return new AIXPPC64TargetInfo(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);
|
2020-08-29 18:02:51 +08:00
|
|
|
case llvm::Triple::FreeBSD:
|
|
|
|
return new FreeBSDTargetInfo<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);
|
2020-08-09 05:51:19 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
|
|
|
return new OpenBSDTargetInfo<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:
|
[RISCV] Add FreeBSD targets
Reviewers: asb
Reviewed By: asb
Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne, emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57795
Patch by James Clarke (jrtc27)
llvm-svn: 367557
2019-08-01 21:14:30 +08:00
|
|
|
// TODO: add cases for NetBSD, RTEMS once tested.
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::FreeBSD:
|
|
|
|
return new FreeBSDTargetInfo<RISCV32TargetInfo>(Triple, Opts);
|
|
|
|
case llvm::Triple::Linux:
|
2018-02-03 19:56:11 +08:00
|
|
|
return new LinuxTargetInfo<RISCV32TargetInfo>(Triple, Opts);
|
[RISCV] Add FreeBSD targets
Reviewers: asb
Reviewed By: asb
Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne, emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57795
Patch by James Clarke (jrtc27)
llvm-svn: 367557
2019-08-01 21:14:30 +08:00
|
|
|
default:
|
|
|
|
return new RISCV32TargetInfo(Triple, Opts);
|
|
|
|
}
|
|
|
|
|
2018-01-11 21:36:56 +08:00
|
|
|
case llvm::Triple::riscv64:
|
[RISCV] Add FreeBSD targets
Reviewers: asb
Reviewed By: asb
Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne, emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57795
Patch by James Clarke (jrtc27)
llvm-svn: 367557
2019-08-01 21:14:30 +08:00
|
|
|
// TODO: add cases for NetBSD, RTEMS once tested.
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::FreeBSD:
|
|
|
|
return new FreeBSDTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
2020-08-19 06:59:55 +08:00
|
|
|
case llvm::Triple::OpenBSD:
|
|
|
|
return new OpenBSDTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
2019-11-20 11:56:54 +08:00
|
|
|
case llvm::Triple::Fuchsia:
|
|
|
|
return new FuchsiaTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
[RISCV] Add FreeBSD targets
Reviewers: asb
Reviewed By: asb
Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne, emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57795
Patch by James Clarke (jrtc27)
llvm-svn: 367557
2019-08-01 21:14:30 +08:00
|
|
|
case llvm::Triple::Linux:
|
2018-02-03 19:56:11 +08:00
|
|
|
return new LinuxTargetInfo<RISCV64TargetInfo>(Triple, Opts);
|
[RISCV] Add FreeBSD targets
Reviewers: asb
Reviewed By: asb
Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne, emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57795
Patch by James Clarke (jrtc27)
llvm-svn: 367557
2019-08-01 21:14:30 +08:00
|
|
|
default:
|
|
|
|
return new RISCV64TargetInfo(Triple, Opts);
|
|
|
|
}
|
2018-01-11 21:36:56 +08:00
|
|
|
|
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);
|
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::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);
|
2020-08-26 01:50:17 +08:00
|
|
|
case llvm::Triple::ZOS:
|
|
|
|
return new ZOSTargetInfo<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);
|
2020-04-23 07:41:03 +08:00
|
|
|
case llvm::Triple::Fuchsia:
|
|
|
|
return new FuchsiaTargetInfo<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);
|
2018-11-29 11:49:14 +08:00
|
|
|
case llvm::Triple::Hurd:
|
|
|
|
return new HurdTargetInfo<X86_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: {
|
2021-03-25 22:38:02 +08:00
|
|
|
if (os != llvm::Triple::UnknownOS ||
|
2015-05-13 05:18:10 +08:00
|
|
|
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: {
|
2021-03-25 22:38:02 +08:00
|
|
|
if (os != llvm::Triple::UnknownOS ||
|
2015-05-13 05:18:10 +08:00
|
|
|
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
|
|
|
}
|
2021-11-08 19:13:09 +08:00
|
|
|
case llvm::Triple::spirv32: {
|
|
|
|
if (os != llvm::Triple::UnknownOS ||
|
|
|
|
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
|
|
|
|
return nullptr;
|
|
|
|
return new SPIRV32TargetInfo(Triple, Opts);
|
|
|
|
}
|
|
|
|
case llvm::Triple::spirv64: {
|
|
|
|
if (os != llvm::Triple::UnknownOS ||
|
|
|
|
Triple.getEnvironment() != llvm::Triple::UnknownEnvironment)
|
|
|
|
return nullptr;
|
|
|
|
return new SPIRV64TargetInfo(Triple, Opts);
|
|
|
|
}
|
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 ||
|
2019-01-15 14:58:16 +08:00
|
|
|
!Triple.isOSBinFormatWasm())
|
|
|
|
return nullptr;
|
2021-03-25 22:38:02 +08:00
|
|
|
switch (os) {
|
2019-01-25 05:05:11 +08:00
|
|
|
case llvm::Triple::WASI:
|
|
|
|
return new WASITargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
|
2019-04-03 09:08:35 +08:00
|
|
|
case llvm::Triple::Emscripten:
|
|
|
|
return new EmscriptenTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
|
2019-01-25 05:05:11 +08:00
|
|
|
case llvm::Triple::UnknownOS:
|
|
|
|
return new WebAssemblyOSTargetInfo<WebAssembly32TargetInfo>(Triple, Opts);
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
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 ||
|
2019-01-15 14:58:16 +08:00
|
|
|
!Triple.isOSBinFormatWasm())
|
|
|
|
return nullptr;
|
2021-03-25 22:38:02 +08:00
|
|
|
switch (os) {
|
2019-01-25 05:05:11 +08:00
|
|
|
case llvm::Triple::WASI:
|
|
|
|
return new WASITargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
|
2019-04-03 09:08:35 +08:00
|
|
|
case llvm::Triple::Emscripten:
|
|
|
|
return new EmscriptenTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
|
2019-01-25 05:05:11 +08:00
|
|
|
case llvm::Triple::UnknownOS:
|
|
|
|
return new WebAssemblyOSTargetInfo<WebAssembly64TargetInfo>(Triple, Opts);
|
|
|
|
default:
|
|
|
|
return nullptr;
|
|
|
|
}
|
2016-07-02 08:05:42 +08:00
|
|
|
|
2022-03-29 02:45:41 +08:00
|
|
|
case llvm::Triple::dxil:
|
|
|
|
return new DirectXTargetInfo(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);
|
2020-06-24 16:11:59 +08:00
|
|
|
|
|
|
|
case llvm::Triple::ve:
|
|
|
|
return new LinuxTargetInfo<VETargetInfo>(Triple, Opts);
|
2022-03-29 16:18:10 +08:00
|
|
|
|
|
|
|
case llvm::Triple::csky:
|
|
|
|
switch (os) {
|
|
|
|
case llvm::Triple::Linux:
|
|
|
|
return new LinuxTargetInfo<CSKYTargetInfo>(Triple, Opts);
|
|
|
|
default:
|
|
|
|
return new CSKYTargetInfo(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
|
|
|
}
|
|
|
|
|
2020-08-19 05:52:44 +08:00
|
|
|
// Check the TuneCPU name if specified.
|
2020-08-23 07:05:01 +08:00
|
|
|
if (!Opts->TuneCPU.empty() &&
|
|
|
|
!Target->isValidTuneCPUName(Opts->TuneCPU)) {
|
2020-08-19 05:52:44 +08:00
|
|
|
Diags.Report(diag::err_target_unknown_cpu) << Opts->TuneCPU;
|
|
|
|
SmallVector<StringRef, 32> ValidList;
|
2020-08-23 07:05:01 +08:00
|
|
|
Target->fillValidTuneCPUList(ValidList);
|
2020-08-19 05:52:44 +08:00
|
|
|
if (!ValidList.empty())
|
|
|
|
Diags.Report(diag::note_valid_options) << llvm::join(ValidList, ", ");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
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.
|
2020-08-13 02:47:29 +08:00
|
|
|
if (!Target->initFeatureMap(Opts->FeatureMap, Diags, Opts->CPU,
|
2015-08-29 06:32:01 +08:00
|
|
|
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();
|
2020-08-13 02:47:29 +08:00
|
|
|
for (const auto &F : Opts->FeatureMap)
|
2015-08-12 21:38:59 +08:00
|
|
|
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.)
|
2018-10-01 05:41:11 +08:00
|
|
|
llvm::sort(Opts->Features);
|
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();
|
2021-01-26 00:23:58 +08:00
|
|
|
Target->setCommandLineOpenCLOpts();
|
2017-09-23 00:30:00 +08:00
|
|
|
Target->setMaxAtomicWidth();
|
2016-05-17 01:06:34 +08:00
|
|
|
|
2022-02-02 16:19:49 +08:00
|
|
|
if (!Opts->DarwinTargetVariantTriple.empty())
|
|
|
|
Target->DarwinTargetVariantTriple =
|
|
|
|
llvm::Triple(Opts->DarwinTargetVariantTriple);
|
|
|
|
|
2016-06-14 16:58:50 +08:00
|
|
|
if (!Target->validateTarget(Diags))
|
|
|
|
return nullptr;
|
|
|
|
|
2018-06-21 01:19:40 +08:00
|
|
|
Target->CheckFixedPointBits();
|
|
|
|
|
2014-03-08 03:33:25 +08:00
|
|
|
return Target.release();
|
2009-11-15 14:48:46 +08:00
|
|
|
}
|
2021-04-23 00:53:59 +08:00
|
|
|
/// validateOpenCLTarget - Check that OpenCL target has valid
|
|
|
|
/// options setting based on OpenCL version.
|
|
|
|
bool TargetInfo::validateOpenCLTarget(const LangOptions &Opts,
|
|
|
|
DiagnosticsEngine &Diags) const {
|
|
|
|
const llvm::StringMap<bool> &OpenCLFeaturesMap = getSupportedOpenCLOpts();
|
|
|
|
|
|
|
|
auto diagnoseNotSupportedCore = [&](llvm::StringRef Name, auto... OptArgs) {
|
|
|
|
if (OpenCLOptions::isOpenCLOptionCoreIn(Opts, OptArgs...) &&
|
|
|
|
!hasFeatureEnabled(OpenCLFeaturesMap, Name))
|
|
|
|
Diags.Report(diag::warn_opencl_unsupported_core_feature)
|
|
|
|
<< Name << Opts.OpenCLCPlusPlus
|
|
|
|
<< Opts.getOpenCLVersionTuple().getAsString();
|
2021-01-26 00:23:58 +08:00
|
|
|
};
|
2021-04-23 00:53:59 +08:00
|
|
|
#define OPENCL_GENERIC_EXTENSION(Ext, ...) \
|
|
|
|
diagnoseNotSupportedCore(#Ext, __VA_ARGS__);
|
2021-01-26 00:23:58 +08:00
|
|
|
#include "clang/Basic/OpenCLExtensions.def"
|
|
|
|
|
2021-05-21 19:07:23 +08:00
|
|
|
// Validate that feature macros are set properly for OpenCL C 3.0.
|
|
|
|
// In other cases assume that target is always valid.
|
2021-08-24 18:59:42 +08:00
|
|
|
if (Opts.getOpenCLCompatibleVersion() < 300)
|
2021-05-21 19:07:23 +08:00
|
|
|
return true;
|
|
|
|
|
2021-07-13 20:09:14 +08:00
|
|
|
return OpenCLOptions::diagnoseUnsupportedFeatureDependencies(*this, Diags) &&
|
|
|
|
OpenCLOptions::diagnoseFeatureExtensionDifferences(*this, Diags);
|
2021-01-26 00:23:58 +08:00
|
|
|
}
|