tint/resolver: Add `DataType<T>::ElementType` typedef

To point to the element type of T. Helpful for tests.

Change-Id: I41b5ad0923375e11509acf67959a849da3d1ebcf
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/91421
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2022-05-25 21:07:04 +00:00 committed by Dawn LUCI CQ
parent 6ae7c06017
commit a8d5228049
1 changed files with 36 additions and 0 deletions

View File

@ -189,6 +189,9 @@ struct DataType<void> {
/// Helper for building bool types and expressions
template <>
struct DataType<bool> {
/// The element type
using ElementType = bool;
/// false as bool is not a composite type
static constexpr bool is_composite = false;
@ -211,6 +214,9 @@ struct DataType<bool> {
/// Helper for building i32 types and expressions
template <>
struct DataType<i32> {
/// The element type
using ElementType = i32;
/// false as i32 is not a composite type
static constexpr bool is_composite = false;
@ -233,6 +239,9 @@ struct DataType<i32> {
/// Helper for building u32 types and expressions
template <>
struct DataType<u32> {
/// The element type
using ElementType = u32;
/// false as u32 is not a composite type
static constexpr bool is_composite = false;
@ -255,6 +264,9 @@ struct DataType<u32> {
/// Helper for building f32 types and expressions
template <>
struct DataType<f32> {
/// The element type
using ElementType = f32;
/// false as f32 is not a composite type
static constexpr bool is_composite = false;
@ -277,6 +289,9 @@ struct DataType<f32> {
/// Helper for building f16 types and expressions
template <>
struct DataType<f16> {
/// The element type
using ElementType = f16;
/// false as f16 is not a composite type
static constexpr bool is_composite = false;
@ -299,6 +314,9 @@ struct DataType<f16> {
/// Helper for building abstract float types and expressions
template <>
struct DataType<AFloat> {
/// The element type
using ElementType = AFloat;
/// false as AFloat is not a composite type
static constexpr bool is_composite = false;
@ -320,6 +338,9 @@ struct DataType<AFloat> {
/// Helper for building abstract integer types and expressions
template <>
struct DataType<AInt> {
/// The element type
using ElementType = AInt;
/// false as AFloat is not a composite type
static constexpr bool is_composite = false;
@ -341,6 +362,9 @@ struct DataType<AInt> {
/// Helper for building vector types and expressions
template <uint32_t N, typename T>
struct DataType<vec<N, T>> {
/// The element type
using ElementType = T;
/// true as vectors are a composite type
static constexpr bool is_composite = true;
@ -381,6 +405,9 @@ struct DataType<vec<N, T>> {
/// Helper for building matrix types and expressions
template <uint32_t N, uint32_t M, typename T>
struct DataType<mat<N, M, T>> {
/// The element type
using ElementType = T;
/// true as matrices are a composite type
static constexpr bool is_composite = true;
@ -423,6 +450,9 @@ struct DataType<mat<N, M, T>> {
/// Helper for building alias types and expressions
template <typename T, int ID>
struct DataType<alias<T, ID>> {
/// The element type
using ElementType = T;
/// true if the aliased type is a composite type
static constexpr bool is_composite = DataType<T>::is_composite;
@ -466,6 +496,9 @@ struct DataType<alias<T, ID>> {
/// Helper for building pointer types and expressions
template <typename T>
struct DataType<ptr<T>> {
/// The element type
using ElementType = T;
/// true if the pointer type is a composite type
static constexpr bool is_composite = false;
@ -496,6 +529,9 @@ struct DataType<ptr<T>> {
/// Helper for building array types and expressions
template <uint32_t N, typename T>
struct DataType<array<N, T>> {
/// The element type
using ElementType = T;
/// true as arrays are a composite type
static constexpr bool is_composite = true;