OLD | NEW |
---|---|
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// | 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 if (TimeThisFunction) { | 1348 if (TimeThisFunction) { |
1349 TimerID = getTranslator().getContext()->getTimerID(StackID, | 1349 TimerID = getTranslator().getContext()->getTimerID(StackID, |
1350 FuncDecl->getName()); | 1350 FuncDecl->getName()); |
1351 getTranslator().getContext()->pushTimer(TimerID, StackID); | 1351 getTranslator().getContext()->pushTimer(TimerID, StackID); |
1352 } | 1352 } |
1353 | 1353 |
1354 // Note: The Cfg is created, even when IR generation is disabled. This is | 1354 // Note: The Cfg is created, even when IR generation is disabled. This is |
1355 // done to install a CfgLocalAllocator for various internal containers. | 1355 // done to install a CfgLocalAllocator for various internal containers. |
1356 Func = Ice::Cfg::create(getTranslator().getContext(), | 1356 Func = Ice::Cfg::create(getTranslator().getContext(), |
1357 getTranslator().getNextSequenceNumber()); | 1357 getTranslator().getNextSequenceNumber()); |
1358 Ice::Cfg::setCurrentCfg(Func.get()); | 1358 bool ParserResult; |
1359 { | |
1360 Ice::CfgLocalAllocatorScope _(Func.get()); | |
1359 | 1361 |
1360 // TODO(kschimpf) Clean up API to add a function signature to a CFG. | 1362 // TODO(kschimpf) Clean up API to add a function signature to a CFG. |
1361 const Ice::FuncSigType &Signature = FuncDecl->getSignature(); | 1363 const Ice::FuncSigType &Signature = FuncDecl->getSignature(); |
1362 | 1364 |
1363 Func->setFunctionName(FuncDecl->getName()); | 1365 Func->setFunctionName(FuncDecl->getName()); |
1364 Func->setReturnType(Signature.getReturnType()); | 1366 Func->setReturnType(Signature.getReturnType()); |
1365 Func->setInternal(FuncDecl->getLinkage() == GlobalValue::InternalLinkage); | 1367 Func->setInternal(FuncDecl->getLinkage() == GlobalValue::InternalLinkage); |
1366 CurrentNode = installNextBasicBlock(); | 1368 CurrentNode = installNextBasicBlock(); |
1367 Func->setEntryNode(CurrentNode); | 1369 Func->setEntryNode(CurrentNode); |
1368 for (Ice::Type ArgType : Signature.getArgList()) { | 1370 for (Ice::Type ArgType : Signature.getArgList()) { |
1369 Func->addArg(getNextInstVar(ArgType)); | 1371 Func->addArg(getNextInstVar(ArgType)); |
1372 } | |
1373 | |
1374 ParserResult = ParseThisBlock(); | |
1375 | |
1376 // Temporarily end per-function timing, which will be resumed by the | |
1377 // translator function. This is because translation may be done | |
1378 // asynchronously in a separate thread. | |
1379 if (TimeThisFunction) | |
1380 getTranslator().getContext()->popTimer(TimerID, StackID); | |
1381 | |
1382 // Note: Once any errors have been found, we turn off all translation of | |
1383 // all remaining functions. This allows successive parsing errors to be | |
1384 // reported, without adding extra checks to the translator for such | |
Jim Stichnoth
2016/02/24 23:31:24
reflow comment
John
2016/02/24 23:46:06
Done.
| |
1385 // parsing | |
1386 // errors. | |
1370 } | 1387 } |
1371 | |
1372 bool ParserResult = ParseThisBlock(); | |
1373 | |
1374 // Temporarily end per-function timing, which will be resumed by the | |
1375 // translator function. This is because translation may be done | |
1376 // asynchronously in a separate thread. | |
1377 if (TimeThisFunction) | |
1378 getTranslator().getContext()->popTimer(TimerID, StackID); | |
1379 | |
1380 Ice::Cfg::setCurrentCfg(nullptr); | |
1381 // Note: Once any errors have been found, we turn off all translation of | |
1382 // all remaining functions. This allows successive parsing errors to be | |
1383 // reported, without adding extra checks to the translator for such parsing | |
1384 // errors. | |
1385 if (Context->getNumErrors() == 0 && Func) { | 1388 if (Context->getNumErrors() == 0 && Func) { |
1386 getTranslator().translateFcn(std::move(Func)); | 1389 getTranslator().translateFcn(std::move(Func)); |
1387 // The translator now has ownership of Func. | 1390 // The translator now has ownership of Func. |
1388 } else { | 1391 } else { |
1389 Func.reset(); | 1392 Func.reset(); |
1390 } | 1393 } |
1391 | 1394 |
1392 return ParserResult; | 1395 return ParserResult; |
1393 } | 1396 } |
1394 | 1397 |
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3203 raw_string_ostream StrBuf(Buffer); | 3206 raw_string_ostream StrBuf(Buffer); |
3204 StrBuf << IRFilename << ": Does not contain a module!"; | 3207 StrBuf << IRFilename << ": Does not contain a module!"; |
3205 llvm::report_fatal_error(StrBuf.str()); | 3208 llvm::report_fatal_error(StrBuf.str()); |
3206 } | 3209 } |
3207 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3210 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
3208 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); | 3211 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); |
3209 } | 3212 } |
3210 } | 3213 } |
3211 | 3214 |
3212 } // end of namespace Ice | 3215 } // end of namespace Ice |
OLD | NEW |