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 <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
Zhaoming Jiang 2022-05-13 08:56:56 +00:00 committed by Dawn LUCI CQ
parent ed6ff9c948
commit c4b380b8af
1 changed files with 5 additions and 21 deletions

View File

@ -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
}