resolver: Track global uses in function decorations

Fixed: tint:1320
Change-Id: Ib92c37d4de0641d11e508be4d8e05d641e808be9
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70662
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2021-11-23 21:46:48 +00:00
committed by Tint LUCI CQ
parent b05e185a36
commit d1f0a14563
7 changed files with 65 additions and 25 deletions

View File

@@ -30,11 +30,11 @@ namespace sem {
Function::Function(const ast::Function* declaration,
Type* return_type,
std::vector<Parameter*> parameters,
sem::WorkgroupSize workgroup_size)
std::vector<Parameter*> parameters)
: Base(return_type, utils::ToConstPtrVec(parameters)),
declaration_(declaration),
workgroup_size_(std::move(workgroup_size)) {
workgroup_size_{WorkgroupDimension{1}, WorkgroupDimension{1},
WorkgroupDimension{1}} {
for (auto* parameter : parameters) {
parameter->SetOwner(this);
}

View File

@@ -62,11 +62,9 @@ class Function : public Castable<Function, CallTarget> {
/// @param declaration the ast::Function
/// @param return_type the return type of the function
/// @param parameters the parameters to the function
/// @param workgroup_size the workgroup size
Function(const ast::Function* declaration,
Type* return_type,
std::vector<Parameter*> parameters,
sem::WorkgroupSize workgroup_size);
std::vector<Parameter*> parameters);
/// Destructor
~Function() override;
@@ -77,6 +75,12 @@ class Function : public Castable<Function, CallTarget> {
/// @returns the workgroup size {x, y, z} for the function.
const sem::WorkgroupSize& WorkgroupSize() const { return workgroup_size_; }
/// Sets the workgroup size {x, y, z} for the function.
/// @param workgroup_size the new workgroup size of the function
void SetWorkgroupSize(sem::WorkgroupSize workgroup_size) {
workgroup_size_ = std::move(workgroup_size);
}
/// @returns all directly referenced global variables
const utils::UniqueVector<const GlobalVariable*>& DirectlyReferencedGlobals()
const {
@@ -243,8 +247,8 @@ class Function : public Castable<Function, CallTarget> {
bool multisampled) const;
const ast::Function* const declaration_;
const sem::WorkgroupSize workgroup_size_;
sem::WorkgroupSize workgroup_size_;
utils::UniqueVector<const GlobalVariable*> directly_referenced_globals_;
utils::UniqueVector<const GlobalVariable*> transitively_referenced_globals_;
utils::UniqueVector<const Function*> transitively_called_functions_;