Skip to content

Commit d56ed32

Browse files
committed
merge main into amd-staging
Change-Id: Ibde2bad660962000de8568b09959ab4c5d20d169
2 parents 4c9a163 + 8ab76a4 commit d56ed32

File tree

285 files changed

+7797
-4020
lines changed

Some content is hidden

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

285 files changed

+7797
-4020
lines changed

clang/include/clang/AST/DeclTemplate.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ class RedeclarableTemplateDecl : public TemplateDecl,
735735
}
736736

737737
void anchor() override;
738-
739738
protected:
740739
template <typename EntryType> struct SpecEntryTraits {
741740
using DeclType = EntryType;
@@ -776,22 +775,13 @@ class RedeclarableTemplateDecl : public TemplateDecl,
776775
return SpecIterator<EntryType>(isEnd ? Specs.end() : Specs.begin());
777776
}
778777

779-
void loadLazySpecializationsImpl(bool OnlyPartial = false) const;
780-
781-
bool loadLazySpecializationsImpl(llvm::ArrayRef<TemplateArgument> Args,
782-
TemplateParameterList *TPL = nullptr) const;
778+
void loadLazySpecializationsImpl() const;
783779

784780
template <class EntryType, typename ...ProfileArguments>
785781
typename SpecEntryTraits<EntryType>::DeclType*
786782
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
787783
void *&InsertPos, ProfileArguments &&...ProfileArgs);
788784

789-
template <class EntryType, typename... ProfileArguments>
790-
typename SpecEntryTraits<EntryType>::DeclType *
791-
findSpecializationLocally(llvm::FoldingSetVector<EntryType> &Specs,
792-
void *&InsertPos,
793-
ProfileArguments &&...ProfileArgs);
794-
795785
template <class Derived, class EntryType>
796786
void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
797787
EntryType *Entry, void *InsertPos);
@@ -806,6 +796,13 @@ class RedeclarableTemplateDecl : public TemplateDecl,
806796
/// was explicitly specialized.
807797
llvm::PointerIntPair<RedeclarableTemplateDecl *, 1, bool>
808798
InstantiatedFromMember;
799+
800+
/// If non-null, points to an array of specializations (including
801+
/// partial specializations) known only by their external declaration IDs.
802+
///
803+
/// The first value in the array is the number of specializations/partial
804+
/// specializations that follow.
805+
GlobalDeclID *LazySpecializations = nullptr;
809806
};
810807

811808
/// Pointer to the common data shared by all declarations of this
@@ -2286,7 +2283,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22862283
friend class TemplateDeclInstantiator;
22872284

22882285
/// Load any lazily-loaded specializations from the external source.
2289-
void LoadLazySpecializations(bool OnlyPartial = false) const;
2286+
void LoadLazySpecializations() const;
22902287

22912288
/// Get the underlying class declarations of the template.
22922289
CXXRecordDecl *getTemplatedDecl() const {
@@ -3036,7 +3033,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
30363033
friend class ASTDeclWriter;
30373034

30383035
/// Load any lazily-loaded specializations from the external source.
3039-
void LoadLazySpecializations(bool OnlyPartial = false) const;
3036+
void LoadLazySpecializations() const;
30403037

30413038
/// Get the underlying variable declarations of the template.
30423039
VarDecl *getTemplatedDecl() const {

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,6 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
152152
virtual bool
153153
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
154154

155-
/// Load all the external specializations for the Decl \param D if \param
156-
/// OnlyPartial is false. Otherwise, load all the external **partial**
157-
/// specializations for the \param D.
158-
///
159-
/// Return true if any new specializations get loaded. Return false otherwise.
160-
virtual bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial);
161-
162-
/// Load all the specializations for the Decl \param D with the same template
163-
/// args specified by \param TemplateArgs.
164-
///
165-
/// Return true if any new specializations get loaded. Return false otherwise.
166-
virtual bool
167-
LoadExternalSpecializations(const Decl *D,
168-
ArrayRef<TemplateArgument> TemplateArgs);
169-
170155
/// Ensures that the table of all visible declarations inside this
171156
/// context is up to date.
172157
///

clang/include/clang/Basic/Diagnostic.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
560560
ArgToStringFnTy ArgToStringFn;
561561

562562
/// Whether the diagnostic should be suppressed in FilePath.
563-
llvm::unique_function<bool(diag::kind, StringRef /*FilePath*/) const>
563+
llvm::unique_function<bool(diag::kind, SourceLocation /*DiagLoc*/,
564+
const SourceManager &) const>
564565
DiagSuppressionMapping;
565566

566567
public:
@@ -972,7 +973,7 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
972973
/// These take presumed locations into account, and can still be overriden by
973974
/// clang-diagnostics pragmas.
974975
void setDiagSuppressionMapping(llvm::MemoryBuffer &Input);
975-
bool isSuppressedViaMapping(diag::kind DiagId, StringRef FilePath) const;
976+
bool isSuppressedViaMapping(diag::kind DiagId, SourceLocation DiagLoc) const;
976977

977978
/// Issue the message to the client.
978979
///

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12765,9 +12765,9 @@ def err_acc_gang_dim_value
1276512765
: Error<"argument to 'gang' clause dimension must be %select{a constant "
1276612766
"expression|1, 2, or 3: evaluated to %1}0">;
1276712767
def err_acc_num_arg_conflict
12768-
: Error<"'num' argument to '%0' clause not allowed on a '%1' "
12769-
"construct%select{| associated with a '%3' construct}2 that has a "
12770-
"'%4' clause">;
12768+
: Error<"'%0' argument to '%1' clause not allowed on a '%2' "
12769+
"construct%select{| associated with a '%4' construct}3 that has a "
12770+
"'%5' clause">;
1277112771
def err_acc_num_arg_conflict_reverse
1277212772
: Error<"'%0' clause not allowed on a 'kernels loop' construct that "
1277312773
"has a '%1' clause with a%select{n| 'num'}2 argument">;

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define LLVM_CLANG_CIR_DIALECT_IR_CIROPS
1616

1717
include "clang/CIR/Dialect/IR/CIRDialect.td"
18+
include "clang/CIR/Dialect/IR/CIRTypes.td"
1819

1920
include "mlir/IR/BuiltinAttributeInterfaces.td"
2021
include "mlir/IR/EnumAttr.td"
@@ -74,6 +75,35 @@ class LLVMLoweringInfo {
7475
class CIR_Op<string mnemonic, list<Trait> traits = []> :
7576
Op<CIR_Dialect, mnemonic, traits>, LLVMLoweringInfo;
7677

78+
//===----------------------------------------------------------------------===//
79+
// GlobalOp
80+
//===----------------------------------------------------------------------===//
81+
82+
// TODO(CIR): For starters, cir.global has only name and type. The other
83+
// properties of a global variable will be added over time as more of ClangIR
84+
// is upstreamed.
85+
86+
def GlobalOp : CIR_Op<"global"> {
87+
let summary = "Declare or define a global variable";
88+
let description = [{
89+
The `cir.global` operation declares or defines a named global variable.
90+
91+
The backing memory for the variable is allocated statically and is
92+
described by the type of the variable.
93+
}];
94+
95+
let arguments = (ins SymbolNameAttr:$sym_name, TypeAttr:$sym_type);
96+
97+
let assemblyFormat = [{ $sym_name `:` $sym_type attr-dict }];
98+
99+
let skipDefaultBuilders = 1;
100+
101+
let builders = [OpBuilder<(ins "llvm::StringRef":$sym_name,
102+
"mlir::Type":$sym_type)>];
103+
104+
let hasVerifier = 1;
105+
}
106+
77107
//===----------------------------------------------------------------------===//
78108
// FuncOp
79109
//===----------------------------------------------------------------------===//
@@ -85,14 +115,15 @@ class CIR_Op<string mnemonic, list<Trait> traits = []> :
85115
def FuncOp : CIR_Op<"func"> {
86116
let summary = "Declare or define a function";
87117
let description = [{
88-
... lots of text to be added later ...
118+
The `cir.func` operation defines a function, similar to the `mlir::FuncOp`
119+
built-in.
89120
}];
90121

91122
let arguments = (ins SymbolNameAttr:$sym_name);
92123

93124
let skipDefaultBuilders = 1;
94125

95-
let builders = [OpBuilder<(ins "llvm::StringRef":$name)>];
126+
let builders = [OpBuilder<(ins "llvm::StringRef":$sym_name)>];
96127

97128
let hasCustomAssemblyFormat = 1;
98129
let hasVerifier = 1;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares the types in the CIR dialect.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_DIALECT_CIR_IR_CIRTYPES_H_
14+
#define MLIR_DIALECT_CIR_IR_CIRTYPES_H_
15+
16+
#include "mlir/IR/BuiltinAttributes.h"
17+
#include "mlir/IR/Types.h"
18+
#include "mlir/Interfaces/DataLayoutInterfaces.h"
19+
20+
//===----------------------------------------------------------------------===//
21+
// CIR Dialect Tablegen'd Types
22+
//===----------------------------------------------------------------------===//
23+
24+
#define GET_TYPEDEF_CLASSES
25+
#include "clang/CIR/Dialect/IR/CIROpsTypes.h.inc"
26+
27+
#endif // MLIR_DIALECT_CIR_IR_CIRTYPES_H_
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//===- CIRTypes.td - CIR dialect types ---------------------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares the CIR dialect types.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_CIR_DIALECT_CIR_TYPES
14+
#define MLIR_CIR_DIALECT_CIR_TYPES
15+
16+
include "clang/CIR/Dialect/IR/CIRDialect.td"
17+
include "mlir/Interfaces/DataLayoutInterfaces.td"
18+
include "mlir/IR/AttrTypeBase.td"
19+
20+
//===----------------------------------------------------------------------===//
21+
// CIR Types
22+
//===----------------------------------------------------------------------===//
23+
24+
class CIR_Type<string name, string typeMnemonic, list<Trait> traits = [],
25+
string baseCppClass = "::mlir::Type">
26+
: TypeDef<CIR_Dialect, name, traits, baseCppClass> {
27+
let mnemonic = typeMnemonic;
28+
}
29+
30+
//===----------------------------------------------------------------------===//
31+
// IntType
32+
//===----------------------------------------------------------------------===//
33+
34+
def CIR_IntType : CIR_Type<"Int", "int",
35+
[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]> {
36+
let summary = "Integer type with arbitrary precision up to a fixed limit";
37+
let description = [{
38+
CIR type that represents integer types with arbitrary precision, including
39+
standard integral types such as `int` and `long`, extended integral types
40+
such as `__int128`, and arbitrary width types such as `_BitInt(n)`.
41+
42+
Those integer types that are directly available in C/C++ standard are called
43+
primitive integer types. Said types are: `signed char`, `short`, `int`,
44+
`long`, `long long`, and their unsigned variations.
45+
}];
46+
let parameters = (ins "unsigned":$width, "bool":$isSigned);
47+
let hasCustomAssemblyFormat = 1;
48+
let extraClassDeclaration = [{
49+
/// Return true if this is a signed integer type.
50+
bool isSigned() const { return getIsSigned(); }
51+
/// Return true if this is an unsigned integer type.
52+
bool isUnsigned() const { return !getIsSigned(); }
53+
/// Return type alias.
54+
std::string getAlias() const {
55+
return (isSigned() ? 's' : 'u') + std::to_string(getWidth()) + 'i';
56+
}
57+
/// Return true if this is a primitive integer type (i.e. signed or unsigned
58+
/// integer types whose bit width is 8, 16, 32, or 64).
59+
bool isPrimitive() const {
60+
return isValidPrimitiveIntBitwidth(getWidth());
61+
}
62+
bool isSignedPrimitive() const {
63+
return isPrimitive() && isSigned();
64+
}
65+
66+
/// Returns a minimum bitwidth of cir::IntType
67+
static unsigned minBitwidth() { return 1; }
68+
/// Returns a maximum bitwidth of cir::IntType
69+
static unsigned maxBitwidth() { return 128; }
70+
71+
/// Returns true if cir::IntType that represents a primitive integer type
72+
/// can be constructed from the provided bitwidth.
73+
static bool isValidPrimitiveIntBitwidth(unsigned width) {
74+
return width == 8 || width == 16 || width == 32 || width == 64;
75+
}
76+
}];
77+
let genVerifyDecl = 1;
78+
}
79+
80+
// Constraints
81+
82+
// Unsigned integer type of a specific width.
83+
class UInt<int width>
84+
: Type<And<[
85+
CPred<"::mlir::isa<::cir::IntType>($_self)">,
86+
CPred<"::mlir::cast<::cir::IntType>($_self).isUnsigned()">,
87+
CPred<"::mlir::cast<::cir::IntType>($_self).getWidth() == " # width>
88+
]>, width # "-bit unsigned integer", "::cir::IntType">,
89+
BuildableType<
90+
"cir::IntType::get($_builder.getContext(), "
91+
# width # ", /*isSigned=*/false)"> {
92+
int bitwidth = width;
93+
}
94+
95+
def UInt1 : UInt<1>;
96+
def UInt8 : UInt<8>;
97+
def UInt16 : UInt<16>;
98+
def UInt32 : UInt<32>;
99+
def UInt64 : UInt<64>;
100+
101+
// Signed integer type of a specific width.
102+
class SInt<int width>
103+
: Type<And<[
104+
CPred<"::mlir::isa<::cir::IntType>($_self)">,
105+
CPred<"::mlir::cast<::cir::IntType>($_self).isSigned()">,
106+
CPred<"::mlir::cast<::cir::IntType>($_self).getWidth() == " # width>
107+
]>, width # "-bit signed integer", "::cir::IntType">,
108+
BuildableType<
109+
"cir::IntType::get($_builder.getContext(), "
110+
# width # ", /*isSigned=*/true)"> {
111+
int bitwidth = width;
112+
}
113+
114+
def SInt1 : SInt<1>;
115+
def SInt8 : SInt<8>;
116+
def SInt16 : SInt<16>;
117+
def SInt32 : SInt<32>;
118+
def SInt64 : SInt<64>;
119+
120+
def PrimitiveUInt
121+
: AnyTypeOf<[UInt8, UInt16, UInt32, UInt64], "primitive unsigned int",
122+
"::cir::IntType">;
123+
124+
def PrimitiveSInt
125+
: AnyTypeOf<[SInt8, SInt16, SInt32, SInt64], "primitive signed int",
126+
"::cir::IntType">;
127+
128+
def PrimitiveInt
129+
: AnyTypeOf<[UInt8, UInt16, UInt32, UInt64, SInt8, SInt16, SInt32, SInt64],
130+
"primitive int", "::cir::IntType">;
131+
132+
#endif // MLIR_CIR_DIALECT_CIR_TYPES

clang/include/clang/Sema/MultiplexExternalSemaSource.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
9797
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
9898
DeclarationName Name) override;
9999

100-
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
101-
102-
bool
103-
LoadExternalSpecializations(const Decl *D,
104-
ArrayRef<TemplateArgument> TemplateArgs) override;
105-
106100
/// Ensures that the table of all visible declarations inside this
107101
/// context is up to date.
108102
void completeVisibleDeclsMap(const DeclContext *DC) override;

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,6 @@ enum ASTRecordTypes {
733733
/// Record code for Sema's vector of functions/blocks with effects to
734734
/// be verified.
735735
DECLS_WITH_EFFECTS_TO_VERIFY = 72,
736-
737-
/// Record code for updated specialization
738-
UPDATE_SPECIALIZATION = 73,
739-
740-
CXX_ADDED_TEMPLATE_SPECIALIZATION = 74,
741-
742-
CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION = 75,
743736
};
744737

745738
/// Record types used within a source manager block.
@@ -1509,12 +1502,6 @@ enum DeclCode {
15091502
/// An ImplicitConceptSpecializationDecl record.
15101503
DECL_IMPLICIT_CONCEPT_SPECIALIZATION,
15111504

1512-
// A decls specilization record.
1513-
DECL_SPECIALIZATIONS,
1514-
1515-
// A decls specilization record.
1516-
DECL_PARTIAL_SPECIALIZATIONS,
1517-
15181505
DECL_LAST = DECL_IMPLICIT_CONCEPT_SPECIALIZATION
15191506
};
15201507

0 commit comments

Comments
 (0)