Skip to content

Commit

Permalink
Enable 2021 operator intrinsics in older modes (microsoft#4882)
Browse files Browse the repository at this point in the history
This enables the `select`, `and`, and `or` intrinsics in older HLSL
language modes to ease transitioning to HLSL 2021.
  • Loading branch information
llvm-beanz authored Dec 15, 2022
1 parent e7aac8e commit ffe931e
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 12 deletions.
12 changes: 0 additions & 12 deletions tools/clang/lib/Sema/SemaHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4783,18 +4783,6 @@ class HLSLExternalSource : public ExternalSemaSource {
pIntrinsic->uNumArgs <= g_MaxIntrinsicParamCount + 1,
"otherwise g_MaxIntrinsicParamCount needs to be updated for wider signatures");

// Some intrinsics only optionally exist in later language versions.
// To prevent collisions with existing functions or templates, exclude
// intrinsics when they aren't enabled.
if (IsBuiltinTable(tableName) &&
m_sema->getLangOpts().HLSLVersion < hlsl::LangStd::v2021) {
if (pIntrinsic->Op == (UINT)IntrinsicOp::IOP_and ||
pIntrinsic->Op == (UINT)IntrinsicOp::IOP_or ||
pIntrinsic->Op == (UINT)IntrinsicOp::IOP_select) {
continue;
}
}

std::vector<QualType> functionArgTypes;
size_t badArgIdx;
bool argsMatch = MatchArguments(cursor, QualType(), QualType(), Args, &functionArgTypes, badArgIdx);
Expand Down
1 change: 1 addition & 0 deletions tools/clang/test/CodeGenSPIRV/intrinsics.and.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %dxc -T ps_6_0 -E main -HV 2021
// RUN: %dxc -T ps_6_0 -E main -HV 2018

void main() {
// CHECK-LABEL: %bb_entry = OpLabel
Expand Down
1 change: 1 addition & 0 deletions tools/clang/test/CodeGenSPIRV/intrinsics.or.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %dxc -T ps_6_0 -E main -HV 2021
// RUN: %dxc -T ps_6_0 -E main -HV 2018

void main() {
// CHECK-LABEL: %bb_entry = OpLabel
Expand Down
1 change: 1 addition & 0 deletions tools/clang/test/CodeGenSPIRV/intrinsics.select.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %dxc -T ps_6_0 -E main -HV 2021
// RUN: %dxc -T ps_6_0 -E main -HV 2018

// CHECK: [[v3i0:%\d+]] = OpConstantComposite %v3int %int_0 %int_0 %int_0

Expand Down

0 comments on commit ffe931e

Please sign in to comment.