From c4b380b8af94fe8b7a61ae8bd3f735f9d7a51380 Mon Sep 17 00:00:00 2001 From: Zhaoming Jiang Date: Fri, 13 May 2022 08:56:56 +0000 Subject: [PATCH] tint: Generalize sem::Vector to allow 16bits subtype This patch make `sem::Vector::Size()` and `Align()` more general to prepare for subtypes of 16bits, e.g. f16. Previously these methods assert that the subtypes are of 4bytes. Change-Id: Ic939f177e87faabdf17d1d404cee82a91072a179 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90163 Kokoro: Kokoro Reviewed-by: Ben Clayton Commit-Queue: Zhaoming Jiang --- src/tint/sem/vector.cc | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/tint/sem/vector.cc b/src/tint/sem/vector.cc index 6b4e15d5b6..2df7cf0a33 100644 --- a/src/tint/sem/vector.cc +++ b/src/tint/sem/vector.cc @@ -52,33 +52,17 @@ bool Vector::IsConstructible() const { } uint32_t Vector::Size() const { - return SizeOf(width_); + return subtype_->Size() * width_; } uint32_t Vector::Align() const { - return AlignOf(width_); -} - -uint32_t Vector::SizeOf(uint32_t width) { - switch (width) { + switch (width_) { case 2: - return 8; + return subtype_->Size() * 2; case 3: - return 12; + return subtype_->Size() * 4; case 4: - return 16; - } - return 0; // Unreachable -} - -uint32_t Vector::AlignOf(uint32_t width) { - switch (width) { - case 2: - return 8; - case 3: - return 16; - case 4: - return 16; + return subtype_->Size() * 4; } return 0; // Unreachable }