Add location into sem::Parameter.

This CL adds a `location` value into the `Parameter` sem object.
This will be set if the parameter has an `@location` attribute
applied.

Bug: tint:1633
Change-Id: I55cb5cbda951f70d071ebe1400865b63af1fb20a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101065
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair
2022-09-06 16:05:54 +00:00
committed by Dawn LUCI CQ
parent 766a458f53
commit 72340d00ce
4 changed files with 53 additions and 6 deletions

View File

@@ -73,11 +73,13 @@ Parameter::Parameter(const ast::Parameter* declaration,
ast::StorageClass storage_class,
ast::Access access,
const ParameterUsage usage /* = ParameterUsage::kNone */,
sem::BindingPoint binding_point /* = {} */)
sem::BindingPoint binding_point /* = {} */,
std::optional<uint32_t> location /* = std::nullopt */)
: Base(declaration, type, EvaluationStage::kRuntime, storage_class, access, nullptr),
index_(index),
usage_(usage),
binding_point_(binding_point) {}
binding_point_(binding_point),
location_(location) {}
Parameter::~Parameter() = default;

View File

@@ -15,6 +15,7 @@
#ifndef SRC_TINT_SEM_VARIABLE_H_
#define SRC_TINT_SEM_VARIABLE_H_
#include <optional>
#include <utility>
#include <vector>
@@ -189,13 +190,15 @@ class Parameter final : public Castable<Parameter, Variable> {
/// @param access the variable access control type
/// @param usage the semantic usage for the parameter
/// @param binding_point the optional resource binding point of the parameter
/// @param location the location value, if set
Parameter(const ast::Parameter* declaration,
uint32_t index,
const sem::Type* type,
ast::StorageClass storage_class,
ast::Access access,
const ParameterUsage usage = ParameterUsage::kNone,
sem::BindingPoint binding_point = {});
sem::BindingPoint binding_point = {},
std::optional<uint32_t> location = std::nullopt);
/// Destructor
~Parameter() override;
@@ -222,12 +225,16 @@ class Parameter final : public Castable<Parameter, Variable> {
/// @returns the resource binding point for the parameter
sem::BindingPoint BindingPoint() const { return binding_point_; }
/// @returns the location value for the parameter, if set
std::optional<uint32_t> Location() const { return location_; }
private:
const uint32_t index_;
const ParameterUsage usage_;
CallTarget const* owner_ = nullptr;
const sem::Node* shadows_ = nullptr;
const sem::BindingPoint binding_point_;
const std::optional<uint32_t> location_;
};
/// VariableUser holds the semantic information for an identifier expression