00001
00022 #ifndef MPICFGIRInterface_h
00023 #define MPICFGIRInterface_h
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <iostream>
00033 #include <map>
00034 #include <list>
00035
00036 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00037 #include <OpenAnalysis/IRInterface/IRHandles.hpp>
00038 #include <OpenAnalysis/IRInterface/ConstValBasicInterface.hpp>
00039 #include <OpenAnalysis/IRInterface/ConstValIntInterface.hpp>
00040 #include <OpenAnalysis/IRInterface/EvalToConstVisitorIRInterface.hpp>
00041 #include <OpenAnalysis/ExprTree/ExprTree.hpp>
00042
00043
00044 #include "CFGIRInterface.hpp"
00045
00046 namespace OA {
00047 namespace MPICFG {
00048
00051
00052
00053
00054
00055
00056 enum IRProcType {
00057 MPI_NONE,
00058 MPI_OTHER,
00059 MPI_INIT,
00060 MPI_COMM_RANK,
00061 MPI_COMM_SIZE,
00062 MPI_COMM_DUP,
00063 MPI_COMM_SPLIT,
00064 MPI_SEND,
00065 MPI_RECV,
00066 MPI_BCAST,
00067 MPI_REDUCE,
00068 MPI_FINALIZE
00069 };
00070
00072
00073
00074
00075 enum IRParamType {
00076 BUF,
00077 COLOR,
00078 COMM,
00079 COUNT,
00080 DATATYPE,
00081 DEST,
00082 GROUP,
00083 IERROR,
00084 KEY,
00085 NEWCOMM,
00086 OP,
00087 RANK,
00088 RECVBUF,
00089 ROOT,
00090 SENDBUF,
00091 SIZE,
00092 SOURCE,
00093 STATUS,
00094 TAG
00095 };
00096
00097
00098
00099
00100
00101 typedef std::pair<bool,OA_ptr<ConstValBasicInterface> > MaybeConstValue;
00102
00103
00104
00105
00106 enum IRRankVarStmtType {
00107 RANK_NO_STMT,
00108 RANK_ANY_STMT,
00109 RANK_DEF_STMT
00110 };
00111
00112 enum IRCopyStmtType {
00113 COPY_NO_STMT,
00114 COPY_ANY_STMT,
00115 COPY_STMT
00116 };
00117
00118
00119 class CopyStmtPairIterator {
00120 public:
00121 CopyStmtPairIterator() {}
00122 virtual ~CopyStmtPairIterator() {}
00123
00124 virtual MemRefHandle currentSource() const = 0;
00125 virtual MemRefHandle currentTarget() const = 0;
00126
00127 virtual bool isValid() const = 0;
00128
00129 virtual void operator++() = 0;
00130 void operator++(int) { ++*this; }
00131 };
00132
00133
00134
00135
00136
00137
00138 enum LatticeType {TOP, VALUE, BOTTOM};
00139
00140
00141
00142
00143
00144 enum RelOp {GREATER,LESSER,EQUAL,GREATER_EQUAL,LESSER_EQUAL,NOT_EQUAL};
00145
00146
00147 enum BoolOp {AND, OR};
00148
00149
00150
00151
00157 class MPICFGIRInterface : public virtual IRHandlesIRInterface,
00158 public virtual EvalToConstVisitorIRInterface
00159 {
00160 public:
00161 MPICFGIRInterface() { }
00162 virtual ~MPICFGIRInterface() { }
00163
00164
00165
00166
00167
00170 virtual OA_ptr<IRStmtIterator> getStmtIterator(ProcHandle h) = 0;
00171
00173 virtual OA_ptr<IRCallsiteIterator> getCallsites(StmtHandle h) = 0;
00174
00175
00176 virtual OA_ptr<IRCallsiteParamIterator> getCallsiteParams(ExprHandle h) = 0;
00177
00178
00179
00180
00181
00183 virtual SymHandle getSymHandle(ExprHandle expr) = 0;
00184
00186 virtual SymHandle getProcSymHandle(ProcHandle h) = 0;
00187
00188
00189
00190
00191
00193 virtual std::string toString(const SymHandle h) = 0;
00194
00196 virtual std::string toString(const ExprHandle h) = 0;
00197
00199 virtual OA_ptr<ExprTree> getExprTree(ExprHandle h) = 0;
00200
00201
00202
00203
00204
00207 virtual IRProcType getMPICFGProcType(SymHandle h) = 0;
00208
00212 virtual bool isMPICFGAnyTag(ConstValHandle h) = 0;
00213
00217 virtual bool isMPICFGAnyTag(ConstSymHandle h) = 0;
00218
00222 virtual bool isMPICFGAnyTag(OA_ptr<ConstValBasicInterface> c) = 0;
00223
00227 virtual bool isMPICFGAnySource(ConstValHandle h) = 0;
00228
00232 virtual bool isMPICFGAnySource(ConstSymHandle h) = 0;
00233
00237 virtual bool isMPICFGAnySource(OA_ptr<ConstValBasicInterface> c) = 0;
00238
00239
00240
00241
00242
00243
00244
00245
00247
00248 virtual ExprHandle getMPICFGCommParam(OA::ExprHandle h) = 0;
00249
00251
00252 virtual ExprHandle getMPICFGDataTypeParam(OA::ExprHandle h) = 0;
00253
00255
00256 virtual ExprHandle getMPICFGDestParam(OA::ExprHandle h) = 0;
00257
00259
00260 virtual ExprHandle getMPICFGGroupParam(OA::ExprHandle h) = 0;
00261
00263
00264 virtual ExprHandle getMPICFGOpParam(OA::ExprHandle h) = 0;
00265
00267
00268 virtual ExprHandle getMPICFGRankParam(OA::ExprHandle h) = 0;
00269
00271
00272 virtual ExprHandle getMPICFGRootParam(OA::ExprHandle h) = 0;
00273
00275
00276 virtual ExprHandle getMPICFGSizeParam(OA::ExprHandle h) = 0;
00277
00279
00280 virtual ExprHandle getMPICFGSourceParam(OA::ExprHandle h) = 0;
00281
00283
00284 virtual ExprHandle getMPICFGTagParam(OA::ExprHandle h) = 0;
00285
00286
00287
00288
00289
00290
00291
00292 virtual void dumpMPICFGparam(ExprHandle h, std::ostream& os) = 0;
00293
00295
00296 virtual int returnOpEnumValInt(OA::OpHandle op) = 0;
00297
00300 virtual void dump(StmtHandle stmt, std::ostream& os)
00301 { os << "Override CFGIRInterfaceDefault::dump(StmtHandle,os)"; }
00302
00304
00305 virtual std::string toString(OA_ptr<OA::ConstValBasicInterface> cvPtr) = 0;
00306
00307
00308
00309
00310
00312
00313
00314
00316 virtual IRRankVarStmtType getMPICFGRankVarStmtType(OA::StmtHandle h) = 0;
00317
00321 virtual MemRefHandle getMPICFGRankDefMemRef(OA::StmtHandle h) = 0;
00322
00324 virtual StmtHandle getStmtFromMemRef(OA::MemRefHandle h) = 0;
00325
00329 virtual OA_ptr<MemRefHandleIterator> getAllMemRefs(StmtHandle stmt) = 0;
00330
00334 virtual OA_ptr<MemRefHandleIterator> getDefMemRefs(StmtHandle stmt) = 0;
00335
00339 virtual OA_ptr<MemRefHandleIterator> getUseMemRefs(StmtHandle stmt) = 0;
00340
00342 virtual std::string toString(const StmtHandle h) = 0;
00343
00345 virtual std::string toString(const MemRefHandle h) = 0;
00346
00349 virtual OA_ptr<ConstValBasicInterface> getConstValBasic(ConstSymHandle c) = 0;
00350
00353 virtual OA_ptr<ConstValBasicInterface> getConstValBasic(ConstValHandle c) = 0;
00354
00356 virtual IRCopyStmtType getCopyStmtType(OA::StmtHandle h) = 0;;
00357
00361 virtual OA_ptr<CopyStmtPairIterator>
00362 getCopyStmtPairIterator(OA::StmtHandle h) = 0;
00363
00364
00365
00366
00367
00371 virtual bool isaRelOp(OA::OpHandle h) = 0;
00372 virtual OA::MPICFG::RelOp getRelOp(OA::OpHandle h) = 0;
00373
00376 virtual OA_ptr<ConstValIntInterface>
00377 getConstValInt(OA_ptr<ConstValBasicInterface> c) =0;
00378
00380 virtual ExprHandle getLoopCondition(OA::StmtHandle h) =0;
00381 virtual ExprHandle getCondition(OA::StmtHandle h) =0;
00382 virtual ExprHandle getSMultiCondition (OA::StmtHandle h, int bodyIndex) =0;
00383 virtual ExprHandle getSMultiTest(OA::StmtHandle h) =0;
00384 virtual ExprHandle getUMultiCondition(OA::StmtHandle h, int targetIndex) =0;
00385 virtual ExprHandle getUMultiTest(OA::StmtHandle h) =0;
00386
00387
00388 virtual int numMultiCases(OA::StmtHandle h)=0;
00389 virtual int numUMultiTargets(OA::StmtHandle h)=0;
00390
00392 virtual CFG::IRStmtType getCFGStmtType(StmtHandle h) = 0;
00393
00396 virtual OA_ptr<OA::ConstValBasicInterface>
00397 getConstFromSwitchCase(OA::ExprHandle h) = 0;
00398
00399
00400
00401
00402
00404
00405
00406
00407
00408 };
00409
00410
00411 }
00412 }
00413
00414 #endif // MPICFGIRInterface_h