| OLD | NEW |
| 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// | 1 //===- subzero/src/IceGlobalInits.cpp - Global declarations ---------------===// |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 std::string Buffer; | 53 std::string Buffer; |
| 54 llvm::raw_string_ostream StrBuf(Buffer); | 54 llvm::raw_string_ostream StrBuf(Buffer); |
| 55 StrBuf << "Unknown calling convention: " << CallingConv; | 55 StrBuf << "Unknown calling convention: " << CallingConv; |
| 56 llvm::report_fatal_error(StrBuf.str()); | 56 llvm::report_fatal_error(StrBuf.str()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // end of anonymous namespace | 59 } // end of anonymous namespace |
| 60 | 60 |
| 61 namespace Ice { | 61 namespace Ice { |
| 62 | 62 |
| 63 const Intrinsics::FullIntrinsicInfo * |
| 64 FunctionDeclaration::getIntrinsicInfo(const GlobalContext *Ctx, |
| 65 bool *IsIntrinsic) const { |
| 66 *IsIntrinsic = false; |
| 67 if (!hasName()) |
| 68 return nullptr; |
| 69 bool BadIntrinsic; |
| 70 const Intrinsics::FullIntrinsicInfo *Info = |
| 71 Ctx->getIntrinsicsInfo().find(getName(), BadIntrinsic); |
| 72 *IsIntrinsic = Info || BadIntrinsic; |
| 73 return Info; |
| 74 } |
| 75 |
| 76 bool FunctionDeclaration::validateRegularTypeSignature() const { |
| 77 for (SizeT i = 0; i < Signature.getNumArgs(); ++i) { |
| 78 if (!isCallParameterType(Signature.getArgType(i))) |
| 79 return false; |
| 80 } |
| 81 return isCallReturnType(Signature.getReturnType()); |
| 82 } |
| 83 |
| 84 bool FunctionDeclaration::validateIntrinsicTypeSignature( |
| 85 const Intrinsics::FullIntrinsicInfo *Info) const { |
| 86 if (Signature.getNumArgs() != Info->getNumArgs()) |
| 87 return false; |
| 88 for (SizeT i = 0; i < Signature.getNumArgs(); ++i) { |
| 89 if (Signature.getArgType(i) != Info->getArgType(i)) |
| 90 return false; |
| 91 } |
| 92 return Signature.getReturnType() == Info->getReturnType(); |
| 93 } |
| 94 |
| 95 IceString FunctionDeclaration::getTypeSignatureError(const GlobalContext *Ctx) { |
| 96 std::string Buffer; |
| 97 llvm::raw_string_ostream StrBuf(Buffer); |
| 98 StrBuf << "Invalid"; |
| 99 bool IsIntrinsic; |
| 100 const Intrinsics::FullIntrinsicInfo *Info = |
| 101 getIntrinsicInfo(Ctx, &IsIntrinsic); |
| 102 if (IsIntrinsic && Info == nullptr) { |
| 103 StrBuf << " intrinsic name: " << getName(); |
| 104 return StrBuf.str(); |
| 105 } |
| 106 StrBuf << " type signature for"; |
| 107 if (IsIntrinsic) |
| 108 StrBuf << " intrinsic"; |
| 109 StrBuf << " " << getName() << ": " << getSignature(); |
| 110 return StrBuf.str(); |
| 111 } |
| 112 |
| 63 void FunctionDeclaration::dumpType(Ostream &Stream) const { | 113 void FunctionDeclaration::dumpType(Ostream &Stream) const { |
| 64 if (!Ice::BuildDefs::dump()) | 114 if (!Ice::BuildDefs::dump()) |
| 65 return; | 115 return; |
| 66 Stream << Signature; | 116 Stream << Signature; |
| 67 } | 117 } |
| 68 | 118 |
| 69 void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { | 119 void FunctionDeclaration::dump(GlobalContext *Ctx, Ostream &Stream) const { |
| 70 if (!Ice::BuildDefs::dump()) | 120 if (!Ice::BuildDefs::dump()) |
| 71 return; | 121 return; |
| 72 if (IsProto) | 122 if (IsProto) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 dumpType(Stream); | 246 dumpType(Stream); |
| 197 Stream << ")"; | 247 Stream << ")"; |
| 198 if (Offset != 0) { | 248 if (Offset != 0) { |
| 199 Stream << ", "; | 249 Stream << ", "; |
| 200 dumpType(Stream); | 250 dumpType(Stream); |
| 201 Stream << " " << Offset << ")"; | 251 Stream << " " << Offset << ")"; |
| 202 } | 252 } |
| 203 } | 253 } |
| 204 | 254 |
| 205 } // end of namespace Ice | 255 } // end of namespace Ice |
| OLD | NEW |