| 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 2033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 std::string Buffer; | 2044 std::string Buffer; |
| 2045 raw_string_ostream StrBuf(Buffer); | 2045 raw_string_ostream StrBuf(Buffer); |
| 2046 StrBuf << "Value index " << Index << " not defined!"; | 2046 StrBuf << "Value index " << Index << " not defined!"; |
| 2047 Error(StrBuf.str()); | 2047 Error(StrBuf.str()); |
| 2048 // Recover and return some value. | 2048 // Recover and return some value. |
| 2049 if (!LocalOperands.empty()) | 2049 if (!LocalOperands.empty()) |
| 2050 return LocalOperands.front(); | 2050 return LocalOperands.front(); |
| 2051 return Context->getGlobalConstantByID(0); | 2051 return Context->getGlobalConstantByID(0); |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 void verifyCallArgTypeMatches(Ice::FunctionDeclaration *Fcn, | 2054 void verifyCallArgTypeMatches(Ice::FunctionDeclaration *Fcn, Ice::SizeT Index, |
| 2055 Ice::SizeT Index, Ice::Type ArgType, | 2055 Ice::Type ArgType, Ice::Type ParamType) { |
| 2056 Ice::Type ParamType) { | |
| 2057 if (ArgType != ParamType) { | 2056 if (ArgType != ParamType) { |
| 2058 std::string Buffer; | 2057 std::string Buffer; |
| 2059 raw_string_ostream StrBuf(Buffer); | 2058 raw_string_ostream StrBuf(Buffer); |
| 2060 StrBuf << "Argument " << (Index + 1) << " of " << printName(Fcn) | 2059 StrBuf << "Argument " << (Index + 1) << " of " << printName(Fcn) |
| 2061 << " expects " << ParamType << ". Found: " << ArgType; | 2060 << " expects " << ParamType << ". Found: " << ArgType; |
| 2062 Error(StrBuf.str()); | 2061 Error(StrBuf.str()); |
| 2063 } | 2062 } |
| 2064 } | 2063 } |
| 2065 | 2064 |
| 2066 const Ice::IceString printName(Ice::FunctionDeclaration *Fcn) { | 2065 const Ice::IceString printName(Ice::FunctionDeclaration *Fcn) { |
| 2067 if (Fcn) | 2066 if (Fcn) |
| 2068 return Fcn->getName(); | 2067 return Fcn->getName(); |
| 2069 return "function"; | 2068 return "function"; |
| 2070 } | 2069 } |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2726 // There is no signature. Assume defined by parameter types. | 2725 // There is no signature. Assume defined by parameter types. |
| 2727 ReturnType = Context->getSimpleTypeByID(Values[2]); | 2726 ReturnType = Context->getSimpleTypeByID(Values[2]); |
| 2728 if (!isIRGenerationDisabled() && Callee != nullptr) | 2727 if (!isIRGenerationDisabled() && Callee != nullptr) |
| 2729 isValidPointerType(Callee, "Call indirect"); | 2728 isValidPointerType(Callee, "Call indirect"); |
| 2730 } | 2729 } |
| 2731 | 2730 |
| 2732 if (Callee == nullptr && !isIRGenerationDisabled()) | 2731 if (Callee == nullptr && !isIRGenerationDisabled()) |
| 2733 return; | 2732 return; |
| 2734 | 2733 |
| 2735 // Extract out the the call parameters. | 2734 // Extract out the the call parameters. |
| 2736 SmallVector<Ice::Operand*, 8> Params; | 2735 SmallVector<Ice::Operand *, 8> Params; |
| 2737 for (Ice::SizeT Index = ParamsStartIndex; Index < Values.size(); ++Index) { | 2736 for (Ice::SizeT Index = ParamsStartIndex; Index < Values.size(); ++Index) { |
| 2738 Ice::Operand *Op = getRelativeOperand(Values[Index], BaseIndex); | 2737 Ice::Operand *Op = getRelativeOperand(Values[Index], BaseIndex); |
| 2739 if (isIRGenerationDisabled()) | 2738 if (isIRGenerationDisabled()) |
| 2740 continue; | 2739 continue; |
| 2741 if (Op == nullptr) { | 2740 if (Op == nullptr) { |
| 2742 std::string Buffer; | 2741 std::string Buffer; |
| 2743 raw_string_ostream StrBuf(Buffer); | 2742 raw_string_ostream StrBuf(Buffer); |
| 2744 StrBuf << "Parameter " << (Index - ParamsStartIndex + 1) | 2743 StrBuf << "Parameter " << (Index - ParamsStartIndex + 1) << " of " |
| 2745 << " of " << printName(Fcn) << " is not defined"; | 2744 << printName(Fcn) << " is not defined"; |
| 2746 Error(StrBuf.str()); | 2745 Error(StrBuf.str()); |
| 2747 if (ReturnType != Ice::IceType_void) | 2746 if (ReturnType != Ice::IceType_void) |
| 2748 setNextLocalInstIndex(nullptr); | 2747 setNextLocalInstIndex(nullptr); |
| 2749 return; | 2748 return; |
| 2750 } | 2749 } |
| 2751 Params.push_back(Op); | 2750 Params.push_back(Op); |
| 2752 } | 2751 } |
| 2753 | 2752 |
| 2754 // Check return type. | 2753 // Check return type. |
| 2755 if (IntrinsicInfo == nullptr && !isCallReturnType(ReturnType)) { | 2754 if (IntrinsicInfo == nullptr && !isCallReturnType(ReturnType)) { |
| 2756 std::string Buffer; | 2755 std::string Buffer; |
| 2757 raw_string_ostream StrBuf(Buffer); | 2756 raw_string_ostream StrBuf(Buffer); |
| 2758 StrBuf << "Return type of " << printName(Fcn) << " is invalid: " | 2757 StrBuf << "Return type of " << printName(Fcn) |
| 2759 << ReturnType; | 2758 << " is invalid: " << ReturnType; |
| 2760 Error(StrBuf.str()); | 2759 Error(StrBuf.str()); |
| 2761 ReturnType = Ice::IceType_i32; | 2760 ReturnType = Ice::IceType_i32; |
| 2762 } | 2761 } |
| 2763 | 2762 |
| 2764 if (isIRGenerationDisabled()) { | 2763 if (isIRGenerationDisabled()) { |
| 2765 if (ReturnType != Ice::IceType_void) | 2764 if (ReturnType != Ice::IceType_void) |
| 2766 setNextLocalInstIndex(nullptr); | 2765 setNextLocalInstIndex(nullptr); |
| 2767 return; | 2766 return; |
| 2768 } | 2767 } |
| 2769 | 2768 |
| 2770 // Type check call parameters. | 2769 // Type check call parameters. |
| 2771 for (Ice::SizeT Index = 0; Index < Params.size(); ++Index) { | 2770 for (Ice::SizeT Index = 0; Index < Params.size(); ++Index) { |
| 2772 Ice::Operand *Op = Params[Index]; | 2771 Ice::Operand *Op = Params[Index]; |
| 2773 Ice::Type OpType = Op->getType(); | 2772 Ice::Type OpType = Op->getType(); |
| 2774 if (Signature) | 2773 if (Signature) |
| 2775 verifyCallArgTypeMatches( | 2774 verifyCallArgTypeMatches(Fcn, Index, OpType, |
| 2776 Fcn, Index, OpType, Signature->getArgType(Index)); | 2775 Signature->getArgType(Index)); |
| 2777 if (IntrinsicInfo) { | 2776 if (IntrinsicInfo) { |
| 2778 verifyCallArgTypeMatches(Fcn, Index, OpType, | 2777 verifyCallArgTypeMatches(Fcn, Index, OpType, |
| 2779 IntrinsicInfo->getArgType(Index)); | 2778 IntrinsicInfo->getArgType(Index)); |
| 2780 } else if (!isCallParameterType(OpType)) { | 2779 } else if (!isCallParameterType(OpType)) { |
| 2781 std::string Buffer; | 2780 std::string Buffer; |
| 2782 raw_string_ostream StrBuf(Buffer); | 2781 raw_string_ostream StrBuf(Buffer); |
| 2783 StrBuf << "Argument " << *Op << " of " << printName(Fcn) | 2782 StrBuf << "Argument " << *Op << " of " << printName(Fcn) |
| 2784 << " has invalid type: " << Op->getType(); | 2783 << " has invalid type: " << Op->getType(); |
| 2785 Error(StrBuf.str()); | 2784 Error(StrBuf.str()); |
| 2786 appendErrorInstruction(ReturnType); | 2785 appendErrorInstruction(ReturnType); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3281 raw_string_ostream StrBuf(Buffer); | 3280 raw_string_ostream StrBuf(Buffer); |
| 3282 StrBuf << IRFilename << ": Does not contain a module!"; | 3281 StrBuf << IRFilename << ": Does not contain a module!"; |
| 3283 llvm::report_fatal_error(StrBuf.str()); | 3282 llvm::report_fatal_error(StrBuf.str()); |
| 3284 } | 3283 } |
| 3285 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3284 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
| 3286 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); | 3285 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); |
| 3287 } | 3286 } |
| 3288 } | 3287 } |
| 3289 | 3288 |
| 3290 } // end of namespace Ice | 3289 } // end of namespace Ice |
| OLD | NEW |