[spirv-writer] Start emitting types

This CL starts the emitting of SPIR-V types. This CL adds code to emit
the `AliasType`, `BoolType`, `F32Type`, `I32Type`, `MatrixType`,
`U32Type`, `VectorType` and `VoidType`.

Bug: tint:5
Change-Id: Ic13026ca9006fc0a253d019b1a6dd984ae992fba
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/17561
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
dan sinclair
2020-03-24 15:03:29 +00:00
committed by dan sinclair
parent 7c6e8ded7d
commit 7a480f4313
11 changed files with 349 additions and 18 deletions

View File

@@ -20,7 +20,7 @@ namespace tint {
namespace ast {
namespace type {
MatrixType::MatrixType(Type* subtype, size_t rows, size_t columns)
MatrixType::MatrixType(Type* subtype, uint32_t rows, uint32_t columns)
: subtype_(subtype), rows_(rows), columns_(columns) {
assert(rows > 1);
assert(rows < 5);

View File

@@ -30,7 +30,7 @@ class MatrixType : public Type {
/// @param subtype type matrix type
/// @param rows the number of rows in the matrix
/// @param columns the number of columns in the matrix
MatrixType(Type* subtype, size_t rows, size_t columns);
MatrixType(Type* subtype, uint32_t rows, uint32_t columns);
/// Move constructor
MatrixType(MatrixType&&) = default;
~MatrixType() override;
@@ -41,9 +41,9 @@ class MatrixType : public Type {
/// @returns the type of the matrix
Type* type() const { return subtype_; }
/// @returns the number of rows in the matrix
size_t rows() const { return rows_; }
uint32_t rows() const { return rows_; }
/// @returns the number of columns in the matrix
size_t columns() const { return columns_; }
uint32_t columns() const { return columns_; }
/// @returns the name for this type
std::string type_name() const override {
@@ -53,8 +53,8 @@ class MatrixType : public Type {
private:
Type* subtype_ = nullptr;
size_t rows_ = 2;
size_t columns_ = 2;
uint32_t rows_ = 2;
uint32_t columns_ = 2;
};
} // namespace type

View File

@@ -63,7 +63,7 @@ class Type {
/// @returns true if the type is a void type
virtual bool IsVoid() const { return false; }
/// @returns the name for this type
/// @returns the name for this type. The |type_name| is unique over all types.
virtual std::string type_name() const = 0;
/// @returns the type as an alias type

View File

@@ -20,7 +20,7 @@ namespace tint {
namespace ast {
namespace type {
VectorType::VectorType(Type* subtype, size_t size)
VectorType::VectorType(Type* subtype, uint32_t size)
: subtype_(subtype), size_(size) {
assert(size_ > 1);
assert(size_ < 5);

View File

@@ -29,7 +29,7 @@ class VectorType : public Type {
/// Constructor
/// @param subtype the vector element type
/// @param size the number of elements in the vector
VectorType(Type* subtype, size_t size);
VectorType(Type* subtype, uint32_t size);
/// Move constructor
VectorType(VectorType&&) = default;
~VectorType() override;
@@ -40,7 +40,7 @@ class VectorType : public Type {
/// @returns the type of the vector elements
Type* type() const { return subtype_; }
/// @returns the size of the vector
size_t size() const { return size_; }
uint32_t size() const { return size_; }
/// @returns the name for th type
std::string type_name() const override {
@@ -49,7 +49,7 @@ class VectorType : public Type {
private:
Type* subtype_ = nullptr;
size_t size_ = 2;
uint32_t size_ = 2;
};
} // namespace type