37 using namespace SVFUtil;
61 SVFIR* PAGBuilderFromFile::build()
65 ifstream myfile(file.c_str());
70 getline(myfile, line);
72 u32_t token_count = 0;
74 istringstream ss(line);
84 else if (token_count == 2)
88 istringstream ss(line);
91 outs() <<
"reading node :" << nodeId <<
"\n";
93 pag->addDummyValNode(nodeId);
94 else if (nodetype ==
"o")
96 const MemObj* mem = pag->addDummyMemObj(nodeId,
nullptr);
97 pag->addFIObjNode(mem);
100 assert(
false &&
"format not support, pls specify node type");
104 else if (token_count == 4)
110 istringstream ss(line);
115 outs() <<
"reading edge :" << nodeSrc <<
" " << edge <<
" "
116 << nodeDst <<
" offsetOrCSId=" << offsetOrCSId <<
" \n";
117 addEdge(nodeSrc, nodeDst, offsetOrCSId, edge);
123 outs() <<
"format not supported, token count = "
124 << token_count <<
"\n";
125 assert(
false &&
"format not supported");
133 outs() <<
"Unable to open file\n";
137 for(
u32_t i = 0; i < lower_bound; i++)
140 pag->setNodeNumAfterPAGBuild(pag->getTotalNodeNum());
153 PAGNode* srcNode = pag->getGNode(srcID);
154 PAGNode* dstNode = pag->getGNode(dstID);
157 assert(SVFUtil::isa<ValVar>(dstNode) &&
"dst not an value node?");
159 assert(SVFUtil::isa<ObjVar>(srcNode) &&
"src not an value node?");
161 assert(!SVFUtil::isa<ObjVar>(srcNode) &&
"src not an object node?");
165 pag->addAddrStmt(srcID, dstID);
167 if (edge.rfind(
"copy-", 0) == 0)
173 if (opType ==
"COPYVAL")
175 pag->addCopyStmt(srcID, dstID, CopyStmt::COPYVAL);
177 else if (opType ==
"ZEXT")
179 pag->addCopyStmt(srcID, dstID, CopyStmt::ZEXT);
181 else if (opType ==
"SEXT")
183 pag->addCopyStmt(srcID, dstID, CopyStmt::SEXT);
185 else if (opType ==
"BITCAST")
187 pag->addCopyStmt(srcID, dstID, CopyStmt::BITCAST);
189 else if (opType ==
"TRUNC")
191 pag->addCopyStmt(srcID, dstID, CopyStmt::TRUNC);
193 else if (opType ==
"FPTRUNC")
195 pag->addCopyStmt(srcID, dstID, CopyStmt::FPTRUNC);
197 else if (opType ==
"FPTOUI")
199 pag->addCopyStmt(srcID, dstID, CopyStmt::FPTOUI);
201 else if (opType ==
"FPTOSI")
203 pag->addCopyStmt(srcID, dstID, CopyStmt::FPTOSI);
205 else if (opType ==
"UITOFP")
207 pag->addCopyStmt(srcID, dstID, CopyStmt::UITOFP);
209 else if (opType ==
"SITOFP")
211 pag->addCopyStmt(srcID, dstID, CopyStmt::SITOFP);
213 else if (opType ==
"INTTOPTR")
215 pag->addCopyStmt(srcID, dstID, CopyStmt::INTTOPTR);
217 else if (opType ==
"PTRTOINT")
219 pag->addCopyStmt(srcID, dstID, CopyStmt::PTRTOINT);
223 assert(
false &&
"format not support, can not create such edge");
226 else if (edge ==
"load")
227 pag->addLoadStmt(srcID, dstID);
228 else if (edge ==
"store")
229 pag->addStoreStmt(srcID, dstID,
nullptr);
230 else if (edge ==
"gep")
231 pag->addNormalGepStmt(srcID, dstID,
AccessPath(offsetOrCSId));
232 else if (edge ==
"variant-gep")
233 pag->addVariantGepStmt(srcID, dstID,
AccessPath(offsetOrCSId));
234 else if (edge ==
"call")
235 pag->addEdge(srcNode, dstNode,
new CallPE(srcNode, dstNode,
nullptr,
nullptr));
236 else if (edge ==
"ret")
237 pag->addEdge(srcNode, dstNode,
new RetPE(srcNode, dstNode,
nullptr,
nullptr));
238 else if (edge ==
"cmp")
239 pag->addCmpStmt(srcID, dstID, dstID, dstID);
240 else if (edge ==
"binary-op")
241 pag->addBinaryOPStmt(srcID, dstID, dstID, dstID);
242 else if (edge ==
"unary-op")
243 pag->addUnaryOPStmt(srcID, dstID, dstID);
244 else if (edge ==
"phi")
245 assert(
false &&
"fix phi here!");
246 else if (edge ==
"select")
247 assert(
false &&
"fix select here!");
248 else if (edge ==
"branch")
250 assert(
false &&
"fix successors here!");
254 assert(
false &&
"format not support, can not create such edge");
static u32_t gepNodeNumIndex
std::ostream & outs()
Overwrite llvm::outs()