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,
nullptr);
94 else if (nodetype ==
"o")
96 pag->addFIObjNode(nodeId,
pag->createObjTypeInfo(
nullptr),
nullptr);
99 assert(
false &&
"format not support, pls specify node type");
103 else if (token_count == 4)
109 istringstream ss(line);
114 outs() <<
"reading edge :" << nodeSrc <<
" " << edge <<
" "
115 << nodeDst <<
" offsetOrCSId=" << offsetOrCSId <<
" \n";
116 addEdge(nodeSrc, nodeDst, offsetOrCSId, edge);
122 outs() <<
"format not supported, token count = "
123 << token_count <<
"\n";
124 assert(
false &&
"format not supported");
132 outs() <<
"Unable to open file\n";
136 for(
u32_t i = 0; i < lower_bound; i++)
139 pag->setNodeNumAfterPAGBuild(
pag->getTotalNodeNum());
148 APOffset offsetOrCSId, std::string edge)
164 pag->addAddrStmt(srcID, dstID);
166 if (edge.rfind(
"copy-", 0) == 0)
170 std::string opType = edge.substr(5);
172 if (opType ==
"COPYVAL")
176 else if (opType ==
"ZEXT")
180 else if (opType ==
"SEXT")
184 else if (opType ==
"BITCAST")
188 else if (opType ==
"TRUNC")
192 else if (opType ==
"FPTRUNC")
196 else if (opType ==
"FPTOUI")
200 else if (opType ==
"FPTOSI")
204 else if (opType ==
"UITOFP")
208 else if (opType ==
"SITOFP")
212 else if (opType ==
"INTTOPTR")
216 else if (opType ==
"PTRTOINT")
222 assert(
false &&
"format not support, can not create such edge");
225 else if (edge ==
"load")
226 pag->addLoadStmt(srcID, dstID);
227 else if (edge ==
"store")
228 pag->addStoreStmt(srcID, dstID,
nullptr);
229 else if (edge ==
"gep")
230 pag->addNormalGepStmt(srcID, dstID,
AccessPath(offsetOrCSId));
231 else if (edge ==
"variant-gep")
232 pag->addVariantGepStmt(srcID, dstID,
AccessPath(offsetOrCSId));
233 else if (edge ==
"call")
235 else if (edge ==
"ret")
236 pag->addEdge(srcNode, dstNode,
new RetPE(srcNode, dstNode,
nullptr,
nullptr));
237 else if (edge ==
"cmp")
238 pag->addCmpStmt(srcID, dstID, dstID, dstID);
239 else if (edge ==
"binary-op")
240 pag->addBinaryOPStmt(srcID, dstID, dstID, dstID);
241 else if (edge ==
"unary-op")
242 pag->addUnaryOPStmt(srcID, dstID, dstID);
243 else if (edge ==
"phi")
244 assert(
false &&
"fix phi here!");
245 else if (edge ==
"select")
246 assert(
false &&
"fix select here!");
247 else if (edge ==
"branch")
249 assert(
false &&
"fix successors here!");
253 assert(
false &&
"format not support, can not create such edge");