@@ -1941,15 +1941,14 @@ static void AddHLSLIntrinsicAttr(FunctionDecl *FD, ASTContext &context,
19411941 FD->addAttr(PureAttr::CreateImplicit(context));
19421942 if (pIntrinsic->Flags & INTRIN_FLAG_IS_WAVE)
19431943 FD->addAttr(HLSLWaveSensitiveAttr::CreateImplicit(context));
1944- // TBD: Add availability attribute if MinShaderModel is set.
1945- // if (pIntrinsic->MinShaderModel) {
1946- // unsigned Major = pIntrinsic->MinShaderModel >> 4;
1947- // unsigned Minor = pIntrinsic->MinShaderModel & 0xF;
1948- // FD->addAttr(AvailabilityAttr::CreateImplicit(
1949- // context, &context.Idents.get(""), clang::VersionTuple(Major, Minor),
1950- // clang::VersionTuple(), clang::VersionTuple(), false,
1951- // "HLSL Intrinsic availability limited by shader model."));
1952- //}
1944+ if (pIntrinsic->MinShaderModel) {
1945+ unsigned Major = pIntrinsic->MinShaderModel >> 4;
1946+ unsigned Minor = pIntrinsic->MinShaderModel & 0xF;
1947+ FD->addAttr(AvailabilityAttr::CreateImplicit(
1948+ context, &context.Idents.get(""), clang::VersionTuple(Major, Minor),
1949+ clang::VersionTuple(), clang::VersionTuple(), false,
1950+ "HLSL Intrinsic availability limited by shader model."));
1951+ }
19531952}
19541953
19551954static FunctionDecl *
@@ -3781,10 +3780,8 @@ class HLSLExternalSource : public ExternalSemaSource {
37813780 recordDecl = DeclareRayQueryType(*m_context);
37823781 } else if (kind == AR_OBJECT_HIT_OBJECT) {
37833782 // Declare 'HitObject' in '::dx' extension namespace.
3784- if (SM->IsSM69Plus()) {
3785- DXASSERT(m_dxNSDecl, "namespace ::dx must be declared in SM6.9+");
3786- recordDecl = DeclareHitObjectType(*m_dxNSDecl);
3787- }
3783+ DXASSERT(m_dxNSDecl, "namespace ::dx must be declared in SM6.9+");
3784+ recordDecl = DeclareHitObjectType(*m_dxNSDecl);
37883785 } else if (kind == AR_OBJECT_HEAP_RESOURCE) {
37893786 recordDecl = DeclareResourceType(*m_context, /*bSampler*/ false);
37903787 if (SM->IsSM66Plus()) {
@@ -4063,8 +4060,6 @@ class HLSLExternalSource : public ExternalSemaSource {
40634060 S.addExternalSource(this);
40644061
40654062 // Namespace ::dx only introduced with SM6.9
4066- const auto *SM =
4067- hlsl::ShaderModel::GetByName(m_sema->getLangOpts().HLSLProfile.c_str());
40684063 m_dxNSDecl =
40694064 NamespaceDecl::Create(context, context.getTranslationUnitDecl(),
40704065 /*Inline*/ false, SourceLocation(),
@@ -4091,8 +4086,7 @@ class HLSLExternalSource : public ExternalSemaSource {
40914086 AddIntrinsicTableMethods(intrinsic);
40924087 }
40934088
4094- if (SM->IsSM69Plus())
4095- AddDxIntrinsicFunctions();
4089+ AddDxIntrinsicFunctions();
40964090
40974091#ifdef ENABLE_SPIRV_CODEGEN
40984092 if (m_sema->getLangOpts().SPIRV) {
@@ -5083,17 +5077,6 @@ class HLSLExternalSource : public ExternalSemaSource {
50835077 nameIdentifier, argumentCount));
50845078 }
50855079
5086- bool IsEnabledIntrinsic(const HLSL_INTRINSIC *pIntrinsic,
5087- const ShaderModel &SM) {
5088- switch ((IntrinsicOp)pIntrinsic->Op) {
5089- default:
5090- return true;
5091- case IntrinsicOp::MOP_DxHitObject_MakeNop:
5092- case IntrinsicOp::IOP_DxMaybeReorderThread:
5093- return SM.IsSM69Plus();
5094- }
5095- }
5096-
50975080 bool AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
50985081 ArrayRef<Expr *> Args,
50995082 OverloadCandidateSet &CandidateSet,
@@ -5145,9 +5128,6 @@ class HLSLExternalSource : public ExternalSemaSource {
51455128 }
51465129#endif // ENABLE_SPIRV_CODEGEN
51475130
5148- const auto *SM =
5149- hlsl::ShaderModel::GetByName(m_sema->getLangOpts().HLSLProfile.c_str());
5150-
51515131 IntrinsicDefIter cursor = FindIntrinsicByNameAndArgCount(
51525132 table, tableCount, StringRef(), nameIdentifier, Args.size());
51535133 IntrinsicDefIter end = IntrinsicDefIter::CreateEnd(
@@ -5156,13 +5136,6 @@ class HLSLExternalSource : public ExternalSemaSource {
51565136 for (; cursor != end; ++cursor) {
51575137 const HLSL_INTRINSIC *pIntrinsic = *cursor;
51585138
5159- // Check whether this extension intrinsic is available in the current
5160- // configuration. Note that this not necessary for member functions:
5161- // if the builtin type is never declared, neither will any type refer
5162- // to the member intrinsics table.
5163- if (!IsEnabledIntrinsic(*cursor, *SM))
5164- continue;
5165-
51665139 // If this is the intrinsic we're interested in, build up a representation
51675140 // of the types we need.
51685141 LPCSTR tableName = cursor.GetTableName();
@@ -11935,11 +11908,6 @@ void Sema::DiagnoseReachableCallForSER(CallExpr *CE, DXIL::ShaderKind EntrySK,
1193511908 << DiagValidShaderKinds;
1193611909 Diag(EntryFD->getLocation(), diag::note_hlsl_entry_defined_here);
1193711910 }
11938-
11939- if (!SM->IsSM69Plus()) {
11940- // Legal entry, but version not supported
11941- Diag(Loc, diag::err_hlsl_ser_invalid_version) << SM->GetName();
11942- }
1194311911}
1194411912
1194511913// Check HLSL member call constraints for used functions.
0 commit comments