| 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 // This file implements the PNaCl bitcode file to Ice, to machine code | 10 // This file implements the PNaCl bitcode file to Ice, to machine code |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 FcnId(Context->getNextFunctionBlockValueID()), | 840 FcnId(Context->getNextFunctionBlockValueID()), |
| 841 LLVMFunc(cast<Function>(Context->getGlobalValueByID(FcnId))), | 841 LLVMFunc(cast<Function>(Context->getGlobalValueByID(FcnId))), |
| 842 CachedNumGlobalValueIDs(Context->getNumGlobalValueIDs()), | 842 CachedNumGlobalValueIDs(Context->getNumGlobalValueIDs()), |
| 843 NextLocalInstIndex(Context->getNumGlobalValueIDs()), | 843 NextLocalInstIndex(Context->getNumGlobalValueIDs()), |
| 844 InstIsTerminating(false) { | 844 InstIsTerminating(false) { |
| 845 Func->setFunctionName(LLVMFunc->getName()); | 845 Func->setFunctionName(LLVMFunc->getName()); |
| 846 Func->setReturnType(Context->convertToIceType(LLVMFunc->getReturnType())); | 846 Func->setReturnType(Context->convertToIceType(LLVMFunc->getReturnType())); |
| 847 Func->setInternal(LLVMFunc->hasInternalLinkage()); | 847 Func->setInternal(LLVMFunc->hasInternalLinkage()); |
| 848 CurrentNode = InstallNextBasicBlock(); | 848 CurrentNode = InstallNextBasicBlock(); |
| 849 Func->setEntryNode(CurrentNode); | 849 Func->setEntryNode(CurrentNode); |
| 850 for (Function::const_arg_iterator ArgI = LLVMFunc->arg_begin(), | 850 for (auto ArgI = LLVMFunc->arg_begin(), ArgE = LLVMFunc->arg_end(); |
| 851 ArgE = LLVMFunc->arg_end(); | |
| 852 ArgI != ArgE; ++ArgI) { | 851 ArgI != ArgE; ++ArgI) { |
| 853 Func->addArg(getNextInstVar(Context->convertToIceType(ArgI->getType()))); | 852 Func->addArg(getNextInstVar(Context->convertToIceType(ArgI->getType()))); |
| 854 } | 853 } |
| 855 } | 854 } |
| 856 | 855 |
| 857 ~FunctionParser() override {}; | 856 ~FunctionParser() override {}; |
| 858 | 857 |
| 859 // Set the next constant ID to the given constant C. | 858 // Set the next constant ID to the given constant C. |
| 860 void setNextConstantID(Ice::Constant *C) { | 859 void setNextConstantID(Ice::Constant *C) { |
| 861 setOperand(NextLocalInstIndex++, C); | 860 setOperand(NextLocalInstIndex++, C); |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 std::string Buffer; | 1379 std::string Buffer; |
| 1381 raw_string_ostream StrBuf(Buffer); | 1380 raw_string_ostream StrBuf(Buffer); |
| 1382 StrBuf << "Binary opcode " << Opcode << "not understood for type " << Ty; | 1381 StrBuf << "Binary opcode " << Opcode << "not understood for type " << Ty; |
| 1383 Error(StrBuf.str()); | 1382 Error(StrBuf.str()); |
| 1384 } | 1383 } |
| 1385 | 1384 |
| 1386 void FunctionParser::ExitBlock() { | 1385 void FunctionParser::ExitBlock() { |
| 1387 // Before translating, check for blocks without instructions, and | 1386 // Before translating, check for blocks without instructions, and |
| 1388 // insert unreachable. This shouldn't happen, but be safe. | 1387 // insert unreachable. This shouldn't happen, but be safe. |
| 1389 unsigned Index = 0; | 1388 unsigned Index = 0; |
| 1390 const Ice::NodeList &Nodes = Func->getNodes(); | 1389 for (Ice::CfgNode *Node : Func->getNodes()) { |
| 1391 for (std::vector<Ice::CfgNode *>::const_iterator Iter = Nodes.begin(), | |
| 1392 IterEnd = Nodes.end(); | |
| 1393 Iter != IterEnd; ++Iter, ++Index) { | |
| 1394 Ice::CfgNode *Node = *Iter; | |
| 1395 if (Node->getInsts().size() == 0) { | 1390 if (Node->getInsts().size() == 0) { |
| 1396 std::string Buffer; | 1391 std::string Buffer; |
| 1397 raw_string_ostream StrBuf(Buffer); | 1392 raw_string_ostream StrBuf(Buffer); |
| 1398 StrBuf << "Basic block " << Index << " contains no instructions"; | 1393 StrBuf << "Basic block " << Index << " contains no instructions"; |
| 1399 Error(StrBuf.str()); | 1394 Error(StrBuf.str()); |
| 1400 // TODO(kschimpf) Remove error recovery once implementation complete. | 1395 // TODO(kschimpf) Remove error recovery once implementation complete. |
| 1401 Node->appendInst(Ice::InstUnreachable::create(Func)); | 1396 Node->appendInst(Ice::InstUnreachable::create(Func)); |
| 1402 } | 1397 } |
| 1398 ++Index; |
| 1403 } | 1399 } |
| 1404 Func->computePredecessors(); | 1400 Func->computePredecessors(); |
| 1405 // Note: Once any errors have been found, we turn off all | 1401 // Note: Once any errors have been found, we turn off all |
| 1406 // translation of all remaining functions. This allows use to see | 1402 // translation of all remaining functions. This allows use to see |
| 1407 // multiple errors, without adding extra checks to the translator | 1403 // multiple errors, without adding extra checks to the translator |
| 1408 // for such parsing errors. | 1404 // for such parsing errors. |
| 1409 if (Context->getNumErrors() == 0) | 1405 if (Context->getNumErrors() == 0) |
| 1410 getTranslator().translateFcn(Func); | 1406 getTranslator().translateFcn(Func); |
| 1411 } | 1407 } |
| 1412 | 1408 |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2423 | 2419 |
| 2424 if (TopLevelBlocks != 1) { | 2420 if (TopLevelBlocks != 1) { |
| 2425 errs() << IRFilename | 2421 errs() << IRFilename |
| 2426 << ": Contains more than one module. Found: " << TopLevelBlocks | 2422 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 2427 << "\n"; | 2423 << "\n"; |
| 2428 ErrorStatus = true; | 2424 ErrorStatus = true; |
| 2429 } | 2425 } |
| 2430 } | 2426 } |
| 2431 | 2427 |
| 2432 } // end of namespace Ice | 2428 } // end of namespace Ice |
| OLD | NEW |