Skip to content

Commit 1dde435

Browse files
committed
rebase
Created using spr 1.3.4
2 parents 75aa55a + 70965ef commit 1dde435

File tree

126 files changed

+1814
-657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1814
-657
lines changed

clang-tools-extra/clang-tidy/tool/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
33
AllTargetsDescs
44
AllTargetsInfos
55
FrontendOpenMP
6+
TargetParser
67
support
78
)
89

clang/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ Bug Fixes to C++ Support
885885
- Fixed recognition of ``std::initializer_list`` when it's surrounded with ``extern "C++"`` and exported
886886
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
887887
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
888+
- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081)
888889

889890
Bug Fixes to AST Handling
890891
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -1005,6 +1006,12 @@ Arm and AArch64 Support
10051006
in leaf functions after enabling ``-fno-omit-frame-pointer``, you can do so by adding
10061007
the ``-momit-leaf-frame-pointer`` option.
10071008

1009+
- Support has been added for the following processors (-mcpu identifiers in parenthesis):
1010+
1011+
For AArch64:
1012+
1013+
* FUJITSU-MONAKA (fujitsu-monaka)
1014+
10081015
Android Support
10091016
^^^^^^^^^^^^^^^
10101017

@@ -1250,6 +1257,9 @@ OpenMP Support
12501257
- Added support for 'omp assume' directive.
12511258
- Added support for 'omp scope' directive.
12521259
- Added support for allocator-modifier in 'allocate' clause.
1260+
- Changed the OpenMP DeviceRTL to use 'generic' IR. The
1261+
``LIBOMPTARGET_DEVICE_ARCHITECTURES`` CMake argument is now unused and will
1262+
always build support for AMDGPU and NVPTX targets.
12531263

12541264
Improvements
12551265
^^^^^^^^^^^^

clang/include/clang/Basic/TargetInfo.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,14 @@ class TargetInfo : public TransferrableTargetInfo,
358358
// void *__saved_reg_area_end_pointer;
359359
// void *__overflow_area_pointer;
360360
//} va_list;
361-
HexagonBuiltinVaList
361+
HexagonBuiltinVaList,
362+
363+
// typedef struct __va_list_tag {
364+
// int* __va_stk;
365+
// int* __va_reg;
366+
// int __va_ndx;
367+
//} va_list;
368+
XtensaABIBuiltinVaList
362369
};
363370

364371
protected:

clang/lib/AST/ASTContext.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9751,6 +9751,43 @@ static TypedefDecl *CreateHexagonBuiltinVaListDecl(const ASTContext *Context) {
97519751
return Context->buildImplicitTypedef(VaListTagArrayType, "__builtin_va_list");
97529752
}
97539753

9754+
static TypedefDecl *
9755+
CreateXtensaABIBuiltinVaListDecl(const ASTContext *Context) {
9756+
// typedef struct __va_list_tag {
9757+
RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list_tag");
9758+
9759+
VaListTagDecl->startDefinition();
9760+
9761+
// int* __va_stk;
9762+
// int* __va_reg;
9763+
// int __va_ndx;
9764+
constexpr size_t NumFields = 3;
9765+
QualType FieldTypes[NumFields] = {Context->getPointerType(Context->IntTy),
9766+
Context->getPointerType(Context->IntTy),
9767+
Context->IntTy};
9768+
const char *FieldNames[NumFields] = {"__va_stk", "__va_reg", "__va_ndx"};
9769+
9770+
// Create fields
9771+
for (unsigned i = 0; i < NumFields; ++i) {
9772+
FieldDecl *Field = FieldDecl::Create(
9773+
*Context, VaListTagDecl, SourceLocation(), SourceLocation(),
9774+
&Context->Idents.get(FieldNames[i]), FieldTypes[i], /*TInfo=*/nullptr,
9775+
/*BitWidth=*/nullptr,
9776+
/*Mutable=*/false, ICIS_NoInit);
9777+
Field->setAccess(AS_public);
9778+
VaListTagDecl->addDecl(Field);
9779+
}
9780+
VaListTagDecl->completeDefinition();
9781+
Context->VaListTagDecl = VaListTagDecl;
9782+
QualType VaListTagType = Context->getRecordType(VaListTagDecl);
9783+
9784+
// } __va_list_tag;
9785+
TypedefDecl *VaListTagTypedefDecl =
9786+
Context->buildImplicitTypedef(VaListTagType, "__builtin_va_list");
9787+
9788+
return VaListTagTypedefDecl;
9789+
}
9790+
97549791
static TypedefDecl *CreateVaListDecl(const ASTContext *Context,
97559792
TargetInfo::BuiltinVaListKind Kind) {
97569793
switch (Kind) {
@@ -9772,6 +9809,8 @@ static TypedefDecl *CreateVaListDecl(const ASTContext *Context,
97729809
return CreateSystemZBuiltinVaListDecl(Context);
97739810
case TargetInfo::HexagonBuiltinVaList:
97749811
return CreateHexagonBuiltinVaListDecl(Context);
9812+
case TargetInfo::XtensaABIBuiltinVaList:
9813+
return CreateXtensaABIBuiltinVaListDecl(Context);
97759814
}
97769815

97779816
llvm_unreachable("Unhandled __builtin_va_list type kind");

clang/lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ add_clang_library(clangBasic
120120
Targets/WebAssembly.cpp
121121
Targets/X86.cpp
122122
Targets/XCore.cpp
123+
Targets/Xtensa.cpp
123124
TokenKinds.cpp
124125
TypeTraits.cpp
125126
Version.cpp

clang/lib/Basic/Targets.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "Targets/WebAssembly.h"
4141
#include "Targets/X86.h"
4242
#include "Targets/XCore.h"
43+
#include "Targets/Xtensa.h"
4344
#include "clang/Basic/Diagnostic.h"
4445
#include "clang/Basic/DiagnosticFrontend.h"
4546
#include "llvm/ADT/StringExtras.h"
@@ -297,6 +298,14 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
297298
case llvm::Triple::NaCl:
298299
return std::make_unique<NaClTargetInfo<NaClMips32TargetInfo>>(Triple,
299300
Opts);
301+
case llvm::Triple::Win32:
302+
switch (Triple.getEnvironment()) {
303+
case llvm::Triple::GNU:
304+
return std::make_unique<MinGWMipsTargetInfo>(Triple, Opts);
305+
case llvm::Triple::MSVC:
306+
default: // Assume MSVC for unknown environments
307+
return std::make_unique<MicrosoftMipsTargetInfo>(Triple, Opts);
308+
}
300309
default:
301310
return std::make_unique<MipsTargetInfo>(Triple, Opts);
302311
}
@@ -743,6 +752,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
743752
default:
744753
return std::make_unique<LoongArch64TargetInfo>(Triple, Opts);
745754
}
755+
756+
case llvm::Triple::xtensa:
757+
return std::make_unique<XtensaTargetInfo>(Triple, Opts);
746758
}
747759
}
748760
} // namespace targets

clang/lib/Basic/Targets/Mips.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,62 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
304304

305305
return true;
306306
}
307+
308+
WindowsMipsTargetInfo::WindowsMipsTargetInfo(const llvm::Triple &Triple,
309+
const TargetOptions &Opts)
310+
: WindowsTargetInfo<MipsTargetInfo>(Triple, Opts), Triple(Triple) {}
311+
312+
void WindowsMipsTargetInfo::getVisualStudioDefines(
313+
const LangOptions &Opts, MacroBuilder &Builder) const {
314+
Builder.defineMacro("_M_MRX000", "4000");
315+
}
316+
317+
TargetInfo::BuiltinVaListKind
318+
WindowsMipsTargetInfo::getBuiltinVaListKind() const {
319+
return TargetInfo::CharPtrBuiltinVaList;
320+
}
321+
322+
TargetInfo::CallingConvCheckResult
323+
WindowsMipsTargetInfo::checkCallingConvention(CallingConv CC) const {
324+
switch (CC) {
325+
case CC_X86StdCall:
326+
case CC_X86ThisCall:
327+
case CC_X86FastCall:
328+
case CC_X86VectorCall:
329+
return CCCR_Ignore;
330+
case CC_C:
331+
case CC_OpenCLKernel:
332+
case CC_PreserveMost:
333+
case CC_PreserveAll:
334+
case CC_Swift:
335+
case CC_SwiftAsync:
336+
return CCCR_OK;
337+
default:
338+
return CCCR_Warning;
339+
}
340+
}
341+
342+
// Windows MIPS, MS (C++) ABI
343+
MicrosoftMipsTargetInfo::MicrosoftMipsTargetInfo(const llvm::Triple &Triple,
344+
const TargetOptions &Opts)
345+
: WindowsMipsTargetInfo(Triple, Opts) {
346+
TheCXXABI.set(TargetCXXABI::Microsoft);
347+
}
348+
349+
void MicrosoftMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
350+
MacroBuilder &Builder) const {
351+
WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
352+
WindowsMipsTargetInfo::getVisualStudioDefines(Opts, Builder);
353+
}
354+
355+
MinGWMipsTargetInfo::MinGWMipsTargetInfo(const llvm::Triple &Triple,
356+
const TargetOptions &Opts)
357+
: WindowsMipsTargetInfo(Triple, Opts) {
358+
TheCXXABI.set(TargetCXXABI::GenericMIPS);
359+
}
360+
361+
void MinGWMipsTargetInfo::getTargetDefines(const LangOptions &Opts,
362+
MacroBuilder &Builder) const {
363+
WindowsMipsTargetInfo::getTargetDefines(Opts, Builder);
364+
Builder.defineMacro("_MIPS_");
365+
}

clang/lib/Basic/Targets/Mips.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
1414
#define LLVM_CLANG_LIB_BASIC_TARGETS_MIPS_H
1515

16+
#include "OSTargets.h"
1617
#include "clang/Basic/TargetInfo.h"
1718
#include "clang/Basic/TargetOptions.h"
1819
#include "llvm/Support/Compiler.h"
@@ -450,6 +451,42 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
450451
return std::make_pair(32, 32);
451452
}
452453
};
454+
455+
class LLVM_LIBRARY_VISIBILITY WindowsMipsTargetInfo
456+
: public WindowsTargetInfo<MipsTargetInfo> {
457+
const llvm::Triple Triple;
458+
459+
public:
460+
WindowsMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
461+
462+
void getVisualStudioDefines(const LangOptions &Opts,
463+
MacroBuilder &Builder) const;
464+
465+
BuiltinVaListKind getBuiltinVaListKind() const override;
466+
467+
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
468+
};
469+
470+
// Windows MIPS, MS (C++) ABI
471+
class LLVM_LIBRARY_VISIBILITY MicrosoftMipsTargetInfo
472+
: public WindowsMipsTargetInfo {
473+
public:
474+
MicrosoftMipsTargetInfo(const llvm::Triple &Triple,
475+
const TargetOptions &Opts);
476+
477+
void getTargetDefines(const LangOptions &Opts,
478+
MacroBuilder &Builder) const override;
479+
};
480+
481+
// MIPS MinGW target
482+
class LLVM_LIBRARY_VISIBILITY MinGWMipsTargetInfo
483+
: public WindowsMipsTargetInfo {
484+
public:
485+
MinGWMipsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
486+
487+
void getTargetDefines(const LangOptions &Opts,
488+
MacroBuilder &Builder) const override;
489+
};
453490
} // namespace targets
454491
} // namespace clang
455492

clang/lib/Basic/Targets/Xtensa.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//===--- Xtensa.cpp - Implement Xtensa target feature support -------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6+
// See https://llvm.org/LICENSE.txt for license information.
7+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8+
//
9+
//===----------------------------------------------------------------------===//
10+
//
11+
// This file implements Xtensa TargetInfo objects.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#include "Xtensa.h"
16+
#include "clang/Basic/Builtins.h"
17+
#include "clang/Basic/MacroBuilder.h"
18+
#include "clang/Basic/TargetBuiltins.h"
19+
20+
using namespace clang;
21+
using namespace clang::targets;
22+
23+
void XtensaTargetInfo::getTargetDefines(const LangOptions &Opts,
24+
MacroBuilder &Builder) const {
25+
Builder.defineMacro("__xtensa__");
26+
Builder.defineMacro("__XTENSA__");
27+
if (BigEndian)
28+
Builder.defineMacro("__XTENSA_EB__");
29+
else
30+
Builder.defineMacro("__XTENSA_EL__");
31+
Builder.defineMacro("__XCHAL_HAVE_BE", BigEndian ? "1" : "0");
32+
Builder.defineMacro("__XCHAL_HAVE_ABS"); // core arch
33+
Builder.defineMacro("__XCHAL_HAVE_ADDX"); // core arch
34+
Builder.defineMacro("__XCHAL_HAVE_L32R"); // core arch
35+
}

0 commit comments

Comments
 (0)