Qt 4.8
|
Describes how a particular optimization pass should be carried out. More...
#include <qoptimizerframework_p.h>
Public Types | |
typedef QList< qint8 > | ExpressionMarker |
typedef QList< OptimizationPass::Ptr > | List |
enum | OperandsMatchMethod { Sequential = 1, AnyOrder } |
typedef QExplicitlySharedDataPointer< OptimizationPass > | Ptr |
Public Functions | |
OptimizationPass (const ExpressionIdentifier::Ptr &startID, const ExpressionIdentifier::List &operandIDs, const ExpressionMarker &sourceExpr, const ExpressionCreator::Ptr &resultCtor=ExpressionCreator::Ptr(), const OperandsMatchMethod matchMethod=Sequential) | |
Public Functions inherited from QSharedData | |
QSharedData () | |
Constructs a QSharedData object with a reference count of 0. More... | |
QSharedData (const QSharedData &) | |
Constructs a QSharedData object with reference count 0. More... | |
Public Variables | |
const ExpressionIdentifier::List | operandIdentifiers |
const OperandsMatchMethod | operandsMatchMethod |
const ExpressionCreator::Ptr | resultCreator |
const ExpressionMarker | sourceExpression |
const ExpressionIdentifier::Ptr | startIdentifier |
Public Variables inherited from QSharedData | |
QAtomicInt | ref |
Describes how a particular optimization pass should be carried out.
OptimizationPass is essentially a declaration, which describes how an optimization pass in the form of an AST rewrite should be done, by describing what that should be rewritten into what how.
Each OptimizationPass is applied to a "start" Expression. The Expression that qualifies as a start Expression for the OptimizationPass in question is determined by startIdentifier; if its ExpressionIdentifier::matches() function returns true
, the optimizer continues to apply this OptimizationPass.
After a start Expression has been found, it is verified if the operands matches as well by applying the ExpressionIdentifiers in operandIdentifiers to the start Expression's operands. Similarly, if the operands matches what operandIdentifiers requires, the optimizer continues to apply this OptimizationPass.
At this stage, it has been concluded that the OptimizationPass validly applies, and what now remains is to carry out the actual rewrite. The Expression rewritten to is the one returned by ExpressionCreator::create(), when invoked via the resultCreator variable.
How these components, startIdentifier, operandIdentifiers, sourceExpression, and resultCreator interacts with one another is described in more detail in the member documentation as well as the classes they are instances of.
Definition at line 182 of file qoptimizerframework_p.h.
An ExpressionMarker identifies an operand Expression relatively the start Expression by that each integer identifies a step in a descending AST walk. For example an ExpressionMarker with only one entry that is 0(zero), identifies the first operand of the start Expression. An ExpressionMarker containing 1, 2 in that order identifies the third operand of the second operand of the start Expression.
Definition at line 215 of file qoptimizerframework_p.h.
Definition at line 186 of file qoptimizerframework_p.h.
Definition at line 185 of file qoptimizerframework_p.h.
Enumerator | |
---|---|
Sequential | All operands must match in the same order the ExpressionMarkers do. |
AnyOrder | Matches if all operands are matched, regardless of their order. This is useful when an OptimizationPass is matching an Expression that has two operands and that both of them can appear on the left or right hand as long as it is those two. This comparison method only works when two operands needs to be matched. |
Definition at line 188 of file qoptimizerframework_p.h.
OptimizationPass::OptimizationPass | ( | const ExpressionIdentifier::Ptr & | startID, |
const ExpressionIdentifier::List & | operandIDs, | ||
const ExpressionMarker & | sourceExpr, | ||
const ExpressionCreator::Ptr & | resultCtor = ExpressionCreator::Ptr() , |
||
const OperandsMatchMethod | matchMethod = Sequential |
||
) |
Creates an OptimizationPass and sets its public variables to the corresponding values passed in this constructor.
Definition at line 56 of file qoptimizerframework.cpp.
const ExpressionIdentifier::List QPatternist::OptimizationPass::operandIdentifiers |
In order for an OptimizationPass to apply, the start Expression's operands must be matched with this list of ExpressionIdentifier instances. The first ExpressionIdentifier is applied to the first operand, the second ExpressionIdentifier to the second operand, and so forth until all operands have been iterated.
Entries in this list may be null
, and those signals that the corresponding operand is not constrained. For example, if the third ExpressionIdentifier in the list is null
, it signals that the third operand may be anykind of expression.
May be empty or contain an arbitrary amount of objects or null
pointers.
Definition at line 257 of file qoptimizerframework_p.h.
const OperandsMatchMethod QPatternist::OptimizationPass::operandsMatchMethod |
Definition at line 284 of file qoptimizerframework_p.h.
const ExpressionCreator::Ptr QPatternist::OptimizationPass::resultCreator |
This is the ExpressionCreator that will be used to create the Expression which is the result. ExpressionCreator::create() will be passed as operands the Expression that sourceExpression specify, if any.
If this variable is null
, the result Expression will be the one sourceExpression identifies.
Definition at line 282 of file qoptimizerframework_p.h.
const ExpressionMarker QPatternist::OptimizationPass::sourceExpression |
Identifies the expression that should be part of the new expression that this OptimizationPass rewrites to. If this list is empty, it means that the result is not derived from the existing tree, and that resultCreator will exclusively be used for creating the result Expression.
How the ExpressionMarker identifies an Expression is document in its documentation.
May be empty.
Definition at line 271 of file qoptimizerframework_p.h.
const ExpressionIdentifier::Ptr QPatternist::OptimizationPass::startIdentifier |
The ExpressionIdentifier that must the Expression this OptimizationPass concerns.
If this variable is null
, it means that the start Expression does not have to match any particular ExpressionIdentifier, but is fine as is.
One might wonder what the purpose of this startIdentifier is, considering that what start Expression an OptimizationPass can at all apply to is naturally determined by what Expression::optimizationPasses() re-implementation that returns this OptimizationPass. The reason is that in some cases an OptimizationPass nevertheless doesn't apply. For example, optimizations applying to a ValueComparison might depend on what operator that is in use.
May be null
or point to an ExpressionIdentifier.
Definition at line 242 of file qoptimizerframework_p.h.