Flutter Engine
The Flutter Engine
SkSLProgramUsage.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SKSL_PROGRAMUSAGE
9#define SKSL_PROGRAMUSAGE
10
12#include "src/core/SkTHash.h"
13
14namespace SkSL {
15
16class Expression;
17class FunctionDeclaration;
18class ProgramElement;
19class Statement;
20class Symbol;
21class Variable;
22
23/**
24 * Side-car class holding mutable information about a Program's IR
25 */
27public:
29 int fVarExists = 0; // if this is zero, the Variable might have already been deleted
30 int fRead = 0;
31 int fWrite = 0;
32 };
33 VariableCounts get(const Variable&) const;
34 bool isDead(const Variable&) const;
35
36 int get(const FunctionDeclaration&) const;
37
38 void add(const Expression* expr);
39 void add(const Statement* stmt);
40 void add(const ProgramElement& element);
41 void remove(const Expression* expr);
42 void remove(const Statement* stmt);
43 void remove(const ProgramElement& element);
44
45 bool operator==(const ProgramUsage& that) const;
46 bool operator!=(const ProgramUsage& that) const { return !(*this == that); }
47
48 // All Symbol* objects in fStructCounts must be StructType*.
50 // All Symbol* objects in fCallCounts must be FunctionDeclaration*.
53};
54
55} // namespace SkSL
56
57#endif
void add(const Expression *expr)
VariableCounts get(const Variable &) const
bool operator==(const ProgramUsage &that) const
bool operator!=(const ProgramUsage &that) const
skia_private::THashMap< const Symbol *, int > fStructCounts
void remove(const Expression *expr)
bool isDead(const Variable &) const
skia_private::THashMap< const Variable *, VariableCounts > fVariableCounts
skia_private::THashMap< const Symbol *, int > fCallCounts