Skip to content

Commit edf06d7

Browse files
authored
merge main into amd-staging (#582)
2 parents da9a9ea + d793a77 commit edf06d7

File tree

135 files changed

+11233
-7598
lines changed

Some content is hidden

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

135 files changed

+11233
-7598
lines changed

clang/include/clang/AST/Attr.h

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -233,44 +233,19 @@ class HLSLAnnotationAttr : public InheritableAttr {
233233
}
234234
};
235235

236-
class HLSLSemanticAttr : public HLSLAnnotationAttr {
237-
unsigned SemanticIndex = 0;
238-
LLVM_PREFERRED_TYPE(bool)
239-
unsigned SemanticIndexable : 1;
240-
LLVM_PREFERRED_TYPE(bool)
241-
unsigned SemanticExplicitIndex : 1;
242-
243-
Decl *TargetDecl = nullptr;
244-
236+
class HLSLSemanticBaseAttr : public HLSLAnnotationAttr {
245237
protected:
246-
HLSLSemanticAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
247-
attr::Kind AK, bool IsLateParsed,
248-
bool InheritEvenIfAlreadyPresent, bool SemanticIndexable)
238+
HLSLSemanticBaseAttr(ASTContext &Context,
239+
const AttributeCommonInfo &CommonInfo, attr::Kind AK,
240+
bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
249241
: HLSLAnnotationAttr(Context, CommonInfo, AK, IsLateParsed,
250-
InheritEvenIfAlreadyPresent) {
251-
this->SemanticIndexable = SemanticIndexable;
252-
this->SemanticExplicitIndex = false;
253-
}
242+
InheritEvenIfAlreadyPresent) {}
254243

255244
public:
256-
bool isSemanticIndexable() const { return SemanticIndexable; }
257-
258-
void setSemanticIndex(unsigned SemanticIndex) {
259-
this->SemanticIndex = SemanticIndex;
260-
this->SemanticExplicitIndex = true;
261-
}
262-
263-
unsigned getSemanticIndex() const { return SemanticIndex; }
264-
265-
bool isSemanticIndexExplicit() const { return SemanticExplicitIndex; }
266-
267-
void setTargetDecl(Decl *D) { TargetDecl = D; }
268-
Decl *getTargetDecl() const { return TargetDecl; }
269-
270245
// Implement isa/cast/dyncast/etc.
271246
static bool classof(const Attr *A) {
272-
return A->getKind() >= attr::FirstHLSLSemanticAttr &&
273-
A->getKind() <= attr::LastHLSLSemanticAttr;
247+
return A->getKind() >= attr::FirstHLSLSemanticBaseAttr &&
248+
A->getKind() <= attr::LastHLSLSemanticBaseAttr;
274249
}
275250
};
276251

clang/include/clang/Analysis/FlowSensitive/StorageLocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class RecordStorageLocation final : public StorageLocation {
131131
<< " on StorageLocation " << this << " of type "
132132
<< getType() << "\n";
133133
llvm::dbgs() << "Existing children:\n";
134-
for ([[maybe_unused]] auto [Field, Loc] : Children) {
134+
for (const auto &Field : Children.keys()) {
135135
llvm::dbgs() << Field->getNameAsString() << "\n";
136136
}
137137
}

clang/include/clang/Basic/Attr.td

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -783,18 +783,6 @@ class DeclOrStmtAttr : InheritableAttr;
783783
/// An attribute class for HLSL Annotations.
784784
class HLSLAnnotationAttr : InheritableAttr;
785785

786-
class HLSLSemanticAttr<bit Indexable> : HLSLAnnotationAttr {
787-
bit SemanticIndexable = Indexable;
788-
int SemanticIndex = 0;
789-
bit SemanticExplicitIndex = 0;
790-
791-
let Spellings = [];
792-
let Subjects = SubjectList<[ParmVar, Field, Function]>;
793-
let LangOpts = [HLSL];
794-
let Args = [DeclArgument<Named, "Target">, IntArgument<"SemanticIndex">,
795-
BoolArgument<"SemanticExplicitIndex">];
796-
}
797-
798786
/// A target-specific attribute. This class is meant to be used as a mixin
799787
/// with InheritableAttr or Attr depending on the attribute's needs.
800788
class TargetSpecificAttr<TargetSpec target> {
@@ -5021,28 +5009,28 @@ def HLSLUnparsedSemantic : HLSLAnnotationAttr {
50215009
let Documentation = [InternalOnly];
50225010
}
50235011

5024-
def HLSLUserSemantic : HLSLSemanticAttr</* Indexable= */ 1> {
5025-
let Documentation = [InternalOnly];
5026-
}
5027-
5028-
def HLSLSV_Position : HLSLSemanticAttr</* Indexable= */ 1> {
5029-
let Documentation = [HLSLSV_PositionDocs];
5030-
}
5012+
class HLSLSemanticBaseAttr : HLSLAnnotationAttr {
5013+
int SemanticIndex = 0;
50315014

5032-
def HLSLSV_GroupThreadID : HLSLSemanticAttr</* Indexable= */ 0> {
5033-
let Documentation = [HLSLSV_GroupThreadIDDocs];
5034-
}
5015+
let Spellings = [];
5016+
let Subjects = SubjectList<[ParmVar, Field, Function]>;
5017+
let LangOpts = [HLSL];
50355018

5036-
def HLSLSV_GroupID : HLSLSemanticAttr</* Indexable= */ 0> {
5037-
let Documentation = [HLSLSV_GroupIDDocs];
5019+
let Args = [StringArgument<"SemanticName">, IntArgument<"SemanticIndex">];
50385020
}
50395021

5040-
def HLSLSV_GroupIndex : HLSLSemanticAttr</* Indexable= */ 0> {
5041-
let Documentation = [HLSLSV_GroupIndexDocs];
5022+
def HLSLParsedSemantic : HLSLSemanticBaseAttr {
5023+
let Spellings = [];
5024+
let Subjects = SubjectList<[ParmVar, Field, Function]>;
5025+
let LangOpts = [HLSL];
5026+
let Documentation = [InternalOnly];
50425027
}
50435028

5044-
def HLSLSV_DispatchThreadID : HLSLSemanticAttr</* Indexable= */ 0> {
5045-
let Documentation = [HLSLSV_DispatchThreadIDDocs];
5029+
def HLSLAppliedSemantic : HLSLSemanticBaseAttr {
5030+
let Spellings = [];
5031+
let Subjects = SubjectList<[ParmVar, Field, Function]>;
5032+
let LangOpts = [HLSL];
5033+
let Documentation = [InternalOnly];
50465034
}
50475035

50485036
def HLSLPackOffset: HLSLAnnotationAttr {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8672,38 +8672,6 @@ randomized.
86728672
}];
86738673
}
86748674

8675-
def HLSLSV_GroupThreadIDDocs : Documentation {
8676-
let Category = DocHLSLSemantics;
8677-
let Content = [{
8678-
The ``SV_GroupThreadID`` semantic, when applied to an input parameter, specifies which
8679-
individual thread within a thread group is executing in. This attribute is
8680-
only supported in compute shaders.
8681-
8682-
The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-groupthreadid
8683-
}];
8684-
}
8685-
8686-
def HLSLSV_GroupIDDocs : Documentation {
8687-
let Category = DocHLSLSemantics;
8688-
let Content = [{
8689-
The ``SV_GroupID`` semantic, when applied to an input parameter, specifies which
8690-
thread group a shader is executing in. This attribute is only supported in compute shaders.
8691-
8692-
The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-groupid
8693-
}];
8694-
}
8695-
8696-
def HLSLSV_GroupIndexDocs : Documentation {
8697-
let Category = DocHLSLSemantics;
8698-
let Content = [{
8699-
The ``SV_GroupIndex`` semantic, when applied to an input parameter, specifies a
8700-
data binding to map the group index to the specified parameter. This attribute
8701-
is only supported in compute shaders.
8702-
8703-
The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-groupindex
8704-
}];
8705-
}
8706-
87078675
def HLSLResourceBindingDocs : Documentation {
87088676
let Category = DocCatFunction;
87098677
let Content = [{
@@ -8750,35 +8718,6 @@ The full documentation is available here: https://learn.microsoft.com/en-us/wind
87508718
}];
87518719
}
87528720

8753-
def HLSLSV_DispatchThreadIDDocs : Documentation {
8754-
let Category = DocHLSLSemantics;
8755-
let Content = [{
8756-
The ``SV_DispatchThreadID`` semantic, when applied to an input parameter,
8757-
specifies a data binding to map the global thread offset within the Dispatch
8758-
call (per dimension of the group) to the specified parameter.
8759-
When applied to a field of a struct, the data binding is specified to the field
8760-
when the struct is used as a parameter type.
8761-
The semantic on the field is ignored when not used as a parameter.
8762-
This attribute is only supported in compute shaders.
8763-
8764-
The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-dispatchthreadid
8765-
}];
8766-
}
8767-
8768-
def HLSLSV_PositionDocs : Documentation {
8769-
let Category = DocHLSLSemantics;
8770-
let Content = [{
8771-
The ``SV_Position`` semantic, when applied to an input parameter in a pixel
8772-
shader, contains the location of the pixel center (x, y) in screen space.
8773-
This semantic can be applied to the parameter, or a field in a struct used
8774-
as an input parameter.
8775-
This attribute is supported as an input in pixel, hull, domain and mesh shaders.
8776-
This attribute is supported as an output in vertex, geometry and domain shaders.
8777-
8778-
The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics
8779-
}];
8780-
}
8781-
87828721
def HLSLGroupSharedAddressSpaceDocs : Documentation {
87838722
let Category = DocCatVariable;
87848723
let Content = [{

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,7 @@ let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] i
617617
def psrlw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<8, short>)">;
618618
def psrld256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<4, int>)">;
619619
def psrlq256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<2, long long int>)">;
620-
def permvarsi256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
621620
def permdf256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Constant int)">;
622-
def permvarsf256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">;
623621
def permti256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<4, long long int>, _Constant int)">;
624622
def permdi256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Constant int)">;
625623
}
@@ -692,6 +690,9 @@ let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWi
692690
def pshuflw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Constant int)">;
693691
def pshufhw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Constant int)">;
694692
def pshufd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Constant int)">;
693+
694+
def permvarsi256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
695+
def permvarsf256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">;
695696
}
696697

697698
let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
@@ -3042,38 +3043,38 @@ let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<512>
30423043
def permdi512 : X86Builtin<"_Vector<8, long long int>(_Vector<8, long long int>, _Constant int)">;
30433044
}
30443045

3045-
let Features = "avx512bw", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
3046+
let Features = "avx512bw", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
30463047
def permvarhi512 : X86Builtin<"_Vector<32, short>(_Vector<32, short>, _Vector<32, short>)">;
30473048
}
30483049

3049-
let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
3050+
let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
30503051
def permvardf512 : X86Builtin<"_Vector<8, double>(_Vector<8, double>, _Vector<8, long long int>)">;
30513052
def permvardi512 : X86Builtin<"_Vector<8, long long int>(_Vector<8, long long int>, _Vector<8, long long int>)">;
30523053
def permvarsf512 : X86Builtin<"_Vector<16, float>(_Vector<16, float>, _Vector<16, int>)">;
30533054
def permvarsi512 : X86Builtin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">;
30543055
}
30553056

3056-
let Features = "avx512vbmi", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
3057+
let Features = "avx512vbmi", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
30573058
def permvarqi512 : X86Builtin<"_Vector<64, char>(_Vector<64, char>, _Vector<64, char>)">;
30583059
}
30593060

3060-
let Features = "avx512vbmi,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
3061+
let Features = "avx512vbmi,avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
30613062
def permvarqi128 : X86Builtin<"_Vector<16, char>(_Vector<16, char>, _Vector<16, char>)">;
30623063
}
30633064

3064-
let Features = "avx512vbmi,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
3065+
let Features = "avx512vbmi,avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
30653066
def permvarqi256 : X86Builtin<"_Vector<32, char>(_Vector<32, char>, _Vector<32, char>)">;
30663067
}
30673068

3068-
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<128>] in {
3069+
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>] in {
30693070
def permvarhi128 : X86Builtin<"_Vector<8, short>(_Vector<8, short>, _Vector<8, short>)">;
30703071
}
30713072

3072-
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
3073+
let Features = "avx512bw,avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
30733074
def permvarhi256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<16, short>)">;
30743075
}
30753076

3076-
let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
3077+
let Features = "avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
30773078
def permvardf256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, long long int>)">;
30783079
def permvardi256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<4, long long int>)">;
30793080
}

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,11 @@ class SemaHLSL : public SemaBase {
178178
bool handleResourceTypeAttr(QualType T, const ParsedAttr &AL);
179179

180180
template <typename T>
181-
T *createSemanticAttr(const AttributeCommonInfo &ACI, NamedDecl *TargetDecl,
181+
T *createSemanticAttr(const AttributeCommonInfo &ACI,
182182
std::optional<unsigned> Location) {
183-
T *Attr =
184-
::new (getASTContext()) T(getASTContext(), ACI, TargetDecl,
185-
Location.value_or(0), Location.has_value());
186-
187-
if (!Attr->isSemanticIndexable() && Location.has_value()) {
188-
Diag(Attr->getLocation(), diag::err_hlsl_semantic_indexing_not_supported)
189-
<< Attr->getAttrName()->getName();
190-
return nullptr;
191-
}
192-
return Attr;
183+
return ::new (getASTContext())
184+
T(getASTContext(), ACI, ACI.getAttrName()->getName(),
185+
Location.value_or(0));
193186
}
194187

195188
void diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL,
@@ -247,7 +240,7 @@ class SemaHLSL : public SemaBase {
247240
IdentifierInfo *RootSigOverrideIdent = nullptr;
248241

249242
struct SemanticInfo {
250-
HLSLSemanticAttr *Semantic;
243+
HLSLParsedSemanticAttr *Semantic;
251244
std::optional<uint32_t> Index;
252245
};
253246

@@ -257,14 +250,14 @@ class SemaHLSL : public SemaBase {
257250
const RecordType *RT);
258251

259252
void checkSemanticAnnotation(FunctionDecl *EntryPoint, const Decl *Param,
260-
const HLSLSemanticAttr *SemanticAttr);
261-
HLSLSemanticAttr *createSemantic(const SemanticInfo &Semantic,
262-
DeclaratorDecl *TargetDecl);
263-
bool determineActiveSemanticOnScalar(FunctionDecl *FD, DeclaratorDecl *D,
253+
const HLSLAppliedSemanticAttr *SemanticAttr);
254+
bool determineActiveSemanticOnScalar(FunctionDecl *FD,
255+
DeclaratorDecl *OutputDecl,
256+
DeclaratorDecl *D,
264257
SemanticInfo &ActiveSemantic,
265258
llvm::StringSet<> &ActiveInputSemantics);
266-
bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *D,
267-
SemanticInfo &ActiveSemantic,
259+
bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *OutputDecl,
260+
DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
268261
llvm::StringSet<> &ActiveInputSemantics);
269262

270263
void processExplicitBindingsOnDecl(VarDecl *D);

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4414,6 +4414,45 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
44144414
return std::pair<unsigned, int>{0, static_cast<int>(DstIdx)};
44154415
}
44164416
});
4417+
case X86::BI__builtin_ia32_permvarsi256:
4418+
case X86::BI__builtin_ia32_permvarsf256:
4419+
case X86::BI__builtin_ia32_permvardf512:
4420+
case X86::BI__builtin_ia32_permvardi512:
4421+
case X86::BI__builtin_ia32_permvarhi128:
4422+
return interp__builtin_ia32_shuffle_generic(
4423+
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
4424+
int Offset = ShuffleMask & 0x7;
4425+
return std::pair<unsigned, int>{0, Offset};
4426+
});
4427+
case X86::BI__builtin_ia32_permvarqi128:
4428+
case X86::BI__builtin_ia32_permvarhi256:
4429+
case X86::BI__builtin_ia32_permvarsi512:
4430+
case X86::BI__builtin_ia32_permvarsf512:
4431+
return interp__builtin_ia32_shuffle_generic(
4432+
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
4433+
int Offset = ShuffleMask & 0xF;
4434+
return std::pair<unsigned, int>{0, Offset};
4435+
});
4436+
case X86::BI__builtin_ia32_permvardi256:
4437+
case X86::BI__builtin_ia32_permvardf256:
4438+
return interp__builtin_ia32_shuffle_generic(
4439+
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
4440+
int Offset = ShuffleMask & 0x3;
4441+
return std::pair<unsigned, int>{0, Offset};
4442+
});
4443+
case X86::BI__builtin_ia32_permvarqi256:
4444+
case X86::BI__builtin_ia32_permvarhi512:
4445+
return interp__builtin_ia32_shuffle_generic(
4446+
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
4447+
int Offset = ShuffleMask & 0x1F;
4448+
return std::pair<unsigned, int>{0, Offset};
4449+
});
4450+
case X86::BI__builtin_ia32_permvarqi512:
4451+
return interp__builtin_ia32_shuffle_generic(
4452+
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
4453+
int Offset = ShuffleMask & 0x3F;
4454+
return std::pair<unsigned, int>{0, Offset};
4455+
});
44174456
case X86::BI__builtin_ia32_vpermi2varq128:
44184457
case X86::BI__builtin_ia32_vpermi2varpd128:
44194458
return interp__builtin_ia32_shuffle_generic(

0 commit comments

Comments
 (0)