Implement barrier intrinsics

Fixed: tint:658
Change-Id: I28d5225f42dacb2b6b0cb51ce9f15951b31f0fc9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/45284
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: David Neto <dneto@google.com>
Reviewed-by: Alan Baker <alanbaker@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-03-22 19:27:06 +00:00
committed by Commit Bot service account
parent 570b3d6509
commit f55091a9ec
18 changed files with 540 additions and 2 deletions

View File

@@ -88,6 +88,7 @@ enum class IntrinsicType {
kSmoothStep,
kSqrt,
kStep,
kStorageBarrier,
kTan,
kTanh,
kTextureDimensions,
@@ -107,6 +108,7 @@ enum class IntrinsicType {
kUnpack2x16Unorm,
kUnpack4x8Snorm,
kUnpack4x8Unorm,
kWorkgroupBarrier,
};
/// Matches the IntrisicType by name
@@ -159,6 +161,11 @@ bool IsDataPackingIntrinsic(IntrinsicType i);
/// @returns true if the given `i` is a data unpacking intrinsic
bool IsDataUnpackingIntrinsic(IntrinsicType i);
/// Determines if the given `i` is a barrier intrinsic
/// @param i the intrinsic
/// @returns true if the given `i` is a barrier intrinsic
bool IsBarrierIntrinsic(IntrinsicType i);
/// Intrinsic holds the semantic information for an intrinsic function.
class Intrinsic : public Castable<Intrinsic, CallTarget> {
public:
@@ -204,6 +211,9 @@ class Intrinsic : public Castable<Intrinsic, CallTarget> {
/// @returns true if intrinsic is a data unpacking intrinsic
bool IsDataUnpacking() const;
/// @returns true if intrinsic is a barrier intrinsic
bool IsBarrier() const;
private:
IntrinsicType const type_;
};

View File

@@ -94,6 +94,7 @@ const char* Intrinsic::str() const {
INTRINSIC(IntrinsicType::kSmoothStep, "smoothStep") \
INTRINSIC(IntrinsicType::kSqrt, "sqrt") \
INTRINSIC(IntrinsicType::kStep, "step") \
INTRINSIC(IntrinsicType::kStorageBarrier, "storageBarrier") \
INTRINSIC(IntrinsicType::kTan, "tan") \
INTRINSIC(IntrinsicType::kTanh, "tanh") \
INTRINSIC(IntrinsicType::kTextureDimensions, "textureDimensions") \
@@ -112,7 +113,8 @@ const char* Intrinsic::str() const {
INTRINSIC(IntrinsicType::kUnpack2x16Snorm, "unpack2x16snorm") \
INTRINSIC(IntrinsicType::kUnpack2x16Unorm, "unpack2x16unorm") \
INTRINSIC(IntrinsicType::kUnpack4x8Snorm, "unpack4x8snorm") \
INTRINSIC(IntrinsicType::kUnpack4x8Unorm, "unpack4x8unorm")
INTRINSIC(IntrinsicType::kUnpack4x8Unorm, "unpack4x8unorm") \
INTRINSIC(IntrinsicType::kWorkgroupBarrier, "workgroupBarrier")
IntrinsicType ParseIntrinsicType(const std::string& name) {
#define INTRINSIC(ENUM, NAME) \
@@ -187,6 +189,11 @@ bool IsDataUnpackingIntrinsic(IntrinsicType i) {
i == IntrinsicType::kUnpack2x16Float;
}
bool IsBarrierIntrinsic(IntrinsicType i) {
return i == IntrinsicType::kWorkgroupBarrier ||
i == IntrinsicType::kStorageBarrier;
}
Intrinsic::Intrinsic(IntrinsicType type,
type::Type* return_type,
const ParameterList& parameters)
@@ -226,5 +233,9 @@ bool Intrinsic::IsDataUnpacking() const {
return IsDataUnpackingIntrinsic(type_);
}
bool Intrinsic::IsBarrier() const {
return IsBarrierIntrinsic(type_);
}
} // namespace semantic
} // namespace tint

View File

@@ -99,6 +99,7 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{"smoothStep", IntrinsicType::kSmoothStep},
IntrinsicData{"sqrt", IntrinsicType::kSqrt},
IntrinsicData{"step", IntrinsicType::kStep},
IntrinsicData{"storageBarrier", IntrinsicType::kStorageBarrier},
IntrinsicData{"tan", IntrinsicType::kTan},
IntrinsicData{"tanh", IntrinsicType::kTanh},
IntrinsicData{"textureDimensions", IntrinsicType::kTextureDimensions},
@@ -117,7 +118,8 @@ INSTANTIATE_TEST_SUITE_P(
IntrinsicData{"unpack2x16snorm", IntrinsicType::kUnpack2x16Snorm},
IntrinsicData{"unpack2x16unorm", IntrinsicType::kUnpack2x16Unorm},
IntrinsicData{"unpack4x8snorm", IntrinsicType::kUnpack4x8Snorm},
IntrinsicData{"unpack4x8unorm", IntrinsicType::kUnpack4x8Unorm}));
IntrinsicData{"unpack4x8unorm", IntrinsicType::kUnpack4x8Unorm},
IntrinsicData{"workgroupBarrier", IntrinsicType::kWorkgroupBarrier}));
TEST_F(IntrinsicTypeTest, ParseNoMatch) {
EXPECT_EQ(ParseIntrinsicType("not_intrinsic"), IntrinsicType::kNone);