ProgramBuilder: Migrate vectors to typ::TypePair

Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: I19d7df9ab684db598783235c1720586966a232e0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48683
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton
2021-04-22 14:24:43 +00:00
committed by Commit Bot service account
parent 43073d8aa3
commit e30ffeb02a
11 changed files with 44 additions and 33 deletions

View File

@@ -45,6 +45,7 @@
#include "src/ast/u32.h"
#include "src/ast/uint_literal.h"
#include "src/ast/variable_decl_statement.h"
#include "src/ast/vector.h"
#include "src/ast/void.h"
#include "src/program.h"
#include "src/program_id.h"
@@ -361,37 +362,40 @@ class ProgramBuilder {
/// @param type vector subtype
/// @return the tint AST type for a 2-element vector of `type`.
sem::Vector* vec2(sem::Type* type) const {
return builder->create<sem::Vector>(type, 2u);
typ::Vector vec2(typ::Type type) const {
return {builder->create<ast::Vector>(type, 2u),
builder->create<sem::Vector>(type, 2u)};
}
/// @param type vector subtype
/// @return the tint AST type for a 3-element vector of `type`.
sem::Vector* vec3(sem::Type* type) const {
return builder->create<sem::Vector>(type, 3u);
typ::Vector vec3(typ::Type type) const {
return {builder->create<ast::Vector>(type, 3u),
builder->create<sem::Vector>(type, 3u)};
}
/// @param type vector subtype
/// @return the tint AST type for a 4-element vector of `type`.
sem::Type* vec4(sem::Type* type) const {
return builder->create<sem::Vector>(type, 4u);
typ::Vector vec4(typ::Type type) const {
return {builder->create<ast::Vector>(type, 4u),
builder->create<sem::Vector>(type, 4u)};
}
/// @return the tint AST type for a 2-element vector of the C type `T`.
template <typename T>
sem::Vector* vec2() const {
typ::Vector vec2() const {
return vec2(Of<T>());
}
/// @return the tint AST type for a 3-element vector of the C type `T`.
template <typename T>
sem::Vector* vec3() const {
typ::Vector vec3() const {
return vec3(Of<T>());
}
/// @return the tint AST type for a 4-element vector of the C type `T`.
template <typename T>
sem::Type* vec4() const {
typ::Vector vec4() const {
return vec4(Of<T>());
}