aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLIRGenerator.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-01-19 10:44:45 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-19 16:17:36 +0000
commitf54b07121f81a56145fb118a2e18841fc135717d (patch)
tree088966a79e4f01641af5f198f985b07b9144b267 /src/sksl/SkSLIRGenerator.h
parent189098e70967c05c8810299b4afa325736a6565e (diff)
Added constant propagation and better variable liveness tracking to
skslc. This allows skslc to track the values of variables with constant values across multiple statements and replace variable references with constant values where appropriate. The improved liveness tracking allows skslc to realize that a variable is no longer alive if all references to it have been replaced. It is not yet doing much with this information; better dead code elimination is coming in a followup change. BUG=skia: Change-Id: I6bf267d478b769caf0063ac3597dc16bbe618cb4 Reviewed-on: https://skia-review.googlesource.com/7033 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'src/sksl/SkSLIRGenerator.h')
-rw-r--r--src/sksl/SkSLIRGenerator.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/sksl/SkSLIRGenerator.h b/src/sksl/SkSLIRGenerator.h
index 13b20fbbcc..2ffcb0df26 100644
--- a/src/sksl/SkSLIRGenerator.h
+++ b/src/sksl/SkSLIRGenerator.h
@@ -88,7 +88,16 @@ public:
std::unique_ptr<ModifiersDeclaration> convertModifiersDeclaration(
const ASTModifiersDeclaration& m);
+ /**
+ * If both operands are compile-time constants and can be folded, returns an expression
+ * representing the folded value. Otherwise, returns null. Note that unlike most other functions
+ * here, null does not represent a compilation error.
+ */
+ std::unique_ptr<Expression> constantFold(const Expression& left,
+ Token::Kind op,
+ const Expression& right) const;
Program::Inputs fInputs;
+ const Context& fContext;
private:
/**
@@ -124,11 +133,6 @@ private:
std::unique_ptr<Statement> convertDiscard(const ASTDiscardStatement& d);
std::unique_ptr<Statement> convertDo(const ASTDoStatement& d);
std::unique_ptr<Expression> convertBinaryExpression(const ASTBinaryExpression& expression);
- // Returns null if it cannot fold the expression. Note that unlike most other functions here, a
- // null return does not represent a compilation error.
- std::unique_ptr<Expression> constantFold(const Expression& left,
- Token::Kind op,
- const Expression& right);
std::unique_ptr<Extension> convertExtension(const ASTExtension& e);
std::unique_ptr<Statement> convertExpressionStatement(const ASTExpressionStatement& s);
std::unique_ptr<Statement> convertFor(const ASTForStatement& f);
@@ -151,10 +155,8 @@ private:
std::unique_ptr<Statement> convertWhile(const ASTWhileStatement& w);
void checkValid(const Expression& expr);
- void markReadFrom(const Variable& var);
- void markWrittenTo(const Expression& expr);
+ void markWrittenTo(const Expression& expr, bool readWrite);
- const Context& fContext;
const FunctionDeclaration* fCurrentFunction;
const Program::Settings* fSettings;
std::unordered_map<SkString, CapValue> fCapsMap;