[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:
parent
44b043d46a
commit
94b7c66858
|
@ -473,18 +473,12 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
|
||||||
if (intrinsic == ast::Intrinsic::kAll) {
|
if (intrinsic == ast::Intrinsic::kAll) {
|
||||||
return "all";
|
return "all";
|
||||||
}
|
}
|
||||||
|
if (intrinsic == ast::Intrinsic::kCountOneBits) {
|
||||||
|
return "countbits";
|
||||||
|
}
|
||||||
if (intrinsic == ast::Intrinsic::kDot) {
|
if (intrinsic == ast::Intrinsic::kDot) {
|
||||||
return "dot";
|
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) {
|
if (intrinsic == ast::Intrinsic::kDpdy) {
|
||||||
return "ddy";
|
return "ddy";
|
||||||
}
|
}
|
||||||
|
@ -508,6 +502,18 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
|
||||||
intrinsic == ast::Intrinsic::kFwidthCoarse) {
|
intrinsic == ast::Intrinsic::kFwidthCoarse) {
|
||||||
return "fwidth";
|
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 "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
HlslIntrinsicTest,
|
HlslIntrinsicTest,
|
||||||
testing::Values(IntrinsicData{ast::Intrinsic::kAny, "any"},
|
testing::Values(IntrinsicData{ast::Intrinsic::kAny, "any"},
|
||||||
IntrinsicData{ast::Intrinsic::kAll, "all"},
|
IntrinsicData{ast::Intrinsic::kAll, "all"},
|
||||||
|
IntrinsicData{ast::Intrinsic::kCountOneBits, "countbits"},
|
||||||
IntrinsicData{ast::Intrinsic::kDot, "dot"},
|
IntrinsicData{ast::Intrinsic::kDot, "dot"},
|
||||||
IntrinsicData{ast::Intrinsic::kDpdx, "ddx"},
|
IntrinsicData{ast::Intrinsic::kDpdx, "ddx"},
|
||||||
IntrinsicData{ast::Intrinsic::kDpdxCoarse, "ddx_coarse"},
|
IntrinsicData{ast::Intrinsic::kDpdxCoarse, "ddx_coarse"},
|
||||||
|
@ -58,7 +59,9 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
IntrinsicData{ast::Intrinsic::kFwidthFine, "fwidth"},
|
IntrinsicData{ast::Intrinsic::kFwidthFine, "fwidth"},
|
||||||
IntrinsicData{ast::Intrinsic::kIsFinite, "isfinite"},
|
IntrinsicData{ast::Intrinsic::kIsFinite, "isfinite"},
|
||||||
IntrinsicData{ast::Intrinsic::kIsInf, "isinf"},
|
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) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_IsNormal) {
|
||||||
FAIL();
|
FAIL();
|
||||||
|
|
|
@ -413,24 +413,12 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
|
||||||
if (intrinsic == ast::Intrinsic::kAll) {
|
if (intrinsic == ast::Intrinsic::kAll) {
|
||||||
return "all";
|
return "all";
|
||||||
}
|
}
|
||||||
|
if (intrinsic == ast::Intrinsic::kCountOneBits) {
|
||||||
|
return "popcount";
|
||||||
|
}
|
||||||
if (intrinsic == ast::Intrinsic::kDot) {
|
if (intrinsic == ast::Intrinsic::kDot) {
|
||||||
return "dot";
|
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 ||
|
if (intrinsic == ast::Intrinsic::kDpdy ||
|
||||||
intrinsic == ast::Intrinsic::kDpdyFine ||
|
intrinsic == ast::Intrinsic::kDpdyFine ||
|
||||||
intrinsic == ast::Intrinsic::kDpdyCoarse) {
|
intrinsic == ast::Intrinsic::kDpdyCoarse) {
|
||||||
|
@ -446,6 +434,24 @@ std::string GeneratorImpl::generate_intrinsic_name(ast::Intrinsic intrinsic) {
|
||||||
intrinsic == ast::Intrinsic::kFwidthCoarse) {
|
intrinsic == ast::Intrinsic::kFwidthCoarse) {
|
||||||
return "fwidth";
|
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 "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
MslIntrinsicTest,
|
MslIntrinsicTest,
|
||||||
testing::Values(IntrinsicData{ast::Intrinsic::kAny, "any"},
|
testing::Values(IntrinsicData{ast::Intrinsic::kAny, "any"},
|
||||||
IntrinsicData{ast::Intrinsic::kAll, "all"},
|
IntrinsicData{ast::Intrinsic::kAll, "all"},
|
||||||
|
IntrinsicData{ast::Intrinsic::kCountOneBits, "popcount"},
|
||||||
IntrinsicData{ast::Intrinsic::kDot, "dot"},
|
IntrinsicData{ast::Intrinsic::kDot, "dot"},
|
||||||
IntrinsicData{ast::Intrinsic::kDpdx, "dfdx"},
|
IntrinsicData{ast::Intrinsic::kDpdx, "dfdx"},
|
||||||
IntrinsicData{ast::Intrinsic::kDpdxCoarse, "dfdx"},
|
IntrinsicData{ast::Intrinsic::kDpdxCoarse, "dfdx"},
|
||||||
|
@ -64,6 +65,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
IntrinsicData{ast::Intrinsic::kIsInf, "isinf"},
|
IntrinsicData{ast::Intrinsic::kIsInf, "isinf"},
|
||||||
IntrinsicData{ast::Intrinsic::kIsNan, "isnan"},
|
IntrinsicData{ast::Intrinsic::kIsNan, "isnan"},
|
||||||
IntrinsicData{ast::Intrinsic::kIsNormal, "isnormal"},
|
IntrinsicData{ast::Intrinsic::kIsNormal, "isnormal"},
|
||||||
|
IntrinsicData{ast::Intrinsic::kReverseBits, "reverse_bits"},
|
||||||
IntrinsicData{ast::Intrinsic::kSelect, "select"}));
|
IntrinsicData{ast::Intrinsic::kSelect, "select"}));
|
||||||
|
|
||||||
TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) {
|
TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) {
|
||||||
|
|
Loading…
Reference in New Issue