Remove outermost loop parameter.
[official-gcc/graphite-test-results.git] / libpcp / pcp_expr_canonicalizer.h
blobbc0b337d77f8accec02380205b835b6c77e4c6f1
1 // Copyright (C) 2009 Free Software Foundation, Inc.
2 // Contributed by Jan Sjodin <jan.sjodin@amd.com>.
4 // This file is part of the Polyhedral Compilation Package Library (libpcp).
6 // Libpcp is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published by
8 // the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
11 // Libpcp is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with libpcp; see the file COPYING.LIB. If not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 // MA 02110-1301, USA.
21 // As a special exception, if you link this library with other files, some
22 // of which are compiled with GCC, to produce an executable, this library
23 // does not by itself cause the resulting executable to be covered by the
24 // GNU General Public License. This exception does not however invalidate
25 // any other reasons why the executable file might be covered by the GNU
26 // General Public License.
28 #ifndef _PCP_EXPR_CANONICALIZER_
29 #define _PCP_EXPR_CANONICALIZER_
30 #include "pcp.h"
31 #include "pcp_visitor.h"
32 #include "pcp_scalar_order.h"
33 #include "pcp_stack.h"
35 class PcpScalarContextStack : public PcpListStack<PcpExpr*>
37 public:
38 virtual PcpExpr* createBaseExpr();
39 PcpScalarContextStack(PcpScop* scop);
42 // Normali
43 class PcpExprCanonicalizer : public PcpVisitor
45 protected:
46 PcpScalarOrder* scalarOrder;
47 PcpScalarContextStack* scalarContextStack;
48 PcpExpr* canonicalizationBase;
50 virtual void setScalarOrder(PcpScalarOrder* scalarOrder);
51 virtual PcpScalarOrder* getScalarOrder();
53 virtual void setScalarContextStack(PcpScalarContextStack* scalarContextStack);
54 virtual PcpScalarContextStack* getScalarContextStack();
56 virtual PcpExpr* stripMultiplier(PcpExpr* expr);
57 virtual bool equal(PcpExpr* expr1, PcpExpr* expr2);
58 virtual bool less(PcpExpr* expr1, PcpExpr* expr2);
60 virtual PcpConstant* negateConstant(PcpConstant* constant);
61 virtual PcpConstant* addConstants(PcpConstant* constant1, PcpConstant* constant2);
62 virtual PcpConstant* addConstants(PcpConstant* constant1, int constant2);
63 virtual PcpConstant* addConstants(int constant1,int constant2);
64 virtual PcpExpr* addTerms(PcpExpr* expr1, PcpExpr* expr2);
65 virtual PcpArith* addSums(PcpArith* sum1, PcpArith* sum2);
67 virtual PcpArith* createUnaryArith(PcpArithOperator oper, PcpExpr* expr);
68 virtual PcpArith* createUnaryPlus(PcpExpr* expr);
69 virtual PcpArith* createUnaryMinus(PcpExpr* expr);
70 virtual bool sameScalarBase(PcpArith* factor1, PcpArith* factor2);
72 virtual PcpConstant* getCanonicalConstant(PcpArith* expr);
73 virtual PcpConstant* multiplyConstants(PcpConstant* constant1, PcpConstant* constant2);
74 virtual PcpArith* multiplyConstMul(PcpConstant* multiplier, PcpArith* multiply);
75 virtual PcpArith* multiplyScalar(PcpConstant* constant1, PcpExpr* scalar);
76 virtual PcpArith* multiplyFactors(PcpConstant* multiplier, PcpArith* sum);
77 virtual PcpArith* multiplyFactors(PcpArith* factor1, PcpArith* factor2);
78 virtual PcpArith* negateExpr(PcpArith* expr);
80 virtual PcpCompare* canonicalizeCompare(PcpCompare* compare);
81 virtual PcpBoolArith* createUnaryOr(PcpBoolExpr* boolExpr);
82 virtual void appendOperandsToBuilder(PcpBoolArithBuilder* builder,
83 PcpBoolArith* boolArith);
84 virtual PcpBoolArith* mergeOr(PcpBoolArith* or1, PcpBoolArith* or2);
85 virtual PcpBoolArith* createFlattenedAnd(PcpBoolExpr* boolExpr1, PcpBoolExpr* boolExpr2);
86 virtual PcpBoolArith* distributeAnd(PcpBoolArith* or1, PcpBoolArith* or2);
88 public:
89 virtual void visit(PcpScop* scop);
90 virtual void visit(PcpLoop* loop);
91 virtual void visit(PcpSequence* sequence);
92 virtual void visit(PcpGuard* guard);
93 virtual void visit(PcpCopy* copy);
94 virtual void visit(PcpUserStmt* userStmt);
95 virtual void visit(PcpArrayAccess* arrayAccess);
97 // Normalizes expressions to have the following form:
98 // +(e0, .. en), where each expression e is either constant ord or a
99 // multiplication of a constant with either a parameter or induction variable
100 // iv: *(c, iv).
101 virtual void setCanonicalizationBase(PcpExpr* expr);
102 virtual PcpExpr* getCanonicalizationBase();
104 virtual PcpArith* canonicalizeExpr(PcpExpr* expr);
105 virtual PcpArith* canonicalizeExprWithBase(PcpExpr* expr);
106 virtual PcpBoolArith* canonicalizeBoolExpr(PcpBoolExpr* boolExpr);
107 virtual void canonicalize(PcpScop* scop);
109 PcpExprCanonicalizer(PcpScalarOrder* scalarOrder);
112 #endif // _PCP_EXPR_CANONICALIZER_