2017-07-22 06:37:03 +08:00
|
|
|
//===--- AArch64.cpp - Implement AArch64 target feature support -----------===//
|
|
|
|
//
|
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
|
2017-07-22 06:37:03 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements AArch64 TargetInfo objects.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AArch64.h"
|
2020-04-02 16:11:01 +08:00
|
|
|
#include "clang/Basic/LangOptions.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
#include "clang/Basic/TargetBuiltins.h"
|
|
|
|
#include "clang/Basic/TargetInfo.h"
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2017-10-07 07:09:55 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2019-11-15 19:34:47 +08:00
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
#include "llvm/Support/AArch64TargetParser.h"
|
2017-07-22 06:37:03 +08:00
|
|
|
|
|
|
|
using namespace clang;
|
|
|
|
using namespace clang::targets;
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
const Builtin::Info AArch64TargetInfo::BuiltinInfo[] = {
|
|
|
|
#define BUILTIN(ID, TYPE, ATTRS) \
|
|
|
|
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
|
|
|
|
#include "clang/Basic/BuiltinsNEON.def"
|
|
|
|
|
2020-03-18 19:07:20 +08:00
|
|
|
#define BUILTIN(ID, TYPE, ATTRS) \
|
|
|
|
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
|
|
|
|
#include "clang/Basic/BuiltinsSVE.def"
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
#define BUILTIN(ID, TYPE, ATTRS) \
|
|
|
|
{#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
|
2017-10-12 15:05:37 +08:00
|
|
|
#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \
|
|
|
|
{#ID, TYPE, ATTRS, nullptr, LANG, nullptr},
|
2018-07-18 14:15:09 +08:00
|
|
|
#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \
|
|
|
|
{#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE},
|
2017-07-25 01:06:23 +08:00
|
|
|
#include "clang/Basic/BuiltinsAArch64.def"
|
|
|
|
};
|
|
|
|
|
|
|
|
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: TargetInfo(Triple), ABI("aapcs") {
|
2018-12-20 21:09:30 +08:00
|
|
|
if (getTriple().isOSOpenBSD()) {
|
2017-07-25 01:06:23 +08:00
|
|
|
Int64Type = SignedLongLong;
|
|
|
|
IntMaxType = SignedLongLong;
|
|
|
|
} else {
|
2018-12-20 21:09:30 +08:00
|
|
|
if (!getTriple().isOSDarwin() && !getTriple().isOSNetBSD())
|
2017-10-07 07:09:55 +08:00
|
|
|
WCharType = UnsignedInt;
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
Int64Type = SignedLong;
|
|
|
|
IntMaxType = SignedLong;
|
|
|
|
}
|
|
|
|
|
2018-03-19 21:22:49 +08:00
|
|
|
// All AArch64 implementations support ARMv8 FP, which makes half a legal type.
|
|
|
|
HasLegalHalfType = true;
|
2019-01-26 01:27:57 +08:00
|
|
|
HasFloat16 = true;
|
2017-10-07 07:09:55 +08:00
|
|
|
|
2018-09-18 17:34:39 +08:00
|
|
|
if (Triple.isArch64Bit())
|
|
|
|
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
|
|
|
|
else
|
|
|
|
LongWidth = LongAlign = PointerWidth = PointerAlign = 32;
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
MaxVectorAlign = 128;
|
|
|
|
MaxAtomicInlineWidth = 128;
|
|
|
|
MaxAtomicPromoteWidth = 128;
|
|
|
|
|
|
|
|
LongDoubleWidth = LongDoubleAlign = SuitableAlign = 128;
|
|
|
|
LongDoubleFormat = &llvm::APFloat::IEEEquad();
|
|
|
|
|
[ARM] Add __bf16 as new Bfloat16 C Type
Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:
https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new bfloat IR type.
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij
Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli
Reviewed By: SjoerdMeijer
Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, danielkiss, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76077
2020-06-05 07:20:02 +08:00
|
|
|
BFloat16Width = BFloat16Align = 16;
|
|
|
|
BFloat16Format = &llvm::APFloat::BFloat();
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
// Make __builtin_ms_va_list available.
|
|
|
|
HasBuiltinMSVaList = true;
|
|
|
|
|
2019-08-09 16:52:54 +08:00
|
|
|
// Make the SVE types available. Note that this deliberately doesn't
|
|
|
|
// depend on SveMode, since in principle it should be possible to turn
|
|
|
|
// SVE on and off within a translation unit. It should also be possible
|
|
|
|
// to compile the global declaration:
|
|
|
|
//
|
|
|
|
// __SVInt8_t *ptr;
|
|
|
|
//
|
|
|
|
// even without SVE.
|
|
|
|
HasAArch64SVETypes = true;
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
// {} in inline assembly are neon specifiers, not assembly variant
|
|
|
|
// specifiers.
|
|
|
|
NoAsmVariants = true;
|
|
|
|
|
|
|
|
// AAPCS gives rules for bitfields. 7.1.7 says: "The container type
|
|
|
|
// contributes to the alignment of the containing aggregate in the same way
|
|
|
|
// a plain (non bit-field) member of that type would, without exception for
|
|
|
|
// zero-sized or anonymous bit-fields."
|
|
|
|
assert(UseBitFieldTypeAlignment && "bitfields affect type alignment");
|
|
|
|
UseZeroLengthBitfieldAlignment = true;
|
|
|
|
|
|
|
|
// AArch64 targets default to using the ARM C++ ABI.
|
|
|
|
TheCXXABI.set(TargetCXXABI::GenericAArch64);
|
|
|
|
|
|
|
|
if (Triple.getOS() == llvm::Triple::Linux)
|
|
|
|
this->MCountName = "\01_mcount";
|
|
|
|
else if (Triple.getOS() == llvm::Triple::UnknownOS)
|
|
|
|
this->MCountName =
|
|
|
|
Opts.EABIVersion == llvm::EABI::GNU ? "\01_mcount" : "mcount";
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef AArch64TargetInfo::getABI() const { return ABI; }
|
|
|
|
|
|
|
|
bool AArch64TargetInfo::setABI(const std::string &Name) {
|
|
|
|
if (Name != "aapcs" && Name != "darwinpcs")
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ABI = Name;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-15 19:34:47 +08:00
|
|
|
bool AArch64TargetInfo::validateBranchProtection(StringRef Spec,
|
|
|
|
BranchProtectionInfo &BPI,
|
|
|
|
StringRef &Err) const {
|
|
|
|
llvm::AArch64::ParsedBranchProtection PBP;
|
|
|
|
if (!llvm::AArch64::parseBranchProtection(Spec, PBP, Err))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
BPI.SignReturnAddr =
|
2020-04-02 16:11:01 +08:00
|
|
|
llvm::StringSwitch<LangOptions::SignReturnAddressScopeKind>(PBP.Scope)
|
|
|
|
.Case("non-leaf", LangOptions::SignReturnAddressScopeKind::NonLeaf)
|
|
|
|
.Case("all", LangOptions::SignReturnAddressScopeKind::All)
|
|
|
|
.Default(LangOptions::SignReturnAddressScopeKind::None);
|
2019-11-15 19:34:47 +08:00
|
|
|
|
|
|
|
if (PBP.Key == "a_key")
|
2020-04-02 16:11:01 +08:00
|
|
|
BPI.SignKey = LangOptions::SignReturnAddressKeyKind::AKey;
|
2019-11-15 19:34:47 +08:00
|
|
|
else
|
2020-04-02 16:11:01 +08:00
|
|
|
BPI.SignKey = LangOptions::SignReturnAddressKeyKind::BKey;
|
2019-11-15 19:34:47 +08:00
|
|
|
|
|
|
|
BPI.BranchTargetEnforcement = PBP.BranchTargetEnforcement;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
bool AArch64TargetInfo::isValidCPUName(StringRef Name) const {
|
|
|
|
return Name == "generic" ||
|
2017-07-28 00:28:39 +08:00
|
|
|
llvm::AArch64::parseCPUArch(Name) != llvm::AArch64::ArchKind::INVALID;
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AArch64TargetInfo::setCPU(const std::string &Name) {
|
|
|
|
return isValidCPUName(Name);
|
|
|
|
}
|
|
|
|
|
2018-02-09 07:14:15 +08:00
|
|
|
void AArch64TargetInfo::fillValidCPUList(
|
|
|
|
SmallVectorImpl<StringRef> &Values) const {
|
|
|
|
llvm::AArch64::fillValidCPUArchList(Values);
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
void AArch64TargetInfo::getTargetDefinesARMV81A(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_QRDMX", "1");
|
2020-11-13 21:56:43 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AArch64TargetInfo::getTargetDefinesARMV82A(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
// Also include the ARMv8.1 defines
|
|
|
|
getTargetDefinesARMV81A(Opts, Builder);
|
|
|
|
}
|
|
|
|
|
2019-07-16 17:27:39 +08:00
|
|
|
void AArch64TargetInfo::getTargetDefinesARMV83A(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
2019-12-02 20:13:04 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_COMPLEX", "1");
|
2019-07-16 17:27:39 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_JCVT", "1");
|
|
|
|
// Also include the Armv8.2 defines
|
|
|
|
getTargetDefinesARMV82A(Opts, Builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AArch64TargetInfo::getTargetDefinesARMV84A(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
// Also include the Armv8.3 defines
|
|
|
|
getTargetDefinesARMV83A(Opts, Builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AArch64TargetInfo::getTargetDefinesARMV85A(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
// Also include the Armv8.4 defines
|
|
|
|
getTargetDefinesARMV84A(Opts, Builder);
|
|
|
|
}
|
|
|
|
|
[PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support
Summary:
This patch introduces command-line support for the Armv8.6-a architecture and assembly support for BFloat16. Details can be found
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
in addition to the GCC patch for the 8..6-a CLI:
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg02647.html
In detail this patch
- march options for armv8.6-a
- BFloat16 assembly
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
Based on work by:
- labrinea
- MarkMurrayARM
- Luke Cheeseman
- Javed Asbar
- Mikhail Maltsev
- Luke Geeson
Reviewers: SjoerdMeijer, craig.topper, rjmccall, jfb, LukeGeeson
Reviewed By: SjoerdMeijer
Subscribers: stuij, kristof.beyls, hiraditya, dexonsmith, danielkiss, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D76062
2020-03-26 16:17:29 +08:00
|
|
|
void AArch64TargetInfo::getTargetDefinesARMV86A(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
// Also include the Armv8.5 defines
|
|
|
|
// FIXME: Armv8.6 makes the following extensions mandatory:
|
|
|
|
// - __ARM_FEATURE_BF16
|
|
|
|
// - __ARM_FEATURE_MATMUL_INT8
|
|
|
|
// Handle them here.
|
|
|
|
getTargetDefinesARMV85A(Opts, Builder);
|
|
|
|
}
|
2019-07-16 17:27:39 +08:00
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
// Target identification.
|
|
|
|
Builder.defineMacro("__aarch64__");
|
2018-10-18 05:07:11 +08:00
|
|
|
// For bare-metal.
|
2017-07-25 01:06:23 +08:00
|
|
|
if (getTriple().getOS() == llvm::Triple::UnknownOS &&
|
2018-10-18 05:07:11 +08:00
|
|
|
getTriple().isOSBinFormatELF())
|
2017-07-25 01:06:23 +08:00
|
|
|
Builder.defineMacro("__ELF__");
|
|
|
|
|
|
|
|
// Target properties.
|
2018-09-18 17:34:39 +08:00
|
|
|
if (!getTriple().isOSWindows() && getTriple().isArch64Bit()) {
|
2017-08-01 04:40:53 +08:00
|
|
|
Builder.defineMacro("_LP64");
|
|
|
|
Builder.defineMacro("__LP64__");
|
|
|
|
}
|
2017-07-25 01:06:23 +08:00
|
|
|
|
2020-02-22 13:25:57 +08:00
|
|
|
std::string CodeModel = getTargetOpts().CodeModel;
|
|
|
|
if (CodeModel == "default")
|
|
|
|
CodeModel = "small";
|
|
|
|
for (char &c : CodeModel)
|
|
|
|
c = toupper(c);
|
|
|
|
Builder.defineMacro("__AARCH64_CMODEL_" + CodeModel + "__");
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
// ACLE predefines. Many can only have one possible value on v8 AArch64.
|
|
|
|
Builder.defineMacro("__ARM_ACLE", "200");
|
|
|
|
Builder.defineMacro("__ARM_ARCH", "8");
|
|
|
|
Builder.defineMacro("__ARM_ARCH_PROFILE", "'A'");
|
|
|
|
|
|
|
|
Builder.defineMacro("__ARM_64BIT_STATE", "1");
|
|
|
|
Builder.defineMacro("__ARM_PCS_AAPCS64", "1");
|
|
|
|
Builder.defineMacro("__ARM_ARCH_ISA_A64", "1");
|
|
|
|
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_CLZ", "1");
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_FMA", "1");
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_LDREX", "0xF");
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_IDIV", "1"); // As specified in ACLE
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_DIV"); // For backwards compatibility
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_NUMERIC_MAXMIN", "1");
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_DIRECTED_ROUNDING", "1");
|
|
|
|
|
|
|
|
Builder.defineMacro("__ARM_ALIGN_MAX_STACK_PWR", "4");
|
|
|
|
|
|
|
|
// 0xe implies support for half, single and double precision operations.
|
|
|
|
Builder.defineMacro("__ARM_FP", "0xE");
|
|
|
|
|
|
|
|
// PCS specifies this for SysV variants, which is all we support. Other ABIs
|
|
|
|
// may choose __ARM_FP16_FORMAT_ALTERNATIVE.
|
|
|
|
Builder.defineMacro("__ARM_FP16_FORMAT_IEEE", "1");
|
|
|
|
Builder.defineMacro("__ARM_FP16_ARGS", "1");
|
|
|
|
|
|
|
|
if (Opts.UnsafeFPMath)
|
|
|
|
Builder.defineMacro("__ARM_FP_FAST", "1");
|
|
|
|
|
2017-10-07 07:09:55 +08:00
|
|
|
Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
|
2017-12-29 00:58:54 +08:00
|
|
|
Twine(Opts.WCharSize ? Opts.WCharSize : 4));
|
2017-07-25 01:06:23 +08:00
|
|
|
|
|
|
|
Builder.defineMacro("__ARM_SIZEOF_MINIMAL_ENUM", Opts.ShortEnums ? "1" : "4");
|
|
|
|
|
|
|
|
if (FPU & NeonMode) {
|
|
|
|
Builder.defineMacro("__ARM_NEON", "1");
|
|
|
|
// 64-bit NEON supports half, single and double precision operations.
|
|
|
|
Builder.defineMacro("__ARM_NEON_FP", "0xE");
|
|
|
|
}
|
|
|
|
|
2020-06-24 23:52:41 +08:00
|
|
|
if (FPU & SveMode)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE", "1");
|
|
|
|
|
|
|
|
if (HasSVE2)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE2", "1");
|
|
|
|
|
|
|
|
if (HasSVE2 && HasSVE2AES)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE2_AES", "1");
|
|
|
|
|
|
|
|
if (HasSVE2 && HasSVE2BitPerm)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE2_BITPERM", "1");
|
|
|
|
|
|
|
|
if (HasSVE2 && HasSVE2SHA3)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE2_SHA3", "1");
|
|
|
|
|
|
|
|
if (HasSVE2 && HasSVE2SM4)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE2_SM4", "1");
|
|
|
|
|
2019-07-17 19:24:37 +08:00
|
|
|
if (HasCRC)
|
2017-07-25 01:06:23 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_CRC32", "1");
|
|
|
|
|
2019-07-17 19:24:37 +08:00
|
|
|
if (HasCrypto)
|
2017-07-25 01:06:23 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_CRYPTO", "1");
|
|
|
|
|
2019-07-17 19:24:37 +08:00
|
|
|
if (HasUnaligned)
|
2017-07-25 01:06:23 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1");
|
|
|
|
|
2017-12-22 03:20:01 +08:00
|
|
|
if ((FPU & NeonMode) && HasFullFP16)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_FP16_VECTOR_ARITHMETIC", "1");
|
2018-01-20 07:11:18 +08:00
|
|
|
if (HasFullFP16)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
|
2017-12-22 03:20:01 +08:00
|
|
|
|
2018-04-18 06:38:40 +08:00
|
|
|
if (HasDotProd)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
|
|
|
|
|
2019-04-27 05:08:11 +08:00
|
|
|
if (HasMTE)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_MEMORY_TAGGING", "1");
|
|
|
|
|
2019-07-31 20:52:17 +08:00
|
|
|
if (HasTME)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_TME", "1");
|
|
|
|
|
2020-04-10 00:21:19 +08:00
|
|
|
if (HasMatMul)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_MATMUL_INT8", "1");
|
|
|
|
|
2020-11-13 21:56:43 +08:00
|
|
|
if (HasLSE)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_ATOMICS", "1");
|
|
|
|
|
[clang][BFloat] add NEON emitter for bfloat
Summary:
This patch adds the bfloat16_t struct typedefs (e.g. bfloat16x8x2_t) to
arm_neon.h
This patch is part of a series implementing the Bfloat16 extension of the
Armv8.6-a architecture, as detailed here:
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:
https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
The following people contributed to this patch:
- Luke Cheeseman
- Simon Tatham
- Ties Stuij
Reviewers: t.p.northover, fpetrogalli, sdesmalen, az, LukeGeeson
Reviewed By: fpetrogalli
Subscribers: SjoerdMeijer, LukeGeeson, pbarrio, mgorny, kristof.beyls, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D79708
2020-06-05 20:06:01 +08:00
|
|
|
if (HasBFloat16) {
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_BF16", "1");
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", "1");
|
|
|
|
Builder.defineMacro("__ARM_BF16_FORMAT_ALTERNATIVE", "1");
|
2020-06-26 05:49:00 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", "1");
|
[clang][BFloat] add NEON emitter for bfloat
Summary:
This patch adds the bfloat16_t struct typedefs (e.g. bfloat16x8x2_t) to
arm_neon.h
This patch is part of a series implementing the Bfloat16 extension of the
Armv8.6-a architecture, as detailed here:
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:
https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
The following people contributed to this patch:
- Luke Cheeseman
- Simon Tatham
- Ties Stuij
Reviewers: t.p.northover, fpetrogalli, sdesmalen, az, LukeGeeson
Reviewed By: fpetrogalli
Subscribers: SjoerdMeijer, LukeGeeson, pbarrio, mgorny, kristof.beyls, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D79708
2020-06-05 20:06:01 +08:00
|
|
|
}
|
|
|
|
|
2020-06-26 05:49:00 +08:00
|
|
|
if ((FPU & SveMode) && HasBFloat16) {
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE_BF16", "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((FPU & SveMode) && HasMatmulFP64)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_FP64", "1");
|
|
|
|
|
|
|
|
if ((FPU & SveMode) && HasMatmulFP32)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_FP32", "1");
|
|
|
|
|
|
|
|
if ((FPU & SveMode) && HasMatMul)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE_MATMUL_INT8", "1");
|
|
|
|
|
2018-10-26 07:47:00 +08:00
|
|
|
if ((FPU & NeonMode) && HasFP16FML)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_FP16FML", "1");
|
|
|
|
|
2020-04-02 18:10:41 +08:00
|
|
|
if (Opts.hasSignReturnAddress()) {
|
|
|
|
// Bitmask:
|
|
|
|
// 0: Protection using the A key
|
|
|
|
// 1: Protection using the B key
|
|
|
|
// 2: Protection including leaf functions
|
|
|
|
unsigned Value = 0;
|
|
|
|
|
|
|
|
if (Opts.isSignReturnAddressWithAKey())
|
|
|
|
Value |= (1 << 0);
|
|
|
|
else
|
|
|
|
Value |= (1 << 1);
|
|
|
|
|
|
|
|
if (Opts.isSignReturnAddressScopeAll())
|
|
|
|
Value |= (1 << 2);
|
|
|
|
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_PAC_DEFAULT", std::to_string(Value));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Opts.BranchTargetEnforcement)
|
|
|
|
Builder.defineMacro("__ARM_FEATURE_BTI_DEFAULT", "1");
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
switch (ArchKind) {
|
|
|
|
default:
|
|
|
|
break;
|
2017-07-28 00:28:39 +08:00
|
|
|
case llvm::AArch64::ArchKind::ARMV8_1A:
|
2017-07-25 01:06:23 +08:00
|
|
|
getTargetDefinesARMV81A(Opts, Builder);
|
|
|
|
break;
|
2017-07-28 00:28:39 +08:00
|
|
|
case llvm::AArch64::ArchKind::ARMV8_2A:
|
2017-07-25 01:06:23 +08:00
|
|
|
getTargetDefinesARMV82A(Opts, Builder);
|
|
|
|
break;
|
2019-07-16 17:27:39 +08:00
|
|
|
case llvm::AArch64::ArchKind::ARMV8_3A:
|
|
|
|
getTargetDefinesARMV83A(Opts, Builder);
|
|
|
|
break;
|
|
|
|
case llvm::AArch64::ArchKind::ARMV8_4A:
|
|
|
|
getTargetDefinesARMV84A(Opts, Builder);
|
|
|
|
break;
|
|
|
|
case llvm::AArch64::ArchKind::ARMV8_5A:
|
|
|
|
getTargetDefinesARMV85A(Opts, Builder);
|
|
|
|
break;
|
[PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support
Summary:
This patch introduces command-line support for the Armv8.6-a architecture and assembly support for BFloat16. Details can be found
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
in addition to the GCC patch for the 8..6-a CLI:
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg02647.html
In detail this patch
- march options for armv8.6-a
- BFloat16 assembly
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
Based on work by:
- labrinea
- MarkMurrayARM
- Luke Cheeseman
- Javed Asbar
- Mikhail Maltsev
- Luke Geeson
Reviewers: SjoerdMeijer, craig.topper, rjmccall, jfb, LukeGeeson
Reviewed By: SjoerdMeijer
Subscribers: stuij, kristof.beyls, hiraditya, dexonsmith, danielkiss, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D76062
2020-03-26 16:17:29 +08:00
|
|
|
case llvm::AArch64::ArchKind::ARMV8_6A:
|
|
|
|
getTargetDefinesARMV86A(Opts, Builder);
|
|
|
|
break;
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// All of the __sync_(bool|val)_compare_and_swap_(1|2|4|8) builtins work.
|
|
|
|
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
|
|
|
|
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
|
|
|
|
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
|
|
|
|
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
|
[Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute
Summary:
This patch implements parsing support for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE, version 00bet5,
section 3.7.3) for SVE [1].
The purpose of this attribute is to define fixed-length (VLST) versions
of existing sizeless types (VLAT). For example:
#if __ARM_FEATURE_SVE_BITS==512
typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512)));
#endif
Creates a type 'fixed_svint32_t' that is a fixed-length version of
'svint32_t' that is normal-sized (rather than sizeless) and contains
exactly 512 bits. Unlike 'svint32_t', this type can be used in places
such as structs and arrays where sizeless types can't.
Implemented in this patch is the following:
* Defined and tested attribute taking single argument.
* Checks the argument is an integer constant expression.
* Attribute can only be attached to a single SVE vector or predicate
type, excluding tuple types such as svint32x4_t.
* Added the `-msve-vector-bits=<bits>` flag. When specified the
`__ARM_FEATURE_SVE_BITS__EXPERIMENTAL` macro is defined.
* Added a language option to store the vector size specified by the
`-msve-vector-bits=<bits>` flag. This is used to validate `N ==
__ARM_FEATURE_SVE_BITS`, where N is the number of bits passed to the
attribute and `__ARM_FEATURE_SVE_BITS` is the feature macro defined under
the same flag.
The `__ARM_FEATURE_SVE_BITS` macro will be made non-experimental in the final
patch of the series.
[1] https://developer.arm.com/documentation/100987/latest
This is patch 1/4 of a patch series.
Reviewers: sdesmalen, rsandifo-arm, efriedma, ctetreau, cameron.mcinally, rengolin, aaron.ballman
Reviewed By: sdesmalen, aaron.ballman
Differential Revision: https://reviews.llvm.org/D83550
2020-05-29 17:17:37 +08:00
|
|
|
|
2020-11-25 17:37:00 +08:00
|
|
|
if (Opts.ArmSveVectorBits) {
|
2020-09-03 17:19:41 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.ArmSveVectorBits));
|
2020-11-25 17:37:00 +08:00
|
|
|
Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS");
|
|
|
|
}
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ArrayRef<Builtin::Info> AArch64TargetInfo::getTargetBuiltins() const {
|
|
|
|
return llvm::makeArrayRef(BuiltinInfo, clang::AArch64::LastTSBuiltin -
|
|
|
|
Builtin::FirstTSBuiltin);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
|
|
|
|
return Feature == "aarch64" || Feature == "arm64" || Feature == "arm" ||
|
|
|
|
(Feature == "neon" && (FPU & NeonMode)) ||
|
2020-06-24 23:52:41 +08:00
|
|
|
((Feature == "sve" || Feature == "sve2" || Feature == "sve2-bitperm" ||
|
|
|
|
Feature == "sve2-aes" || Feature == "sve2-sha3" ||
|
2020-06-26 05:49:00 +08:00
|
|
|
Feature == "sve2-sm4" || Feature == "f64mm" || Feature == "f32mm" ||
|
|
|
|
Feature == "i8mm" || Feature == "bf16") &&
|
2020-06-24 23:52:41 +08:00
|
|
|
(FPU & SveMode));
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
|
|
|
|
DiagnosticsEngine &Diags) {
|
|
|
|
FPU = FPUMode;
|
2019-07-17 19:24:37 +08:00
|
|
|
HasCRC = false;
|
|
|
|
HasCrypto = false;
|
|
|
|
HasUnaligned = true;
|
|
|
|
HasFullFP16 = false;
|
|
|
|
HasDotProd = false;
|
|
|
|
HasFP16FML = false;
|
|
|
|
HasMTE = false;
|
2019-07-31 20:52:17 +08:00
|
|
|
HasTME = false;
|
2020-04-10 00:21:19 +08:00
|
|
|
HasMatMul = false;
|
[ARM] Add __bf16 as new Bfloat16 C Type
Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:
https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new bfloat IR type.
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij
Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli
Reviewed By: SjoerdMeijer
Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, danielkiss, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76077
2020-06-05 07:20:02 +08:00
|
|
|
HasBFloat16 = false;
|
2020-06-24 23:52:41 +08:00
|
|
|
HasSVE2 = false;
|
|
|
|
HasSVE2AES = false;
|
|
|
|
HasSVE2SHA3 = false;
|
|
|
|
HasSVE2SM4 = false;
|
|
|
|
HasSVE2BitPerm = false;
|
2020-06-26 05:49:00 +08:00
|
|
|
HasMatmulFP64 = false;
|
|
|
|
HasMatmulFP32 = false;
|
2020-11-13 21:56:43 +08:00
|
|
|
HasLSE = false;
|
2020-06-24 23:52:41 +08:00
|
|
|
|
2017-07-28 00:28:39 +08:00
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8A;
|
2017-07-25 01:06:23 +08:00
|
|
|
|
|
|
|
for (const auto &Feature : Features) {
|
|
|
|
if (Feature == "+neon")
|
|
|
|
FPU |= NeonMode;
|
2020-06-24 23:52:41 +08:00
|
|
|
if (Feature == "+sve") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasFullFP16 = 1;
|
|
|
|
}
|
|
|
|
if (Feature == "+sve2") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasFullFP16 = 1;
|
|
|
|
HasSVE2 = 1;
|
|
|
|
}
|
|
|
|
if (Feature == "+sve2-aes") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasFullFP16 = 1;
|
|
|
|
HasSVE2 = 1;
|
|
|
|
HasSVE2AES = 1;
|
|
|
|
}
|
|
|
|
if (Feature == "+sve2-sha3") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasFullFP16 = 1;
|
|
|
|
HasSVE2 = 1;
|
|
|
|
HasSVE2SHA3 = 1;
|
|
|
|
}
|
|
|
|
if (Feature == "+sve2-sm4") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasFullFP16 = 1;
|
|
|
|
HasSVE2 = 1;
|
|
|
|
HasSVE2SM4 = 1;
|
|
|
|
}
|
|
|
|
if (Feature == "+sve2-bitperm") {
|
2017-07-25 01:06:23 +08:00
|
|
|
FPU |= SveMode;
|
2020-06-24 23:52:41 +08:00
|
|
|
HasFullFP16 = 1;
|
|
|
|
HasSVE2 = 1;
|
|
|
|
HasSVE2BitPerm = 1;
|
|
|
|
}
|
2020-06-26 05:49:00 +08:00
|
|
|
if (Feature == "+f32mm") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasMatmulFP32 = true;
|
|
|
|
}
|
|
|
|
if (Feature == "+f64mm") {
|
|
|
|
FPU |= SveMode;
|
|
|
|
HasMatmulFP64 = true;
|
|
|
|
}
|
2017-07-25 01:06:23 +08:00
|
|
|
if (Feature == "+crc")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasCRC = true;
|
2017-07-25 01:06:23 +08:00
|
|
|
if (Feature == "+crypto")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasCrypto = true;
|
2017-07-25 01:06:23 +08:00
|
|
|
if (Feature == "+strict-align")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasUnaligned = false;
|
2017-07-25 01:06:23 +08:00
|
|
|
if (Feature == "+v8.1a")
|
2017-07-28 00:28:39 +08:00
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
|
2017-07-25 01:06:23 +08:00
|
|
|
if (Feature == "+v8.2a")
|
2017-07-28 00:28:39 +08:00
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
|
2019-07-16 17:27:39 +08:00
|
|
|
if (Feature == "+v8.3a")
|
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8_3A;
|
|
|
|
if (Feature == "+v8.4a")
|
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8_4A;
|
|
|
|
if (Feature == "+v8.5a")
|
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
|
[PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support
Summary:
This patch introduces command-line support for the Armv8.6-a architecture and assembly support for BFloat16. Details can be found
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
in addition to the GCC patch for the 8..6-a CLI:
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg02647.html
In detail this patch
- march options for armv8.6-a
- BFloat16 assembly
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
Based on work by:
- labrinea
- MarkMurrayARM
- Luke Cheeseman
- Javed Asbar
- Mikhail Maltsev
- Luke Geeson
Reviewers: SjoerdMeijer, craig.topper, rjmccall, jfb, LukeGeeson
Reviewed By: SjoerdMeijer
Subscribers: stuij, kristof.beyls, hiraditya, dexonsmith, danielkiss, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D76062
2020-03-26 16:17:29 +08:00
|
|
|
if (Feature == "+v8.6a")
|
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8_6A;
|
2020-10-01 22:47:31 +08:00
|
|
|
if (Feature == "+v8r")
|
|
|
|
ArchKind = llvm::AArch64::ArchKind::ARMV8R;
|
2017-07-25 01:06:23 +08:00
|
|
|
if (Feature == "+fullfp16")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasFullFP16 = true;
|
2018-04-18 06:38:40 +08:00
|
|
|
if (Feature == "+dotprod")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasDotProd = true;
|
2018-10-26 07:47:00 +08:00
|
|
|
if (Feature == "+fp16fml")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasFP16FML = true;
|
2019-04-27 05:08:11 +08:00
|
|
|
if (Feature == "+mte")
|
2019-07-17 19:24:37 +08:00
|
|
|
HasMTE = true;
|
2019-07-31 20:52:17 +08:00
|
|
|
if (Feature == "+tme")
|
|
|
|
HasTME = true;
|
2020-04-10 00:21:19 +08:00
|
|
|
if (Feature == "+i8mm")
|
|
|
|
HasMatMul = true;
|
[ARM] Add __bf16 as new Bfloat16 C Type
Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:
https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a
The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:
https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile
In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new bfloat IR type.
This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.
The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij
Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli
Reviewed By: SjoerdMeijer
Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, danielkiss, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76077
2020-06-05 07:20:02 +08:00
|
|
|
if (Feature == "+bf16")
|
|
|
|
HasBFloat16 = true;
|
2020-11-13 21:56:43 +08:00
|
|
|
if (Feature == "+lse")
|
|
|
|
HasLSE = true;
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
setDataLayout();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetInfo::CallingConvCheckResult
|
|
|
|
AArch64TargetInfo::checkCallingConvention(CallingConv CC) const {
|
|
|
|
switch (CC) {
|
|
|
|
case CC_C:
|
|
|
|
case CC_Swift:
|
|
|
|
case CC_PreserveMost:
|
|
|
|
case CC_PreserveAll:
|
|
|
|
case CC_OpenCLKernel:
|
2018-11-27 00:38:37 +08:00
|
|
|
case CC_AArch64VectorCall:
|
2017-07-25 01:06:23 +08:00
|
|
|
case CC_Win64:
|
|
|
|
return CCCR_OK;
|
|
|
|
default:
|
|
|
|
return CCCR_Warning;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AArch64TargetInfo::isCLZForZeroUndef() const { return false; }
|
|
|
|
|
|
|
|
TargetInfo::BuiltinVaListKind AArch64TargetInfo::getBuiltinVaListKind() const {
|
|
|
|
return TargetInfo::AArch64ABIBuiltinVaList;
|
|
|
|
}
|
|
|
|
|
2017-07-22 06:37:03 +08:00
|
|
|
const char *const AArch64TargetInfo::GCCRegNames[] = {
|
|
|
|
// 32-bit Integer registers
|
|
|
|
"w0", "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11",
|
|
|
|
"w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22",
|
|
|
|
"w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30", "wsp",
|
|
|
|
|
|
|
|
// 64-bit Integer registers
|
|
|
|
"x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10", "x11",
|
|
|
|
"x12", "x13", "x14", "x15", "x16", "x17", "x18", "x19", "x20", "x21", "x22",
|
|
|
|
"x23", "x24", "x25", "x26", "x27", "x28", "fp", "lr", "sp",
|
|
|
|
|
|
|
|
// 32-bit floating point regsisters
|
|
|
|
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11",
|
|
|
|
"s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19", "s20", "s21", "s22",
|
|
|
|
"s23", "s24", "s25", "s26", "s27", "s28", "s29", "s30", "s31",
|
|
|
|
|
|
|
|
// 64-bit floating point regsisters
|
|
|
|
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "d11",
|
|
|
|
"d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22",
|
|
|
|
"d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
|
|
|
|
|
2019-07-24 16:42:34 +08:00
|
|
|
// Neon vector registers
|
2017-07-22 06:37:03 +08:00
|
|
|
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
|
|
|
|
"v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22",
|
2019-07-24 16:42:34 +08:00
|
|
|
"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
|
|
|
|
|
|
|
|
// SVE vector registers
|
|
|
|
"z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8", "z9", "z10",
|
|
|
|
"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21",
|
|
|
|
"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
|
|
|
|
|
|
|
|
// SVE predicate registers
|
|
|
|
"p0", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8", "p9", "p10",
|
|
|
|
"p11", "p12", "p13", "p14", "p15"
|
2017-07-22 06:37:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ArrayRef<const char *> AArch64TargetInfo::getGCCRegNames() const {
|
|
|
|
return llvm::makeArrayRef(GCCRegNames);
|
|
|
|
}
|
|
|
|
|
|
|
|
const TargetInfo::GCCRegAlias AArch64TargetInfo::GCCRegAliases[] = {
|
2018-03-30 05:11:15 +08:00
|
|
|
{{"w31"}, "wsp"},
|
|
|
|
{{"x31"}, "sp"},
|
|
|
|
// GCC rN registers are aliases of xN registers.
|
|
|
|
{{"r0"}, "x0"},
|
|
|
|
{{"r1"}, "x1"},
|
|
|
|
{{"r2"}, "x2"},
|
|
|
|
{{"r3"}, "x3"},
|
|
|
|
{{"r4"}, "x4"},
|
|
|
|
{{"r5"}, "x5"},
|
|
|
|
{{"r6"}, "x6"},
|
|
|
|
{{"r7"}, "x7"},
|
|
|
|
{{"r8"}, "x8"},
|
|
|
|
{{"r9"}, "x9"},
|
|
|
|
{{"r10"}, "x10"},
|
|
|
|
{{"r11"}, "x11"},
|
|
|
|
{{"r12"}, "x12"},
|
|
|
|
{{"r13"}, "x13"},
|
|
|
|
{{"r14"}, "x14"},
|
|
|
|
{{"r15"}, "x15"},
|
|
|
|
{{"r16"}, "x16"},
|
|
|
|
{{"r17"}, "x17"},
|
|
|
|
{{"r18"}, "x18"},
|
|
|
|
{{"r19"}, "x19"},
|
|
|
|
{{"r20"}, "x20"},
|
|
|
|
{{"r21"}, "x21"},
|
|
|
|
{{"r22"}, "x22"},
|
|
|
|
{{"r23"}, "x23"},
|
|
|
|
{{"r24"}, "x24"},
|
|
|
|
{{"r25"}, "x25"},
|
|
|
|
{{"r26"}, "x26"},
|
|
|
|
{{"r27"}, "x27"},
|
|
|
|
{{"r28"}, "x28"},
|
|
|
|
{{"r29", "x29"}, "fp"},
|
|
|
|
{{"r30", "x30"}, "lr"},
|
2017-07-22 06:37:03 +08:00
|
|
|
// The S/D/Q and W/X registers overlap, but aren't really aliases; we
|
|
|
|
// don't want to substitute one of these for a different-sized one.
|
|
|
|
};
|
|
|
|
|
|
|
|
ArrayRef<TargetInfo::GCCRegAlias> AArch64TargetInfo::getGCCRegAliases() const {
|
|
|
|
return llvm::makeArrayRef(GCCRegAliases);
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
bool AArch64TargetInfo::validateAsmConstraint(
|
|
|
|
const char *&Name, TargetInfo::ConstraintInfo &Info) const {
|
|
|
|
switch (*Name) {
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
case 'w': // Floating point and SIMD registers (V0-V31)
|
|
|
|
Info.setAllowsRegister();
|
|
|
|
return true;
|
|
|
|
case 'I': // Constant that can be used with an ADD instruction
|
|
|
|
case 'J': // Constant that can be used with a SUB instruction
|
|
|
|
case 'K': // Constant that can be used with a 32-bit logical instruction
|
|
|
|
case 'L': // Constant that can be used with a 64-bit logical instruction
|
|
|
|
case 'M': // Constant that can be used as a 32-bit MOV immediate
|
|
|
|
case 'N': // Constant that can be used as a 64-bit MOV immediate
|
|
|
|
case 'Y': // Floating point constant zero
|
|
|
|
case 'Z': // Integer constant zero
|
|
|
|
return true;
|
|
|
|
case 'Q': // A memory reference with base register and no offset
|
|
|
|
Info.setAllowsMemory();
|
|
|
|
return true;
|
|
|
|
case 'S': // A symbolic address
|
|
|
|
Info.setAllowsRegister();
|
|
|
|
return true;
|
|
|
|
case 'U':
|
2020-03-17 18:27:29 +08:00
|
|
|
if (Name[1] == 'p' && (Name[2] == 'l' || Name[2] == 'a')) {
|
|
|
|
// SVE predicate registers ("Upa"=P0-15, "Upl"=P0-P7)
|
|
|
|
Info.setAllowsRegister();
|
|
|
|
Name += 2;
|
|
|
|
return true;
|
|
|
|
}
|
2017-07-25 01:06:23 +08:00
|
|
|
// Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes.
|
|
|
|
// Utf: A memory address suitable for ldp/stp in TF mode.
|
|
|
|
// Usa: An absolute symbolic address.
|
|
|
|
// Ush: The high part (bits 32:12) of a pc-relative symbolic address.
|
2020-03-17 18:27:29 +08:00
|
|
|
|
|
|
|
// Better to return an error saying that it's an unrecognised constraint
|
|
|
|
// even if this is a valid constraint in gcc.
|
|
|
|
return false;
|
2017-07-25 01:06:23 +08:00
|
|
|
case 'z': // Zero register, wzr or xzr
|
|
|
|
Info.setAllowsRegister();
|
|
|
|
return true;
|
|
|
|
case 'x': // Floating point and SIMD registers (V0-V15)
|
|
|
|
Info.setAllowsRegister();
|
|
|
|
return true;
|
2020-03-17 18:27:29 +08:00
|
|
|
case 'y': // SVE registers (V0-V7)
|
|
|
|
Info.setAllowsRegister();
|
|
|
|
return true;
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-07-22 06:37:03 +08:00
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
bool AArch64TargetInfo::validateConstraintModifier(
|
|
|
|
StringRef Constraint, char Modifier, unsigned Size,
|
|
|
|
std::string &SuggestedModifier) const {
|
|
|
|
// Strip off constraint modifiers.
|
|
|
|
while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&')
|
|
|
|
Constraint = Constraint.substr(1);
|
|
|
|
|
|
|
|
switch (Constraint[0]) {
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
case 'z':
|
|
|
|
case 'r': {
|
|
|
|
switch (Modifier) {
|
|
|
|
case 'x':
|
|
|
|
case 'w':
|
|
|
|
// For now assume that the person knows what they're
|
|
|
|
// doing with the modifier.
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
// By default an 'r' constraint will be in the 'x'
|
|
|
|
// registers.
|
|
|
|
if (Size == 64)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
SuggestedModifier = "w";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *AArch64TargetInfo::getClobbers() const { return ""; }
|
|
|
|
|
|
|
|
int AArch64TargetInfo::getEHDataRegisterNumber(unsigned RegNo) const {
|
|
|
|
if (RegNo == 0)
|
|
|
|
return 0;
|
|
|
|
if (RegNo == 1)
|
|
|
|
return 1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2018-09-18 17:34:39 +08:00
|
|
|
bool AArch64TargetInfo::hasInt128Type() const { return true; }
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
AArch64leTargetInfo::AArch64leTargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: AArch64TargetInfo(Triple, Opts) {}
|
|
|
|
|
|
|
|
void AArch64leTargetInfo::setDataLayout() {
|
2018-09-18 17:34:39 +08:00
|
|
|
if (getTriple().isOSBinFormatMachO()) {
|
|
|
|
if(getTriple().isArch32Bit())
|
|
|
|
resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128");
|
|
|
|
else
|
|
|
|
resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128");
|
|
|
|
} else
|
2017-07-25 01:06:23 +08:00
|
|
|
resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
|
|
|
|
}
|
|
|
|
|
|
|
|
void AArch64leTargetInfo::getTargetDefines(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
Builder.defineMacro("__AARCH64EL__");
|
|
|
|
AArch64TargetInfo::getTargetDefines(Opts, Builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
AArch64beTargetInfo::AArch64beTargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: AArch64TargetInfo(Triple, Opts) {}
|
|
|
|
|
|
|
|
void AArch64beTargetInfo::getTargetDefines(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
Builder.defineMacro("__AARCH64EB__");
|
|
|
|
Builder.defineMacro("__AARCH_BIG_ENDIAN");
|
|
|
|
Builder.defineMacro("__ARM_BIG_ENDIAN");
|
|
|
|
AArch64TargetInfo::getTargetDefines(Opts, Builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AArch64beTargetInfo::setDataLayout() {
|
|
|
|
assert(!getTriple().isOSBinFormatMachO());
|
|
|
|
resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128");
|
|
|
|
}
|
|
|
|
|
2017-08-14 03:42:17 +08:00
|
|
|
WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
2017-07-25 01:06:23 +08:00
|
|
|
: WindowsTargetInfo<AArch64leTargetInfo>(Triple, Opts), Triple(Triple) {
|
|
|
|
|
|
|
|
// This is an LLP64 platform.
|
|
|
|
// int:4, long:4, long long:8, long double:8.
|
|
|
|
IntWidth = IntAlign = 32;
|
|
|
|
LongWidth = LongAlign = 32;
|
|
|
|
DoubleAlign = LongLongAlign = 64;
|
|
|
|
LongDoubleWidth = LongDoubleAlign = 64;
|
|
|
|
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
|
|
|
|
IntMaxType = SignedLongLong;
|
|
|
|
Int64Type = SignedLongLong;
|
|
|
|
SizeType = UnsignedLongLong;
|
|
|
|
PtrDiffType = SignedLongLong;
|
|
|
|
IntPtrType = SignedLongLong;
|
|
|
|
}
|
|
|
|
|
2017-08-14 03:42:17 +08:00
|
|
|
void WindowsARM64TargetInfo::setDataLayout() {
|
2020-11-11 10:36:10 +08:00
|
|
|
resetDataLayout(Triple.isOSBinFormatMachO()
|
|
|
|
? "e-m:o-i64:64-i128:128-n32:64-S128"
|
|
|
|
: "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128");
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TargetInfo::BuiltinVaListKind
|
2017-08-14 03:42:17 +08:00
|
|
|
WindowsARM64TargetInfo::getBuiltinVaListKind() const {
|
2017-07-25 01:06:23 +08:00
|
|
|
return TargetInfo::CharPtrBuiltinVaList;
|
|
|
|
}
|
|
|
|
|
2017-08-08 04:52:04 +08:00
|
|
|
TargetInfo::CallingConvCheckResult
|
2017-08-14 03:42:17 +08:00
|
|
|
WindowsARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
|
2017-08-08 04:52:04 +08:00
|
|
|
switch (CC) {
|
|
|
|
case CC_X86StdCall:
|
|
|
|
case CC_X86ThisCall:
|
|
|
|
case CC_X86FastCall:
|
|
|
|
case CC_X86VectorCall:
|
|
|
|
return CCCR_Ignore;
|
|
|
|
case CC_C:
|
|
|
|
case CC_OpenCLKernel:
|
2017-09-27 03:26:01 +08:00
|
|
|
case CC_PreserveMost:
|
|
|
|
case CC_PreserveAll:
|
2018-12-06 11:28:37 +08:00
|
|
|
case CC_Swift:
|
2017-08-08 04:52:04 +08:00
|
|
|
case CC_Win64:
|
|
|
|
return CCCR_OK;
|
|
|
|
default:
|
|
|
|
return CCCR_Warning;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-14 03:42:17 +08:00
|
|
|
MicrosoftARM64TargetInfo::MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: WindowsARM64TargetInfo(Triple, Opts) {
|
|
|
|
TheCXXABI.set(TargetCXXABI::Microsoft);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MicrosoftARM64TargetInfo::getTargetDefines(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
2019-07-10 04:57:28 +08:00
|
|
|
WindowsARM64TargetInfo::getTargetDefines(Opts, Builder);
|
|
|
|
Builder.defineMacro("_M_ARM64", "1");
|
2017-08-14 03:42:17 +08:00
|
|
|
}
|
|
|
|
|
[ARM64] [Windows] Follow MS X86_64 C++ ABI when passing structs
Summary: Microsoft's C++ object model for ARM64 is the same as that for X86_64.
For example, small structs with non-trivial copy constructors or virtual
function tables are passed indirectly. Currently, they are passed in registers
when compiled with clang.
Reviewers: rnk, mstorsjo, TomTan, haripul, javed.absar
Reviewed By: rnk, mstorsjo
Subscribers: kristof.beyls, chrib, llvm-commits, cfe-commits
Differential Revision: https://reviews.llvm.org/D49770
llvm-svn: 338076
2018-07-27 06:18:28 +08:00
|
|
|
TargetInfo::CallingConvKind
|
|
|
|
MicrosoftARM64TargetInfo::getCallingConvKind(bool ClangABICompat4) const {
|
|
|
|
return CCK_MicrosoftWin64;
|
|
|
|
}
|
|
|
|
|
2019-05-02 08:38:14 +08:00
|
|
|
unsigned MicrosoftARM64TargetInfo::getMinGlobalAlign(uint64_t TypeSize) const {
|
|
|
|
unsigned Align = WindowsARM64TargetInfo::getMinGlobalAlign(TypeSize);
|
|
|
|
|
|
|
|
// MSVC does size based alignment for arm64 based on alignment section in
|
|
|
|
// below document, replicate that to keep alignment consistent with object
|
|
|
|
// files compiled by MSVC.
|
|
|
|
// https://docs.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions
|
|
|
|
if (TypeSize >= 512) { // TypeSize >= 64 bytes
|
|
|
|
Align = std::max(Align, 128u); // align type at least 16 bytes
|
|
|
|
} else if (TypeSize >= 64) { // TypeSize >= 8 bytes
|
|
|
|
Align = std::max(Align, 64u); // align type at least 8 butes
|
|
|
|
} else if (TypeSize >= 16) { // TypeSize >= 2 bytes
|
|
|
|
Align = std::max(Align, 32u); // align type at least 4 bytes
|
|
|
|
}
|
|
|
|
return Align;
|
|
|
|
}
|
|
|
|
|
2017-08-14 03:42:17 +08:00
|
|
|
MinGWARM64TargetInfo::MinGWARM64TargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: WindowsARM64TargetInfo(Triple, Opts) {
|
|
|
|
TheCXXABI.set(TargetCXXABI::GenericAArch64);
|
|
|
|
}
|
|
|
|
|
2017-07-25 01:06:23 +08:00
|
|
|
DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: DarwinTargetInfo<AArch64leTargetInfo>(Triple, Opts) {
|
|
|
|
Int64Type = SignedLongLong;
|
2018-09-18 17:34:39 +08:00
|
|
|
if (getTriple().isArch32Bit())
|
|
|
|
IntMaxType = SignedLongLong;
|
|
|
|
|
|
|
|
WCharType = SignedInt;
|
2017-07-25 01:06:23 +08:00
|
|
|
UseSignedCharForObjCBool = false;
|
|
|
|
|
|
|
|
LongDoubleWidth = LongDoubleAlign = SuitableAlign = 64;
|
|
|
|
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
|
|
|
|
|
2018-09-18 17:34:39 +08:00
|
|
|
UseZeroLengthBitfieldAlignment = false;
|
|
|
|
|
|
|
|
if (getTriple().isArch32Bit()) {
|
|
|
|
UseBitFieldTypeAlignment = false;
|
|
|
|
ZeroLengthBitfieldBoundary = 32;
|
|
|
|
UseZeroLengthBitfieldAlignment = true;
|
|
|
|
TheCXXABI.set(TargetCXXABI::WatchOS);
|
|
|
|
} else
|
2020-12-03 22:11:03 +08:00
|
|
|
TheCXXABI.set(TargetCXXABI::AppleARM64);
|
2017-07-25 01:06:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void DarwinAArch64TargetInfo::getOSDefines(const LangOptions &Opts,
|
|
|
|
const llvm::Triple &Triple,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
Builder.defineMacro("__AARCH64_SIMD__");
|
2018-09-18 17:34:39 +08:00
|
|
|
if (Triple.isArch32Bit())
|
|
|
|
Builder.defineMacro("__ARM64_ARCH_8_32__");
|
|
|
|
else
|
|
|
|
Builder.defineMacro("__ARM64_ARCH_8__");
|
2017-07-25 01:06:23 +08:00
|
|
|
Builder.defineMacro("__ARM_NEON__");
|
|
|
|
Builder.defineMacro("__LITTLE_ENDIAN__");
|
|
|
|
Builder.defineMacro("__REGISTER_PREFIX__", "");
|
|
|
|
Builder.defineMacro("__arm64", "1");
|
|
|
|
Builder.defineMacro("__arm64__", "1");
|
|
|
|
|
|
|
|
getDarwinDefines(Builder, Opts, Triple, PlatformName, PlatformMinVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetInfo::BuiltinVaListKind
|
|
|
|
DarwinAArch64TargetInfo::getBuiltinVaListKind() const {
|
|
|
|
return TargetInfo::CharPtrBuiltinVaList;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 64-bit RenderScript is aarch64
|
|
|
|
RenderScript64TargetInfo::RenderScript64TargetInfo(const llvm::Triple &Triple,
|
|
|
|
const TargetOptions &Opts)
|
|
|
|
: AArch64leTargetInfo(llvm::Triple("aarch64", Triple.getVendorName(),
|
|
|
|
Triple.getOSName(),
|
|
|
|
Triple.getEnvironmentName()),
|
|
|
|
Opts) {
|
|
|
|
IsRenderScriptTarget = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderScript64TargetInfo::getTargetDefines(const LangOptions &Opts,
|
|
|
|
MacroBuilder &Builder) const {
|
|
|
|
Builder.defineMacro("__RENDERSCRIPT__");
|
|
|
|
AArch64leTargetInfo::getTargetDefines(Opts, Builder);
|
|
|
|
}
|