[ir] Cleanup composite creation in tests

This CL adds some helpers to make composites easier to use in tests.

Bug: tint:1718
Change-Id: I16a0e94978c43efa619b31b6815089c8fff6983f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133920
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
dan sinclair
2023-05-24 00:27:17 +00:00
committed by Dawn LUCI CQ
parent 4e2be2d083
commit 07a1d65fbc
4 changed files with 78 additions and 48 deletions

View File

@@ -18,6 +18,7 @@
#include <utility>
#include "src/tint/type/type.h"
#include "src/tint/type/vector.h"
#include "src/tint/utils/hash.h"
#include "src/tint/utils/unique_allocator.h"
@@ -84,6 +85,23 @@ class Manager final {
return types_.Find<TYPE>(std::forward<ARGS>(args)...);
}
/// @param inner the inner type
/// @param size the vector size
/// @returns the vector type
type::Type* vec(type::Type* inner, uint32_t size) { return Get<type::Vector>(inner, size); }
/// @param inner the inner type
/// @returns the vector type
type::Type* vec2(type::Type* inner) { return vec(inner, 2); }
/// @param inner the inner type
/// @returns the vector type
type::Type* vec3(type::Type* inner) { return vec(inner, 3); }
/// @param inner the inner type
/// @returns the vector type
type::Type* vec4(type::Type* inner) { return vec(inner, 4); }
/// @returns an iterator to the beginning of the types
TypeIterator begin() const { return types_.begin(); }
/// @returns an iterator to the end of the types