[msl-writer][hlsl-writer] Add countOneBits and reverseBits

This Cl adds countOneBits and reverseBits intrinsic support to the MSL
and HLSL backends.

Bug: tint:250
Change-Id: Idb572da32e9c10767a27326cacf58aafef44a77a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/29401
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2020-10-05 19:46:16 +00:00 committed by Commit Bot service account
parent 44b043d46a
commit 94b7c66858
4 changed files with 42 additions and 25 deletions

View File

@ -473,18 +473,12 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
if (intrinsic == ast::Intrinsic::kAll) {
return "all";
}
if (intrinsic == ast::Intrinsic::kCountOneBits) {
return "countbits";
}
if (intrinsic == ast::Intrinsic::kDot) {
return "dot";
}
if (intrinsic == ast::Intrinsic::kIsFinite) {
return "isfinite";
}
if (intrinsic == ast::Intrinsic::kIsInf) {
return "isinf";
}
if (intrinsic == ast::Intrinsic::kIsNan) {
return "isnan";
}
if (intrinsic == ast::Intrinsic::kDpdy) {
return "ddy";
}
@ -508,6 +502,18 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
intrinsic == ast::Intrinsic::kFwidthCoarse) {
return "fwidth";
}
if (intrinsic == ast::Intrinsic::kIsFinite) {
return "isfinite";
}
if (intrinsic == ast::Intrinsic::kIsInf) {
return "isinf";
}
if (intrinsic == ast::Intrinsic::kIsNan) {
return "isnan";
}
if (intrinsic == ast::Intrinsic::kReverseBits) {
return "reversebits";
}
return "";
}

View File

@ -46,6 +46,7 @@ INSTANTIATE_TEST_SUITE_P(
HlslIntrinsicTest,
testing::Values(IntrinsicData{ast::Intrinsic::kAny, "any"},
IntrinsicData{ast::Intrinsic::kAll, "all"},
IntrinsicData{ast::Intrinsic::kCountOneBits, "countbits"},
IntrinsicData{ast::Intrinsic::kDot, "dot"},
IntrinsicData{ast::Intrinsic::kDpdx, "ddx"},
IntrinsicData{ast::Intrinsic::kDpdxCoarse, "ddx_coarse"},
@ -58,7 +59,9 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{ast::Intrinsic::kFwidthFine, "fwidth"},
IntrinsicData{ast::Intrinsic::kIsFinite, "isfinite"},
IntrinsicData{ast::Intrinsic::kIsInf, "isinf"},
IntrinsicData{ast::Intrinsic::kIsNan, "isnan"}));
IntrinsicData{ast::Intrinsic::kIsNan, "isnan"},
IntrinsicData{ast::Intrinsic::kReverseBits,
"reversebits"}));
TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_IsNormal) {
FAIL();

View File

@ -413,24 +413,12 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
if (intrinsic == ast::Intrinsic::kAll) {
return "all";
}
if (intrinsic == ast::Intrinsic::kCountOneBits) {
return "popcount";
}
if (intrinsic == ast::Intrinsic::kDot) {
return "dot";
}
if (intrinsic == ast::Intrinsic::kIsFinite) {
return "isfinite";
}
if (intrinsic == ast::Intrinsic::kIsInf) {
return "isinf";
}
if (intrinsic == ast::Intrinsic::kIsNan) {
return "isnan";
}
if (intrinsic == ast::Intrinsic::kIsNormal) {
return "isnormal";
}
if (intrinsic == ast::Intrinsic::kSelect) {
return "select";
}
if (intrinsic == ast::Intrinsic::kDpdy ||
intrinsic == ast::Intrinsic::kDpdyFine ||
intrinsic == ast::Intrinsic::kDpdyCoarse) {
@ -446,6 +434,24 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
intrinsic == ast::Intrinsic::kFwidthCoarse) {
return "fwidth";
}
if (intrinsic == ast::Intrinsic::kIsFinite) {
return "isfinite";
}
if (intrinsic == ast::Intrinsic::kIsInf) {
return "isinf";
}
if (intrinsic == ast::Intrinsic::kIsNan) {
return "isnan";
}
if (intrinsic == ast::Intrinsic::kIsNormal) {
return "isnormal";
}
if (intrinsic == ast::Intrinsic::kReverseBits) {
return "reverse_bits";
}
if (intrinsic == ast::Intrinsic::kSelect) {
return "select";
}
return "";
}

View File

@ -50,6 +50,7 @@ INSTANTIATE_TEST_SUITE_P(
MslIntrinsicTest,
testing::Values(IntrinsicData{ast::Intrinsic::kAny, "any"},
IntrinsicData{ast::Intrinsic::kAll, "all"},
IntrinsicData{ast::Intrinsic::kCountOneBits, "popcount"},
IntrinsicData{ast::Intrinsic::kDot, "dot"},
IntrinsicData{ast::Intrinsic::kDpdx, "dfdx"},
IntrinsicData{ast::Intrinsic::kDpdxCoarse, "dfdx"},
@ -64,6 +65,7 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{ast::Intrinsic::kIsInf, "isinf"},
IntrinsicData{ast::Intrinsic::kIsNan, "isnan"},
IntrinsicData{ast::Intrinsic::kIsNormal, "isnormal"},
IntrinsicData{ast::Intrinsic::kReverseBits, "reverse_bits"},
IntrinsicData{ast::Intrinsic::kSelect, "select"}));
TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) {