mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 06:45:16 +00:00
spirv parser: create ast types along with sem types
The spirv parser now creates ast types along with sem types via typ::Type. All sem::Type* were replaced with typ::Type, and its `ast` member is used over the `sem` member to make it easier to migrate to ast-only. The parser was written to take advantage of the fact that types were resolved to semantic types during parsing. For instance, a mapping of spirv typeid to sem::Type* was used throughout (`id_to_type_`) to resolve types once, and to support type aliasing. Since the goal is to only create AST types, and to resolve only in the Resolver, I made many changes to remove this dependency on semantic types. For instance, we now always call ConvertType(typeid) instead of looking up via id_to_type. Similarly, the `signed_type_for_` and `unsigned_type_for_` maps were replaced with `UnsignedTypeFor` and `SignedTypeFor` functions. Bug: tint:724 Change-Id: I3aee3928834febd71b473d6a8d8cb77b1ac94e21 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49542 Reviewed-by: David Neto <dneto@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
b6831c3395
commit
1b898d56b4
@@ -46,6 +46,12 @@ class Type : public Castable<Type, Node> {
|
||||
/// @returns the pointee type if this is a pointer, `this` otherwise
|
||||
Type* UnwrapPtrIfNeeded();
|
||||
|
||||
/// @returns the most deeply nested aliased type if this is an alias, `this`
|
||||
/// otherwise
|
||||
const Type* UnwrapAliasIfNeeded() const {
|
||||
return const_cast<Type*>(this)->UnwrapAliasIfNeeded();
|
||||
}
|
||||
|
||||
/// @returns the most deeply nested aliased type if this is an alias, `this`
|
||||
/// otherwise
|
||||
Type* UnwrapAliasIfNeeded();
|
||||
@@ -58,6 +64,16 @@ class Type : public Castable<Type, Node> {
|
||||
/// @returns the completely unaliased type.
|
||||
Type* UnwrapIfNeeded();
|
||||
|
||||
/// Removes all levels of aliasing and access control.
|
||||
/// This is just enough to assist with WGSL translation
|
||||
/// in that you want see through one level of pointer to get from an
|
||||
/// identifier-like expression as an l-value to its corresponding r-value,
|
||||
/// plus see through the wrappers on either side.
|
||||
/// @returns the completely unaliased type.
|
||||
const Type* UnwrapIfNeeded() const {
|
||||
return const_cast<Type*>(this)->UnwrapIfNeeded();
|
||||
}
|
||||
|
||||
/// Returns the type found after:
|
||||
/// - removing all layers of aliasing and access control if they exist, then
|
||||
/// - removing the pointer, if it exists, then
|
||||
@@ -65,6 +81,13 @@ class Type : public Castable<Type, Node> {
|
||||
/// @returns the unwrapped type
|
||||
Type* UnwrapAll();
|
||||
|
||||
/// Returns the type found after:
|
||||
/// - removing all layers of aliasing and access control if they exist, then
|
||||
/// - removing the pointer, if it exists, then
|
||||
/// - removing all further layers of aliasing or access control, if they exist
|
||||
/// @returns the unwrapped type
|
||||
const Type* UnwrapAll() const { return const_cast<Type*>(this)->UnwrapAll(); }
|
||||
|
||||
/// @returns true if this type is a scalar
|
||||
bool is_scalar() const;
|
||||
/// @returns true if this type is a float scalar
|
||||
|
||||
Reference in New Issue
Block a user