aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Basic
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic')
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Attributes.cpp10
-rw-r--r--contrib/llvm-project/clang/lib/Basic/BuiltinTargetFeatures.h95
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Builtins.cpp48
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Cuda.cpp9
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Diagnostic.cpp92
-rw-r--r--contrib/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp42
-rw-r--r--contrib/llvm-project/clang/lib/Basic/FileManager.cpp191
-rw-r--r--contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp8
-rw-r--r--contrib/llvm-project/clang/lib/Basic/LangOptions.cpp132
-rw-r--r--contrib/llvm-project/clang/lib/Basic/LangStandards.cpp45
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Module.cpp5
-rw-r--r--contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp12
-rw-r--r--contrib/llvm-project/clang/lib/Basic/OpenMPKinds.cpp64
-rw-r--r--contrib/llvm-project/clang/lib/Basic/SourceManager.cpp22
-rw-r--r--contrib/llvm-project/clang/lib/Basic/TargetID.cpp6
-rw-r--r--contrib/llvm-project/clang/lib/Basic/TargetInfo.cpp24
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets.cpp18
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp30
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/AArch64.h2
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp40
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.h7
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp1
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/AVR.cpp557
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/CSKY.cpp314
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/CSKY.h107
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/DirectX.cpp22
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/DirectX.h93
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/NVPTX.cpp8
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.cpp52
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.h62
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp35
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/PPC.h16
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp16
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/RISCV.h4
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/SPIR.h10
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.cpp13
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.h24
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/VE.cpp9
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp19
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.h1
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp25
-rw-r--r--contrib/llvm-project/clang/lib/Basic/Targets/X86.h25
-rw-r--r--contrib/llvm-project/clang/lib/Basic/TokenKinds.cpp9
43 files changed, 1808 insertions, 516 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Attributes.cpp b/contrib/llvm-project/clang/lib/Basic/Attributes.cpp
index 62eea9c59082..960c9773d192 100644
--- a/contrib/llvm-project/clang/lib/Basic/Attributes.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Attributes.cpp
@@ -5,9 +5,9 @@
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
-int clang::hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
- const IdentifierInfo *Attr, const TargetInfo &Target,
- const LangOptions &LangOpts) {
+int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
+ const IdentifierInfo *Scope, const IdentifierInfo *Attr,
+ const TargetInfo &Target, const LangOptions &LangOpts) {
StringRef Name = Attr->getName();
// Normalize the attribute name, __foo__ becomes foo.
if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
@@ -85,6 +85,10 @@ bool AttributeCommonInfo::isGNUScope() const {
return ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"));
}
+bool AttributeCommonInfo::isClangScope() const {
+ return ScopeName && (ScopeName->isStr("clang") || ScopeName->isStr("_Clang"));
+}
+
#include "clang/Sema/AttrParsedAttrKinds.inc"
static SmallString<64> normalizeName(const IdentifierInfo *Name,
diff --git a/contrib/llvm-project/clang/lib/Basic/BuiltinTargetFeatures.h b/contrib/llvm-project/clang/lib/Basic/BuiltinTargetFeatures.h
new file mode 100644
index 000000000000..4d3358de5076
--- /dev/null
+++ b/contrib/llvm-project/clang/lib/Basic/BuiltinTargetFeatures.h
@@ -0,0 +1,95 @@
+//===-- CodeGenFunction.h - Target features for builtin ---------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This is the internal required target features for builtin.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_BUILTINTARGETFEATURES_H
+#define LLVM_CLANG_LIB_BASIC_BUILTINTARGETFEATURES_H
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+
+using llvm::StringRef;
+
+namespace clang {
+namespace Builtin {
+/// TargetFeatures - This class is used to check whether the builtin function
+/// has the required tagert specific features. It is able to support the
+/// combination of ','(and), '|'(or), and '()'. By default, the priority of
+/// ',' is higher than that of '|' .
+/// E.g:
+/// A,B|C means the builtin function requires both A and B, or C.
+/// If we want the builtin function requires both A and B, or both A and C,
+/// there are two ways: A,B|A,C or A,(B|C).
+/// The FeaturesList should not contain spaces, and brackets must appear in
+/// pairs.
+class TargetFeatures {
+ struct FeatureListStatus {
+ bool HasFeatures;
+ StringRef CurFeaturesList;
+ };
+
+ const llvm::StringMap<bool> &CallerFeatureMap;
+
+ FeatureListStatus getAndFeatures(StringRef FeatureList) {
+ int InParentheses = 0;
+ bool HasFeatures = true;
+ size_t SubexpressionStart = 0;
+ for (size_t i = 0, e = FeatureList.size(); i < e; ++i) {
+ char CurrentToken = FeatureList[i];
+ switch (CurrentToken) {
+ default:
+ break;
+ case '(':
+ if (InParentheses == 0)
+ SubexpressionStart = i + 1;
+ ++InParentheses;
+ break;
+ case ')':
+ --InParentheses;
+ assert(InParentheses >= 0 && "Parentheses are not in pair");
+ LLVM_FALLTHROUGH;
+ case '|':
+ case ',':
+ if (InParentheses == 0) {
+ if (HasFeatures && i != SubexpressionStart) {
+ StringRef F = FeatureList.slice(SubexpressionStart, i);
+ HasFeatures = CurrentToken == ')' ? hasRequiredFeatures(F)
+ : CallerFeatureMap.lookup(F);
+ }
+ SubexpressionStart = i + 1;
+ if (CurrentToken == '|') {
+ return {HasFeatures, FeatureList.substr(SubexpressionStart)};
+ }
+ }
+ break;
+ }
+ }
+ assert(InParentheses == 0 && "Parentheses are not in pair");
+ if (HasFeatures && SubexpressionStart != FeatureList.size())
+ HasFeatures =
+ CallerFeatureMap.lookup(FeatureList.substr(SubexpressionStart));
+ return {HasFeatures, StringRef()};
+ }
+
+public:
+ bool hasRequiredFeatures(StringRef FeatureList) {
+ FeatureListStatus FS = {false, FeatureList};
+ while (!FS.HasFeatures && !FS.CurFeaturesList.empty())
+ FS = getAndFeatures(FS.CurFeaturesList);
+ return FS.HasFeatures;
+ }
+
+ TargetFeatures(const llvm::StringMap<bool> &CallerFeatureMap)
+ : CallerFeatureMap(CallerFeatureMap) {}
+};
+
+} // namespace Builtin
+} // namespace clang
+#endif /* CLANG_LIB_BASIC_BUILTINTARGETFEATURES_H */
diff --git a/contrib/llvm-project/clang/lib/Basic/Builtins.cpp b/contrib/llvm-project/clang/lib/Basic/Builtins.cpp
index 6d278e9c4a22..b42e8f416cfc 100644
--- a/contrib/llvm-project/clang/lib/Basic/Builtins.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Builtins.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/Builtins.h"
+#include "BuiltinTargetFeatures.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/TargetInfo.h"
@@ -48,18 +49,22 @@ void Builtin::Context::InitializeTarget(const TargetInfo &Target,
}
bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) {
- for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin; ++i)
- if (FuncName.equals(BuiltinInfo[i].Name))
+ bool InStdNamespace = FuncName.consume_front("std-");
+ for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin;
+ ++i) {
+ if (FuncName.equals(BuiltinInfo[i].Name) &&
+ (bool)strchr(BuiltinInfo[i].Attributes, 'z') == InStdNamespace)
return strchr(BuiltinInfo[i].Attributes, 'f') != nullptr;
+ }
return false;
}
-bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo,
- const LangOptions &LangOpts) {
+/// Is this builtin supported according to the given language options?
+static bool builtinIsSupported(const Builtin::Info &BuiltinInfo,
+ const LangOptions &LangOpts) {
bool BuiltinsUnsupported =
- (LangOpts.NoBuiltin || LangOpts.isNoBuiltinFunc(BuiltinInfo.Name)) &&
- strchr(BuiltinInfo.Attributes, 'f');
+ LangOpts.NoBuiltin && strchr(BuiltinInfo.Attributes, 'f') != nullptr;
bool CorBuiltinsUnsupported =
!LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG);
bool MathBuiltinsUnsupported =
@@ -111,6 +116,19 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table,
for (unsigned i = 0, e = AuxTSRecords.size(); i != e; ++i)
Table.get(AuxTSRecords[i].Name)
.setBuiltinID(i + Builtin::FirstTSBuiltin + TSRecords.size());
+
+ // Step #4: Unregister any builtins specified by -fno-builtin-foo.
+ for (llvm::StringRef Name : LangOpts.NoBuiltinFuncs) {
+ bool InStdNamespace = Name.consume_front("std-");
+ auto NameIt = Table.find(Name);
+ if (NameIt != Table.end()) {
+ unsigned ID = NameIt->second->getBuiltinID();
+ if (ID != Builtin::NotBuiltin && isPredefinedLibFunction(ID) &&
+ isInStdNamespace(ID) == InStdNamespace) {
+ Table.get(Name).setBuiltinID(Builtin::NotBuiltin);
+ }
+ }
+ }
}
unsigned Builtin::Context::getRequiredVectorWidth(unsigned ID) const {
@@ -190,8 +208,18 @@ bool Builtin::Context::performsCallback(unsigned ID,
}
bool Builtin::Context::canBeRedeclared(unsigned ID) const {
- return ID == Builtin::NotBuiltin ||
- ID == Builtin::BI__va_start ||
- (!hasReferenceArgsOrResult(ID) &&
- !hasCustomTypechecking(ID));
+ return ID == Builtin::NotBuiltin || ID == Builtin::BI__va_start ||
+ (!hasReferenceArgsOrResult(ID) && !hasCustomTypechecking(ID)) ||
+ isInStdNamespace(ID);
+}
+
+bool Builtin::evaluateRequiredTargetFeatures(
+ StringRef RequiredFeatures, const llvm::StringMap<bool> &TargetFetureMap) {
+ // Return true if the builtin doesn't have any required features.
+ if (RequiredFeatures.empty())
+ return true;
+ assert(!RequiredFeatures.contains(' ') && "Space in feature list");
+
+ TargetFeatures TF(TargetFetureMap);
+ return TF.hasRequiredFeatures(RequiredFeatures);
}
diff --git a/contrib/llvm-project/clang/lib/Basic/Cuda.cpp b/contrib/llvm-project/clang/lib/Basic/Cuda.cpp
index 2d75578b3de0..d75cc410f2d9 100644
--- a/contrib/llvm-project/clang/lib/Basic/Cuda.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Cuda.cpp
@@ -113,6 +113,7 @@ static const CudaArchToStringMap arch_names[] = {
GFX(909), // gfx909
GFX(90a), // gfx90a
GFX(90c), // gfx90c
+ GFX(940), // gfx940
GFX(1010), // gfx1010
GFX(1011), // gfx1011
GFX(1012), // gfx1012
@@ -123,6 +124,11 @@ static const CudaArchToStringMap arch_names[] = {
GFX(1033), // gfx1033
GFX(1034), // gfx1034
GFX(1035), // gfx1035
+ GFX(1036), // gfx1036
+ GFX(1100), // gfx1100
+ GFX(1101), // gfx1101
+ GFX(1102), // gfx1102
+ GFX(1103), // gfx1103
{CudaArch::Generic, "generic", ""},
// clang-format on
};
@@ -214,8 +220,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) {
}
CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
- int IVer =
- Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
+ int IVer = Version.getMajor() * 10 + Version.getMinor().value_or(0);
switch(IVer) {
case 70:
return CudaVersion::CUDA_70;
diff --git a/contrib/llvm-project/clang/lib/Basic/Diagnostic.cpp b/contrib/llvm-project/clang/lib/Basic/Diagnostic.cpp
index ac4b9d2cd5a2..dbe62ecb50d3 100644
--- a/contrib/llvm-project/clang/lib/Basic/Diagnostic.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Diagnostic.cpp
@@ -25,8 +25,9 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/CrashRecoveryContext.h"
-#include "llvm/Support/Locale.h"
+#include "llvm/Support/Unicode.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
@@ -130,7 +131,7 @@ bool DiagnosticsEngine::popMappings(SourceLocation Loc) {
return true;
}
-void DiagnosticsEngine::Reset() {
+void DiagnosticsEngine::Reset(bool soft /*=false*/) {
ErrorOccurred = false;
UncompilableErrorOccurred = false;
FatalErrorOccurred = false;
@@ -145,15 +146,17 @@ void DiagnosticsEngine::Reset() {
LastDiagLevel = DiagnosticIDs::Ignored;
DelayedDiagID = 0;
- // Clear state related to #pragma diagnostic.
- DiagStates.clear();
- DiagStatesByLoc.clear();
- DiagStateOnPushStack.clear();
+ if (!soft) {
+ // Clear state related to #pragma diagnostic.
+ DiagStates.clear();
+ DiagStatesByLoc.clear();
+ DiagStateOnPushStack.clear();
- // Create a DiagState and DiagStatePoint representing diagnostic changes
- // through command-line.
- DiagStates.emplace_back();
- DiagStatesByLoc.appendFirst(&DiagStates.back());
+ // Create a DiagState and DiagStatePoint representing diagnostic changes
+ // through command-line.
+ DiagStates.emplace_back();
+ DiagStatesByLoc.appendFirst(&DiagStates.back());
+ }
}
void DiagnosticsEngine::SetDelayedDiagnostic(unsigned DiagID, StringRef Arg1,
@@ -801,6 +804,50 @@ FormatDiagnostic(SmallVectorImpl<char> &OutStr) const {
FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
}
+/// pushEscapedString - Append Str to the diagnostic buffer,
+/// escaping non-printable characters and ill-formed code unit sequences.
+static void pushEscapedString(StringRef Str, SmallVectorImpl<char> &OutStr) {
+ OutStr.reserve(OutStr.size() + Str.size());
+ auto *Begin = reinterpret_cast<const unsigned char *>(Str.data());
+ llvm::raw_svector_ostream OutStream(OutStr);
+ const unsigned char *End = Begin + Str.size();
+ while (Begin != End) {
+ // ASCII case
+ if (isPrintable(*Begin) || isWhitespace(*Begin)) {
+ OutStream << *Begin;
+ ++Begin;
+ continue;
+ }
+ if (llvm::isLegalUTF8Sequence(Begin, End)) {
+ llvm::UTF32 CodepointValue;
+ llvm::UTF32 *CpPtr = &CodepointValue;
+ const unsigned char *CodepointBegin = Begin;
+ const unsigned char *CodepointEnd =
+ Begin + llvm::getNumBytesForUTF8(*Begin);
+ llvm::ConversionResult Res = llvm::ConvertUTF8toUTF32(
+ &Begin, CodepointEnd, &CpPtr, CpPtr + 1, llvm::strictConversion);
+ (void)Res;
+ assert(
+ llvm::conversionOK == Res &&
+ "the sequence is legal UTF-8 but we couldn't convert it to UTF-32");
+ assert(Begin == CodepointEnd &&
+ "we must be further along in the string now");
+ if (llvm::sys::unicode::isPrintable(CodepointValue) ||
+ llvm::sys::unicode::isFormatting(CodepointValue)) {
+ OutStr.append(CodepointBegin, CodepointEnd);
+ continue;
+ }
+ // Unprintable code point.
+ OutStream << "<U+" << llvm::format_hex_no_prefix(CodepointValue, 4, true)
+ << ">";
+ continue;
+ }
+ // Invalid code unit.
+ OutStream << "<" << llvm::format_hex_no_prefix(*Begin, 2, true) << ">";
+ ++Begin;
+ }
+}
+
void Diagnostic::
FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
SmallVectorImpl<char> &OutStr) const {
@@ -811,11 +858,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
StringRef(DiagStr, DiagEnd - DiagStr).equals("%0") &&
getArgKind(0) == DiagnosticsEngine::ak_std_string) {
const std::string &S = getArgStdStr(0);
- for (char c : S) {
- if (llvm::sys::locale::isPrint(c) || c == '\t') {
- OutStr.push_back(c);
- }
- }
+ pushEscapedString(S, OutStr);
return;
}
@@ -922,7 +965,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
case DiagnosticsEngine::ak_std_string: {
const std::string &S = getArgStdStr(ArgNo);
assert(ModifierLen == 0 && "No modifiers for strings yet");
- OutStr.append(S.begin(), S.end());
+ pushEscapedString(S, OutStr);
break;
}
case DiagnosticsEngine::ak_c_string: {
@@ -932,8 +975,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
// Don't crash if get passed a null pointer by accident.
if (!S)
S = "(null)";
-
- OutStr.append(S, S + strlen(S));
+ pushEscapedString(S, OutStr);
break;
}
// ---- INTEGERS ----
@@ -983,13 +1025,13 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
if (const char *S = tok::getPunctuatorSpelling(Kind))
// Quoted token spelling for punctuators.
Out << '\'' << S << '\'';
- else if (const char *S = tok::getKeywordSpelling(Kind))
+ else if ((S = tok::getKeywordSpelling(Kind)))
// Unquoted token spelling for keywords.
Out << S;
- else if (const char *S = getTokenDescForDiagnostic(Kind))
+ else if ((S = getTokenDescForDiagnostic(Kind)))
// Unquoted translatable token name.
Out << S;
- else if (const char *S = tok::getTokenName(Kind))
+ else if ((S = tok::getTokenName(Kind)))
// Debug name, shouldn't appear in user-facing diagnostics.
Out << '<' << S << '>';
else
@@ -1138,6 +1180,14 @@ StoredDiagnostic::StoredDiagnostic(DiagnosticsEngine::Level Level, unsigned ID,
{
}
+llvm::raw_ostream &clang::operator<<(llvm::raw_ostream &OS,
+ const StoredDiagnostic &SD) {
+ if (SD.getLocation().hasManager())
+ OS << SD.getLocation().printToString(SD.getLocation().getManager()) << ": ";
+ OS << SD.getMessage();
+ return OS;
+}
+
/// IncludeInDiagnosticCounts - This method (whose default implementation
/// returns true) indicates whether the diagnostics handled by this
/// DiagnosticConsumer should be included in the number of diagnostics
diff --git a/contrib/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp b/contrib/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp
index 87db131992e4..8e2593b103d1 100644
--- a/contrib/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/DiagnosticIDs.cpp
@@ -607,6 +607,7 @@ namespace {
uint16_t NameOffset;
uint16_t Members;
uint16_t SubGroups;
+ StringRef Documentation;
// String is stored with a pascal-style length byte.
StringRef getName() const {
@@ -618,28 +619,47 @@ namespace {
// Second the table of options, sorted by name for fast binary lookup.
static const WarningOption OptionTable[] = {
-#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups) \
- {FlagNameOffset, Members, SubGroups},
+#define DIAG_ENTRY(GroupName, FlagNameOffset, Members, SubGroups, Docs) \
+ {FlagNameOffset, Members, SubGroups, Docs},
#include "clang/Basic/DiagnosticGroups.inc"
#undef DIAG_ENTRY
};
+/// Given a diagnostic group ID, return its documentation.
+StringRef DiagnosticIDs::getWarningOptionDocumentation(diag::Group Group) {
+ return OptionTable[static_cast<int>(Group)].Documentation;
+}
+
StringRef DiagnosticIDs::getWarningOptionForGroup(diag::Group Group) {
return OptionTable[static_cast<int>(Group)].getName();
}
+llvm::Optional<diag::Group>
+DiagnosticIDs::getGroupForWarningOption(StringRef Name) {
+ const auto *Found = llvm::partition_point(
+ OptionTable, [=](const WarningOption &O) { return O.getName() < Name; });
+ if (Found == std::end(OptionTable) || Found->getName() != Name)
+ return llvm::None;
+ return static_cast<diag::Group>(Found - OptionTable);
+}
+
+llvm::Optional<diag::Group> DiagnosticIDs::getGroupForDiag(unsigned DiagID) {
+ if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
+ return static_cast<diag::Group>(Info->getOptionGroupIndex());
+ return llvm::None;
+}
+
/// getWarningOptionForDiag - Return the lowest-level warning option that
/// enables the specified diagnostic. If there is no -Wfoo flag that controls
/// the diagnostic, this returns null.
StringRef DiagnosticIDs::getWarningOptionForDiag(unsigned DiagID) {
- if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
- return getWarningOptionForGroup(
- static_cast<diag::Group>(Info->getOptionGroupIndex()));
+ if (auto G = getGroupForDiag(DiagID))
+ return getWarningOptionForGroup(*G);
return StringRef();
}
std::vector<std::string> DiagnosticIDs::getDiagnosticFlags() {
- std::vector<std::string> Res;
+ std::vector<std::string> Res{"-W", "-Wno-"};
for (size_t I = 1; DiagGroupNames[I] != '\0';) {
std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]);
I += DiagGroupNames[I] + 1;
@@ -683,12 +703,10 @@ static bool getDiagnosticsInGroup(diag::Flavor Flavor,
bool
DiagnosticIDs::getDiagnosticsInGroup(diag::Flavor Flavor, StringRef Group,
SmallVectorImpl<diag::kind> &Diags) const {
- auto Found = llvm::partition_point(
- OptionTable, [=](const WarningOption &O) { return O.getName() < Group; });
- if (Found == std::end(OptionTable) || Found->getName() != Group)
- return true; // Option not found.
-
- return ::getDiagnosticsInGroup(Flavor, Found, Diags);
+ if (llvm::Optional<diag::Group> G = getGroupForWarningOption(Group))
+ return ::getDiagnosticsInGroup(
+ Flavor, &OptionTable[static_cast<unsigned>(*G)], Diags);
+ return true;
}
void DiagnosticIDs::getAllDiagnostics(diag::Flavor Flavor,
diff --git a/contrib/llvm-project/clang/lib/Basic/FileManager.cpp b/contrib/llvm-project/clang/lib/Basic/FileManager.cpp
index f4cf27848d7d..b66780a1d1d1 100644
--- a/contrib/llvm-project/clang/lib/Basic/FileManager.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/FileManager.cpp
@@ -105,10 +105,10 @@ void FileManager::addAncestorsAsVirtualDirs(StringRef Path) {
return;
// Add the virtual directory to the cache.
- auto UDE = std::make_unique<DirectoryEntry>();
+ auto *UDE = new (DirsAlloc.Allocate()) DirectoryEntry();
UDE->Name = NamedDirEnt.first();
- NamedDirEnt.second = *UDE.get();
- VirtualDirectoryEntries.push_back(std::move(UDE));
+ NamedDirEnt.second = *UDE;
+ VirtualDirectoryEntries.push_back(UDE);
// Recursively add the other ancestors.
addAncestorsAsVirtualDirs(DirName);
@@ -172,14 +172,15 @@ FileManager::getDirectoryRef(StringRef DirName, bool CacheFailure) {
// same inode (this occurs on Unix-like systems when one dir is
// symlinked to another, for example) or the same path (on
// Windows).
- DirectoryEntry &UDE = UniqueRealDirs[Status.getUniqueID()];
+ DirectoryEntry *&UDE = UniqueRealDirs[Status.getUniqueID()];
- NamedDirEnt.second = UDE;
- if (UDE.getName().empty()) {
+ if (!UDE) {
// We don't have this directory yet, add it. We use the string
// key from the SeenDirEntries map as the string.
- UDE.Name = InterndDirName;
+ UDE = new (DirsAlloc.Allocate()) DirectoryEntry();
+ UDE->Name = InterndDirName;
}
+ NamedDirEnt.second = *UDE;
return DirectoryEntryRef(NamedDirEnt);
}
@@ -268,11 +269,14 @@ FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) {
// It exists. See if we have already opened a file with the same inode.
// This occurs when one dir is symlinked to another, for example.
- FileEntry &UFE = UniqueRealFiles[Status.getUniqueID()];
+ FileEntry *&UFE = UniqueRealFiles[Status.getUniqueID()];
+ bool ReusingEntry = UFE != nullptr;
+ if (!UFE)
+ UFE = new (FilesAlloc.Allocate()) FileEntry();
if (Status.getName() == Filename) {
// The name matches. Set the FileEntry.
- NamedFileEnt->second = FileEntryRef::MapValue(UFE, DirInfo);
+ NamedFileEnt->second = FileEntryRef::MapValue(*UFE, DirInfo);
} else {
// Name mismatch. We need a redirect. First grab the actual entry we want
// to return.
@@ -283,18 +287,55 @@ FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) {
// name to users (in diagnostics) and to tools that don't have access to
// the VFS (in debug info and dependency '.d' files).
//
- // FIXME: This is pretty complicated. It's also inconsistent with how
- // "real" filesystems behave and confuses parts of clang expect to see the
- // name-as-accessed on the \a FileEntryRef. Maybe the returned \a
- // FileEntryRef::getName() could return the accessed name unmodified, but
- // make the external name available via a separate API.
+ // FIXME: This is pretty complex and has some very complicated interactions
+ // with the rest of clang. It's also inconsistent with how "real"
+ // filesystems behave and confuses parts of clang expect to see the
+ // name-as-accessed on the \a FileEntryRef.
+ //
+ // Further, it isn't *just* external names, but will also give back absolute
+ // paths when a relative path was requested - the check is comparing the
+ // name from the status, which is passed an absolute path resolved from the
+ // current working directory. `clang-apply-replacements` appears to depend
+ // on this behaviour, though it's adjusting the working directory, which is
+ // definitely not supported. Once that's fixed this hack should be able to
+ // be narrowed to only when there's an externally mapped name given back.
+ //
+ // A potential plan to remove this is as follows -
+ // - Add API to determine if the name has been rewritten by the VFS.
+ // - Fix `clang-apply-replacements` to pass down the absolute path rather
+ // than changing the CWD. Narrow this hack down to just externally
+ // mapped paths.
+ // - Expose the requested filename. One possibility would be to allow
+ // redirection-FileEntryRefs to be returned, rather than returning
+ // the pointed-at-FileEntryRef, and customizing `getName()` to look
+ // through the indirection.
+ // - Update callers such as `HeaderSearch::findUsableModuleForHeader()`
+ // to explicitly use the requested filename rather than just using
+ // `getName()`.
+ // - Add a `FileManager::getExternalPath` API for explicitly getting the
+ // remapped external filename when there is one available. Adopt it in
+ // callers like diagnostics/deps reporting instead of calling
+ // `getName()` directly.
+ // - Switch the meaning of `FileEntryRef::getName()` to get the requested
+ // name, not the external name. Once that sticks, revert callers that
+ // want the requested name back to calling `getName()`.
+ // - Update the VFS to always return the requested name. This could also
+ // return the external name, or just have an API to request it
+ // lazily. The latter has the benefit of making accesses of the
+ // external path easily tracked, but may also require extra work than
+ // just returning up front.
+ // - (Optionally) Add an API to VFS to get the external filename lazily
+ // and update `FileManager::getExternalPath()` to use it instead. This
+ // has the benefit of making such accesses easily tracked, though isn't
+ // necessarily required (and could cause extra work than just adding to
+ // eg. `vfs::Status` up front).
auto &Redirection =
*SeenFileEntries
- .insert({Status.getName(), FileEntryRef::MapValue(UFE, DirInfo)})
+ .insert({Status.getName(), FileEntryRef::MapValue(*UFE, DirInfo)})
.first;
assert(Redirection.second->V.is<FileEntry *>() &&
"filename redirected to a non-canonical filename?");
- assert(Redirection.second->V.get<FileEntry *>() == &UFE &&
+ assert(Redirection.second->V.get<FileEntry *>() == UFE &&
"filename from getStatValue() refers to wrong file");
// Cache the redirection in the previously-inserted entry, still available
@@ -306,16 +347,18 @@ FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) {
}
FileEntryRef ReturnedRef(*NamedFileEnt);
- if (UFE.isValid()) { // Already have an entry with this inode, return it.
+ if (ReusingEntry) { // Already have an entry with this inode, return it.
- // FIXME: this hack ensures that if we look up a file by a virtual path in
- // the VFS that the getDir() will have the virtual path, even if we found
- // the file by a 'real' path first. This is required in order to find a
- // module's structure when its headers/module map are mapped in the VFS.
- // We should remove this as soon as we can properly support a file having
- // multiple names.
- if (&DirInfo.getDirEntry() != UFE.Dir && Status.IsVFSMapped)
- UFE.Dir = &DirInfo.getDirEntry();
+ // FIXME: This hack ensures that `getDir()` will use the path that was
+ // used to lookup this file, even if we found a file by different path
+ // first. This is required in order to find a module's structure when its
+ // headers/module map are mapped in the VFS.
+ //
+ // See above for how this will eventually be removed. `IsVFSMapped`
+ // *cannot* be narrowed to `ExposesExternalVFSPath` as crash reproducers
+ // also depend on this logic and they have `use-external-paths: false`.
+ if (&DirInfo.getDirEntry() != UFE->Dir && Status.IsVFSMapped)
+ UFE->Dir = &DirInfo.getDirEntry();
// Always update LastRef to the last name by which a file was accessed.
// FIXME: Neither this nor always using the first reference is correct; we
@@ -324,28 +367,27 @@ FileManager::getFileRef(StringRef Filename, bool openFile, bool CacheFailure) {
// corresponding FileEntry.
// FIXME: LastRef should be removed from FileEntry once all clients adopt
// FileEntryRef.
- UFE.LastRef = ReturnedRef;
+ UFE->LastRef = ReturnedRef;
return ReturnedRef;
}
// Otherwise, we don't have this file yet, add it.
- UFE.LastRef = ReturnedRef;
- UFE.Size = Status.getSize();
- UFE.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
- UFE.Dir = &DirInfo.getDirEntry();
- UFE.UID = NextFileUID++;
- UFE.UniqueID = Status.getUniqueID();
- UFE.IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;
- UFE.File = std::move(F);
- UFE.IsValid = true;
-
- if (UFE.File) {
- if (auto PathName = UFE.File->getName())
- fillRealPathName(&UFE, *PathName);
+ UFE->LastRef = ReturnedRef;
+ UFE->Size = Status.getSize();
+ UFE->ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
+ UFE->Dir = &DirInfo.getDirEntry();
+ UFE->UID = NextFileUID++;
+ UFE->UniqueID = Status.getUniqueID();
+ UFE->IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;
+ UFE->File = std::move(F);
+
+ if (UFE->File) {
+ if (auto PathName = UFE->File->getName())
+ fillRealPathName(UFE, *PathName);
} else if (!openFile) {
// We should still fill the path even if we aren't opening the file.
- fillRealPathName(&UFE, InterndFileName);
+ fillRealPathName(UFE, InterndFileName);
}
return ReturnedRef;
}
@@ -409,43 +451,46 @@ FileEntryRef FileManager::getVirtualFileRef(StringRef Filename, off_t Size,
llvm::vfs::Status Status;
const char *InterndFileName = NamedFileEnt.first().data();
if (!getStatValue(InterndFileName, Status, true, nullptr)) {
- UFE = &UniqueRealFiles[Status.getUniqueID()];
Status = llvm::vfs::Status(
Status.getName(), Status.getUniqueID(),
llvm::sys::toTimePoint(ModificationTime),
Status.getUser(), Status.getGroup(), Size,
Status.getType(), Status.getPermissions());
- NamedFileEnt.second = FileEntryRef::MapValue(*UFE, *DirInfo);
-
- // If we had already opened this file, close it now so we don't
- // leak the descriptor. We're not going to use the file
- // descriptor anyway, since this is a virtual file.
- if (UFE->File)
- UFE->closeFile();
-
- // If we already have an entry with this inode, return it.
- //
- // FIXME: Surely this should add a reference by the new name, and return
- // it instead...
- if (UFE->isValid())
+ auto &RealFE = UniqueRealFiles[Status.getUniqueID()];
+ if (RealFE) {
+ // If we had already opened this file, close it now so we don't
+ // leak the descriptor. We're not going to use the file
+ // descriptor anyway, since this is a virtual file.
+ if (RealFE->File)
+ RealFE->closeFile();
+ // If we already have an entry with this inode, return it.
+ //
+ // FIXME: Surely this should add a reference by the new name, and return
+ // it instead...
+ NamedFileEnt.second = FileEntryRef::MapValue(*RealFE, *DirInfo);
return FileEntryRef(NamedFileEnt);
-
- UFE->UniqueID = Status.getUniqueID();
- UFE->IsNamedPipe = Status.getType() == llvm::sys::fs::file_type::fifo_file;
- fillRealPathName(UFE, Status.getName());
+ }
+ // File exists, but no entry - create it.
+ RealFE = new (FilesAlloc.Allocate()) FileEntry();
+ RealFE->UniqueID = Status.getUniqueID();
+ RealFE->IsNamedPipe =
+ Status.getType() == llvm::sys::fs::file_type::fifo_file;
+ fillRealPathName(RealFE, Status.getName());
+
+ UFE = RealFE;
} else {
- VirtualFileEntries.push_back(std::make_unique<FileEntry>());
- UFE = VirtualFileEntries.back().get();
- NamedFileEnt.second = FileEntryRef::MapValue(*UFE, *DirInfo);
+ // File does not exist, create a virtual entry.
+ UFE = new (FilesAlloc.Allocate()) FileEntry();
+ VirtualFileEntries.push_back(UFE);
}
+ NamedFileEnt.second = FileEntryRef::MapValue(*UFE, *DirInfo);
UFE->LastRef = FileEntryRef(NamedFileEnt);
UFE->Size = Size;
UFE->ModTime = ModificationTime;
UFE->Dir = &DirInfo->getDirEntry();
UFE->UID = NextFileUID++;
- UFE->IsValid = true;
UFE->File.reset();
return FileEntryRef(NamedFileEnt);
}
@@ -467,16 +512,14 @@ llvm::Optional<FileEntryRef> FileManager::getBypassFile(FileEntryRef VF) {
return FileEntryRef(*Insertion.first);
// Fill in the new entry from the stat.
- BypassFileEntries.push_back(std::make_unique<FileEntry>());
- const FileEntry &VFE = VF.getFileEntry();
- FileEntry &BFE = *BypassFileEntries.back();
- Insertion.first->second = FileEntryRef::MapValue(BFE, VF.getDir());
- BFE.LastRef = FileEntryRef(*Insertion.first);
- BFE.Size = Status.getSize();
- BFE.Dir = VFE.Dir;
- BFE.ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
- BFE.UID = NextFileUID++;
- BFE.IsValid = true;
+ FileEntry *BFE = new (FilesAlloc.Allocate()) FileEntry();
+ BypassFileEntries.push_back(BFE);
+ Insertion.first->second = FileEntryRef::MapValue(*BFE, VF.getDir());
+ BFE->LastRef = FileEntryRef(*Insertion.first);
+ BFE->Size = Status.getSize();
+ BFE->Dir = VF.getFileEntry().Dir;
+ BFE->ModTime = llvm::sys::toTimeT(Status.getLastModificationTime());
+ BFE->UID = NextFileUID++;
// Save the entry in the bypass table and return.
return FileEntryRef(*Insertion.first);
@@ -593,7 +636,7 @@ FileManager::getNoncachedStatValue(StringRef Path,
}
void FileManager::GetUniqueIDMapping(
- SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
+ SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
UIDToFiles.clear();
UIDToFiles.resize(NextFileUID);
@@ -610,7 +653,7 @@ void FileManager::GetUniqueIDMapping(
// Map virtual file entries
for (const auto &VFE : VirtualFileEntries)
- UIDToFiles[VFE->getUID()] = VFE.get();
+ UIDToFiles[VFE->getUID()] = VFE;
}
StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
diff --git a/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp b/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
index b86cb7af69bd..82cee4aa052d 100644
--- a/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
@@ -108,9 +108,11 @@ namespace {
KEYOPENCLCXX = 0x400000,
KEYMSCOMPAT = 0x800000,
KEYSYCL = 0x1000000,
+ KEYCUDA = 0x2000000,
+ KEYMAX = KEYCUDA, // The maximum key
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
- KEYALL = (0x1ffffff & ~KEYNOMS18 &
- ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
+ KEYALL = (KEYMAX | (KEYMAX-1)) & ~KEYNOMS18 &
+ ~KEYNOOPENCL // KEYNOMS18 and KEYNOOPENCL are used to exclude.
};
/// How a keyword is treated in the selected standard.
@@ -158,6 +160,8 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
return KS_Future;
if (LangOpts.isSYCL() && (Flags & KEYSYCL))
return KS_Enabled;
+ if (LangOpts.CUDA && (Flags & KEYCUDA))
+ return KS_Enabled;
return KS_Disabled;
}
diff --git a/contrib/llvm-project/clang/lib/Basic/LangOptions.cpp b/contrib/llvm-project/clang/lib/Basic/LangOptions.cpp
index b6dc73d66304..753b6bfe18a3 100644
--- a/contrib/llvm-project/clang/lib/Basic/LangOptions.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/LangOptions.cpp
@@ -62,7 +62,7 @@ unsigned LangOptions::getOpenCLCompatibleVersion() const {
llvm_unreachable("Unknown OpenCL version");
}
-void LangOptions::remapPathPrefix(SmallString<256> &Path) const {
+void LangOptions::remapPathPrefix(SmallVectorImpl<char> &Path) const {
for (const auto &Entry : MacroPrefixMap)
if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
break;
@@ -78,11 +78,141 @@ std::string LangOptions::getOpenCLVersionString() const {
return Result;
}
+void LangOptions::setLangDefaults(LangOptions &Opts, Language Lang,
+ const llvm::Triple &T,
+ std::vector<std::string> &Includes,
+ LangStandard::Kind LangStd) {
+ // Set some properties which depend solely on the input kind; it would be nice
+ // to move these to the language standard, and have the driver resolve the
+ // input kind + language standard.
+ //
+ // FIXME: Perhaps a better model would be for a single source file to have
+ // multiple language standards (C / C++ std, ObjC std, OpenCL std, OpenMP std)
+ // simultaneously active?
+ if (Lang == Language::Asm) {
+ Opts.AsmPreprocessor = 1;
+ } else if (Lang == Language::ObjC || Lang == Language::ObjCXX) {
+ Opts.ObjC = 1;
+ }
+
+ if (LangStd == LangStandard::lang_unspecified)
+ LangStd = getDefaultLanguageStandard(Lang, T);
+ const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
+ Opts.LangStd = LangStd;
+ Opts.LineComment = Std.hasLineComments();
+ Opts.C99 = Std.isC99();
+ Opts.C11 = Std.isC11();
+ Opts.C17 = Std.isC17();
+ Opts.C2x = Std.isC2x();
+ Opts.CPlusPlus = Std.isCPlusPlus();
+ Opts.CPlusPlus11 = Std.isCPlusPlus11();
+ Opts.CPlusPlus14 = Std.isCPlusPlus14();
+ Opts.CPlusPlus17 = Std.isCPlusPlus17();
+ Opts.CPlusPlus20 = Std.isCPlusPlus20();
+ Opts.CPlusPlus2b = Std.isCPlusPlus2b();
+ Opts.GNUMode = Std.isGNUMode();
+ Opts.GNUCVersion = 0;
+ Opts.HexFloats = Std.hasHexFloats();
+ Opts.WChar = Std.isCPlusPlus();
+ Opts.Digraphs = Std.hasDigraphs();
+
+ Opts.HLSL = Lang == Language::HLSL;
+ if (Opts.HLSL && Opts.IncludeDefaultHeader)
+ Includes.push_back("hlsl.h");
+
+ // Set OpenCL Version.
+ Opts.OpenCL = Std.isOpenCL();
+ if (LangStd == LangStandard::lang_opencl10)
+ Opts.OpenCLVersion = 100;
+ else if (LangStd == LangStandard::lang_opencl11)
+ Opts.OpenCLVersion = 110;
+ else if (LangStd == LangStandard::lang_opencl12)
+ Opts.OpenCLVersion = 120;
+ else if (LangStd == LangStandard::lang_opencl20)
+ Opts.OpenCLVersion = 200;
+ else if (LangStd == LangStandard::lang_opencl30)
+ Opts.OpenCLVersion = 300;
+ else if (LangStd == LangStandard::lang_openclcpp10)
+ Opts.OpenCLCPlusPlusVersion = 100;
+ else if (LangStd == LangStandard::lang_openclcpp2021)
+ Opts.OpenCLCPlusPlusVersion = 202100;
+ else if (LangStd == LangStandard::lang_hlsl2015)
+ Opts.HLSLVersion = (unsigned)LangOptions::HLSL_2015;
+ else if (LangStd == LangStandard::lang_hlsl2016)
+ Opts.HLSLVersion = (unsigned)LangOptions::HLSL_2016;
+ else if (LangStd == LangStandard::lang_hlsl2017)
+ Opts.HLSLVersion = (unsigned)LangOptions::HLSL_2017;
+ else if (LangStd == LangStandard::lang_hlsl2018)
+ Opts.HLSLVersion = (unsigned)LangOptions::HLSL_2018;
+ else if (LangStd == LangStandard::lang_hlsl2021)
+ Opts.HLSLVersion = (unsigned)LangOptions::HLSL_2021;
+ else if (LangStd == LangStandard::lang_hlsl202x)
+ Opts.HLSLVersion = (unsigned)LangOptions::HLSL_202x;
+
+ // OpenCL has some additional defaults.
+ if (Opts.OpenCL) {
+ Opts.AltiVec = 0;
+ Opts.ZVector = 0;
+ Opts.setDefaultFPContractMode(LangOptions::FPM_On);
+ Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
+ Opts.OpenCLPipes = Opts.getOpenCLCompatibleVersion() == 200;
+ Opts.OpenCLGenericAddressSpace = Opts.getOpenCLCompatibleVersion() == 200;
+
+ // Include default header file for OpenCL.
+ if (Opts.IncludeDefaultHeader) {
+ if (Opts.DeclareOpenCLBuiltins) {
+ // Only include base header file for builtin types and constants.
+ Includes.push_back("opencl-c-base.h");
+ } else {
+ Includes.push_back("opencl-c.h");
+ }
+ }
+ }
+
+ Opts.HIP = Lang == Language::HIP;
+ Opts.CUDA = Lang == Language::CUDA || Opts.HIP;
+ if (Opts.HIP) {
+ // HIP toolchain does not support 'Fast' FPOpFusion in backends since it
+ // fuses multiplication/addition instructions without contract flag from
+ // device library functions in LLVM bitcode, which causes accuracy loss in
+ // certain math functions, e.g. tan(-1e20) becomes -0.933 instead of 0.8446.
+ // For device library functions in bitcode to work, 'Strict' or 'Standard'
+ // FPOpFusion options in backends is needed. Therefore 'fast-honor-pragmas'
+ // FP contract option is used to allow fuse across statements in frontend
+ // whereas respecting contract flag in backend.
+ Opts.setDefaultFPContractMode(LangOptions::FPM_FastHonorPragmas);
+ } else if (Opts.CUDA) {
+ if (T.isSPIRV()) {
+ // Emit OpenCL version metadata in LLVM IR when targeting SPIR-V.
+ Opts.OpenCLVersion = 200;
+ }
+ // Allow fuse across statements disregarding pragmas.
+ Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
+ }
+
+ Opts.RenderScript = Lang == Language::RenderScript;
+
+ // OpenCL, C++ and C2x have bool, true, false keywords.
+ Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C2x;
+
+ // OpenCL and HLSL have half keyword
+ Opts.Half = Opts.OpenCL || Opts.HLSL;
+}
+
FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
FPOptions result(LO);
return result;
}
+FPOptionsOverride FPOptions::getChangesSlow(const FPOptions &Base) const {
+ FPOptions::storage_type OverrideMask = 0;
+#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
+ if (get##NAME() != Base.get##NAME()) \
+ OverrideMask |= NAME##Mask;
+#include "clang/Basic/FPOptions.def"
+ return FPOptionsOverride(*this, OverrideMask);
+}
+
LLVM_DUMP_METHOD void FPOptions::dump() {
#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
llvm::errs() << "\n " #NAME " " << get##NAME();
diff --git a/contrib/llvm-project/clang/lib/Basic/LangStandards.cpp b/contrib/llvm-project/clang/lib/Basic/LangStandards.cpp
index ee27bfd12113..5bacc3b16496 100644
--- a/contrib/llvm-project/clang/lib/Basic/LangStandards.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/LangStandards.cpp
@@ -7,7 +7,9 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/LangStandard.h"
+#include "clang/Config/config.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Support/ErrorHandling.h"
using namespace clang;
@@ -42,4 +44,47 @@ const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
return &getLangStandardForKind(K);
}
+LangStandard::Kind clang::getDefaultLanguageStandard(clang::Language Lang,
+ const llvm::Triple &T) {
+ switch (Lang) {
+ case Language::Unknown:
+ case Language::LLVM_IR:
+ llvm_unreachable("Invalid input kind!");
+ case Language::OpenCL:
+ return LangStandard::lang_opencl12;
+ case Language::OpenCLCXX:
+ return LangStandard::lang_openclcpp10;
+ case Language::CUDA:
+ return LangStandard::lang_cuda;
+ case Language::Asm:
+ case Language::C:
+ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
+ return CLANG_DEFAULT_STD_C;
+ // The PS4 and PS5 use C99 as the default C standard.
+ if (T.isPS())
+ return LangStandard::lang_gnu99;
+ return LangStandard::lang_gnu17;
+ case Language::ObjC:
+ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
+ return CLANG_DEFAULT_STD_C;
+
+ return LangStandard::lang_gnu11;
+ case Language::CXX:
+ case Language::ObjCXX:
+ if (CLANG_DEFAULT_STD_CXX != LangStandard::lang_unspecified)
+ return CLANG_DEFAULT_STD_CXX;
+
+ if (T.isDriverKit())
+ return LangStandard::lang_gnucxx17;
+ else
+ return LangStandard::lang_gnucxx14;
+ case Language::RenderScript:
+ return LangStandard::lang_c99;
+ case Language::HIP:
+ return LangStandard::lang_hip;
+ case Language::HLSL:
+ return LangStandard::lang_hlsl2021;
+ }
+ llvm_unreachable("unhandled Language kind!");
+}
diff --git a/contrib/llvm-project/clang/lib/Basic/Module.cpp b/contrib/llvm-project/clang/lib/Basic/Module.cpp
index 09bd3251fea0..17b83184abb6 100644
--- a/contrib/llvm-project/clang/lib/Basic/Module.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Module.cpp
@@ -267,7 +267,7 @@ ArrayRef<const FileEntry *> Module::getTopHeaders(FileManager &FileMgr) {
return llvm::makeArrayRef(TopHeaders.begin(), TopHeaders.end());
}
-bool Module::directlyUses(const Module *Requested) const {
+bool Module::directlyUses(const Module *Requested) {
auto *Top = getTopLevelModule();
// A top-level module implicitly uses itself.
@@ -282,6 +282,9 @@ bool Module::directlyUses(const Module *Requested) const {
if (!Requested->Parent && Requested->Name == "_Builtin_stddef_max_align_t")
return true;
+ if (NoUndeclaredIncludes)
+ UndeclaredUses.insert(Requested);
+
return false;
}
diff --git a/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp b/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
index 7e89b3f1b804..44edf5402540 100644
--- a/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
@@ -12,14 +12,16 @@
namespace clang {
-const OpenCLOptions::FeatureDepList OpenCLOptions::DependentFeaturesList = {
+// First feature in a pair requires the second one to be supported.
+static const std::pair<StringRef, StringRef> DependentFeaturesList[] = {
{"__opencl_c_read_write_images", "__opencl_c_images"},
{"__opencl_c_3d_image_writes", "__opencl_c_images"},
{"__opencl_c_pipes", "__opencl_c_generic_address_space"},
{"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
{"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}};
-const llvm::StringMap<llvm::StringRef> OpenCLOptions::FeatureExtensionMap = {
+// Extensions and equivalent feature pairs.
+static const std::pair<StringRef, StringRef> FeatureExtensionMap[] = {
{"cl_khr_fp64", "__opencl_c_fp64"},
{"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
@@ -140,11 +142,11 @@ bool OpenCLOptions::diagnoseFeatureExtensionDifferences(
bool IsValid = true;
for (auto &ExtAndFeat : FeatureExtensionMap)
- if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getKey()) !=
- TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getValue())) {
+ if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.first) !=
+ TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.second)) {
IsValid = false;
Diags.Report(diag::err_opencl_extension_and_feature_differs)
- << ExtAndFeat.getKey() << ExtAndFeat.getValue();
+ << ExtAndFeat.first << ExtAndFeat.second;
}
return IsValid;
}
diff --git a/contrib/llvm-project/clang/lib/Basic/OpenMPKinds.cpp b/contrib/llvm-project/clang/lib/Basic/OpenMPKinds.cpp
index 1761c6d3d89b..2f2e6537ebd3 100644
--- a/contrib/llvm-project/clang/lib/Basic/OpenMPKinds.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/OpenMPKinds.cpp
@@ -41,11 +41,15 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
.Case(#Name, static_cast<unsigned>(OMPC_SCHEDULE_MODIFIER_##Name))
#include "clang/Basic/OpenMPKinds.def"
.Default(OMPC_SCHEDULE_unknown);
- case OMPC_depend:
- return llvm::StringSwitch<OpenMPDependClauseKind>(Str)
+ case OMPC_depend: {
+ unsigned Type = llvm::StringSwitch<unsigned>(Str)
#define OPENMP_DEPEND_KIND(Name) .Case(#Name, OMPC_DEPEND_##Name)
#include "clang/Basic/OpenMPKinds.def"
- .Default(OMPC_DEPEND_unknown);
+ .Default(OMPC_DEPEND_unknown);
+ if (LangOpts.OpenMP < 51 && Type == OMPC_DEPEND_inoutset)
+ return OMPC_DEPEND_unknown;
+ return Type;
+ }
case OMPC_linear:
return llvm::StringSwitch<OpenMPLinearClauseKind>(Str)
#define OPENMP_LINEAR_KIND(Name) .Case(#Name, OMPC_LINEAR_##Name)
@@ -182,6 +186,7 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
case OMPC_use_device_ptr:
case OMPC_use_device_addr:
case OMPC_is_device_ptr:
+ case OMPC_has_device_addr:
case OMPC_unified_address:
case OMPC_unified_shared_memory:
case OMPC_reverse_offload:
@@ -448,6 +453,7 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
case OMPC_use_device_ptr:
case OMPC_use_device_addr:
case OMPC_is_device_ptr:
+ case OMPC_has_device_addr:
case OMPC_unified_address:
case OMPC_unified_shared_memory:
case OMPC_reverse_offload:
@@ -478,7 +484,10 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
DKind == OMPD_parallel_master_taskloop ||
DKind == OMPD_parallel_master_taskloop_simd ||
- DKind == OMPD_distribute || DKind == OMPD_target_parallel_for ||
+ DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
+ DKind == OMPD_parallel_masked_taskloop || DKind == OMPD_distribute ||
+ DKind == OMPD_parallel_masked_taskloop_simd ||
+ DKind == OMPD_target_parallel_for ||
DKind == OMPD_distribute_parallel_for ||
DKind == OMPD_distribute_parallel_for_simd ||
DKind == OMPD_distribute_simd ||
@@ -491,7 +500,9 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_target_teams_distribute_parallel_for ||
DKind == OMPD_target_teams_distribute_parallel_for_simd ||
DKind == OMPD_target_teams_distribute_simd || DKind == OMPD_tile ||
- DKind == OMPD_unroll || DKind == OMPD_loop;
+ DKind == OMPD_unroll || DKind == OMPD_loop ||
+ DKind == OMPD_teams_loop || DKind == OMPD_target_teams_loop ||
+ DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
}
bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -513,6 +524,9 @@ bool clang::isOpenMPTaskLoopDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_taskloop || DKind == OMPD_taskloop_simd ||
DKind == OMPD_master_taskloop || DKind == OMPD_master_taskloop_simd ||
DKind == OMPD_parallel_master_taskloop ||
+ DKind == OMPD_masked_taskloop || DKind == OMPD_masked_taskloop_simd ||
+ DKind == OMPD_parallel_masked_taskloop ||
+ DKind == OMPD_parallel_masked_taskloop_simd ||
DKind == OMPD_parallel_master_taskloop_simd;
}
@@ -527,9 +541,12 @@ bool clang::isOpenMPParallelDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_teams_distribute_parallel_for_simd ||
DKind == OMPD_target_teams_distribute_parallel_for ||
DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_parallel_master ||
+ DKind == OMPD_parallel_master || DKind == OMPD_parallel_masked ||
DKind == OMPD_parallel_master_taskloop ||
- DKind == OMPD_parallel_master_taskloop_simd;
+ DKind == OMPD_parallel_master_taskloop_simd ||
+ DKind == OMPD_parallel_masked_taskloop ||
+ DKind == OMPD_parallel_masked_taskloop_simd ||
+ DKind == OMPD_parallel_loop || DKind == OMPD_target_parallel_loop;
}
bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
@@ -539,7 +556,8 @@ bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
DKind == OMPD_target_teams_distribute_parallel_for ||
DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd;
+ DKind == OMPD_target_teams_distribute_simd ||
+ DKind == OMPD_target_teams_loop || DKind == OMPD_target_parallel_loop;
}
bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
@@ -551,22 +569,26 @@ bool clang::isOpenMPNestingTeamsDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_teams || DKind == OMPD_teams_distribute ||
DKind == OMPD_teams_distribute_simd ||
DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_teams_distribute_parallel_for;
+ DKind == OMPD_teams_distribute_parallel_for ||
+ DKind == OMPD_teams_loop;
}
bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
- return isOpenMPNestingTeamsDirective(DKind) ||
- DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
+ return isOpenMPNestingTeamsDirective(DKind) || DKind == OMPD_target_teams ||
+ DKind == OMPD_target_teams_distribute ||
DKind == OMPD_target_teams_distribute_parallel_for ||
DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd;
+ DKind == OMPD_target_teams_distribute_simd ||
+ DKind == OMPD_target_teams_loop;
}
bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
return DKind == OMPD_simd || DKind == OMPD_for_simd ||
DKind == OMPD_parallel_for_simd || DKind == OMPD_taskloop_simd ||
DKind == OMPD_master_taskloop_simd ||
+ DKind == OMPD_masked_taskloop_simd ||
DKind == OMPD_parallel_master_taskloop_simd ||
+ DKind == OMPD_parallel_masked_taskloop_simd ||
DKind == OMPD_distribute_parallel_for_simd ||
DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
DKind == OMPD_teams_distribute_simd ||
@@ -595,7 +617,9 @@ bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
}
bool clang::isOpenMPGenericLoopDirective(OpenMPDirectiveKind Kind) {
- return Kind == OMPD_loop;
+ return Kind == OMPD_loop || Kind == OMPD_teams_loop ||
+ Kind == OMPD_target_teams_loop || Kind == OMPD_parallel_loop ||
+ Kind == OMPD_target_parallel_loop;
}
bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {
@@ -638,14 +662,17 @@ void clang::getOpenMPCaptureRegions(
case OMPD_parallel_for:
case OMPD_parallel_for_simd:
case OMPD_parallel_master:
+ case OMPD_parallel_masked:
case OMPD_parallel_sections:
case OMPD_distribute_parallel_for:
case OMPD_distribute_parallel_for_simd:
+ case OMPD_parallel_loop:
CaptureRegions.push_back(OMPD_parallel);
break;
case OMPD_target_teams:
case OMPD_target_teams_distribute:
case OMPD_target_teams_distribute_simd:
+ case OMPD_target_teams_loop:
CaptureRegions.push_back(OMPD_task);
CaptureRegions.push_back(OMPD_target);
CaptureRegions.push_back(OMPD_teams);
@@ -668,6 +695,7 @@ void clang::getOpenMPCaptureRegions(
case OMPD_target_parallel:
case OMPD_target_parallel_for:
case OMPD_target_parallel_for_simd:
+ case OMPD_target_parallel_loop:
CaptureRegions.push_back(OMPD_task);
CaptureRegions.push_back(OMPD_target);
CaptureRegions.push_back(OMPD_parallel);
@@ -682,8 +710,12 @@ void clang::getOpenMPCaptureRegions(
case OMPD_taskloop_simd:
case OMPD_master_taskloop:
case OMPD_master_taskloop_simd:
+ case OMPD_masked_taskloop:
+ case OMPD_masked_taskloop_simd:
CaptureRegions.push_back(OMPD_taskloop);
break;
+ case OMPD_parallel_masked_taskloop:
+ case OMPD_parallel_masked_taskloop_simd:
case OMPD_parallel_master_taskloop:
case OMPD_parallel_master_taskloop_simd:
CaptureRegions.push_back(OMPD_parallel);
@@ -696,6 +728,12 @@ void clang::getOpenMPCaptureRegions(
CaptureRegions.push_back(OMPD_teams);
CaptureRegions.push_back(OMPD_parallel);
break;
+ case OMPD_teams_loop:
+ CaptureRegions.push_back(OMPD_teams);
+ break;
+ case OMPD_nothing:
+ CaptureRegions.push_back(OMPD_nothing);
+ break;
case OMPD_loop:
// TODO: 'loop' may require different capture regions depending on the bind
// clause or the parent directive when there is no bind clause. Use
diff --git a/contrib/llvm-project/clang/lib/Basic/SourceManager.cpp b/contrib/llvm-project/clang/lib/Basic/SourceManager.cpp
index ec3e35595bb7..98e731eb12e6 100644
--- a/contrib/llvm-project/clang/lib/Basic/SourceManager.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/SourceManager.cpp
@@ -629,23 +629,21 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, StringRef Filename,
return LastFileIDLookup = FID;
}
-SourceLocation
-SourceManager::createMacroArgExpansionLoc(SourceLocation SpellingLoc,
- SourceLocation ExpansionLoc,
- unsigned TokLength) {
+SourceLocation SourceManager::createMacroArgExpansionLoc(
+ SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length) {
ExpansionInfo Info = ExpansionInfo::createForMacroArg(SpellingLoc,
ExpansionLoc);
- return createExpansionLocImpl(Info, TokLength);
+ return createExpansionLocImpl(Info, Length);
}
SourceLocation SourceManager::createExpansionLoc(
SourceLocation SpellingLoc, SourceLocation ExpansionLocStart,
- SourceLocation ExpansionLocEnd, unsigned TokLength,
+ SourceLocation ExpansionLocEnd, unsigned Length,
bool ExpansionIsTokenRange, int LoadedID,
SourceLocation::UIntTy LoadedOffset) {
ExpansionInfo Info = ExpansionInfo::create(
SpellingLoc, ExpansionLocStart, ExpansionLocEnd, ExpansionIsTokenRange);
- return createExpansionLocImpl(Info, TokLength, LoadedID, LoadedOffset);
+ return createExpansionLocImpl(Info, Length, LoadedID, LoadedOffset);
}
SourceLocation SourceManager::createTokenSplitLoc(SourceLocation Spelling,
@@ -660,7 +658,7 @@ SourceLocation SourceManager::createTokenSplitLoc(SourceLocation Spelling,
SourceLocation
SourceManager::createExpansionLocImpl(const ExpansionInfo &Info,
- unsigned TokLength, int LoadedID,
+ unsigned Length, int LoadedID,
SourceLocation::UIntTy LoadedOffset) {
if (LoadedID < 0) {
assert(LoadedID != -1 && "Loading sentinel FileID");
@@ -672,12 +670,12 @@ SourceManager::createExpansionLocImpl(const ExpansionInfo &Info,
return SourceLocation::getMacroLoc(LoadedOffset);
}
LocalSLocEntryTable.push_back(SLocEntry::get(NextLocalOffset, Info));
- assert(NextLocalOffset + TokLength + 1 > NextLocalOffset &&
- NextLocalOffset + TokLength + 1 <= CurrentLoadedOffset &&
+ assert(NextLocalOffset + Length + 1 > NextLocalOffset &&
+ NextLocalOffset + Length + 1 <= CurrentLoadedOffset &&
"Ran out of source locations!");
// See createFileID for that +1.
- NextLocalOffset += TokLength + 1;
- return SourceLocation::getMacroLoc(NextLocalOffset - (TokLength + 1));
+ NextLocalOffset += Length + 1;
+ return SourceLocation::getMacroLoc(NextLocalOffset - (Length + 1));
}
llvm::Optional<llvm::MemoryBufferRef>
diff --git a/contrib/llvm-project/clang/lib/Basic/TargetID.cpp b/contrib/llvm-project/clang/lib/Basic/TargetID.cpp
index 3b8f4c13b9bf..abfbe49e1a91 100644
--- a/contrib/llvm-project/clang/lib/Basic/TargetID.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/TargetID.cpp
@@ -109,8 +109,7 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID,
if (!OptionalProcessor)
return llvm::None;
- llvm::StringRef Processor =
- getCanonicalProcessorName(T, OptionalProcessor.getValue());
+ llvm::StringRef Processor = getCanonicalProcessorName(T, *OptionalProcessor);
if (Processor.empty())
return llvm::None;
@@ -150,8 +149,7 @@ getConflictTargetIDCombination(const std::set<llvm::StringRef> &TargetIDs) {
llvm::StringMap<Info> FeatureMap;
for (auto &&ID : TargetIDs) {
llvm::StringMap<bool> Features;
- llvm::StringRef Proc =
- parseTargetIDWithFormatCheckingOnly(ID, &Features).getValue();
+ llvm::StringRef Proc = *parseTargetIDWithFormatCheckingOnly(ID, &Features);
auto Loc = FeatureMap.find(Proc);
if (Loc == FeatureMap.end())
FeatureMap[Proc] = Info{ID, Features};
diff --git a/contrib/llvm-project/clang/lib/Basic/TargetInfo.cpp b/contrib/llvm-project/clang/lib/Basic/TargetInfo.cpp
index 188ffb5f2f78..e22ed34e7da4 100644
--- a/contrib/llvm-project/clang/lib/Basic/TargetInfo.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/TargetInfo.cpp
@@ -131,7 +131,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
ARMCDECoprocMask = 0;
// Default to no types using fpret.
- RealTypeUsesObjCFPRet = 0;
+ RealTypeUsesObjCFPRetMask = 0;
// Default to not using fp2ret for __Complex long double
ComplexLongDoubleUsesFP2Ret = false;
@@ -150,6 +150,9 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
PlatformMinVersion = VersionTuple();
MaxOpenCLWorkGroupSize = 1024;
+
+ MaxBitIntWidth.reset();
+
ProgramAddrSpace = 0;
}
@@ -284,6 +287,8 @@ TargetInfo::IntType TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth,
FloatModeKind TargetInfo::getRealTypeByWidth(unsigned BitWidth,
FloatModeKind ExplicitType) const {
+ if (getHalfWidth() == BitWidth)
+ return FloatModeKind::Half;
if (getFloatWidth() == BitWidth)
return FloatModeKind::Float;
if (getDoubleWidth() == BitWidth)
@@ -449,6 +454,20 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
} else if (Opts.LongDoubleSize == 128) {
LongDoubleWidth = LongDoubleAlign = 128;
LongDoubleFormat = &llvm::APFloat::IEEEquad();
+ } else if (Opts.LongDoubleSize == 80) {
+ LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
+ if (getTriple().isWindowsMSVCEnvironment()) {
+ LongDoubleWidth = 128;
+ LongDoubleAlign = 128;
+ } else { // Linux
+ if (getTriple().getArch() == llvm::Triple::x86) {
+ LongDoubleWidth = 96;
+ LongDoubleAlign = 32;
+ } else {
+ LongDoubleWidth = 128;
+ LongDoubleAlign = 128;
+ }
+ }
}
}
@@ -464,6 +483,9 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
Diags.Report(diag::err_opt_not_valid_on_target) << "-fprotect-parens";
Opts.ProtectParens = false;
}
+
+ if (Opts.MaxBitIntWidth)
+ MaxBitIntWidth = Opts.MaxBitIntWidth;
}
bool TargetInfo::initFeatureMap(
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets.cpp b/contrib/llvm-project/clang/lib/Basic/Targets.cpp
index 994a491cddf2..2d6ef998485a 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets.cpp
@@ -19,6 +19,8 @@
#include "Targets/ARM.h"
#include "Targets/AVR.h"
#include "Targets/BPF.h"
+#include "Targets/CSKY.h"
+#include "Targets/DirectX.h"
#include "Targets/Hexagon.h"
#include "Targets/Lanai.h"
#include "Targets/Le64.h"
@@ -590,6 +592,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return new NaClTargetInfo<X86_64TargetInfo>(Triple, Opts);
case llvm::Triple::PS4:
return new PS4OSTargetInfo<X86_64TargetInfo>(Triple, Opts);
+ case llvm::Triple::PS5:
+ return new PS5OSTargetInfo<X86_64TargetInfo>(Triple, Opts);
default:
return new X86_64TargetInfo(Triple, Opts);
}
@@ -649,6 +653,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
return nullptr;
}
+ case llvm::Triple::dxil:
+ return new DirectXTargetInfo(Triple,Opts);
case llvm::Triple::renderscript32:
return new LinuxTargetInfo<RenderScript32TargetInfo>(Triple, Opts);
case llvm::Triple::renderscript64:
@@ -656,6 +662,14 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
case llvm::Triple::ve:
return new LinuxTargetInfo<VETargetInfo>(Triple, Opts);
+
+ case llvm::Triple::csky:
+ switch (os) {
+ case llvm::Triple::Linux:
+ return new LinuxTargetInfo<CSKYTargetInfo>(Triple, Opts);
+ default:
+ return new CSKYTargetInfo(Triple, Opts);
+ }
}
}
} // namespace targets
@@ -731,6 +745,10 @@ TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
Target->setCommandLineOpenCLOpts();
Target->setMaxAtomicWidth();
+ if (!Opts->DarwinTargetVariantTriple.empty())
+ Target->DarwinTargetVariantTriple =
+ llvm::Triple(Opts->DarwinTargetVariantTriple);
+
if (!Target->validateTarget(Diags))
return nullptr;
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp
index 34bdb58dffc1..60ef52ac3f0d 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp
@@ -435,6 +435,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
if (HasRandGen)
Builder.defineMacro("__ARM_FEATURE_RNG", "1");
+ if (HasMOPS)
+ Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
+
switch (ArchKind) {
default:
break;
@@ -482,6 +485,10 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
+ // Allow detection of fast FMA support.
+ Builder.defineMacro("__FP_FAST_FMA", "1");
+ Builder.defineMacro("__FP_FAST_FMAF", "1");
+
if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) {
Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128));
Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS");
@@ -506,21 +513,18 @@ AArch64TargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
}
bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
- return Feature == "aarch64" || Feature == "arm64" || Feature == "arm" ||
- (Feature == "neon" && (FPU & NeonMode)) ||
- ((Feature == "sve" || Feature == "sve2" || Feature == "sve2-bitperm" ||
- Feature == "sve2-aes" || Feature == "sve2-sha3" ||
- Feature == "sve2-sm4" || Feature == "f64mm" || Feature == "f32mm" ||
- Feature == "i8mm" || Feature == "bf16") &&
- (FPU & SveMode)) ||
- (Feature == "ls64" && HasLS64);
+ return llvm::StringSwitch<bool>(Feature)
+ .Cases("aarch64", "arm64", "arm", true)
+ .Case("neon", FPU & NeonMode)
+ .Cases("sve", "sve2", "sve2-bitperm", "sve2-aes", "sve2-sha3", "sve2-sm4", "f64mm", "f32mm", "i8mm", "bf16", FPU & SveMode)
+ .Case("ls64", HasLS64)
+ .Default(false);
}
bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
DiagnosticsEngine &Diags) {
FPU = FPUMode;
HasCRC = false;
- HasCrypto = false;
HasAES = false;
HasSHA2 = false;
HasSHA3 = false;
@@ -543,7 +547,6 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasMatmulFP64 = false;
HasMatmulFP32 = false;
HasLSE = false;
- HasHBC = false;
HasMOPS = false;
ArchKind = llvm::AArch64::ArchKind::INVALID;
@@ -594,8 +597,6 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
}
if (Feature == "+crc")
HasCRC = true;
- if (Feature == "+crypto")
- HasCrypto = true;
if (Feature == "+aes")
HasAES = true;
if (Feature == "+sha2")
@@ -660,8 +661,8 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasRandGen = true;
if (Feature == "+flagm")
HasFlagM = true;
- if (Feature == "+hbc")
- HasHBC = true;
+ if (Feature == "+mops")
+ HasMOPS = true;
}
setDataLayout();
@@ -679,6 +680,7 @@ AArch64TargetInfo::checkCallingConvention(CallingConv CC) const {
case CC_PreserveAll:
case CC_OpenCLKernel:
case CC_AArch64VectorCall:
+ case CC_AArch64SVEPCS:
case CC_Win64:
return CCCR_OK;
default:
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.h b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.h
index 9e22aeaff251..bd6812d1257c 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.h
@@ -30,7 +30,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
unsigned FPU;
bool HasCRC;
- bool HasCrypto;
bool HasAES;
bool HasSHA2;
bool HasSHA3;
@@ -54,7 +53,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
bool HasMatmulFP32;
bool HasLSE;
bool HasFlagM;
- bool HasHBC;
bool HasMOPS;
llvm::AArch64::ArchKind ArchKind;
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp
index ba7ffa34c73e..50256d8e210c 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -183,6 +183,27 @@ bool AMDGPUTargetInfo::initFeatureMap(
// XXX - What does the member GPU mean if device name string passed here?
if (isAMDGCN(getTriple())) {
switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
+ case GK_GFX1103:
+ case GK_GFX1102:
+ case GK_GFX1101:
+ case GK_GFX1100:
+ Features["ci-insts"] = true;
+ Features["dot1-insts"] = true;
+ Features["dot5-insts"] = true;
+ Features["dot6-insts"] = true;
+ Features["dot7-insts"] = true;
+ Features["dot8-insts"] = true;
+ Features["dl-insts"] = true;
+ Features["flat-address-space"] = true;
+ Features["16-bit-insts"] = true;
+ Features["dpp"] = true;
+ Features["gfx8-insts"] = true;
+ Features["gfx9-insts"] = true;
+ Features["gfx10-insts"] = true;
+ Features["gfx10-3-insts"] = true;
+ Features["gfx11-insts"] = true;
+ break;
+ case GK_GFX1036:
case GK_GFX1035:
case GK_GFX1034:
case GK_GFX1033:
@@ -227,6 +248,9 @@ bool AMDGPUTargetInfo::initFeatureMap(
Features["s-memrealtime"] = true;
Features["s-memtime-inst"] = true;
break;
+ case GK_GFX940:
+ Features["gfx940-insts"] = true;
+ LLVM_FALLTHROUGH;
case GK_GFX90A:
Features["gfx90a-insts"] = true;
LLVM_FALLTHROUGH;
@@ -384,12 +408,17 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
StringRef CanonName = isAMDGCN(getTriple()) ?
getArchNameAMDGCN(GPUKind) : getArchNameR600(GPUKind);
Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
+ // Emit macros for gfx family e.g. gfx906 -> __GFX9__, gfx1030 -> __GFX10___
+ if (isAMDGCN(getTriple())) {
+ assert(CanonName.startswith("gfx") && "Invalid amdgcn canonical name");
+ Builder.defineMacro(Twine("__") + Twine(CanonName.drop_back(2).upper()) +
+ Twine("__"));
+ }
if (isAMDGCN(getTriple())) {
Builder.defineMacro("__amdgcn_processor__",
Twine("\"") + Twine(CanonName) + Twine("\""));
Builder.defineMacro("__amdgcn_target_id__",
- Twine("\"") + Twine(getTargetID().getValue()) +
- Twine("\""));
+ Twine("\"") + Twine(*getTargetID()) + Twine("\""));
for (auto F : getAllPossibleTargetIDFeatures(getTriple(), CanonName)) {
auto Loc = OffloadArchFeatures.find(F);
if (Loc != OffloadArchFeatures.end()) {
@@ -403,6 +432,9 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
}
}
+ if (AllowAMDGPUUnsafeFPAtomics)
+ Builder.defineMacro("__AMDGCN_UNSAFE_FP_ATOMICS__");
+
// TODO: __HAS_FMAF__, __HAS_LDEXPF__, __HAS_FP64__ are deprecated and will be
// removed in the near future.
if (hasFMAF())
@@ -429,9 +461,13 @@ void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
// supported by AMDGPU. Therefore keep its own format for these two types.
auto SaveLongDoubleFormat = LongDoubleFormat;
auto SaveFloat128Format = Float128Format;
+ auto SaveLongDoubleWidth = LongDoubleWidth;
+ auto SaveLongDoubleAlign = LongDoubleAlign;
copyAuxTarget(Aux);
LongDoubleFormat = SaveLongDoubleFormat;
Float128Format = SaveFloat128Format;
+ LongDoubleWidth = SaveLongDoubleWidth;
+ LongDoubleAlign = SaveLongDoubleAlign;
// For certain builtin types support on the host target, claim they are
// support to pass the compilation of the host code during the device-side
// compilation.
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.h b/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.h
index 974922191488..5e73a3cb8019 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/AMDGPU.h
@@ -411,6 +411,7 @@ public:
return CCCR_Warning;
case CC_C:
case CC_OpenCLKernel:
+ case CC_AMDGPUKernelCall:
return CCCR_OK;
}
}
@@ -434,17 +435,17 @@ public:
DiagnosticsEngine &Diags) override {
auto TargetIDFeatures =
getAllPossibleTargetIDFeatures(getTriple(), getArchNameAMDGCN(GPUKind));
- llvm::for_each(Features, [&](const auto &F) {
+ for (const auto &F : Features) {
assert(F.front() == '+' || F.front() == '-');
if (F == "+wavefrontsize64")
WavefrontSize = 64;
bool IsOn = F.front() == '+';
StringRef Name = StringRef(F).drop_front();
if (!llvm::is_contained(TargetIDFeatures, Name))
- return;
+ continue;
assert(OffloadArchFeatures.find(Name) == OffloadArchFeatures.end());
OffloadArchFeatures[Name] = IsOn;
- });
+ }
return true;
}
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp
index 9c9d198e8f32..b2f61cff81c9 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/ARM.cpp
@@ -955,6 +955,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts,
case llvm::ARM::ArchKind::ARMV8_4A:
case llvm::ARM::ArchKind::ARMV8_5A:
case llvm::ARM::ArchKind::ARMV8_6A:
+ case llvm::ARM::ArchKind::ARMV8_7A:
case llvm::ARM::ArchKind::ARMV8_8A:
case llvm::ARM::ArchKind::ARMV9A:
case llvm::ARM::ArchKind::ARMV9_1A:
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AVR.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/AVR.cpp
index 93ed0671119f..67e27ebd58de 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/AVR.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/AVR.cpp
@@ -28,246 +28,261 @@ struct LLVM_LIBRARY_VISIBILITY MCUInfo {
bool IsTiny; // Set to true for the devices belong to the avrtiny family.
};
-// This list should be kept up-to-date with AVRDevices.td in LLVM.
+// NOTE: This list has been synchronized with gcc-avr 5.4.0 and avr-libc 2.0.0.
static MCUInfo AVRMcus[] = {
- {"at90s1200", "__AVR_AT90S1200__", 0},
- {"attiny11", "__AVR_ATtiny11__", 0},
- {"attiny12", "__AVR_ATtiny12__", 0},
- {"attiny15", "__AVR_ATtiny15__", 0},
- {"attiny28", "__AVR_ATtiny28__", 0},
- {"at90s2313", "__AVR_AT90S2313__", 1},
- {"at90s2323", "__AVR_AT90S2323__", 1},
- {"at90s2333", "__AVR_AT90S2333__", 1},
- {"at90s2343", "__AVR_AT90S2343__", 1},
- {"attiny22", "__AVR_ATtiny22__", 1},
- {"attiny26", "__AVR_ATtiny26__", 1},
- {"at86rf401", "__AVR_AT86RF401__", 1},
- {"at90s4414", "__AVR_AT90S4414__", 1},
- {"at90s4433", "__AVR_AT90S4433__", 1},
- {"at90s4434", "__AVR_AT90S4434__", 1},
- {"at90s8515", "__AVR_AT90S8515__", 1},
- {"at90c8534", "__AVR_AT90c8534__", 1},
- {"at90s8535", "__AVR_AT90S8535__", 1},
- {"ata5272", "__AVR_ATA5272__", 1},
- {"attiny13", "__AVR_ATtiny13__", 1},
- {"attiny13a", "__AVR_ATtiny13A__", 1},
- {"attiny2313", "__AVR_ATtiny2313__", 1},
- {"attiny2313a", "__AVR_ATtiny2313A__", 1},
- {"attiny24", "__AVR_ATtiny24__", 1},
- {"attiny24a", "__AVR_ATtiny24A__", 1},
- {"attiny4313", "__AVR_ATtiny4313__", 1},
- {"attiny44", "__AVR_ATtiny44__", 1},
- {"attiny44a", "__AVR_ATtiny44A__", 1},
- {"attiny84", "__AVR_ATtiny84__", 1},
- {"attiny84a", "__AVR_ATtiny84A__", 1},
- {"attiny25", "__AVR_ATtiny25__", 1},
- {"attiny45", "__AVR_ATtiny45__", 1},
- {"attiny85", "__AVR_ATtiny85__", 1},
- {"attiny261", "__AVR_ATtiny261__", 1},
- {"attiny261a", "__AVR_ATtiny261A__", 1},
- {"attiny441", "__AVR_ATtiny441__", 1},
- {"attiny461", "__AVR_ATtiny461__", 1},
- {"attiny461a", "__AVR_ATtiny461A__", 1},
- {"attiny841", "__AVR_ATtiny841__", 1},
- {"attiny861", "__AVR_ATtiny861__", 1},
- {"attiny861a", "__AVR_ATtiny861A__", 1},
- {"attiny87", "__AVR_ATtiny87__", 1},
- {"attiny43u", "__AVR_ATtiny43U__", 1},
- {"attiny48", "__AVR_ATtiny48__", 1},
- {"attiny88", "__AVR_ATtiny88__", 1},
- {"attiny828", "__AVR_ATtiny828__", 1},
- {"at43usb355", "__AVR_AT43USB355__", 1},
- {"at76c711", "__AVR_AT76C711__", 1},
- {"atmega103", "__AVR_ATmega103__", 1},
- {"at43usb320", "__AVR_AT43USB320__", 1},
- {"attiny167", "__AVR_ATtiny167__", 1},
- {"at90usb82", "__AVR_AT90USB82__", 1},
- {"at90usb162", "__AVR_AT90USB162__", 1},
- {"ata5505", "__AVR_ATA5505__", 1},
- {"atmega8u2", "__AVR_ATmega8U2__", 1},
- {"atmega16u2", "__AVR_ATmega16U2__", 1},
- {"atmega32u2", "__AVR_ATmega32U2__", 1},
- {"attiny1634", "__AVR_ATtiny1634__", 1},
- {"atmega8", "__AVR_ATmega8__", 1},
- {"ata6289", "__AVR_ATA6289__", 1},
- {"atmega8a", "__AVR_ATmega8A__", 1},
- {"ata6285", "__AVR_ATA6285__", 1},
- {"ata6286", "__AVR_ATA6286__", 1},
- {"atmega48", "__AVR_ATmega48__", 1},
- {"atmega48a", "__AVR_ATmega48A__", 1},
- {"atmega48pa", "__AVR_ATmega48PA__", 1},
- {"atmega48pb", "__AVR_ATmega48PB__", 1},
- {"atmega48p", "__AVR_ATmega48P__", 1},
- {"atmega88", "__AVR_ATmega88__", 1},
- {"atmega88a", "__AVR_ATmega88A__", 1},
- {"atmega88p", "__AVR_ATmega88P__", 1},
- {"atmega88pa", "__AVR_ATmega88PA__", 1},
- {"atmega88pb", "__AVR_ATmega88PB__", 1},
- {"atmega8515", "__AVR_ATmega8515__", 1},
- {"atmega8535", "__AVR_ATmega8535__", 1},
- {"atmega8hva", "__AVR_ATmega8HVA__", 1},
- {"at90pwm1", "__AVR_AT90PWM1__", 1},
- {"at90pwm2", "__AVR_AT90PWM2__", 1},
- {"at90pwm2b", "__AVR_AT90PWM2B__", 1},
- {"at90pwm3", "__AVR_AT90PWM3__", 1},
- {"at90pwm3b", "__AVR_AT90PWM3B__", 1},
- {"at90pwm81", "__AVR_AT90PWM81__", 1},
- {"ata5790", "__AVR_ATA5790__", 1},
- {"ata5795", "__AVR_ATA5795__", 1},
- {"atmega16", "__AVR_ATmega16__", 1},
- {"atmega16a", "__AVR_ATmega16A__", 1},
- {"atmega161", "__AVR_ATmega161__", 1},
- {"atmega162", "__AVR_ATmega162__", 1},
- {"atmega163", "__AVR_ATmega163__", 1},
- {"atmega164a", "__AVR_ATmega164A__", 1},
- {"atmega164p", "__AVR_ATmega164P__", 1},
- {"atmega164pa", "__AVR_ATmega164PA__", 1},
- {"atmega165", "__AVR_ATmega165__", 1},
- {"atmega165a", "__AVR_ATmega165A__", 1},
- {"atmega165p", "__AVR_ATmega165P__", 1},
- {"atmega165pa", "__AVR_ATmega165PA__", 1},
- {"atmega168", "__AVR_ATmega168__", 1},
- {"atmega168a", "__AVR_ATmega168A__", 1},
- {"atmega168p", "__AVR_ATmega168P__", 1},
- {"atmega168pa", "__AVR_ATmega168PA__", 1},
- {"atmega168pb", "__AVR_ATmega168PB__", 1},
- {"atmega169", "__AVR_ATmega169__", 1},
- {"atmega169a", "__AVR_ATmega169A__", 1},
- {"atmega169p", "__AVR_ATmega169P__", 1},
- {"atmega169pa", "__AVR_ATmega169PA__", 1},
- {"atmega32", "__AVR_ATmega32__", 1},
- {"atmega32a", "__AVR_ATmega32A__", 1},
- {"atmega323", "__AVR_ATmega323__", 1},
- {"atmega324a", "__AVR_ATmega324A__", 1},
- {"atmega324p", "__AVR_ATmega324P__", 1},
- {"atmega324pa", "__AVR_ATmega324PA__", 1},
- {"atmega324pb", "__AVR_ATmega324PB__", 1},
- {"atmega325", "__AVR_ATmega325__", 1},
- {"atmega325a", "__AVR_ATmega325A__", 1},
- {"atmega325p", "__AVR_ATmega325P__", 1},
- {"atmega325pa", "__AVR_ATmega325PA__", 1},
- {"atmega3250", "__AVR_ATmega3250__", 1},
- {"atmega3250a", "__AVR_ATmega3250A__", 1},
- {"atmega3250p", "__AVR_ATmega3250P__", 1},
- {"atmega3250pa", "__AVR_ATmega3250PA__", 1},
- {"atmega328", "__AVR_ATmega328__", 1},
- {"atmega328p", "__AVR_ATmega328P__", 1},
- {"atmega328pb", "__AVR_ATmega328PB__", 1},
- {"atmega329", "__AVR_ATmega329__", 1},
- {"atmega329a", "__AVR_ATmega329A__", 1},
- {"atmega329p", "__AVR_ATmega329P__", 1},
- {"atmega329pa", "__AVR_ATmega329PA__", 1},
- {"atmega3290", "__AVR_ATmega3290__", 1},
- {"atmega3290a", "__AVR_ATmega3290A__", 1},
- {"atmega3290p", "__AVR_ATmega3290P__", 1},
- {"atmega3290pa", "__AVR_ATmega3290PA__", 1},
- {"atmega406", "__AVR_ATmega406__", 1},
- {"atmega64", "__AVR_ATmega64__", 1},
- {"atmega64a", "__AVR_ATmega64A__", 1},
- {"atmega640", "__AVR_ATmega640__", 1},
- {"atmega644", "__AVR_ATmega644__", 1},
- {"atmega644a", "__AVR_ATmega644A__", 1},
- {"atmega644p", "__AVR_ATmega644P__", 1},
- {"atmega644pa", "__AVR_ATmega644PA__", 1},
- {"atmega645", "__AVR_ATmega645__", 1},
- {"atmega645a", "__AVR_ATmega645A__", 1},
- {"atmega645p", "__AVR_ATmega645P__", 1},
- {"atmega649", "__AVR_ATmega649__", 1},
- {"atmega649a", "__AVR_ATmega649A__", 1},
- {"atmega649p", "__AVR_ATmega649P__", 1},
- {"atmega6450", "__AVR_ATmega6450__", 1},
- {"atmega6450a", "__AVR_ATmega6450A__", 1},
- {"atmega6450p", "__AVR_ATmega6450P__", 1},
- {"atmega6490", "__AVR_ATmega6490__", 1},
- {"atmega6490a", "__AVR_ATmega6490A__", 1},
- {"atmega6490p", "__AVR_ATmega6490P__", 1},
- {"atmega64rfr2", "__AVR_ATmega64RFR2__", 1},
- {"atmega644rfr2", "__AVR_ATmega644RFR2__", 1},
- {"atmega16hva", "__AVR_ATmega16HVA__", 1},
- {"atmega16hva2", "__AVR_ATmega16HVA2__", 1},
- {"atmega16hvb", "__AVR_ATmega16HVB__", 1},
- {"atmega16hvbrevb", "__AVR_ATmega16HVBREVB__", 1},
- {"atmega32hvb", "__AVR_ATmega32HVB__", 1},
- {"atmega32hvbrevb", "__AVR_ATmega32HVBREVB__", 1},
- {"atmega64hve", "__AVR_ATmega64HVE__", 1},
- {"at90can32", "__AVR_AT90CAN32__", 1},
- {"at90can64", "__AVR_AT90CAN64__", 1},
- {"at90pwm161", "__AVR_AT90PWM161__", 1},
- {"at90pwm216", "__AVR_AT90PWM216__", 1},
- {"at90pwm316", "__AVR_AT90PWM316__", 1},
- {"atmega32c1", "__AVR_ATmega32C1__", 1},
- {"atmega64c1", "__AVR_ATmega64C1__", 1},
- {"atmega16m1", "__AVR_ATmega16M1__", 1},
- {"atmega32m1", "__AVR_ATmega32M1__", 1},
- {"atmega64m1", "__AVR_ATmega64M1__", 1},
- {"atmega16u4", "__AVR_ATmega16U4__", 1},
- {"atmega32u4", "__AVR_ATmega32U4__", 1},
- {"atmega32u6", "__AVR_ATmega32U6__", 1},
- {"at90usb646", "__AVR_AT90USB646__", 1},
- {"at90usb647", "__AVR_AT90USB647__", 1},
- {"at90scr100", "__AVR_AT90SCR100__", 1},
- {"at94k", "__AVR_AT94K__", 1},
- {"m3000", "__AVR_AT000__", 1},
- {"atmega128", "__AVR_ATmega128__", 2},
- {"atmega128a", "__AVR_ATmega128A__", 2},
- {"atmega1280", "__AVR_ATmega1280__", 2},
- {"atmega1281", "__AVR_ATmega1281__", 2},
- {"atmega1284", "__AVR_ATmega1284__", 2},
- {"atmega1284p", "__AVR_ATmega1284P__", 2},
- {"atmega128rfa1", "__AVR_ATmega128RFA1__", 2},
- {"atmega128rfr2", "__AVR_ATmega128RFR2__", 2},
- {"atmega1284rfr2", "__AVR_ATmega1284RFR2__", 2},
- {"at90can128", "__AVR_AT90CAN128__", 2},
- {"at90usb1286", "__AVR_AT90USB1286__", 2},
- {"at90usb1287", "__AVR_AT90USB1287__", 2},
- {"atmega2560", "__AVR_ATmega2560__", 4},
- {"atmega2561", "__AVR_ATmega2561__", 4},
- {"atmega256rfr2", "__AVR_ATmega256RFR2__", 4},
- {"atmega2564rfr2", "__AVR_ATmega2564RFR2__", 4},
- {"atxmega16a4", "__AVR_ATxmega16A4__", 1},
- {"atxmega16a4u", "__AVR_ATxmega16A4U__", 1},
- {"atxmega16c4", "__AVR_ATxmega16C4__", 1},
- {"atxmega16d4", "__AVR_ATxmega16D4__", 1},
- {"atxmega32a4", "__AVR_ATxmega32A4__", 1},
- {"atxmega32a4u", "__AVR_ATxmega32A4U__", 1},
- {"atxmega32c4", "__AVR_ATxmega32C4__", 1},
- {"atxmega32d4", "__AVR_ATxmega32D4__", 1},
- {"atxmega32e5", "__AVR_ATxmega32E5__", 1},
- {"atxmega16e5", "__AVR_ATxmega16E5__", 1},
- {"atxmega8e5", "__AVR_ATxmega8E5__", 1},
- {"atxmega32x1", "__AVR_ATxmega32X1__", 1},
- {"atxmega64a3", "__AVR_ATxmega64A3__", 1},
- {"atxmega64a3u", "__AVR_ATxmega64A3U__", 1},
- {"atxmega64a4u", "__AVR_ATxmega64A4U__", 1},
- {"atxmega64b1", "__AVR_ATxmega64B1__", 1},
- {"atxmega64b3", "__AVR_ATxmega64B3__", 1},
- {"atxmega64c3", "__AVR_ATxmega64C3__", 1},
- {"atxmega64d3", "__AVR_ATxmega64D3__", 1},
- {"atxmega64d4", "__AVR_ATxmega64D4__", 1},
- {"atxmega64a1", "__AVR_ATxmega64A1__", 1},
- {"atxmega64a1u", "__AVR_ATxmega64A1U__", 1},
- {"atxmega128a3", "__AVR_ATxmega128A3__", 2},
- {"atxmega128a3u", "__AVR_ATxmega128A3U__", 2},
- {"atxmega128b1", "__AVR_ATxmega128B1__", 2},
- {"atxmega128b3", "__AVR_ATxmega128B3__", 2},
- {"atxmega128c3", "__AVR_ATxmega128C3__", 2},
- {"atxmega128d3", "__AVR_ATxmega128D3__", 2},
- {"atxmega128d4", "__AVR_ATxmega128D4__", 2},
- {"atxmega192a3", "__AVR_ATxmega192A3__", 3},
- {"atxmega192a3u", "__AVR_ATxmega192A3U__", 3},
- {"atxmega192c3", "__AVR_ATxmega192C3__", 3},
- {"atxmega192d3", "__AVR_ATxmega192D3__", 3},
- {"atxmega256a3", "__AVR_ATxmega256A3__", 4},
- {"atxmega256a3u", "__AVR_ATxmega256A3U__", 4},
- {"atxmega256a3b", "__AVR_ATxmega256A3B__", 4},
- {"atxmega256a3bu", "__AVR_ATxmega256A3BU__", 4},
- {"atxmega256c3", "__AVR_ATxmega256C3__", 4},
- {"atxmega256d3", "__AVR_ATxmega256D3__", 4},
- {"atxmega384c3", "__AVR_ATxmega384C3__", 6},
- {"atxmega384d3", "__AVR_ATxmega384D3__", 6},
- {"atxmega128a1", "__AVR_ATxmega128A1__", 2},
- {"atxmega128a1u", "__AVR_ATxmega128A1U__", 2},
- {"atxmega128a4u", "__AVR_ATxmega128A4U__", 2},
+ {"at90s1200", "__AVR_AT90S1200__", 0, false},
+ {"attiny11", "__AVR_ATtiny11__", 0, false},
+ {"attiny12", "__AVR_ATtiny12__", 0, false},
+ {"attiny15", "__AVR_ATtiny15__", 0, false},
+ {"attiny28", "__AVR_ATtiny28__", 0, false},
+ {"at90s2313", "__AVR_AT90S2313__", 1, false},
+ {"at90s2323", "__AVR_AT90S2323__", 1, false},
+ {"at90s2333", "__AVR_AT90S2333__", 1, false},
+ {"at90s2343", "__AVR_AT90S2343__", 1, false},
+ {"attiny22", "__AVR_ATtiny22__", 1, false},
+ {"attiny26", "__AVR_ATtiny26__", 1, false},
+ {"at86rf401", "__AVR_AT86RF401__", 1, false},
+ {"at90s4414", "__AVR_AT90S4414__", 1, false},
+ {"at90s4433", "__AVR_AT90S4433__", 1, false},
+ {"at90s4434", "__AVR_AT90S4434__", 1, false},
+ {"at90s8515", "__AVR_AT90S8515__", 1, false},
+ {"at90c8534", "__AVR_AT90c8534__", 1, false},
+ {"at90s8535", "__AVR_AT90S8535__", 1, false},
+ {"ata5272", "__AVR_ATA5272__", 1, false},
+ {"ata6616c", "__AVR_ATA6616c__", 1, false},
+ {"attiny13", "__AVR_ATtiny13__", 1, false},
+ {"attiny13a", "__AVR_ATtiny13A__", 1, false},
+ {"attiny2313", "__AVR_ATtiny2313__", 1, false},
+ {"attiny2313a", "__AVR_ATtiny2313A__", 1, false},
+ {"attiny24", "__AVR_ATtiny24__", 1, false},
+ {"attiny24a", "__AVR_ATtiny24A__", 1, false},
+ {"attiny4313", "__AVR_ATtiny4313__", 1, false},
+ {"attiny44", "__AVR_ATtiny44__", 1, false},
+ {"attiny44a", "__AVR_ATtiny44A__", 1, false},
+ {"attiny84", "__AVR_ATtiny84__", 1, false},
+ {"attiny84a", "__AVR_ATtiny84A__", 1, false},
+ {"attiny25", "__AVR_ATtiny25__", 1, false},
+ {"attiny45", "__AVR_ATtiny45__", 1, false},
+ {"attiny85", "__AVR_ATtiny85__", 1, false},
+ {"attiny261", "__AVR_ATtiny261__", 1, false},
+ {"attiny261a", "__AVR_ATtiny261A__", 1, false},
+ {"attiny441", "__AVR_ATtiny441__", 1, false},
+ {"attiny461", "__AVR_ATtiny461__", 1, false},
+ {"attiny461a", "__AVR_ATtiny461A__", 1, false},
+ {"attiny841", "__AVR_ATtiny841__", 1, false},
+ {"attiny861", "__AVR_ATtiny861__", 1, false},
+ {"attiny861a", "__AVR_ATtiny861A__", 1, false},
+ {"attiny87", "__AVR_ATtiny87__", 1, false},
+ {"attiny43u", "__AVR_ATtiny43U__", 1, false},
+ {"attiny48", "__AVR_ATtiny48__", 1, false},
+ {"attiny88", "__AVR_ATtiny88__", 1, false},
+ {"attiny828", "__AVR_ATtiny828__", 1, false},
+ {"at43usb355", "__AVR_AT43USB355__", 1, false},
+ {"at76c711", "__AVR_AT76C711__", 1, false},
+ {"atmega103", "__AVR_ATmega103__", 1, false},
+ {"at43usb320", "__AVR_AT43USB320__", 1, false},
+ {"attiny167", "__AVR_ATtiny167__", 1, false},
+ {"at90usb82", "__AVR_AT90USB82__", 1, false},
+ {"at90usb162", "__AVR_AT90USB162__", 1, false},
+ {"ata5505", "__AVR_ATA5505__", 1, false},
+ {"ata6617c", "__AVR_ATA6617C__", 1, false},
+ {"ata664251", "__AVR_ATA664251__", 1, false},
+ {"atmega8u2", "__AVR_ATmega8U2__", 1, false},
+ {"atmega16u2", "__AVR_ATmega16U2__", 1, false},
+ {"atmega32u2", "__AVR_ATmega32U2__", 1, false},
+ {"attiny1634", "__AVR_ATtiny1634__", 1, false},
+ {"atmega8", "__AVR_ATmega8__", 1, false},
+ {"ata6289", "__AVR_ATA6289__", 1, false},
+ {"atmega8a", "__AVR_ATmega8A__", 1, false},
+ {"ata6285", "__AVR_ATA6285__", 1, false},
+ {"ata6286", "__AVR_ATA6286__", 1, false},
+ {"ata6612c", "__AVR_ATA6612C__", 1, false},
+ {"atmega48", "__AVR_ATmega48__", 1, false},
+ {"atmega48a", "__AVR_ATmega48A__", 1, false},
+ {"atmega48pa", "__AVR_ATmega48PA__", 1, false},
+ {"atmega48pb", "__AVR_ATmega48PB__", 1, false},
+ {"atmega48p", "__AVR_ATmega48P__", 1, false},
+ {"atmega88", "__AVR_ATmega88__", 1, false},
+ {"atmega88a", "__AVR_ATmega88A__", 1, false},
+ {"atmega88p", "__AVR_ATmega88P__", 1, false},
+ {"atmega88pa", "__AVR_ATmega88PA__", 1, false},
+ {"atmega88pb", "__AVR_ATmega88PB__", 1, false},
+ {"atmega8515", "__AVR_ATmega8515__", 1, false},
+ {"atmega8535", "__AVR_ATmega8535__", 1, false},
+ {"atmega8hva", "__AVR_ATmega8HVA__", 1, false},
+ {"at90pwm1", "__AVR_AT90PWM1__", 1, false},
+ {"at90pwm2", "__AVR_AT90PWM2__", 1, false},
+ {"at90pwm2b", "__AVR_AT90PWM2B__", 1, false},
+ {"at90pwm3", "__AVR_AT90PWM3__", 1, false},
+ {"at90pwm3b", "__AVR_AT90PWM3B__", 1, false},
+ {"at90pwm81", "__AVR_AT90PWM81__", 1, false},
+ {"ata5702m322", "__AVR_ATA5702M322__", 1, false},
+ {"ata5782", "__AVR_ATA5782__", 1, false},
+ {"ata5790", "__AVR_ATA5790__", 1, false},
+ {"ata5790n", "__AVR_ATA5790N__", 1, false},
+ {"ata5791", "__AVR_ATA5791__", 1, false},
+ {"ata5795", "__AVR_ATA5795__", 1, false},
+ {"ata5831", "__AVR_ATA5831__", 1, false},
+ {"ata6613c", "__AVR_ATA6613C__", 1, false},
+ {"ata6614q", "__AVR_ATA6614Q__", 1, false},
+ {"ata8210", "__AVR_ATA8210__", 1, false},
+ {"ata8510", "__AVR_ATA8510__", 1, false},
+ {"atmega16", "__AVR_ATmega16__", 1, false},
+ {"atmega16a", "__AVR_ATmega16A__", 1, false},
+ {"atmega161", "__AVR_ATmega161__", 1, false},
+ {"atmega162", "__AVR_ATmega162__", 1, false},
+ {"atmega163", "__AVR_ATmega163__", 1, false},
+ {"atmega164a", "__AVR_ATmega164A__", 1, false},
+ {"atmega164p", "__AVR_ATmega164P__", 1, false},
+ {"atmega164pa", "__AVR_ATmega164PA__", 1, false},
+ {"atmega165", "__AVR_ATmega165__", 1, false},
+ {"atmega165a", "__AVR_ATmega165A__", 1, false},
+ {"atmega165p", "__AVR_ATmega165P__", 1, false},
+ {"atmega165pa", "__AVR_ATmega165PA__", 1, false},
+ {"atmega168", "__AVR_ATmega168__", 1, false},
+ {"atmega168a", "__AVR_ATmega168A__", 1, false},
+ {"atmega168p", "__AVR_ATmega168P__", 1, false},
+ {"atmega168pa", "__AVR_ATmega168PA__", 1, false},
+ {"atmega168pb", "__AVR_ATmega168PB__", 1, false},
+ {"atmega169", "__AVR_ATmega169__", 1, false},
+ {"atmega169a", "__AVR_ATmega169A__", 1, false},
+ {"atmega169p", "__AVR_ATmega169P__", 1, false},
+ {"atmega169pa", "__AVR_ATmega169PA__", 1, false},
+ {"atmega32", "__AVR_ATmega32__", 1, false},
+ {"atmega32a", "__AVR_ATmega32A__", 1, false},
+ {"atmega323", "__AVR_ATmega323__", 1, false},
+ {"atmega324a", "__AVR_ATmega324A__", 1, false},
+ {"atmega324p", "__AVR_ATmega324P__", 1, false},
+ {"atmega324pa", "__AVR_ATmega324PA__", 1, false},
+ {"atmega324pb", "__AVR_ATmega324PB__", 1, false},
+ {"atmega325", "__AVR_ATmega325__", 1, false},
+ {"atmega325a", "__AVR_ATmega325A__", 1, false},
+ {"atmega325p", "__AVR_ATmega325P__", 1, false},
+ {"atmega325pa", "__AVR_ATmega325PA__", 1, false},
+ {"atmega3250", "__AVR_ATmega3250__", 1, false},
+ {"atmega3250a", "__AVR_ATmega3250A__", 1, false},
+ {"atmega3250p", "__AVR_ATmega3250P__", 1, false},
+ {"atmega3250pa", "__AVR_ATmega3250PA__", 1, false},
+ {"atmega328", "__AVR_ATmega328__", 1, false},
+ {"atmega328p", "__AVR_ATmega328P__", 1, false},
+ {"atmega328pb", "__AVR_ATmega328PB__", 1, false},
+ {"atmega329", "__AVR_ATmega329__", 1, false},
+ {"atmega329a", "__AVR_ATmega329A__", 1, false},
+ {"atmega329p", "__AVR_ATmega329P__", 1, false},
+ {"atmega329pa", "__AVR_ATmega329PA__", 1, false},
+ {"atmega3290", "__AVR_ATmega3290__", 1, false},
+ {"atmega3290a", "__AVR_ATmega3290A__", 1, false},
+ {"atmega3290p", "__AVR_ATmega3290P__", 1, false},
+ {"atmega3290pa", "__AVR_ATmega3290PA__", 1, false},
+ {"atmega406", "__AVR_ATmega406__", 1, false},
+ {"atmega64", "__AVR_ATmega64__", 1, false},
+ {"atmega64a", "__AVR_ATmega64A__", 1, false},
+ {"atmega640", "__AVR_ATmega640__", 1, false},
+ {"atmega644", "__AVR_ATmega644__", 1, false},
+ {"atmega644a", "__AVR_ATmega644A__", 1, false},
+ {"atmega644p", "__AVR_ATmega644P__", 1, false},
+ {"atmega644pa", "__AVR_ATmega644PA__", 1, false},
+ {"atmega645", "__AVR_ATmega645__", 1, false},
+ {"atmega645a", "__AVR_ATmega645A__", 1, false},
+ {"atmega645p", "__AVR_ATmega645P__", 1, false},
+ {"atmega649", "__AVR_ATmega649__", 1, false},
+ {"atmega649a", "__AVR_ATmega649A__", 1, false},
+ {"atmega649p", "__AVR_ATmega649P__", 1, false},
+ {"atmega6450", "__AVR_ATmega6450__", 1, false},
+ {"atmega6450a", "__AVR_ATmega6450A__", 1, false},
+ {"atmega6450p", "__AVR_ATmega6450P__", 1, false},
+ {"atmega6490", "__AVR_ATmega6490__", 1, false},
+ {"atmega6490a", "__AVR_ATmega6490A__", 1, false},
+ {"atmega6490p", "__AVR_ATmega6490P__", 1, false},
+ {"atmega64rfr2", "__AVR_ATmega64RFR2__", 1, false},
+ {"atmega644rfr2", "__AVR_ATmega644RFR2__", 1, false},
+ {"atmega16hva", "__AVR_ATmega16HVA__", 1, false},
+ {"atmega16hva2", "__AVR_ATmega16HVA2__", 1, false},
+ {"atmega16hvb", "__AVR_ATmega16HVB__", 1, false},
+ {"atmega16hvbrevb", "__AVR_ATmega16HVBREVB__", 1, false},
+ {"atmega32hvb", "__AVR_ATmega32HVB__", 1, false},
+ {"atmega32hvbrevb", "__AVR_ATmega32HVBREVB__", 1, false},
+ {"atmega64hve", "__AVR_ATmega64HVE__", 1, false},
+ {"atmega64hve2", "__AVR_ATmega64HVE2__", 1, false},
+ {"at90can32", "__AVR_AT90CAN32__", 1, false},
+ {"at90can64", "__AVR_AT90CAN64__", 1, false},
+ {"at90pwm161", "__AVR_AT90PWM161__", 1, false},
+ {"at90pwm216", "__AVR_AT90PWM216__", 1, false},
+ {"at90pwm316", "__AVR_AT90PWM316__", 1, false},
+ {"atmega32c1", "__AVR_ATmega32C1__", 1, false},
+ {"atmega64c1", "__AVR_ATmega64C1__", 1, false},
+ {"atmega16m1", "__AVR_ATmega16M1__", 1, false},
+ {"atmega32m1", "__AVR_ATmega32M1__", 1, false},
+ {"atmega64m1", "__AVR_ATmega64M1__", 1, false},
+ {"atmega16u4", "__AVR_ATmega16U4__", 1, false},
+ {"atmega32u4", "__AVR_ATmega32U4__", 1, false},
+ {"atmega32u6", "__AVR_ATmega32U6__", 1, false},
+ {"at90usb646", "__AVR_AT90USB646__", 1, false},
+ {"at90usb647", "__AVR_AT90USB647__", 1, false},
+ {"at90scr100", "__AVR_AT90SCR100__", 1, false},
+ {"at94k", "__AVR_AT94K__", 1, false},
+ {"m3000", "__AVR_AT000__", 1, false},
+ {"atmega128", "__AVR_ATmega128__", 2, false},
+ {"atmega128a", "__AVR_ATmega128A__", 2, false},
+ {"atmega1280", "__AVR_ATmega1280__", 2, false},
+ {"atmega1281", "__AVR_ATmega1281__", 2, false},
+ {"atmega1284", "__AVR_ATmega1284__", 2, false},
+ {"atmega1284p", "__AVR_ATmega1284P__", 2, false},
+ {"atmega128rfa1", "__AVR_ATmega128RFA1__", 2, false},
+ {"atmega128rfr2", "__AVR_ATmega128RFR2__", 2, false},
+ {"atmega1284rfr2", "__AVR_ATmega1284RFR2__", 2, false},
+ {"at90can128", "__AVR_AT90CAN128__", 2, false},
+ {"at90usb1286", "__AVR_AT90USB1286__", 2, false},
+ {"at90usb1287", "__AVR_AT90USB1287__", 2, false},
+ {"atmega2560", "__AVR_ATmega2560__", 4, false},
+ {"atmega2561", "__AVR_ATmega2561__", 4, false},
+ {"atmega256rfr2", "__AVR_ATmega256RFR2__", 4, false},
+ {"atmega2564rfr2", "__AVR_ATmega2564RFR2__", 4, false},
+ {"atxmega16a4", "__AVR_ATxmega16A4__", 1, false},
+ {"atxmega16a4u", "__AVR_ATxmega16A4U__", 1, false},
+ {"atxmega16c4", "__AVR_ATxmega16C4__", 1, false},
+ {"atxmega16d4", "__AVR_ATxmega16D4__", 1, false},
+ {"atxmega32a4", "__AVR_ATxmega32A4__", 1, false},
+ {"atxmega32a4u", "__AVR_ATxmega32A4U__", 1, false},
+ {"atxmega32c3", "__AVR_ATxmega32C3__", 1, false},
+ {"atxmega32c4", "__AVR_ATxmega32C4__", 1, false},
+ {"atxmega32d3", "__AVR_ATxmega32D3__", 1, false},
+ {"atxmega32d4", "__AVR_ATxmega32D4__", 1, false},
+ {"atxmega32e5", "__AVR_ATxmega32E5__", 1, false},
+ {"atxmega16e5", "__AVR_ATxmega16E5__", 1, false},
+ {"atxmega8e5", "__AVR_ATxmega8E5__", 1, false},
+ {"atxmega64a3", "__AVR_ATxmega64A3__", 1, false},
+ {"atxmega64a3u", "__AVR_ATxmega64A3U__", 1, false},
+ {"atxmega64a4u", "__AVR_ATxmega64A4U__", 1, false},
+ {"atxmega64b1", "__AVR_ATxmega64B1__", 1, false},
+ {"atxmega64b3", "__AVR_ATxmega64B3__", 1, false},
+ {"atxmega64c3", "__AVR_ATxmega64C3__", 1, false},
+ {"atxmega64d3", "__AVR_ATxmega64D3__", 1, false},
+ {"atxmega64d4", "__AVR_ATxmega64D4__", 1, false},
+ {"atxmega64a1", "__AVR_ATxmega64A1__", 1, false},
+ {"atxmega64a1u", "__AVR_ATxmega64A1U__", 1, false},
+ {"atxmega128a3", "__AVR_ATxmega128A3__", 2, false},
+ {"atxmega128a3u", "__AVR_ATxmega128A3U__", 2, false},
+ {"atxmega128b1", "__AVR_ATxmega128B1__", 2, false},
+ {"atxmega128b3", "__AVR_ATxmega128B3__", 2, false},
+ {"atxmega128c3", "__AVR_ATxmega128C3__", 2, false},
+ {"atxmega128d3", "__AVR_ATxmega128D3__", 2, false},
+ {"atxmega128d4", "__AVR_ATxmega128D4__", 2, false},
+ {"atxmega192a3", "__AVR_ATxmega192A3__", 3, false},
+ {"atxmega192a3u", "__AVR_ATxmega192A3U__", 3, false},
+ {"atxmega192c3", "__AVR_ATxmega192C3__", 3, false},
+ {"atxmega192d3", "__AVR_ATxmega192D3__", 3, false},
+ {"atxmega256a3", "__AVR_ATxmega256A3__", 4, false},
+ {"atxmega256a3u", "__AVR_ATxmega256A3U__", 4, false},
+ {"atxmega256a3b", "__AVR_ATxmega256A3B__", 4, false},
+ {"atxmega256a3bu", "__AVR_ATxmega256A3BU__", 4, false},
+ {"atxmega256c3", "__AVR_ATxmega256C3__", 4, false},
+ {"atxmega256d3", "__AVR_ATxmega256D3__", 4, false},
+ {"atxmega384c3", "__AVR_ATxmega384C3__", 6, false},
+ {"atxmega384d3", "__AVR_ATxmega384D3__", 6, false},
+ {"atxmega128a1", "__AVR_ATxmega128A1__", 2, false},
+ {"atxmega128a1u", "__AVR_ATxmega128A1U__", 2, false},
+ {"atxmega128a4u", "__AVR_ATxmega128A4U__", 2, false},
{"attiny4", "__AVR_ATtiny4__", 0, true},
{"attiny5", "__AVR_ATtiny5__", 0, true},
{"attiny9", "__AVR_ATtiny9__", 0, true},
@@ -276,31 +291,42 @@ static MCUInfo AVRMcus[] = {
{"attiny40", "__AVR_ATtiny40__", 0, true},
{"attiny102", "__AVR_ATtiny102__", 0, true},
{"attiny104", "__AVR_ATtiny104__", 0, true},
- {"attiny202", "__AVR_ATtiny202__", 1},
- {"attiny402", "__AVR_ATtiny402__", 1},
- {"attiny204", "__AVR_ATtiny204__", 1},
- {"attiny404", "__AVR_ATtiny404__", 1},
- {"attiny804", "__AVR_ATtiny804__", 1},
- {"attiny1604", "__AVR_ATtiny1604__", 1},
- {"attiny406", "__AVR_ATtiny406__", 1},
- {"attiny806", "__AVR_ATtiny806__", 1},
- {"attiny1606", "__AVR_ATtiny1606__", 1},
- {"attiny807", "__AVR_ATtiny807__", 1},
- {"attiny1607", "__AVR_ATtiny1607__", 1},
- {"attiny212", "__AVR_ATtiny212__", 1},
- {"attiny412", "__AVR_ATtiny412__", 1},
- {"attiny214", "__AVR_ATtiny214__", 1},
- {"attiny414", "__AVR_ATtiny414__", 1},
- {"attiny814", "__AVR_ATtiny814__", 1},
- {"attiny1614", "__AVR_ATtiny1614__", 1},
- {"attiny416", "__AVR_ATtiny416__", 1},
- {"attiny816", "__AVR_ATtiny816__", 1},
- {"attiny1616", "__AVR_ATtiny1616__", 1},
- {"attiny3216", "__AVR_ATtiny3216__", 1},
- {"attiny417", "__AVR_ATtiny417__", 1},
- {"attiny817", "__AVR_ATtiny817__", 1},
- {"attiny1617", "__AVR_ATtiny1617__", 1},
- {"attiny3217", "__AVR_ATtiny3217__", 1},
+ {"attiny202", "__AVR_ATtiny202__", 1, false},
+ {"attiny402", "__AVR_ATtiny402__", 1, false},
+ {"attiny204", "__AVR_ATtiny204__", 1, false},
+ {"attiny404", "__AVR_ATtiny404__", 1, false},
+ {"attiny804", "__AVR_ATtiny804__", 1, false},
+ {"attiny1604", "__AVR_ATtiny1604__", 1, false},
+ {"attiny406", "__AVR_ATtiny406__", 1, false},
+ {"attiny806", "__AVR_ATtiny806__", 1, false},
+ {"attiny1606", "__AVR_ATtiny1606__", 1, false},
+ {"attiny807", "__AVR_ATtiny807__", 1, false},
+ {"attiny1607", "__AVR_ATtiny1607__", 1, false},
+ {"attiny212", "__AVR_ATtiny212__", 1, false},
+ {"attiny412", "__AVR_ATtiny412__", 1, false},
+ {"attiny214", "__AVR_ATtiny214__", 1, false},
+ {"attiny414", "__AVR_ATtiny414__", 1, false},
+ {"attiny814", "__AVR_ATtiny814__", 1, false},
+ {"attiny1614", "__AVR_ATtiny1614__", 1, false},
+ {"attiny416", "__AVR_ATtiny416__", 1, false},
+ {"attiny816", "__AVR_ATtiny816__", 1, false},
+ {"attiny1616", "__AVR_ATtiny1616__", 1, false},
+ {"attiny3216", "__AVR_ATtiny3216__", 1, false},
+ {"attiny417", "__AVR_ATtiny417__", 1, false},
+ {"attiny817", "__AVR_ATtiny817__", 1, false},
+ {"attiny1617", "__AVR_ATtiny1617__", 1, false},
+ {"attiny3217", "__AVR_ATtiny3217__", 1, false},
+ {"attiny1624", "__AVR_ATtiny1624__", 1, false},
+ {"attiny1626", "__AVR_ATtiny1626__", 1, false},
+ {"attiny1627", "__AVR_ATtiny1627__", 1, false},
+ {"atmega808", "__AVR_ATmega808__", 1, false},
+ {"atmega809", "__AVR_ATmega809__", 1, false},
+ {"atmega1608", "__AVR_ATmega1608__", 1, false},
+ {"atmega1609", "__AVR_ATmega1609__", 1, false},
+ {"atmega3208", "__AVR_ATmega3208__", 1, false},
+ {"atmega3209", "__AVR_ATmega3209__", 1, false},
+ {"atmega4808", "__AVR_ATmega4808__", 1, false},
+ {"atmega4809", "__AVR_ATmega4809__", 1, false},
};
} // namespace targets
@@ -354,6 +380,9 @@ void AVRTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__AVR__");
Builder.defineMacro("__ELF__");
+ if (ABI == "avrtiny")
+ Builder.defineMacro("__AVR_TINY__", "1");
+
if (!this->CPU.empty()) {
auto It = llvm::find_if(
AVRMcus, [&](const MCUInfo &Info) { return Info.Name == this->CPU; });
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/CSKY.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/CSKY.cpp
new file mode 100644
index 000000000000..adcffd90ae78
--- /dev/null
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/CSKY.cpp
@@ -0,0 +1,314 @@
+//===--- CSKY.cpp - Implement CSKY target feature support -----------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements CSKY TargetInfo objects.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CSKY.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+bool CSKYTargetInfo::isValidCPUName(StringRef Name) const {
+ return llvm::CSKY::parseCPUArch(Name) != llvm::CSKY::ArchKind::INVALID;
+}
+
+bool CSKYTargetInfo::setCPU(const std::string &Name) {
+ llvm::CSKY::ArchKind archKind = llvm::CSKY::parseCPUArch(Name);
+ bool isValid = (archKind != llvm::CSKY::ArchKind::INVALID);
+
+ if (isValid) {
+ CPU = Name;
+ Arch = archKind;
+ }
+
+ return isValid;
+}
+
+void CSKYTargetInfo::getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+ Builder.defineMacro("__ELF__");
+ Builder.defineMacro("__csky__", "2");
+ Builder.defineMacro("__CSKY__", "2");
+ Builder.defineMacro("__ckcore__", "2");
+ Builder.defineMacro("__CKCORE__", "2");
+
+ Builder.defineMacro("__CSKYABI__", ABI == "abiv2" ? "2" : "1");
+ Builder.defineMacro("__cskyabi__", ABI == "abiv2" ? "2" : "1");
+
+ StringRef ArchName = "ck810";
+ StringRef CPUName = "ck810";
+
+ if (Arch != llvm::CSKY::ArchKind::INVALID) {
+ ArchName = llvm::CSKY::getArchName(Arch);
+ CPUName = CPU;
+ }
+
+ Builder.defineMacro("__" + ArchName.upper() + "__");
+ Builder.defineMacro("__" + ArchName.lower() + "__");
+ Builder.defineMacro("__" + CPUName.upper() + "__");
+ Builder.defineMacro("__" + CPUName.lower() + "__");
+
+ // TODO: Add support for BE if BE was supported later
+ StringRef endian = "__cskyLE__";
+
+ Builder.defineMacro(endian);
+ Builder.defineMacro(endian.upper());
+ Builder.defineMacro(endian.lower());
+
+ if (DSPV2) {
+ StringRef dspv2 = "__CSKY_DSPV2__";
+ Builder.defineMacro(dspv2);
+ Builder.defineMacro(dspv2.lower());
+ }
+
+ if (VDSPV2) {
+ StringRef vdspv2 = "__CSKY_VDSPV2__";
+ Builder.defineMacro(vdspv2);
+ Builder.defineMacro(vdspv2.lower());
+
+ if (HardFloat) {
+ StringRef vdspv2_f = "__CSKY_VDSPV2_F__";
+ Builder.defineMacro(vdspv2_f);
+ Builder.defineMacro(vdspv2_f.lower());
+ }
+ }
+ if (VDSPV1) {
+ StringRef vdspv1_64 = "__CSKY_VDSP64__";
+ StringRef vdspv1_128 = "__CSKY_VDSP128__";
+
+ Builder.defineMacro(vdspv1_64);
+ Builder.defineMacro(vdspv1_64.lower());
+ Builder.defineMacro(vdspv1_128);
+ Builder.defineMacro(vdspv1_128.lower());
+ }
+ if (is3E3R1) {
+ StringRef is3e3r1 = "__CSKY_3E3R1__";
+ Builder.defineMacro(is3e3r1);
+ Builder.defineMacro(is3e3r1.lower());
+ }
+}
+
+bool CSKYTargetInfo::hasFeature(StringRef Feature) const {
+ return llvm::StringSwitch<bool>(Feature)
+ .Case("hard-float", HardFloat)
+ .Case("hard-float-abi", HardFloatABI)
+ .Case("fpuv2_sf", FPUV2_SF)
+ .Case("fpuv2_df", FPUV2_DF)
+ .Case("fpuv3_sf", FPUV3_SF)
+ .Case("fpuv3_df", FPUV3_DF)
+ .Case("vdspv2", VDSPV2)
+ .Case("dspv2", DSPV2)
+ .Case("vdspv1", VDSPV1)
+ .Case("3e3r1", is3E3R1)
+ .Default(false);
+}
+
+bool CSKYTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
+ DiagnosticsEngine &Diags) {
+ for (const auto &Feature : Features) {
+ if (Feature == "+hard-float")
+ HardFloat = true;
+ if (Feature == "+hard-float-abi")
+ HardFloatABI = true;
+ if (Feature == "+fpuv2_sf")
+ FPUV2_SF = true;
+ if (Feature == "+fpuv2_df")
+ FPUV2_DF = true;
+ if (Feature == "+fpuv3_sf")
+ FPUV3_SF = true;
+ if (Feature == "+fpuv3_df")
+ FPUV3_DF = true;
+ if (Feature == "+vdspv2")
+ VDSPV2 = true;
+ if (Feature == "+dspv2")
+ DSPV2 = true;
+ if (Feature == "+vdspv1")
+ VDSPV1 = true;
+ if (Feature == "+3e3r1")
+ is3E3R1 = true;
+ }
+
+ return true;
+}
+
+ArrayRef<Builtin::Info> CSKYTargetInfo::getTargetBuiltins() const {
+ return ArrayRef<Builtin::Info>();
+}
+
+ArrayRef<const char *> CSKYTargetInfo::getGCCRegNames() const {
+ static const char *const GCCRegNames[] = {
+ // Integer registers
+ "r0",
+ "r1",
+ "r2",
+ "r3",
+ "r4",
+ "r5",
+ "r6",
+ "r7",
+ "r8",
+ "r9",
+ "r10",
+ "r11",
+ "r12",
+ "r13",
+ "r14",
+ "r15",
+ "r16",
+ "r17",
+ "r18",
+ "r19",
+ "r20",
+ "r21",
+ "r22",
+ "r23",
+ "r24",
+ "r25",
+ "r26",
+ "r27",
+ "r28",
+ "r29",
+ "r30",
+ "r31",
+
+ // Floating point registers
+ "fr0",
+ "fr1",
+ "fr2",
+ "fr3",
+ "fr4",
+ "fr5",
+ "fr6",
+ "fr7",
+ "fr8",
+ "fr9",
+ "fr10",
+ "fr11",
+ "fr12",
+ "fr13",
+ "fr14",
+ "fr15",
+ "fr16",
+ "fr17",
+ "fr18",
+ "fr19",
+ "fr20",
+ "fr21",
+ "fr22",
+ "fr23",
+ "fr24",
+ "fr25",
+ "fr26",
+ "fr27",
+ "fr28",
+ "fr29",
+ "fr30",
+ "fr31",
+
+ };
+ return llvm::makeArrayRef(GCCRegNames);
+}
+
+ArrayRef<TargetInfo::GCCRegAlias> CSKYTargetInfo::getGCCRegAliases() const {
+ static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
+ {{"a0"}, "r0"},
+ {{"a1"}, "r1"},
+ {{"a2"}, "r2"},
+ {{"a3"}, "r3"},
+ {{"l0"}, "r4"},
+ {{"l1"}, "r5"},
+ {{"l2"}, "r6"},
+ {{"l3"}, "r7"},
+ {{"l4"}, "r8"},
+ {{"l5"}, "r9"},
+ {{"l6"}, "r10"},
+ {{"l7"}, "r11"},
+ {{"t0"}, "r12"},
+ {{"t1"}, "r13"},
+ {{"sp"}, "r14"},
+ {{"lr"}, "r15"},
+ {{"l8"}, "r16"},
+ {{"l9"}, "r17"},
+ {{"t2"}, "r18"},
+ {{"t3"}, "r19"},
+ {{"t4"}, "r20"},
+ {{"t5"}, "r21"},
+ {{"t6"}, "r22"},
+ {{"t7", "fp"}, "r23"},
+ {{"t8", "top"}, "r24"},
+ {{"t9", "bsp"}, "r25"},
+ {{"r26"}, "r26"},
+ {{"r27"}, "r27"},
+ {{"gb", "rgb", "rdb"}, "r28"},
+ {{"tb", "rtb"}, "r29"},
+ {{"svbr"}, "r30"},
+ {{"tls"}, "r31"},
+
+ {{"vr0"}, "fr0"},
+ {{"vr1"}, "fr1"},
+ {{"vr2"}, "fr2"},
+ {{"vr3"}, "fr3"},
+ {{"vr4"}, "fr4"},
+ {{"vr5"}, "fr5"},
+ {{"vr6"}, "fr6"},
+ {{"vr7"}, "fr7"},
+ {{"vr8"}, "fr8"},
+ {{"vr9"}, "fr9"},
+ {{"vr10"}, "fr10"},
+ {{"vr11"}, "fr11"},
+ {{"vr12"}, "fr12"},
+ {{"vr13"}, "fr13"},
+ {{"vr14"}, "fr14"},
+ {{"vr15"}, "fr15"},
+ {{"vr16"}, "fr16"},
+ {{"vr17"}, "fr17"},
+ {{"vr18"}, "fr18"},
+ {{"vr19"}, "fr19"},
+ {{"vr20"}, "fr20"},
+ {{"vr21"}, "fr21"},
+ {{"vr22"}, "fr22"},
+ {{"vr23"}, "fr23"},
+ {{"vr24"}, "fr24"},
+ {{"vr25"}, "fr25"},
+ {{"vr26"}, "fr26"},
+ {{"vr27"}, "fr27"},
+ {{"vr28"}, "fr28"},
+ {{"vr29"}, "fr29"},
+ {{"vr30"}, "fr30"},
+ {{"vr31"}, "fr31"},
+
+ };
+ return llvm::makeArrayRef(GCCRegAliases);
+}
+
+bool CSKYTargetInfo::validateAsmConstraint(
+ const char *&Name, TargetInfo::ConstraintInfo &Info) const {
+ switch (*Name) {
+ default:
+ return false;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'y':
+ case 'l':
+ case 'h':
+ case 'w':
+ case 'v': // A floating-point and vector register.
+ case 'z':
+ Info.setAllowsRegister();
+ return true;
+ }
+}
+
+unsigned CSKYTargetInfo::getMinGlobalAlign(uint64_t Size) const {
+ if (Size >= 32)
+ return 32;
+ return 0;
+}
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/CSKY.h b/contrib/llvm-project/clang/lib/Basic/Targets/CSKY.h
new file mode 100644
index 000000000000..7e932e7c86b1
--- /dev/null
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/CSKY.h
@@ -0,0 +1,107 @@
+//===--- CSKY.h - Declare CSKY target feature support -----------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares CSKY TargetInfo objects.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_CSKY_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_CSKY_H
+
+#include "clang/Basic/MacroBuilder.h"
+#include "clang/Basic/TargetInfo.h"
+#include "llvm/Support/CSKYTargetParser.h"
+
+namespace clang {
+namespace targets {
+
+class LLVM_LIBRARY_VISIBILITY CSKYTargetInfo : public TargetInfo {
+protected:
+ std::string ABI;
+ llvm::CSKY::ArchKind Arch = llvm::CSKY::ArchKind::INVALID;
+ std::string CPU;
+
+ bool HardFloat = false;
+ bool HardFloatABI = false;
+ bool FPUV2_SF = false;
+ bool FPUV2_DF = false;
+ bool FPUV3_SF = false;
+ bool FPUV3_DF = false;
+ bool VDSPV2 = false;
+ bool VDSPV1 = false;
+ bool DSPV2 = false;
+ bool is3E3R1 = false;
+
+public:
+ CSKYTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ : TargetInfo(Triple) {
+ NoAsmVariants = true;
+ LongLongAlign = 32;
+ SuitableAlign = 32;
+ DoubleAlign = LongDoubleAlign = 32;
+ SizeType = UnsignedInt;
+ PtrDiffType = SignedInt;
+ IntPtrType = SignedInt;
+ WCharType = SignedInt;
+ WIntType = UnsignedInt;
+
+ UseZeroLengthBitfieldAlignment = true;
+ MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
+ resetDataLayout("e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-"
+ "v64:32:32-v128:32:32-a:0:32-Fi32-n32");
+
+ setABI("abiv2");
+ }
+
+ StringRef getABI() const override { return ABI; }
+ bool setABI(const std::string &Name) override {
+ if (Name == "abiv2" || Name == "abiv1") {
+ ABI = Name;
+ return true;
+ }
+ return false;
+ }
+
+ bool setCPU(const std::string &Name) override;
+
+ bool isValidCPUName(StringRef Name) const override;
+
+ virtual unsigned getMinGlobalAlign(uint64_t) const override;
+
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override;
+
+ BuiltinVaListKind getBuiltinVaListKind() const override {
+ return VoidPtrBuiltinVaList;
+ }
+
+ bool validateAsmConstraint(const char *&Name,
+ TargetInfo::ConstraintInfo &info) const override;
+
+ const char *getClobbers() const override { return ""; }
+
+ void getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const override;
+ bool hasFeature(StringRef Feature) const override;
+ bool handleTargetFeatures(std::vector<std::string> &Features,
+ DiagnosticsEngine &Diags) override;
+
+ /// Whether target allows to overalign ABI-specified preferred alignment
+ bool allowsLargerPreferedTypeAlignment() const override { return false; }
+
+ bool hasBitIntType() const override { return true; }
+
+protected:
+ ArrayRef<const char *> getGCCRegNames() const override;
+
+ ArrayRef<GCCRegAlias> getGCCRegAliases() const override;
+};
+
+} // namespace targets
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_BASIC_TARGETS_CSKY_H
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/DirectX.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/DirectX.cpp
new file mode 100644
index 000000000000..0dd27e6e93b3
--- /dev/null
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/DirectX.cpp
@@ -0,0 +1,22 @@
+//===--- DirectX.cpp - Implement DirectX target feature support -----------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements DirectX TargetInfo objects.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DirectX.h"
+#include "Targets.h"
+
+using namespace clang;
+using namespace clang::targets;
+
+void DirectXTargetInfo::getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+ DefineStd(Builder, "DIRECTX", Opts);
+}
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/DirectX.h b/contrib/llvm-project/clang/lib/Basic/Targets/DirectX.h
new file mode 100644
index 000000000000..a773090b413f
--- /dev/null
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/DirectX.h
@@ -0,0 +1,93 @@
+//===--- DirectX.h - Declare DirectX target feature support -----*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares DXIL TargetInfo objects.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
+#define LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/Compiler.h"
+
+namespace clang {
+namespace targets {
+
+static const unsigned DirectXAddrSpaceMap[] = {
+ 0, // Default
+ 1, // opencl_global
+ 3, // opencl_local
+ 2, // opencl_constant
+ 0, // opencl_private
+ 4, // opencl_generic
+ 5, // opencl_global_device
+ 6, // opencl_global_host
+ 0, // cuda_device
+ 0, // cuda_constant
+ 0, // cuda_shared
+ // SYCL address space values for this map are dummy
+ 0, // sycl_global
+ 0, // sycl_global_device
+ 0, // sycl_global_host
+ 0, // sycl_local
+ 0, // sycl_private
+ 0, // ptr32_sptr
+ 0, // ptr32_uptr
+ 0 // ptr64
+};
+
+class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
+public:
+ DirectXTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
+ : TargetInfo(Triple) {
+ TLSSupported = false;
+ VLASupported = false;
+ LongWidth = LongAlign = 64;
+ AddrSpaceMap = &DirectXAddrSpaceMap;
+ UseAddrSpaceMapMangling = true;
+ HasLegalHalfType = true;
+ HasFloat16 = true;
+ NoAsmVariants = true;
+ resetDataLayout("e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:"
+ "32-f64:64-n8:16:32:64");
+ TheCXXABI.set(TargetCXXABI::Microsoft);
+ }
+ bool useFP16ConversionIntrinsics() const override { return false; }
+ void getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const override;
+
+ bool hasFeature(StringRef Feature) const override {
+ return Feature == "directx";
+ }
+
+ ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
+
+ const char *getClobbers() const override { return ""; }
+
+ ArrayRef<const char *> getGCCRegNames() const override { return None; }
+
+ bool validateAsmConstraint(const char *&Name,
+ TargetInfo::ConstraintInfo &info) const override {
+ return true;
+ }
+
+ ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
+ return None;
+ }
+
+ BuiltinVaListKind getBuiltinVaListKind() const override {
+ return TargetInfo::VoidPtrBuiltinVaList;
+ }
+};
+
+} // namespace targets
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/NVPTX.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/NVPTX.cpp
index 75e82d819900..9dd60adb00fb 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/NVPTX.cpp
@@ -179,7 +179,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
Builder.defineMacro("__PTX__");
Builder.defineMacro("__NVPTX__");
- if (Opts.CUDAIsDevice) {
+ if (Opts.CUDAIsDevice || Opts.OpenMPIsDevice) {
// Set __CUDA_ARCH__ for the GPU specified.
std::string CUDAArchCode = [this] {
switch (GPU) {
@@ -205,6 +205,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
case CudaArch::GFX909:
case CudaArch::GFX90a:
case CudaArch::GFX90c:
+ case CudaArch::GFX940:
case CudaArch::GFX1010:
case CudaArch::GFX1011:
case CudaArch::GFX1012:
@@ -215,6 +216,11 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
case CudaArch::GFX1033:
case CudaArch::GFX1034:
case CudaArch::GFX1035:
+ case CudaArch::GFX1036:
+ case CudaArch::GFX1100:
+ case CudaArch::GFX1101:
+ case CudaArch::GFX1102:
+ case CudaArch::GFX1103:
case CudaArch::Generic:
case CudaArch::LAST:
break;
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.cpp
index f8f12daaa072..f2ed076039a0 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.cpp
@@ -73,19 +73,19 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
char Str[7];
if (OsVersion.getMajor() < 10) {
Str[0] = '0' + OsVersion.getMajor();
- Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
- Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
- Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
- Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+ Str[1] = '0' + (OsVersion.getMinor().value_or(0) / 10);
+ Str[2] = '0' + (OsVersion.getMinor().value_or(0) % 10);
+ Str[3] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
+ Str[4] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[5] = '\0';
} else {
// Handle versions >= 10.
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
- Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
- Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
- Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
- Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+ Str[2] = '0' + (OsVersion.getMinor().value_or(0) / 10);
+ Str[3] = '0' + (OsVersion.getMinor().value_or(0) % 10);
+ Str[4] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
+ Str[5] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[6] = '\0';
}
if (Triple.isTvOS())
@@ -98,12 +98,25 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
assert(OsVersion < VersionTuple(10) && "Invalid version!");
char Str[6];
Str[0] = '0' + OsVersion.getMajor();
- Str[1] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
- Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
- Str[3] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
- Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+ Str[1] = '0' + (OsVersion.getMinor().value_or(0) / 10);
+ Str[2] = '0' + (OsVersion.getMinor().value_or(0) % 10);
+ Str[3] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
+ Str[4] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[5] = '\0';
Builder.defineMacro("__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__", Str);
+ } else if (Triple.isDriverKit()) {
+ assert(OsVersion.getMajor() < 100 &&
+ OsVersion.getMinor().value_or(0) < 100 &&
+ OsVersion.getSubminor().value_or(0) < 100 && "Invalid version!");
+ char Str[7];
+ Str[0] = '0' + (OsVersion.getMajor() / 10);
+ Str[1] = '0' + (OsVersion.getMajor() % 10);
+ Str[2] = '0' + (OsVersion.getMinor().value_or(0) / 10);
+ Str[3] = '0' + (OsVersion.getMinor().value_or(0) % 10);
+ Str[4] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
+ Str[5] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
+ Str[6] = '\0';
+ Builder.defineMacro("__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__", Str);
} else if (Triple.isMacOSX()) {
// Note that the Driver allows versions which aren't representable in the
// define (because we only get a single digit for the minor and micro
@@ -114,17 +127,17 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
if (OsVersion < VersionTuple(10, 10)) {
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
- Str[2] = '0' + std::min(OsVersion.getMinor().getValueOr(0), 9U);
- Str[3] = '0' + std::min(OsVersion.getSubminor().getValueOr(0), 9U);
+ Str[2] = '0' + std::min(OsVersion.getMinor().value_or(0), 9U);
+ Str[3] = '0' + std::min(OsVersion.getSubminor().value_or(0), 9U);
Str[4] = '\0';
} else {
// Handle versions > 10.9.
Str[0] = '0' + (OsVersion.getMajor() / 10);
Str[1] = '0' + (OsVersion.getMajor() % 10);
- Str[2] = '0' + (OsVersion.getMinor().getValueOr(0) / 10);
- Str[3] = '0' + (OsVersion.getMinor().getValueOr(0) % 10);
- Str[4] = '0' + (OsVersion.getSubminor().getValueOr(0) / 10);
- Str[5] = '0' + (OsVersion.getSubminor().getValueOr(0) % 10);
+ Str[2] = '0' + (OsVersion.getMinor().value_or(0) / 10);
+ Str[3] = '0' + (OsVersion.getMinor().value_or(0) % 10);
+ Str[4] = '0' + (OsVersion.getSubminor().value_or(0) / 10);
+ Str[5] = '0' + (OsVersion.getSubminor().value_or(0) % 10);
Str[6] = '\0';
}
Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str);
@@ -202,6 +215,9 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
}
}
+ if (Opts.Kernel)
+ Builder.defineMacro("_KERNEL_MODE");
+
Builder.defineMacro("_INTEGRAL_MAX_BITS", "64");
Builder.defineMacro("__STDC_NO_THREADS__");
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.h b/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.h
index 3c1830d5f8e8..a814f681b146 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/OSTargets.h
@@ -108,6 +108,8 @@ public:
this->TLSSupported = !Triple.isOSVersionLT(2);
else
this->TLSSupported = !Triple.isOSVersionLT(3);
+ } else if (Triple.isDriverKit()) {
+ // No TLS on DriverKit.
}
this->MCountName = "\01mcount";
@@ -539,8 +541,9 @@ public:
}
};
+// Common base class for PS4/PS5 targets.
template <typename Target>
-class LLVM_LIBRARY_VISIBILITY PS4OSTargetInfo : public OSTargetInfo<Target> {
+class LLVM_LIBRARY_VISIBILITY PSOSTargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {
@@ -550,35 +553,66 @@ protected:
DefineStd(Builder, "unix", Opts);
Builder.defineMacro("__ELF__");
Builder.defineMacro("__SCE__");
- Builder.defineMacro("__ORBIS__");
}
public:
- PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ PSOSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: OSTargetInfo<Target>(Triple, Opts) {
this->WCharType = TargetInfo::UnsignedShort;
- // On PS4, TLS variable cannot be aligned to more than 32 bytes (256 bits).
+ // On PS4/PS5, TLS variable cannot be aligned to more than 32 bytes (256
+ // bits).
this->MaxTLSAlign = 256;
- // On PS4, do not honor explicit bit field alignment,
+ // On PS4/PS5, do not honor explicit bit field alignment,
// as in "__attribute__((aligned(2))) int b : 1;".
this->UseExplicitBitFieldAlignment = false;
- switch (Triple.getArch()) {
- default:
- case llvm::Triple::x86_64:
- this->MCountName = ".mcount";
- this->NewAlign = 256;
- break;
- }
+ this->MCountName = ".mcount";
+ this->NewAlign = 256;
+ this->SuitableAlign = 256;
}
+
TargetInfo::CallingConvCheckResult
checkCallingConvention(CallingConv CC) const override {
return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error;
}
};
+// PS4 Target
+template <typename Target>
+class LLVM_LIBRARY_VISIBILITY PS4OSTargetInfo : public PSOSTargetInfo<Target> {
+protected:
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+ MacroBuilder &Builder) const override {
+ // Start with base class defines.
+ PSOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
+
+ Builder.defineMacro("__ORBIS__");
+ }
+
+public:
+ PS4OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ : PSOSTargetInfo<Target>(Triple, Opts) {}
+};
+
+// PS5 Target
+template <typename Target>
+class LLVM_LIBRARY_VISIBILITY PS5OSTargetInfo : public PSOSTargetInfo<Target> {
+protected:
+ void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
+ MacroBuilder &Builder) const override {
+ // Start with base class defines.
+ PSOSTargetInfo<Target>::getOSDefines(Opts, Triple, Builder);
+
+ Builder.defineMacro("__PROSPERO__");
+ }
+
+public:
+ PS5OSTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
+ : PSOSTargetInfo<Target>(Triple, Opts) {}
+};
+
// RTEMS Target
template <typename Target>
class LLVM_LIBRARY_VISIBILITY RTEMSTargetInfo : public OSTargetInfo<Target> {
@@ -749,7 +783,9 @@ public:
}
// AIX sets FLT_EVAL_METHOD to be 1.
- unsigned getFloatEvalMethod() const override { return 1; }
+ LangOptions::FPEvalMethodKind getFPEvalMethod() const override {
+ return LangOptions::FPEvalMethodKind::FEM_Double;
+ }
bool defaultsToAIXPowerAlignment() const override { return true; }
};
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp
index 1eb0317af60b..9120808e298d 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp
@@ -36,6 +36,8 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasAltivec = true;
} else if (Feature == "+vsx") {
HasVSX = true;
+ } else if (Feature == "+crbits") {
+ UseCRBits = true;
} else if (Feature == "+bpermd") {
HasBPERMD = true;
} else if (Feature == "+extdiv") {
@@ -81,6 +83,8 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
IsISA3_0 = true;
} else if (Feature == "+isa-v31-instructions") {
IsISA3_1 = true;
+ } else if (Feature == "+quadword-atomics") {
+ HasQuadwordAtomics = true;
}
// TODO: Finish this list and add an assert that we've handled them
// all.
@@ -206,6 +210,7 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
Builder.defineMacro("__dcbf", "__builtin_dcbf");
Builder.defineMacro("__fmadd", "__builtin_fma");
Builder.defineMacro("__fmadds", "__builtin_fmaf");
+ Builder.defineMacro("__abs", "__builtin_abs");
Builder.defineMacro("__labs", "__builtin_labs");
Builder.defineMacro("__llabs", "__builtin_llabs");
Builder.defineMacro("__popcnt4", "__builtin_popcount");
@@ -247,6 +252,14 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
Builder.defineMacro("__test_data_class", "__builtin_ppc_test_data_class");
Builder.defineMacro("__swdiv", "__builtin_ppc_swdiv");
Builder.defineMacro("__swdivs", "__builtin_ppc_swdivs");
+ Builder.defineMacro("__fnabs", "__builtin_ppc_fnabs");
+ Builder.defineMacro("__fnabss", "__builtin_ppc_fnabss");
+ Builder.defineMacro("__builtin_maxfe", "__builtin_ppc_maxfe");
+ Builder.defineMacro("__builtin_maxfl", "__builtin_ppc_maxfl");
+ Builder.defineMacro("__builtin_maxfs", "__builtin_ppc_maxfs");
+ Builder.defineMacro("__builtin_minfe", "__builtin_ppc_minfe");
+ Builder.defineMacro("__builtin_minfl", "__builtin_ppc_minfl");
+ Builder.defineMacro("__builtin_minfs", "__builtin_ppc_minfs");
}
/// PPCTargetInfo::getTargetDefines - Return a set of the PowerPC-specific
@@ -506,6 +519,11 @@ bool PPCTargetInfo::initFeatureMap(
.Case("pwr9", true)
.Case("pwr8", true)
.Default(false);
+ Features["crbits"] = llvm::StringSwitch<bool>(CPU)
+ .Case("ppc64le", true)
+ .Case("pwr9", true)
+ .Case("pwr8", true)
+ .Default(false);
Features["vsx"] = llvm::StringSwitch<bool>(CPU)
.Case("ppc64le", true)
.Case("pwr9", true)
@@ -533,6 +551,7 @@ bool PPCTargetInfo::initFeatureMap(
.Case("pwr9", true)
.Case("pwr8", true)
.Case("pwr7", true)
+ .Case("a2", true)
.Default(false);
Features["isa-v207-instructions"] = llvm::StringSwitch<bool>(CPU)
@@ -544,6 +563,12 @@ bool PPCTargetInfo::initFeatureMap(
Features["isa-v30-instructions"] =
llvm::StringSwitch<bool>(CPU).Case("pwr9", true).Default(false);
+ Features["quadword-atomics"] =
+ getTriple().isArch64Bit() && llvm::StringSwitch<bool>(CPU)
+ .Case("pwr9", true)
+ .Case("pwr8", true)
+ .Default(false);
+
// Power10 includes all the same features as Power9 plus any features specific
// to the Power10 core.
if (CPU == "pwr10" || CPU == "power10") {
@@ -569,12 +594,12 @@ bool PPCTargetInfo::initFeatureMap(
}
if (!(ArchDefs & ArchDefinePwr10)) {
- if (llvm::find(FeaturesVec, "+mma") != FeaturesVec.end()) {
+ if (llvm::is_contained(FeaturesVec, "+mma")) {
// MMA operations are not available pre-Power10.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mmma" << CPU;
return false;
}
- if (llvm::find(FeaturesVec, "+pcrel") != FeaturesVec.end()) {
+ if (llvm::is_contained(FeaturesVec, "+pcrel")) {
// PC-Relative instructions are not available pre-Power10,
// and these instructions also require prefixed instructions support.
Diags.Report(diag::err_opt_not_valid_without_opt)
@@ -582,13 +607,13 @@ bool PPCTargetInfo::initFeatureMap(
<< "-mcpu=pwr10 -mprefixed";
return false;
}
- if (llvm::find(FeaturesVec, "+prefixed") != FeaturesVec.end()) {
+ if (llvm::is_contained(FeaturesVec, "+prefixed")) {
// Prefixed instructions are not available pre-Power10.
Diags.Report(diag::err_opt_not_valid_without_opt) << "-mprefixed"
<< "-mcpu=pwr10";
return false;
}
- if (llvm::find(FeaturesVec, "+paired-vector-memops") != FeaturesVec.end()) {
+ if (llvm::is_contained(FeaturesVec, "+paired-vector-memops")) {
// Paired vector memops are not available pre-Power10.
Diags.Report(diag::err_opt_not_valid_without_opt)
<< "-mpaired-vector-memops"
@@ -634,6 +659,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
.Case("powerpc", true)
.Case("altivec", HasAltivec)
.Case("vsx", HasVSX)
+ .Case("crbits", UseCRBits)
.Case("power8-vector", HasP8Vector)
.Case("crypto", HasP8Crypto)
.Case("direct-move", HasDirectMove)
@@ -654,6 +680,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
.Case("isa-v207-instructions", IsISA2_07)
.Case("isa-v30-instructions", IsISA3_0)
.Case("isa-v31-instructions", IsISA3_1)
+ .Case("quadword-atomics", HasQuadwordAtomics)
.Default(false);
}
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
index ac52eb219f54..8148762f446b 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.h
@@ -62,6 +62,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
bool HasROPProtect = false;
bool HasPrivileged = false;
bool HasVSX = false;
+ bool UseCRBits = false;
bool HasP8Vector = false;
bool HasP8Crypto = false;
bool HasDirectMove = false;
@@ -78,6 +79,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
bool IsISA2_07 = false;
bool IsISA3_0 = false;
bool IsISA3_1 = false;
+ bool HasQuadwordAtomics = false;
protected:
std::string ABI;
@@ -439,8 +441,18 @@ public:
DataLayout += "-S128-v256:256:256-v512:512:512";
resetDataLayout(DataLayout);
- // PPC64 supports atomics up to 8 bytes.
- MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+ // Newer PPC64 instruction sets support atomics up to 16 bytes.
+ MaxAtomicPromoteWidth = 128;
+ // Baseline PPC64 supports inlining atomics up to 8 bytes.
+ MaxAtomicInlineWidth = 64;
+ }
+
+ void setMaxAtomicWidth() override {
+ // For power8 and up, backend is able to inline 16-byte atomic lock free
+ // code.
+ // TODO: We should allow AIX to inline quadword atomics in the future.
+ if (!getTriple().isOSAIX() && hasFeature("quadword-atomics"))
+ MaxAtomicInlineWidth = 128;
}
BuiltinVaListKind getBuiltinVaListKind() const override {
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
index 0680cad5b07c..32dd2bad2c5c 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
@@ -188,7 +188,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
if (ISAInfo->hasExtension("c"))
Builder.defineMacro("__riscv_compressed");
- if (ISAInfo->hasExtension("zve32x") || ISAInfo->hasExtension("v"))
+ if (ISAInfo->hasExtension("zve32x"))
Builder.defineMacro("__riscv_vector");
}
@@ -232,8 +232,14 @@ bool RISCVTargetInfo::initFeatureMap(
return false;
}
- return TargetInfo::initFeatureMap(Features, Diags, CPU,
- (*ParseResult)->toFeatureVector());
+ // RISCVISAInfo makes implications for ISA features
+ std::vector<std::string> ImpliedFeatures = (*ParseResult)->toFeatureVector();
+ // Add non-ISA features like `relax` and `save-restore` back
+ for (const std::string &Feature : FeaturesVec)
+ if (!llvm::is_contained(ImpliedFeatures, Feature))
+ ImpliedFeatures.push_back(Feature);
+
+ return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures);
}
/// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -245,7 +251,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
.Case("riscv64", Is64Bit)
.Case("64bit", Is64Bit)
.Default(None);
- if (Result.hasValue())
+ if (Result)
return Result.getValue();
if (ISAInfo->isSupportedExtensionFeature(Feature))
@@ -272,7 +278,7 @@ bool RISCVTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
}
if (ABI.empty())
- ABI = llvm::RISCV::computeDefaultABIFromArch(*ISAInfo).str();
+ ABI = ISAInfo->computeDefaultABI().str();
return true;
}
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.h b/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.h
index 5331ed4a50ae..7817e6e81e26 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/RISCV.h
@@ -96,6 +96,10 @@ public:
DiagnosticsEngine &Diags) override;
bool hasBitIntType() const override { return true; }
+
+ bool useFP16ConversionIntrinsics() const override {
+ return false;
+ }
};
class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
public:
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/SPIR.h b/contrib/llvm-project/clang/lib/Basic/Targets/SPIR.h
index a40d4b3ca27e..08c49f018ac7 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/SPIR.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/SPIR.h
@@ -144,16 +144,16 @@ public:
// FIXME: SYCL specification considers unannotated pointers and references
// to be pointing to the generic address space. See section 5.9.3 of
// SYCL 2020 specification.
- // Currently, there is no way of representing SYCL's and HIP's default
+ // Currently, there is no way of representing SYCL's and HIP/CUDA's default
// address space language semantic along with the semantics of embedded C's
// default address space in the same address space map. Hence the map needs
// to be reset to allow mapping to the desired value of 'Default' entry for
- // SYCL and HIP.
+ // SYCL and HIP/CUDA.
setAddressSpaceMap(
/*DefaultIsGeneric=*/Opts.SYCLIsDevice ||
- // The address mapping from HIP language for device code is only defined
- // for SPIR-V.
- (getTriple().isSPIRV() && Opts.HIP && Opts.CUDAIsDevice));
+ // The address mapping from HIP/CUDA language for device code is only
+ // defined for SPIR-V.
+ (getTriple().isSPIRV() && Opts.CUDAIsDevice));
}
void setSupportedOpenCLOpts() override {
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.cpp
index e3e0da21f8d5..84874b58ba68 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.cpp
@@ -59,6 +59,17 @@ bool SystemZTargetInfo::validateAsmConstraint(
default:
return false;
+ case 'Z':
+ switch (Name[1]) {
+ default:
+ return false;
+ case 'Q': // Address with base and unsigned 12-bit displacement
+ case 'R': // Likewise, plus an index
+ case 'S': // Address with base and signed 20-bit displacement
+ case 'T': // Likewise, plus an index
+ break;
+ }
+ LLVM_FALLTHROUGH;
case 'a': // Address register
case 'd': // Data register (equivalent to 'r')
case 'f': // Floating-point register
@@ -93,7 +104,7 @@ static constexpr ISANameRevision ISARevisions[] = {
{{"arch11"}, 11}, {{"z13"}, 11},
{{"arch12"}, 12}, {{"z14"}, 12},
{{"arch13"}, 13}, {{"z15"}, 13},
- {{"arch14"}, 14}
+ {{"arch14"}, 14}, {{"z16"}, 14},
};
int SystemZTargetInfo::getISARevision(StringRef Name) const {
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.h b/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.h
index 92cefeea5d26..d12045c756c1 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/SystemZ.h
@@ -82,6 +82,30 @@ public:
bool validateAsmConstraint(const char *&Name,
TargetInfo::ConstraintInfo &info) const override;
+ std::string convertConstraint(const char *&Constraint) const override {
+ switch (Constraint[0]) {
+ case 'p': // Keep 'p' constraint.
+ return std::string("p");
+ case 'Z':
+ switch (Constraint[1]) {
+ case 'Q': // Address with base and unsigned 12-bit displacement
+ case 'R': // Likewise, plus an index
+ case 'S': // Address with base and signed 20-bit displacement
+ case 'T': // Likewise, plus an index
+ // "^" hints llvm that this is a 2 letter constraint.
+ // "Constraint++" is used to promote the string iterator
+ // to the next constraint.
+ return std::string("^") + std::string(Constraint++, 2);
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return TargetInfo::convertConstraint(Constraint);
+ }
+
const char *getClobbers() const override {
// FIXME: Is this really right?
return "";
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/VE.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/VE.cpp
index 22223654e8ad..4d66c98edc92 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/VE.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/VE.cpp
@@ -18,6 +18,12 @@
using namespace clang;
using namespace clang::targets;
+const Builtin::Info VETargetInfo::BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS) \
+ {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#include "clang/Basic/BuiltinsVE.def"
+};
+
void VETargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
Builder.defineMacro("_LP64", "1");
@@ -35,5 +41,6 @@ void VETargetInfo::getTargetDefines(const LangOptions &Opts,
}
ArrayRef<Builtin::Info> VETargetInfo::getTargetBuiltins() const {
- return ArrayRef<Builtin::Info>();
+ return llvm::makeArrayRef(BuiltinInfo,
+ clang::VE::LastTSBuiltin - Builtin::FirstTSBuiltin);
}
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp
index 2309997eb77b..b3b6c2be5c13 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -56,6 +56,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
.Case("multivalue", HasMultivalue)
.Case("tail-call", HasTailCall)
.Case("reference-types", HasReferenceTypes)
+ .Case("extended-const", HasExtendedConst)
.Default(false);
}
@@ -93,6 +94,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__wasm_tail_call__");
if (HasReferenceTypes)
Builder.defineMacro("__wasm_reference_types__");
+ if (HasExtendedConst)
+ Builder.defineMacro("__wasm_extended_const__");
}
void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features,
@@ -240,6 +243,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
HasReferenceTypes = false;
continue;
}
+ if (Feature == "+extended-const") {
+ HasExtendedConst = true;
+ continue;
+ }
+ if (Feature == "-extended-const") {
+ HasExtendedConst = false;
+ continue;
+ }
Diags.Report(diag::err_opt_not_valid_with_opt)
<< Feature << "-target-feature";
@@ -255,9 +266,11 @@ ArrayRef<Builtin::Info> WebAssemblyTargetInfo::getTargetBuiltins() const {
void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags,
LangOptions &Opts) {
- // If the Atomics feature isn't available, turn off POSIXThreads and
- // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__.
- if (!HasAtomics) {
+ TargetInfo::adjust(Diags, Opts);
+ // Turn off POSIXThreads and ThreadModel so that we don't predefine _REENTRANT
+ // or __STDCPP_THREADS__ if we will eventually end up stripping atomics
+ // because they are unsupported.
+ if (!HasAtomics || !HasBulkMemory) {
Opts.POSIXThreads = false;
Opts.setThreadModel(LangOptions::ThreadModelKind::Single);
Opts.ThreadsafeStatics = false;
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.h b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.h
index 075486990558..63418869d10a 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.h
@@ -39,6 +39,7 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo {
bool HasMultivalue = false;
bool HasTailCall = false;
bool HasReferenceTypes = false;
+ bool HasExtendedConst = false;
std::string ABI;
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
index 5c4bd364b06a..06988830eaed 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
@@ -239,7 +239,6 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasAVX512ER = true;
} else if (Feature == "+avx512fp16") {
HasAVX512FP16 = true;
- HasFloat16 = true;
} else if (Feature == "+avx512pf") {
HasAVX512PF = true;
} else if (Feature == "+avx512dq") {
@@ -355,6 +354,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
.Default(NoSSE);
SSELevel = std::max(SSELevel, Level);
+ HasFloat16 = SSELevel >= SSE2;
+
MMX3DNowEnum ThreeDNowLevel = llvm::StringSwitch<MMX3DNowEnum>(Feature)
.Case("+3dnowa", AMD3DNowAthlon)
.Case("+3dnow", AMD3DNow)
@@ -1095,22 +1096,22 @@ unsigned X86TargetInfo::multiVersionSortPriority(StringRef Name) const {
bool X86TargetInfo::validateCPUSpecificCPUDispatch(StringRef Name) const {
return llvm::StringSwitch<bool>(Name)
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES) .Case(NAME, true)
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) .Case(NEW_NAME, true)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, true)
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, true)
#include "llvm/Support/X86TargetParser.def"
.Default(false);
}
static StringRef CPUSpecificCPUDispatchNameDealias(StringRef Name) {
return llvm::StringSwitch<StringRef>(Name)
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) .Case(NEW_NAME, NAME)
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, NAME)
#include "llvm/Support/X86TargetParser.def"
.Default(Name);
}
char X86TargetInfo::CPUSpecificManglingCharacter(StringRef Name) const {
return llvm::StringSwitch<char>(CPUSpecificCPUDispatchNameDealias(Name))
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES) .Case(NAME, MANGLING)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, MANGLING)
#include "llvm/Support/X86TargetParser.def"
.Default(0);
}
@@ -1119,12 +1120,20 @@ void X86TargetInfo::getCPUSpecificCPUDispatchFeatures(
StringRef Name, llvm::SmallVectorImpl<StringRef> &Features) const {
StringRef WholeList =
llvm::StringSwitch<StringRef>(CPUSpecificCPUDispatchNameDealias(Name))
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES) .Case(NAME, FEATURES)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, FEATURES)
#include "llvm/Support/X86TargetParser.def"
.Default("");
WholeList.split(Features, ',', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
}
+StringRef X86TargetInfo::getCPUSpecificTuneName(StringRef Name) const {
+ return llvm::StringSwitch<StringRef>(Name)
+#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, TUNE_NAME)
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, TUNE_NAME)
+#include "llvm/Support/X86TargetParser.def"
+ .Default("");
+}
+
// We can't use a generic validation scheme for the cpus accepted here
// versus subtarget cpus accepted in the target attribute because the
// variables intitialized by the runtime only support the below currently
@@ -1482,8 +1491,8 @@ std::string X86TargetInfo::convertConstraint(const char *&Constraint) const {
return std::string("{si}");
case 'D':
return std::string("{di}");
- case 'p': // address
- return std::string("im");
+ case 'p': // Keep 'p' constraint (address).
+ return std::string("p");
case 't': // top of floating point stack.
return std::string("{st}");
case 'u': // second from top of floating point stack.
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
index b34a16bb5f5b..e582a2932b4f 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
@@ -14,6 +14,7 @@
#define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
#include "OSTargets.h"
+#include "clang/Basic/BitmaskEnum.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "llvm/ADT/Triple.h"
@@ -168,11 +169,15 @@ public:
return LongDoubleFormat == &llvm::APFloat::IEEEquad() ? "g" : "e";
}
- unsigned getFloatEvalMethod() const override {
+ LangOptions::FPEvalMethodKind getFPEvalMethod() const override {
// X87 evaluates with 80 bits "long double" precision.
- return SSELevel == NoSSE ? 2 : 0;
+ return SSELevel == NoSSE ? LangOptions::FPEvalMethodKind::FEM_Extended
+ : LangOptions::FPEvalMethodKind::FEM_Source;
}
+ // EvalMethod `source` is not supported for targets with `NoSSE` feature.
+ bool supportSourceEvalMethod() const override { return SSELevel > NoSSE; }
+
ArrayRef<const char *> getGCCRegNames() const override;
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
@@ -197,6 +202,8 @@ public:
StringRef Name,
llvm::SmallVectorImpl<StringRef> &Features) const override;
+ StringRef getCPUSpecificTuneName(StringRef Name) const override;
+
Optional<unsigned> getCPUCacheLineSize() const override;
bool validateAsmConstraint(const char *&Name,
@@ -416,9 +423,9 @@ public:
RegParmMax = 3;
// Use fpret for all types.
- RealTypeUsesObjCFPRet =
- ((1 << (int)FloatModeKind::Float) | (1 << (int)FloatModeKind::Double) |
- (1 << (int)FloatModeKind::LongDouble));
+ RealTypeUsesObjCFPRetMask =
+ (int)(FloatModeKind::Float | FloatModeKind::Double |
+ FloatModeKind::LongDouble);
// x86-32 has atomics up to 8 bytes
MaxAtomicPromoteWidth = 64;
@@ -475,13 +482,13 @@ public:
NetBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
- unsigned getFloatEvalMethod() const override {
+ LangOptions::FPEvalMethodKind getFPEvalMethod() const override {
VersionTuple OsVersion = getTriple().getOSVersion();
// New NetBSD uses the default rounding mode.
if (OsVersion >= VersionTuple(6, 99, 26) || OsVersion.getMajor() == 0)
- return X86_32TargetInfo::getFloatEvalMethod();
+ return X86_32TargetInfo::getFPEvalMethod();
// NetBSD before 6.99.26 defaults to "double" rounding.
- return 1;
+ return LangOptions::FPEvalMethodKind::FEM_Double;
}
};
@@ -697,7 +704,7 @@ public:
"64-i64:64-f80:128-n8:16:32:64-S128");
// Use fpret only for long double.
- RealTypeUsesObjCFPRet = (1 << (int)FloatModeKind::LongDouble);
+ RealTypeUsesObjCFPRetMask = (int)FloatModeKind::LongDouble;
// Use fp2ret for _Complex long double.
ComplexLongDoubleUsesFP2Ret = true;
diff --git a/contrib/llvm-project/clang/lib/Basic/TokenKinds.cpp b/contrib/llvm-project/clang/lib/Basic/TokenKinds.cpp
index d55e176c72c4..c300175ce90b 100644
--- a/contrib/llvm-project/clang/lib/Basic/TokenKinds.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/TokenKinds.cpp
@@ -46,6 +46,15 @@ const char *tok::getKeywordSpelling(TokenKind Kind) {
return nullptr;
}
+const char *tok::getPPKeywordSpelling(tok::PPKeywordKind Kind) {
+ switch (Kind) {
+#define PPKEYWORD(x) case tok::pp_##x: return #x;
+#include "clang/Basic/TokenKinds.def"
+ default: break;
+ }
+ return nullptr;
+}
+
bool tok::isAnnotation(TokenKind Kind) {
switch (Kind) {
#define ANNOTATION(X) case annot_ ## X: return true;