Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: src/sksl/SkSLIRGenerator.h

Issue 2131223002: SkSL performance improvements (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/sksl/SkSLContext.h ('k') | src/sksl/SkSLIRGenerator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SKSL_IRGENERATOR 8 #ifndef SKSL_IRGENERATOR
9 #define SKSL_IRGENERATOR 9 #define SKSL_IRGENERATOR
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "ir/SkSLVarDeclaration.h" 46 #include "ir/SkSLVarDeclaration.h"
47 47
48 namespace SkSL { 48 namespace SkSL {
49 49
50 /** 50 /**
51 * Performs semantic analysis on an abstract syntax tree (AST) and produces the corresponding 51 * Performs semantic analysis on an abstract syntax tree (AST) and produces the corresponding
52 * (unoptimized) intermediate representation (IR). 52 * (unoptimized) intermediate representation (IR).
53 */ 53 */
54 class IRGenerator { 54 class IRGenerator {
55 public: 55 public:
56 IRGenerator(std::shared_ptr<SymbolTable> root, ErrorReporter& errorReporter) ; 56 IRGenerator(const Context* context, std::shared_ptr<SymbolTable> root,
57 ErrorReporter& errorReporter);
57 58
58 std::unique_ptr<VarDeclaration> convertVarDeclaration(const ASTVarDeclaratio n& decl, 59 std::unique_ptr<VarDeclaration> convertVarDeclaration(const ASTVarDeclaratio n& decl,
59 Variable::Storage stor age); 60 Variable::Storage stor age);
60 std::unique_ptr<FunctionDefinition> convertFunction(const ASTFunction& f); 61 std::unique_ptr<FunctionDefinition> convertFunction(const ASTFunction& f);
61 std::unique_ptr<Statement> convertStatement(const ASTStatement& statement); 62 std::unique_ptr<Statement> convertStatement(const ASTStatement& statement);
62 std::unique_ptr<Expression> convertExpression(const ASTExpression& expressio n); 63 std::unique_ptr<Expression> convertExpression(const ASTExpression& expressio n);
63 64
64 private: 65 private:
65 void pushSymbolTable(); 66 void pushSymbolTable();
66 void popSymbolTable(); 67 void popSymbolTable();
67 68
68 std::shared_ptr<Type> convertType(const ASTType& type); 69 const Type* convertType(const ASTType& type);
69 std::unique_ptr<Expression> call(Position position, 70 std::unique_ptr<Expression> call(Position position,
70 std::shared_ptr<FunctionDeclaration> functi on, 71 const FunctionDeclaration& function,
71 std::vector<std::unique_ptr<Expression>> ar guments); 72 std::vector<std::unique_ptr<Expression>> ar guments);
72 bool determineCallCost(std::shared_ptr<FunctionDeclaration> function, 73 bool determineCallCost(const FunctionDeclaration& function,
73 const std::vector<std::unique_ptr<Expression>>& argum ents, 74 const std::vector<std::unique_ptr<Expression>>& argum ents,
74 int* outCost); 75 int* outCost);
75 std::unique_ptr<Expression> call(Position position, std::unique_ptr<Expressi on> function, 76 std::unique_ptr<Expression> call(Position position, std::unique_ptr<Expressi on> function,
76 std::vector<std::unique_ptr<Expression>> ar guments); 77 std::vector<std::unique_ptr<Expression>> ar guments);
77 std::unique_ptr<Expression> coerce(std::unique_ptr<Expression> expr, 78 std::unique_ptr<Expression> coerce(std::unique_ptr<Expression> expr, const T ype& type);
78 std::shared_ptr<Type> type);
79 std::unique_ptr<Block> convertBlock(const ASTBlock& block); 79 std::unique_ptr<Block> convertBlock(const ASTBlock& block);
80 std::unique_ptr<Statement> convertBreak(const ASTBreakStatement& b); 80 std::unique_ptr<Statement> convertBreak(const ASTBreakStatement& b);
81 std::unique_ptr<Expression> convertConstructor(Position position, 81 std::unique_ptr<Expression> convertConstructor(Position position,
82 std::shared_ptr<Type> type, 82 const Type& type,
83 std::vector<std::unique_ptr<E xpression>> params); 83 std::vector<std::unique_ptr<E xpression>> params);
84 std::unique_ptr<Statement> convertContinue(const ASTContinueStatement& c); 84 std::unique_ptr<Statement> convertContinue(const ASTContinueStatement& c);
85 std::unique_ptr<Statement> convertDiscard(const ASTDiscardStatement& d); 85 std::unique_ptr<Statement> convertDiscard(const ASTDiscardStatement& d);
86 std::unique_ptr<Statement> convertDo(const ASTDoStatement& d); 86 std::unique_ptr<Statement> convertDo(const ASTDoStatement& d);
87 std::unique_ptr<Expression> convertBinaryExpression(const ASTBinaryExpressio n& expression); 87 std::unique_ptr<Expression> convertBinaryExpression(const ASTBinaryExpressio n& expression);
88 std::unique_ptr<Extension> convertExtension(const ASTExtension& e); 88 std::unique_ptr<Extension> convertExtension(const ASTExtension& e);
89 std::unique_ptr<Statement> convertExpressionStatement(const ASTExpressionSta tement& s); 89 std::unique_ptr<Statement> convertExpressionStatement(const ASTExpressionSta tement& s);
90 std::unique_ptr<Statement> convertFor(const ASTForStatement& f); 90 std::unique_ptr<Statement> convertFor(const ASTForStatement& f);
91 std::unique_ptr<Expression> convertIdentifier(const ASTIdentifier& identifie r); 91 std::unique_ptr<Expression> convertIdentifier(const ASTIdentifier& identifie r);
92 std::unique_ptr<Statement> convertIf(const ASTIfStatement& s); 92 std::unique_ptr<Statement> convertIf(const ASTIfStatement& s);
93 std::unique_ptr<Expression> convertIndex(std::unique_ptr<Expression> base, 93 std::unique_ptr<Expression> convertIndex(std::unique_ptr<Expression> base,
94 const ASTExpression& index); 94 const ASTExpression& index);
95 std::unique_ptr<InterfaceBlock> convertInterfaceBlock(const ASTInterfaceBloc k& s); 95 std::unique_ptr<InterfaceBlock> convertInterfaceBlock(const ASTInterfaceBloc k& s);
96 Modifiers convertModifiers(const ASTModifiers& m); 96 Modifiers convertModifiers(const ASTModifiers& m);
97 std::unique_ptr<Expression> convertPrefixExpression(const ASTPrefixExpressio n& expression); 97 std::unique_ptr<Expression> convertPrefixExpression(const ASTPrefixExpressio n& expression);
98 std::unique_ptr<Statement> convertReturn(const ASTReturnStatement& r); 98 std::unique_ptr<Statement> convertReturn(const ASTReturnStatement& r);
99 std::unique_ptr<Expression> convertSuffixExpression(const ASTSuffixExpressio n& expression); 99 std::unique_ptr<Expression> convertSuffixExpression(const ASTSuffixExpressio n& expression);
100 std::unique_ptr<Expression> convertField(std::unique_ptr<Expression> base, 100 std::unique_ptr<Expression> convertField(std::unique_ptr<Expression> base,
101 const std::string& field); 101 const std::string& field);
102 std::unique_ptr<Expression> convertSwizzle(std::unique_ptr<Expression> base, 102 std::unique_ptr<Expression> convertSwizzle(std::unique_ptr<Expression> base,
103 const std::string& fields); 103 const std::string& fields);
104 std::unique_ptr<Expression> convertTernaryExpression(const ASTTernaryExpress ion& expression); 104 std::unique_ptr<Expression> convertTernaryExpression(const ASTTernaryExpress ion& expression);
105 std::unique_ptr<Statement> convertVarDeclarationStatement(const ASTVarDeclar ationStatement& s); 105 std::unique_ptr<Statement> convertVarDeclarationStatement(const ASTVarDeclar ationStatement& s);
106 std::unique_ptr<Statement> convertWhile(const ASTWhileStatement& w); 106 std::unique_ptr<Statement> convertWhile(const ASTWhileStatement& w);
107 107
108 void checkValid(const Expression& expr); 108 void checkValid(const Expression& expr);
109 void markReadFrom(std::shared_ptr<Variable> var); 109 void markReadFrom(const Variable& var);
110 void markWrittenTo(const Expression& expr); 110 void markWrittenTo(const Expression& expr);
111 111
112 std::shared_ptr<FunctionDeclaration> fCurrentFunction; 112 const Context& fContext;
113 const FunctionDeclaration* fCurrentFunction;
113 std::shared_ptr<SymbolTable> fSymbolTable; 114 std::shared_ptr<SymbolTable> fSymbolTable;
114 ErrorReporter& fErrors; 115 ErrorReporter& fErrors;
115 116
116 friend class AutoSymbolTable; 117 friend class AutoSymbolTable;
117 friend class Compiler; 118 friend class Compiler;
118 }; 119 };
119 120
120 } 121 }
121 122
122 #endif 123 #endif
OLDNEW
« no previous file with comments | « src/sksl/SkSLContext.h ('k') | src/sksl/SkSLIRGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698