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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 } | 519 } |
520 | 520 |
521 Ice::FunctionDeclaration * | 521 Ice::FunctionDeclaration * |
522 TopLevelParser::reportGetFunctionByIDError(NaClBcIndexSize_t ID) { | 522 TopLevelParser::reportGetFunctionByIDError(NaClBcIndexSize_t ID) { |
523 std::string Buffer; | 523 std::string Buffer; |
524 raw_string_ostream StrBuf(Buffer); | 524 raw_string_ostream StrBuf(Buffer); |
525 StrBuf << "Function index " << ID | 525 StrBuf << "Function index " << ID |
526 << " not allowed. Out of range. Must be less than " | 526 << " not allowed. Out of range. Must be less than " |
527 << FunctionDeclarationList.size(); | 527 << FunctionDeclarationList.size(); |
528 blockError(StrBuf.str()); | 528 blockError(StrBuf.str()); |
529 // TODO(kschimpf) Remove error recovery once implementation complete. | |
530 if (!FunctionDeclarationList.empty()) | 529 if (!FunctionDeclarationList.empty()) |
531 return FunctionDeclarationList[0]; | 530 return FunctionDeclarationList[0]; |
532 Fatal(); | 531 Fatal(); |
533 } | 532 } |
534 | 533 |
535 Ice::VariableDeclaration * | 534 Ice::VariableDeclaration * |
536 TopLevelParser::reportGetGlobalVariableByIDError(NaClBcIndexSize_t Index) { | 535 TopLevelParser::reportGetGlobalVariableByIDError(NaClBcIndexSize_t Index) { |
537 std::string Buffer; | 536 std::string Buffer; |
538 raw_string_ostream StrBuf(Buffer); | 537 raw_string_ostream StrBuf(Buffer); |
539 StrBuf << "Global index " << Index | 538 StrBuf << "Global index " << Index |
540 << " not allowed. Out of range. Must be less than " | 539 << " not allowed. Out of range. Must be less than " |
541 << VariableDeclarations->size(); | 540 << VariableDeclarations->size(); |
542 blockError(StrBuf.str()); | 541 blockError(StrBuf.str()); |
543 // TODO(kschimpf) Remove error recovery once implementation complete. | |
544 if (!VariableDeclarations->empty()) | 542 if (!VariableDeclarations->empty()) |
545 return VariableDeclarations->at(0); | 543 return VariableDeclarations->at(0); |
546 Fatal(); | 544 Fatal(); |
547 } | 545 } |
548 | 546 |
549 Ice::Type TopLevelParser::convertToIceTypeError(Type *LLVMTy) { | 547 Ice::Type TopLevelParser::convertToIceTypeError(Type *LLVMTy) { |
550 std::string Buffer; | 548 std::string Buffer; |
551 raw_string_ostream StrBuf(Buffer); | 549 raw_string_ostream StrBuf(Buffer); |
552 StrBuf << "Invalid LLVM type: " << *LLVMTy; | 550 StrBuf << "Invalid LLVM type: " << *LLVMTy; |
553 Error(StrBuf.str()); | 551 Error(StrBuf.str()); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 Error(StrBuf.str()); | 702 Error(StrBuf.str()); |
705 } | 703 } |
706 | 704 |
707 bool BlockParserBaseClass::ParseBlock(unsigned BlockID) { | 705 bool BlockParserBaseClass::ParseBlock(unsigned BlockID) { |
708 // If called, derived class doesn't know how to handle block. | 706 // If called, derived class doesn't know how to handle block. |
709 // Report error and skip. | 707 // Report error and skip. |
710 std::string Buffer; | 708 std::string Buffer; |
711 raw_string_ostream StrBuf(Buffer); | 709 raw_string_ostream StrBuf(Buffer); |
712 StrBuf << "Don't know how to parse block id: " << BlockID; | 710 StrBuf << "Don't know how to parse block id: " << BlockID; |
713 Error(StrBuf.str()); | 711 Error(StrBuf.str()); |
714 // TODO(kschimpf) Remove error recovery once implementation complete. | |
715 SkipBlock(); | 712 SkipBlock(); |
716 return false; | 713 return false; |
717 } | 714 } |
718 | 715 |
719 void BlockParserBaseClass::ProcessRecord() { | 716 void BlockParserBaseClass::ProcessRecord() { |
720 // If called, derived class doesn't know how to handle. | 717 // If called, derived class doesn't know how to handle. |
721 std::string Buffer; | 718 std::string Buffer; |
722 raw_string_ostream StrBuf(Buffer); | 719 raw_string_ostream StrBuf(Buffer); |
723 StrBuf << "Don't know how to process " << getBlockName() | 720 StrBuf << "Don't know how to process " << getBlockName() |
724 << " record:" << Record; | 721 << " record:" << Record; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 for (size_t i = 2, e = Values.size(); i != e; ++i) { | 907 for (size_t i = 2, e = Values.size(); i != e; ++i) { |
911 // Check that type void not used as argument type. | 908 // Check that type void not used as argument type. |
912 // Note: PNaCl restrictions can't be checked until we | 909 // Note: PNaCl restrictions can't be checked until we |
913 // know the name, because we have to check for intrinsic signatures. | 910 // know the name, because we have to check for intrinsic signatures. |
914 Ice::Type ArgTy = Context->getSimpleTypeByID(Values[i]); | 911 Ice::Type ArgTy = Context->getSimpleTypeByID(Values[i]); |
915 if (ArgTy == Ice::IceType_void) { | 912 if (ArgTy == Ice::IceType_void) { |
916 std::string Buffer; | 913 std::string Buffer; |
917 raw_string_ostream StrBuf(Buffer); | 914 raw_string_ostream StrBuf(Buffer); |
918 StrBuf << "Type for parameter " << (i - 1) | 915 StrBuf << "Type for parameter " << (i - 1) |
919 << " not valid. Found: " << ArgTy; | 916 << " not valid. Found: " << ArgTy; |
920 // TODO(kschimpf) Remove error recovery once implementation complete. | |
921 ArgTy = Ice::IceType_i32; | 917 ArgTy = Ice::IceType_i32; |
922 } | 918 } |
923 FuncTy->appendArgType(ArgTy); | 919 FuncTy->appendArgType(ArgTy); |
924 } | 920 } |
925 return; | 921 return; |
926 } | 922 } |
927 default: | 923 default: |
928 BlockParserBaseClass::ProcessRecord(); | 924 BlockParserBaseClass::ProcessRecord(); |
929 return; | 925 return; |
930 } | 926 } |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 bool verifyAllForwardRefsDefined(); | 1386 bool verifyAllForwardRefsDefined(); |
1391 | 1387 |
1392 // Returns the Index-th basic block in the list of basic blocks. | 1388 // Returns the Index-th basic block in the list of basic blocks. |
1393 // Assumes Index corresponds to a branch instruction. Hence, if | 1389 // Assumes Index corresponds to a branch instruction. Hence, if |
1394 // the branch references the entry block, it also generates a | 1390 // the branch references the entry block, it also generates a |
1395 // corresponding error. | 1391 // corresponding error. |
1396 Ice::CfgNode *getBranchBasicBlock(NaClBcIndexSize_t Index) { | 1392 Ice::CfgNode *getBranchBasicBlock(NaClBcIndexSize_t Index) { |
1397 assert(!isIRGenerationDisabled()); | 1393 assert(!isIRGenerationDisabled()); |
1398 if (Index == 0) { | 1394 if (Index == 0) { |
1399 Error("Branch to entry block not allowed"); | 1395 Error("Branch to entry block not allowed"); |
1400 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1401 } | 1396 } |
1402 return getBasicBlock(Index); | 1397 return getBasicBlock(Index); |
1403 } | 1398 } |
1404 | 1399 |
1405 // Generate an instruction variable with type Ty. | 1400 // Generate an instruction variable with type Ty. |
1406 Ice::Variable *createInstVar(Ice::Type Ty) { | 1401 Ice::Variable *createInstVar(Ice::Type Ty) { |
1407 assert(!isIRGenerationDisabled()); | 1402 assert(!isIRGenerationDisabled()); |
1408 if (Ty == Ice::IceType_void) { | 1403 if (Ty == Ice::IceType_void) { |
1409 Error("Can't define instruction value using type void"); | 1404 Error("Can't define instruction value using type void"); |
1410 // Recover since we can't throw an exception. | 1405 // Recover since we can't throw an exception. |
(...skipping 15 matching lines...) Expand all Loading... |
1426 if (Var->getType() == Ty) { | 1421 if (Var->getType() == Ty) { |
1427 ++NextLocalInstIndex; | 1422 ++NextLocalInstIndex; |
1428 return Var; | 1423 return Var; |
1429 } | 1424 } |
1430 } | 1425 } |
1431 std::string Buffer; | 1426 std::string Buffer; |
1432 raw_string_ostream StrBuf(Buffer); | 1427 raw_string_ostream StrBuf(Buffer); |
1433 StrBuf << "Illegal forward referenced instruction (" | 1428 StrBuf << "Illegal forward referenced instruction (" |
1434 << NextLocalInstIndex << "): " << *Op; | 1429 << NextLocalInstIndex << "): " << *Op; |
1435 Error(StrBuf.str()); | 1430 Error(StrBuf.str()); |
1436 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1437 ++NextLocalInstIndex; | 1431 ++NextLocalInstIndex; |
1438 return createInstVar(Ty); | 1432 return createInstVar(Ty); |
1439 } | 1433 } |
1440 } | 1434 } |
1441 Ice::Variable *Var = createInstVar(Ty); | 1435 Ice::Variable *Var = createInstVar(Ty); |
1442 setOperand(NextLocalInstIndex++, Var); | 1436 setOperand(NextLocalInstIndex++, Var); |
1443 return Var; | 1437 return Var; |
1444 } | 1438 } |
1445 | 1439 |
1446 // Converts a relative index (wrt to BaseIndex) to an absolute value | 1440 // Converts a relative index (wrt to BaseIndex) to an absolute value |
1447 // index. | 1441 // index. |
1448 NaClBcIndexSize_t convertRelativeToAbsIndex(NaClRelBcIndexSize_t Id, | 1442 NaClBcIndexSize_t convertRelativeToAbsIndex(NaClRelBcIndexSize_t Id, |
1449 NaClRelBcIndexSize_t BaseIndex) { | 1443 NaClRelBcIndexSize_t BaseIndex) { |
1450 if (BaseIndex < Id) { | 1444 if (BaseIndex < Id) { |
1451 std::string Buffer; | 1445 std::string Buffer; |
1452 raw_string_ostream StrBuf(Buffer); | 1446 raw_string_ostream StrBuf(Buffer); |
1453 StrBuf << "Invalid relative value id: " << Id | 1447 StrBuf << "Invalid relative value id: " << Id |
1454 << " (must be <= " << BaseIndex << ")"; | 1448 << " (must be <= " << BaseIndex << ")"; |
1455 Error(StrBuf.str()); | 1449 Error(StrBuf.str()); |
1456 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1457 return 0; | 1450 return 0; |
1458 } | 1451 } |
1459 return BaseIndex - Id; | 1452 return BaseIndex - Id; |
1460 } | 1453 } |
1461 | 1454 |
1462 // Sets element Index (in the local operands list) to Op. | 1455 // Sets element Index (in the local operands list) to Op. |
1463 void setOperand(NaClBcIndexSize_t Index, Ice::Operand *Op) { | 1456 void setOperand(NaClBcIndexSize_t Index, Ice::Operand *Op) { |
1464 assert(Op || isIRGenerationDisabled()); | 1457 assert(Op || isIRGenerationDisabled()); |
1465 // Check if simple push works. | 1458 // Check if simple push works. |
1466 NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs; | 1459 NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs; |
1467 | 1460 |
1468 // If element not defined, set it. | 1461 // If element not defined, set it. |
1469 Ice::Operand *&IndexedOp = LocalOperands[LocalIndex]; | 1462 Ice::Operand *&IndexedOp = LocalOperands[LocalIndex]; |
1470 if (IndexedOp == nullptr) { | 1463 if (IndexedOp == nullptr) { |
1471 IndexedOp = Op; | 1464 IndexedOp = Op; |
1472 return; | 1465 return; |
1473 } | 1466 } |
1474 | 1467 |
1475 // See if forward reference matchers. | 1468 // See if forward reference matchers. |
1476 if (IndexedOp == Op) | 1469 if (IndexedOp == Op) |
1477 return; | 1470 return; |
1478 | 1471 |
1479 // Error has occurred. | 1472 // Error has occurred. |
1480 std::string Buffer; | 1473 std::string Buffer; |
1481 raw_string_ostream StrBuf(Buffer); | 1474 raw_string_ostream StrBuf(Buffer); |
1482 StrBuf << "Multiple definitions for index " << Index << ": " << *Op | 1475 StrBuf << "Multiple definitions for index " << Index << ": " << *Op |
1483 << " and " << *IndexedOp; | 1476 << " and " << *IndexedOp; |
1484 Error(StrBuf.str()); | 1477 Error(StrBuf.str()); |
1485 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1486 IndexedOp = Op; | 1478 IndexedOp = Op; |
1487 } | 1479 } |
1488 | 1480 |
1489 // Returns the relative operand (wrt to BaseIndex) referenced by | 1481 // Returns the relative operand (wrt to BaseIndex) referenced by |
1490 // the given value Index. | 1482 // the given value Index. |
1491 Ice::Operand *getRelativeOperand(NaClBcIndexSize_t Index, | 1483 Ice::Operand *getRelativeOperand(NaClBcIndexSize_t Index, |
1492 NaClBcIndexSize_t BaseIndex) { | 1484 NaClBcIndexSize_t BaseIndex) { |
1493 return getOperand(convertRelativeToAbsIndex(Index, BaseIndex)); | 1485 return getOperand(convertRelativeToAbsIndex(Index, BaseIndex)); |
1494 } | 1486 } |
1495 | 1487 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 // type Ty, and sets Op to the corresponding ICE binary | 1629 // type Ty, and sets Op to the corresponding ICE binary |
1638 // opcode. Returns true if able to convert, false otherwise. | 1630 // opcode. Returns true if able to convert, false otherwise. |
1639 bool convertBinopOpcode(unsigned Opcode, Ice::Type Ty, | 1631 bool convertBinopOpcode(unsigned Opcode, Ice::Type Ty, |
1640 Ice::InstArithmetic::OpKind &Op) { | 1632 Ice::InstArithmetic::OpKind &Op) { |
1641 switch (Opcode) { | 1633 switch (Opcode) { |
1642 default: { | 1634 default: { |
1643 std::string Buffer; | 1635 std::string Buffer; |
1644 raw_string_ostream StrBuf(Buffer); | 1636 raw_string_ostream StrBuf(Buffer); |
1645 StrBuf << "Binary opcode " << Opcode << "not understood for type " << Ty; | 1637 StrBuf << "Binary opcode " << Opcode << "not understood for type " << Ty; |
1646 Error(StrBuf.str()); | 1638 Error(StrBuf.str()); |
1647 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1648 Op = Ice::InstArithmetic::Add; | 1639 Op = Ice::InstArithmetic::Add; |
1649 return false; | 1640 return false; |
1650 } | 1641 } |
1651 case naclbitc::BINOP_ADD: | 1642 case naclbitc::BINOP_ADD: |
1652 if (Ice::isIntegerType(Ty)) { | 1643 if (Ice::isIntegerType(Ty)) { |
1653 Op = Ice::InstArithmetic::Add; | 1644 Op = Ice::InstArithmetic::Add; |
1654 return isValidIntegerArithOp(Op, Ty); | 1645 return isValidIntegerArithOp(Op, Ty); |
1655 } else { | 1646 } else { |
1656 Op = Ice::InstArithmetic::Fadd; | 1647 Op = Ice::InstArithmetic::Fadd; |
1657 return isValidFloatingArithOp(Op, Ty); | 1648 return isValidFloatingArithOp(Op, Ty); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 bool convertCastOpToIceOp(uint64_t Opcode, Ice::Type SourceType, | 1797 bool convertCastOpToIceOp(uint64_t Opcode, Ice::Type SourceType, |
1807 Ice::Type TargetType, | 1798 Ice::Type TargetType, |
1808 Ice::InstCast::OpKind &CastKind) { | 1799 Ice::InstCast::OpKind &CastKind) { |
1809 bool Result; | 1800 bool Result; |
1810 switch (Opcode) { | 1801 switch (Opcode) { |
1811 default: { | 1802 default: { |
1812 std::string Buffer; | 1803 std::string Buffer; |
1813 raw_string_ostream StrBuf(Buffer); | 1804 raw_string_ostream StrBuf(Buffer); |
1814 StrBuf << "Cast opcode " << Opcode << " not understood.\n"; | 1805 StrBuf << "Cast opcode " << Opcode << " not understood.\n"; |
1815 Error(StrBuf.str()); | 1806 Error(StrBuf.str()); |
1816 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1817 CastKind = Ice::InstCast::Bitcast; | 1807 CastKind = Ice::InstCast::Bitcast; |
1818 return false; | 1808 return false; |
1819 } | 1809 } |
1820 case naclbitc::CAST_TRUNC: | 1810 case naclbitc::CAST_TRUNC: |
1821 CastKind = Ice::InstCast::Trunc; | 1811 CastKind = Ice::InstCast::Trunc; |
1822 Result = isIntTruncCastValid(SourceType, TargetType); | 1812 Result = isIntTruncCastValid(SourceType, TargetType); |
1823 break; | 1813 break; |
1824 case naclbitc::CAST_ZEXT: | 1814 case naclbitc::CAST_ZEXT: |
1825 CastKind = Ice::InstCast::Zext; | 1815 CastKind = Ice::InstCast::Zext; |
1826 Result = isIntExtCastValid(SourceType, TargetType); | 1816 Result = isIntExtCastValid(SourceType, TargetType); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 return false; | 1959 return false; |
1970 } | 1960 } |
1971 } | 1961 } |
1972 | 1962 |
1973 // Creates an error instruction, generating a value of type Ty, and | 1963 // Creates an error instruction, generating a value of type Ty, and |
1974 // adds a placeholder so that instruction indices line up. | 1964 // adds a placeholder so that instruction indices line up. |
1975 // Some instructions, such as a call, will not generate a value | 1965 // Some instructions, such as a call, will not generate a value |
1976 // if the return type is void. In such cases, a placeholder value | 1966 // if the return type is void. In such cases, a placeholder value |
1977 // for the badly formed instruction is not needed. Hence, if Ty is | 1967 // for the badly formed instruction is not needed. Hence, if Ty is |
1978 // void, an error instruction is not appended. | 1968 // void, an error instruction is not appended. |
1979 // TODO(kschimpf) Remove error recovery once implementation complete. | |
1980 void appendErrorInstruction(Ice::Type Ty) { | 1969 void appendErrorInstruction(Ice::Type Ty) { |
1981 // Note: we don't worry about downstream translation errors because | 1970 // Note: we don't worry about downstream translation errors because |
1982 // the function will not be translated if any errors occur. | 1971 // the function will not be translated if any errors occur. |
1983 if (Ty == Ice::IceType_void) | 1972 if (Ty == Ice::IceType_void) |
1984 return; | 1973 return; |
1985 Ice::Variable *Var = getNextInstVar(Ty); | 1974 Ice::Variable *Var = getNextInstVar(Ty); |
1986 CurrentNode->appendInst(Ice::InstAssign::create(Func.get(), Var, Var)); | 1975 CurrentNode->appendInst(Ice::InstAssign::create(Func.get(), Var, Var)); |
1987 } | 1976 } |
1988 }; | 1977 }; |
1989 | 1978 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2062 return; | 2051 return; |
2063 // Before translating, check for blocks without instructions, and | 2052 // Before translating, check for blocks without instructions, and |
2064 // insert unreachable. This shouldn't happen, but be safe. | 2053 // insert unreachable. This shouldn't happen, but be safe. |
2065 size_t Index = 0; | 2054 size_t Index = 0; |
2066 for (Ice::CfgNode *Node : Func->getNodes()) { | 2055 for (Ice::CfgNode *Node : Func->getNodes()) { |
2067 if (Node->getInsts().empty()) { | 2056 if (Node->getInsts().empty()) { |
2068 std::string Buffer; | 2057 std::string Buffer; |
2069 raw_string_ostream StrBuf(Buffer); | 2058 raw_string_ostream StrBuf(Buffer); |
2070 StrBuf << "Basic block " << Index << " contains no instructions"; | 2059 StrBuf << "Basic block " << Index << " contains no instructions"; |
2071 Error(StrBuf.str()); | 2060 Error(StrBuf.str()); |
2072 // TODO(kschimpf) Remove error recovery once implementation complete. | |
2073 Node->appendInst(Ice::InstUnreachable::create(Func.get())); | 2061 Node->appendInst(Ice::InstUnreachable::create(Func.get())); |
2074 } | 2062 } |
2075 ++Index; | 2063 ++Index; |
2076 } | 2064 } |
2077 Func->computeInOutEdges(); | 2065 Func->computeInOutEdges(); |
2078 } | 2066 } |
2079 | 2067 |
2080 void FunctionParser::reportInvalidBinaryOp(Ice::InstArithmetic::OpKind Op, | 2068 void FunctionParser::reportInvalidBinaryOp(Ice::InstArithmetic::OpKind Op, |
2081 Ice::Type OpTy) { | 2069 Ice::Type OpTy) { |
2082 std::string Buffer; | 2070 std::string Buffer; |
(...skipping 17 matching lines...) Expand all Loading... |
2100 // The base index for relative indexing. | 2088 // The base index for relative indexing. |
2101 NaClBcIndexSize_t BaseIndex = getNextInstIndex(); | 2089 NaClBcIndexSize_t BaseIndex = getNextInstIndex(); |
2102 switch (Record.GetCode()) { | 2090 switch (Record.GetCode()) { |
2103 case naclbitc::FUNC_CODE_DECLAREBLOCKS: { | 2091 case naclbitc::FUNC_CODE_DECLAREBLOCKS: { |
2104 // DECLAREBLOCKS: [n] | 2092 // DECLAREBLOCKS: [n] |
2105 if (!isValidRecordSize(1, "count")) | 2093 if (!isValidRecordSize(1, "count")) |
2106 return; | 2094 return; |
2107 uint64_t NumBbsRaw = Values[0]; | 2095 uint64_t NumBbsRaw = Values[0]; |
2108 if (NumBbsRaw == 0) { | 2096 if (NumBbsRaw == 0) { |
2109 Error("Functions must contain at least one basic block."); | 2097 Error("Functions must contain at least one basic block."); |
2110 // TODO(kschimpf) Remove error recovery once implementation complete. | |
2111 NumBbsRaw = 1; | 2098 NumBbsRaw = 1; |
2112 } else if (NumBbsRaw > NaClBcIndexSize_t_Max) { | 2099 } else if (NumBbsRaw > NaClBcIndexSize_t_Max) { |
2113 std::string Buffer; | 2100 std::string Buffer; |
2114 raw_string_ostream StrBuf(Buffer); | 2101 raw_string_ostream StrBuf(Buffer); |
2115 StrBuf << "To many basic blocks specified: " << NumBbsRaw; | 2102 StrBuf << "To many basic blocks specified: " << NumBbsRaw; |
2116 Error(StrBuf.str()); | 2103 Error(StrBuf.str()); |
2117 NumBbsRaw = NaClBcIndexSize_t_Max; | 2104 NumBbsRaw = NaClBcIndexSize_t_Max; |
2118 } | 2105 } |
2119 if (isIRGenerationDisabled()) | 2106 if (isIRGenerationDisabled()) |
2120 return; | 2107 return; |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2708 switch (IntrinsicInfo->validateCall(Inst, ArgIndex)) { | 2695 switch (IntrinsicInfo->validateCall(Inst, ArgIndex)) { |
2709 case Ice::Intrinsics::IsValidCall: | 2696 case Ice::Intrinsics::IsValidCall: |
2710 break; | 2697 break; |
2711 case Ice::Intrinsics::BadReturnType: { | 2698 case Ice::Intrinsics::BadReturnType: { |
2712 std::string Buffer; | 2699 std::string Buffer; |
2713 raw_string_ostream StrBuf(Buffer); | 2700 raw_string_ostream StrBuf(Buffer); |
2714 StrBuf << "Intrinsic call expects return type " | 2701 StrBuf << "Intrinsic call expects return type " |
2715 << IntrinsicInfo->getReturnType() | 2702 << IntrinsicInfo->getReturnType() |
2716 << ". Found: " << Inst->getReturnType(); | 2703 << ". Found: " << Inst->getReturnType(); |
2717 Error(StrBuf.str()); | 2704 Error(StrBuf.str()); |
2718 // TODO(kschimpf) Remove error recovery once implementation complete. | |
2719 break; | 2705 break; |
2720 } | 2706 } |
2721 case Ice::Intrinsics::WrongNumOfArgs: { | 2707 case Ice::Intrinsics::WrongNumOfArgs: { |
2722 std::string Buffer; | 2708 std::string Buffer; |
2723 raw_string_ostream StrBuf(Buffer); | 2709 raw_string_ostream StrBuf(Buffer); |
2724 StrBuf << "Intrinsic call expects " << IntrinsicInfo->getNumArgs() | 2710 StrBuf << "Intrinsic call expects " << IntrinsicInfo->getNumArgs() |
2725 << ". Found: " << Inst->getNumArgs(); | 2711 << ". Found: " << Inst->getNumArgs(); |
2726 Error(StrBuf.str()); | 2712 Error(StrBuf.str()); |
2727 // TODO(kschimpf) Remove error recovery once implementation complete. | |
2728 break; | 2713 break; |
2729 } | 2714 } |
2730 case Ice::Intrinsics::WrongCallArgType: { | 2715 case Ice::Intrinsics::WrongCallArgType: { |
2731 std::string Buffer; | 2716 std::string Buffer; |
2732 raw_string_ostream StrBuf(Buffer); | 2717 raw_string_ostream StrBuf(Buffer); |
2733 StrBuf << "Intrinsic call argument " << ArgIndex << " expects type " | 2718 StrBuf << "Intrinsic call argument " << ArgIndex << " expects type " |
2734 << IntrinsicInfo->getArgType(ArgIndex) | 2719 << IntrinsicInfo->getArgType(ArgIndex) |
2735 << ". Found: " << Inst->getArg(ArgIndex)->getType(); | 2720 << ". Found: " << Inst->getArg(ArgIndex)->getType(); |
2736 Error(StrBuf.str()); | 2721 Error(StrBuf.str()); |
2737 // TODO(kschimpf) Remove error recovery once implementation complete. | |
2738 break; | 2722 break; |
2739 } | 2723 } |
2740 } | 2724 } |
2741 } | 2725 } |
2742 | 2726 |
2743 CurrentNode->appendInst(Inst); | 2727 CurrentNode->appendInst(Inst); |
2744 return; | 2728 return; |
2745 } | 2729 } |
2746 case naclbitc::FUNC_CODE_INST_FORWARDTYPEREF: { | 2730 case naclbitc::FUNC_CODE_INST_FORWARDTYPEREF: { |
2747 // FORWARDTYPEREF: [opval, ty] | 2731 // FORWARDTYPEREF: [opval, ty] |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 Error(StrBuf.str()); | 2905 Error(StrBuf.str()); |
2922 } | 2906 } |
2923 }; | 2907 }; |
2924 | 2908 |
2925 void FunctionValuesymtabParser::setValueName(NaClBcIndexSize_t Index, | 2909 void FunctionValuesymtabParser::setValueName(NaClBcIndexSize_t Index, |
2926 StringType &Name) { | 2910 StringType &Name) { |
2927 // Note: We check when Index is too small, so that we can error recover | 2911 // Note: We check when Index is too small, so that we can error recover |
2928 // (FP->getOperand will create fatal error). | 2912 // (FP->getOperand will create fatal error). |
2929 if (Index < getFunctionParser()->getNumGlobalIDs()) { | 2913 if (Index < getFunctionParser()->getNumGlobalIDs()) { |
2930 reportUnableToAssign("instruction", Index, Name); | 2914 reportUnableToAssign("instruction", Index, Name); |
2931 // TODO(kschimpf) Remove error recovery once implementation complete. | |
2932 return; | 2915 return; |
2933 } | 2916 } |
2934 if (isIRGenerationDisabled()) | 2917 if (isIRGenerationDisabled()) |
2935 return; | 2918 return; |
2936 Ice::Operand *Op = getFunctionParser()->getOperand(Index); | 2919 Ice::Operand *Op = getFunctionParser()->getOperand(Index); |
2937 if (Ice::Variable *V = dyn_cast<Ice::Variable>(Op)) { | 2920 if (Ice::Variable *V = dyn_cast<Ice::Variable>(Op)) { |
2938 if (Ice::BuildDefs::dump()) { | 2921 if (Ice::BuildDefs::dump()) { |
2939 std::string Nm(Name.data(), Name.size()); | 2922 std::string Nm(Name.data(), Name.size()); |
2940 V->setName(getFunctionParser()->getFunc(), Nm); | 2923 V->setName(getFunctionParser()->getFunc(), Nm); |
2941 } | 2924 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3191 } | 3174 } |
3192 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3175 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
3193 ErrStream | 3176 ErrStream |
3194 << IRFilename | 3177 << IRFilename |
3195 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; | 3178 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; |
3196 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); | 3179 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); |
3197 } | 3180 } |
3198 } | 3181 } |
3199 | 3182 |
3200 } // end of namespace Ice | 3183 } // end of namespace Ice |
OLD | NEW |