Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
971e124
[MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in AsyncR…
joker-eph Aug 21, 2025
3cfe6aa
[MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in mlir-o…
joker-eph Aug 21, 2025
edd8b29
[Float2Int] Make sure the CFP can be represented in the integer type …
dtcxzyw Nov 13, 2025
be2f875
[MLIR Attr] Allow LocationAttr to be used as an operation attribute (…
timnoack Nov 13, 2025
78554d9
Reapply "[HLSL] Rework semantic handling as attributes" (#167862)
Keenuts Nov 13, 2025
c0f7d51
[VPlan] Simplify ExplicitVectorLength(%AVL) -> %AVL when AVL <= VF (#…
lukel97 Nov 13, 2025
f73bcdb
[ROCDL] Added missing s.get.named.barrier.state op (gfx1250) (#167876)
ravil-mobile Nov 13, 2025
31536e6
[MLIR] [Python] `ir.Value` is now generic in the type of the value it…
superbobry Nov 13, 2025
7b7a422
[MLIR][LLVMIR] Add {s,u}cmp intrinsics to LLVM dialect (#167870)
Jezurko Nov 13, 2025
4cd8361
[AMDGPU] Lower S_ABSDIFF_I32 to VALU instructions (#167691)
mariusz-sikora-at-amd Nov 13, 2025
e5baf07
[AArch64] Generalize CSEL a, b, cc, SUBS(SUB(x,y), 0) -> CSEL a, b, …
AZero13 Nov 13, 2025
f969c86
[X86] bfloat.ll - cleaned up check prefixes to stop update script con…
RKSimon Nov 13, 2025
56eef98
[libc][stdlib] Simplify getenv_test by using strcmp instead of custom…
kaladron Nov 13, 2025
35ffe10
[opt] Add --save-stats option (#167304)
tomershafir Nov 13, 2025
91a1bde
[Clang] Add constexpr support for AVX512 permutexvar intrinsics (#16…
chaitanyav Nov 13, 2025
f67409c
Redesign Straight-Line Strength Reduction (SLSR) (#162930)
fiigii Nov 13, 2025
ec490b1
[AArch64] Add SchedReadAdvance to the Neoverse-N3 scheduling model (#…
Nov 13, 2025
1618e49
[clang][x86] Add SSE2/AVX/AVX512VLFP16 constrained sqrt test coverage…
RKSimon Nov 13, 2025
94fb856
[lldb] Add libstdcpp initializer_list formatter (#167515)
da-viper Nov 13, 2025
0f45a33
[Scalar] Fix warnings
kazutakahirata Nov 13, 2025
7129d76
Revert "[lldb][NFC] Mark ValueObject library with NO_PLUGIN_DEPENDENC…
kparzysz Nov 13, 2025
55aff64
[PowerPC] fold i128 equality/inequality compares of two loads into a …
diggerlin Nov 13, 2025
bb5f3a0
[Flang][OpenMP] Update declare mapper lookup via use-module (#163860)
TIFitis Nov 13, 2025
3c85d04
[clang] Use DenseMap::keys (NFC) (#167831)
kazutakahirata Nov 13, 2025
e6fb012
[IPO] Remove a redundant cast (NFC) (#167832)
kazutakahirata Nov 13, 2025
9651a04
[mlir] Use llvm::make_pointer_range (NFC) (#167833)
kazutakahirata Nov 13, 2025
5ad56ca
[Utils][update_mc_test_checks][NFC] Support sorting disassembler test…
kosarev Nov 13, 2025
cfa590e
[ROCDL] Added missing cluster.ids op (gfx1250) (#167890)
ravil-mobile Nov 13, 2025
b18ca21
Reapply "[X86] Remove Redundant memset Calls"
boomanaiden154 Nov 13, 2025
f87d6af
[clang][CIR] Fix build after 59c01cc8bb37dcff2d2efc2ddf287b6b89438200
darkbuck Nov 13, 2025
c243406
[clang][CIR] Fix build after 4d10c1165442cbbbc0017b48fcdd7dae1ccf3678
darkbuck Nov 13, 2025
d793a77
merge main into amd-staging
z1-cciauto Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 7 additions & 32 deletions clang/include/clang/AST/Attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,44 +233,19 @@ class HLSLAnnotationAttr : public InheritableAttr {
}
};

class HLSLSemanticAttr : public HLSLAnnotationAttr {
unsigned SemanticIndex = 0;
LLVM_PREFERRED_TYPE(bool)
unsigned SemanticIndexable : 1;
LLVM_PREFERRED_TYPE(bool)
unsigned SemanticExplicitIndex : 1;

Decl *TargetDecl = nullptr;

class HLSLSemanticBaseAttr : public HLSLAnnotationAttr {
protected:
HLSLSemanticAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,
attr::Kind AK, bool IsLateParsed,
bool InheritEvenIfAlreadyPresent, bool SemanticIndexable)
HLSLSemanticBaseAttr(ASTContext &Context,
const AttributeCommonInfo &CommonInfo, attr::Kind AK,
bool IsLateParsed, bool InheritEvenIfAlreadyPresent)
: HLSLAnnotationAttr(Context, CommonInfo, AK, IsLateParsed,
InheritEvenIfAlreadyPresent) {
this->SemanticIndexable = SemanticIndexable;
this->SemanticExplicitIndex = false;
}
InheritEvenIfAlreadyPresent) {}

public:
bool isSemanticIndexable() const { return SemanticIndexable; }

void setSemanticIndex(unsigned SemanticIndex) {
this->SemanticIndex = SemanticIndex;
this->SemanticExplicitIndex = true;
}

unsigned getSemanticIndex() const { return SemanticIndex; }

bool isSemanticIndexExplicit() const { return SemanticExplicitIndex; }

void setTargetDecl(Decl *D) { TargetDecl = D; }
Decl *getTargetDecl() const { return TargetDecl; }

// Implement isa/cast/dyncast/etc.
static bool classof(const Attr *A) {
return A->getKind() >= attr::FirstHLSLSemanticAttr &&
A->getKind() <= attr::LastHLSLSemanticAttr;
return A->getKind() >= attr::FirstHLSLSemanticBaseAttr &&
A->getKind() <= attr::LastHLSLSemanticBaseAttr;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class RecordStorageLocation final : public StorageLocation {
<< " on StorageLocation " << this << " of type "
<< getType() << "\n";
llvm::dbgs() << "Existing children:\n";
for ([[maybe_unused]] auto [Field, Loc] : Children) {
for (const auto &Field : Children.keys()) {
llvm::dbgs() << Field->getNameAsString() << "\n";
}
}
Expand Down
44 changes: 16 additions & 28 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -783,18 +783,6 @@ class DeclOrStmtAttr : InheritableAttr;
/// An attribute class for HLSL Annotations.
class HLSLAnnotationAttr : InheritableAttr;

class HLSLSemanticAttr<bit Indexable> : HLSLAnnotationAttr {
bit SemanticIndexable = Indexable;
int SemanticIndex = 0;
bit SemanticExplicitIndex = 0;

let Spellings = [];
let Subjects = SubjectList<[ParmVar, Field, Function]>;
let LangOpts = [HLSL];
let Args = [DeclArgument<Named, "Target">, IntArgument<"SemanticIndex">,
BoolArgument<"SemanticExplicitIndex">];
}

/// A target-specific attribute. This class is meant to be used as a mixin
/// with InheritableAttr or Attr depending on the attribute's needs.
class TargetSpecificAttr<TargetSpec target> {
Expand Down Expand Up @@ -5021,28 +5009,28 @@ def HLSLUnparsedSemantic : HLSLAnnotationAttr {
let Documentation = [InternalOnly];
}

def HLSLUserSemantic : HLSLSemanticAttr</* Indexable= */ 1> {
let Documentation = [InternalOnly];
}

def HLSLSV_Position : HLSLSemanticAttr</* Indexable= */ 1> {
let Documentation = [HLSLSV_PositionDocs];
}
class HLSLSemanticBaseAttr : HLSLAnnotationAttr {
int SemanticIndex = 0;

def HLSLSV_GroupThreadID : HLSLSemanticAttr</* Indexable= */ 0> {
let Documentation = [HLSLSV_GroupThreadIDDocs];
}
let Spellings = [];
let Subjects = SubjectList<[ParmVar, Field, Function]>;
let LangOpts = [HLSL];

def HLSLSV_GroupID : HLSLSemanticAttr</* Indexable= */ 0> {
let Documentation = [HLSLSV_GroupIDDocs];
let Args = [StringArgument<"SemanticName">, IntArgument<"SemanticIndex">];
}

def HLSLSV_GroupIndex : HLSLSemanticAttr</* Indexable= */ 0> {
let Documentation = [HLSLSV_GroupIndexDocs];
def HLSLParsedSemantic : HLSLSemanticBaseAttr {
let Spellings = [];
let Subjects = SubjectList<[ParmVar, Field, Function]>;
let LangOpts = [HLSL];
let Documentation = [InternalOnly];
}

def HLSLSV_DispatchThreadID : HLSLSemanticAttr</* Indexable= */ 0> {
let Documentation = [HLSLSV_DispatchThreadIDDocs];
def HLSLAppliedSemantic : HLSLSemanticBaseAttr {
let Spellings = [];
let Subjects = SubjectList<[ParmVar, Field, Function]>;
let LangOpts = [HLSL];
let Documentation = [InternalOnly];
}

def HLSLPackOffset: HLSLAnnotationAttr {
Expand Down
61 changes: 0 additions & 61 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -8672,38 +8672,6 @@ randomized.
}];
}

def HLSLSV_GroupThreadIDDocs : Documentation {
let Category = DocHLSLSemantics;
let Content = [{
The ``SV_GroupThreadID`` semantic, when applied to an input parameter, specifies which
individual thread within a thread group is executing in. This attribute is
only supported in compute shaders.

The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-groupthreadid
}];
}

def HLSLSV_GroupIDDocs : Documentation {
let Category = DocHLSLSemantics;
let Content = [{
The ``SV_GroupID`` semantic, when applied to an input parameter, specifies which
thread group a shader is executing in. This attribute is only supported in compute shaders.

The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-groupid
}];
}

def HLSLSV_GroupIndexDocs : Documentation {
let Category = DocHLSLSemantics;
let Content = [{
The ``SV_GroupIndex`` semantic, when applied to an input parameter, specifies a
data binding to map the group index to the specified parameter. This attribute
is only supported in compute shaders.

The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-groupindex
}];
}

def HLSLResourceBindingDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Expand Down Expand Up @@ -8750,35 +8718,6 @@ The full documentation is available here: https://learn.microsoft.com/en-us/wind
}];
}

def HLSLSV_DispatchThreadIDDocs : Documentation {
let Category = DocHLSLSemantics;
let Content = [{
The ``SV_DispatchThreadID`` semantic, when applied to an input parameter,
specifies a data binding to map the global thread offset within the Dispatch
call (per dimension of the group) to the specified parameter.
When applied to a field of a struct, the data binding is specified to the field
when the struct is used as a parameter type.
The semantic on the field is ignored when not used as a parameter.
This attribute is only supported in compute shaders.

The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sv-dispatchthreadid
}];
}

def HLSLSV_PositionDocs : Documentation {
let Category = DocHLSLSemantics;
let Content = [{
The ``SV_Position`` semantic, when applied to an input parameter in a pixel
shader, contains the location of the pixel center (x, y) in screen space.
This semantic can be applied to the parameter, or a field in a struct used
as an input parameter.
This attribute is supported as an input in pixel, hull, domain and mesh shaders.
This attribute is supported as an output in vertex, geometry and domain shaders.

The full documentation is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics
}];
}

def HLSLGroupSharedAddressSpaceDocs : Documentation {
let Category = DocCatVariable;
let Content = [{
Expand Down
21 changes: 11 additions & 10 deletions clang/include/clang/Basic/BuiltinsX86.td
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,7 @@ let Features = "avx2", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] i
def psrlw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Vector<8, short>)">;
def psrld256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<4, int>)">;
def psrlq256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<2, long long int>)">;
def permvarsi256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
def permdf256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Constant int)">;
def permvarsf256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">;
def permti256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<4, long long int>, _Constant int)">;
def permdi256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Constant int)">;
}
Expand Down Expand Up @@ -692,6 +690,9 @@ let Features = "avx2", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWi
def pshuflw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Constant int)">;
def pshufhw256 : X86Builtin<"_Vector<16, short>(_Vector<16, short>, _Constant int)">;
def pshufd256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Constant int)">;

def permvarsi256 : X86Builtin<"_Vector<8, int>(_Vector<8, int>, _Vector<8, int>)">;
def permvarsf256 : X86Builtin<"_Vector<8, float>(_Vector<8, float>, _Vector<8, int>)">;
}

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

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

let Features = "avx512f", Attributes = [NoThrow, Const, RequiredVectorWidth<512>] in {
let Features = "avx512f", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<512>] in {
def permvardf512 : X86Builtin<"_Vector<8, double>(_Vector<8, double>, _Vector<8, long long int>)">;
def permvardi512 : X86Builtin<"_Vector<8, long long int>(_Vector<8, long long int>, _Vector<8, long long int>)">;
def permvarsf512 : X86Builtin<"_Vector<16, float>(_Vector<16, float>, _Vector<16, int>)">;
def permvarsi512 : X86Builtin<"_Vector<16, int>(_Vector<16, int>, _Vector<16, int>)">;
}

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

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

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

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

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

let Features = "avx512vl", Attributes = [NoThrow, Const, RequiredVectorWidth<256>] in {
let Features = "avx512vl", Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<256>] in {
def permvardf256 : X86Builtin<"_Vector<4, double>(_Vector<4, double>, _Vector<4, long long int>)">;
def permvardi256 : X86Builtin<"_Vector<4, long long int>(_Vector<4, long long int>, _Vector<4, long long int>)">;
}
Expand Down
29 changes: 11 additions & 18 deletions clang/include/clang/Sema/SemaHLSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,11 @@ class SemaHLSL : public SemaBase {
bool handleResourceTypeAttr(QualType T, const ParsedAttr &AL);

template <typename T>
T *createSemanticAttr(const AttributeCommonInfo &ACI, NamedDecl *TargetDecl,
T *createSemanticAttr(const AttributeCommonInfo &ACI,
std::optional<unsigned> Location) {
T *Attr =
::new (getASTContext()) T(getASTContext(), ACI, TargetDecl,
Location.value_or(0), Location.has_value());

if (!Attr->isSemanticIndexable() && Location.has_value()) {
Diag(Attr->getLocation(), diag::err_hlsl_semantic_indexing_not_supported)
<< Attr->getAttrName()->getName();
return nullptr;
}
return Attr;
return ::new (getASTContext())
T(getASTContext(), ACI, ACI.getAttrName()->getName(),
Location.value_or(0));
}

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

struct SemanticInfo {
HLSLSemanticAttr *Semantic;
HLSLParsedSemanticAttr *Semantic;
std::optional<uint32_t> Index;
};

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

void checkSemanticAnnotation(FunctionDecl *EntryPoint, const Decl *Param,
const HLSLSemanticAttr *SemanticAttr);
HLSLSemanticAttr *createSemantic(const SemanticInfo &Semantic,
DeclaratorDecl *TargetDecl);
bool determineActiveSemanticOnScalar(FunctionDecl *FD, DeclaratorDecl *D,
const HLSLAppliedSemanticAttr *SemanticAttr);
bool determineActiveSemanticOnScalar(FunctionDecl *FD,
DeclaratorDecl *OutputDecl,
DeclaratorDecl *D,
SemanticInfo &ActiveSemantic,
llvm::StringSet<> &ActiveInputSemantics);
bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *D,
SemanticInfo &ActiveSemantic,
bool determineActiveSemantic(FunctionDecl *FD, DeclaratorDecl *OutputDecl,
DeclaratorDecl *D, SemanticInfo &ActiveSemantic,
llvm::StringSet<> &ActiveInputSemantics);

void processExplicitBindingsOnDecl(VarDecl *D);
Expand Down
39 changes: 39 additions & 0 deletions clang/lib/AST/ByteCode/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4414,6 +4414,45 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
return std::pair<unsigned, int>{0, static_cast<int>(DstIdx)};
}
});
case X86::BI__builtin_ia32_permvarsi256:
case X86::BI__builtin_ia32_permvarsf256:
case X86::BI__builtin_ia32_permvardf512:
case X86::BI__builtin_ia32_permvardi512:
case X86::BI__builtin_ia32_permvarhi128:
return interp__builtin_ia32_shuffle_generic(
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
int Offset = ShuffleMask & 0x7;
return std::pair<unsigned, int>{0, Offset};
});
case X86::BI__builtin_ia32_permvarqi128:
case X86::BI__builtin_ia32_permvarhi256:
case X86::BI__builtin_ia32_permvarsi512:
case X86::BI__builtin_ia32_permvarsf512:
return interp__builtin_ia32_shuffle_generic(
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
int Offset = ShuffleMask & 0xF;
return std::pair<unsigned, int>{0, Offset};
});
case X86::BI__builtin_ia32_permvardi256:
case X86::BI__builtin_ia32_permvardf256:
return interp__builtin_ia32_shuffle_generic(
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
int Offset = ShuffleMask & 0x3;
return std::pair<unsigned, int>{0, Offset};
});
case X86::BI__builtin_ia32_permvarqi256:
case X86::BI__builtin_ia32_permvarhi512:
return interp__builtin_ia32_shuffle_generic(
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
int Offset = ShuffleMask & 0x1F;
return std::pair<unsigned, int>{0, Offset};
});
case X86::BI__builtin_ia32_permvarqi512:
return interp__builtin_ia32_shuffle_generic(
S, OpPC, Call, [](unsigned DstIdx, unsigned ShuffleMask) {
int Offset = ShuffleMask & 0x3F;
return std::pair<unsigned, int>{0, Offset};
});
case X86::BI__builtin_ia32_vpermi2varq128:
case X86::BI__builtin_ia32_vpermi2varpd128:
return interp__builtin_ia32_shuffle_generic(
Expand Down
Loading