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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 protected: | 80 protected: |
81 // Note: For simple types, the return type of the signature will | 81 // Note: For simple types, the return type of the signature will |
82 // be used to hold the simple type. | 82 // be used to hold the simple type. |
83 Ice::FuncSigType Signature; | 83 Ice::FuncSigType Signature; |
84 | 84 |
85 private: | 85 private: |
86 ExtendedType::TypeKind Kind; | 86 ExtendedType::TypeKind Kind; |
87 }; | 87 }; |
88 | 88 |
89 Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { | 89 Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { |
| 90 if (!ALLOW_DUMP) |
| 91 return Stream; |
90 Ty.dump(Stream); | 92 Ty.dump(Stream); |
91 return Stream; | 93 return Stream; |
92 } | 94 } |
93 | 95 |
94 Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { | 96 Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { |
| 97 if (!ALLOW_DUMP) |
| 98 return Stream; |
95 Stream << "ExtendedType::"; | 99 Stream << "ExtendedType::"; |
96 switch (Kind) { | 100 switch (Kind) { |
97 case ExtendedType::Undefined: | 101 case ExtendedType::Undefined: |
98 Stream << "Undefined"; | 102 Stream << "Undefined"; |
99 break; | 103 break; |
100 case ExtendedType::Simple: | 104 case ExtendedType::Simple: |
101 Stream << "Simple"; | 105 Stream << "Simple"; |
102 break; | 106 break; |
103 case ExtendedType::FuncSig: | 107 case ExtendedType::FuncSig: |
104 Stream << "FuncSig"; | 108 Stream << "FuncSig"; |
(...skipping 26 matching lines...) Expand all Loading... |
131 void setReturnType(Ice::Type ReturnType) { | 135 void setReturnType(Ice::Type ReturnType) { |
132 Signature.setReturnType(ReturnType); | 136 Signature.setReturnType(ReturnType); |
133 } | 137 } |
134 void appendArgType(Ice::Type ArgType) { Signature.appendArgType(ArgType); } | 138 void appendArgType(Ice::Type ArgType) { Signature.appendArgType(ArgType); } |
135 static bool classof(const ExtendedType *Ty) { | 139 static bool classof(const ExtendedType *Ty) { |
136 return Ty->getKind() == FuncSig; | 140 return Ty->getKind() == FuncSig; |
137 } | 141 } |
138 }; | 142 }; |
139 | 143 |
140 void ExtendedType::dump(Ice::Ostream &Stream) const { | 144 void ExtendedType::dump(Ice::Ostream &Stream) const { |
| 145 if (!ALLOW_DUMP) |
| 146 return; |
141 Stream << Kind; | 147 Stream << Kind; |
142 switch (Kind) { | 148 switch (Kind) { |
143 case Simple: { | 149 case Simple: { |
144 Stream << " " << Signature.getReturnType(); | 150 Stream << " " << Signature.getReturnType(); |
145 break; | 151 break; |
146 } | 152 } |
147 case FuncSig: { | 153 case FuncSig: { |
148 Stream << " " << Signature; | 154 Stream << " " << Signature; |
149 } | 155 } |
150 default: | 156 default: |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return ALLOW_DISABLE_IR_GEN ? getTranslator().getFlags().DisableIRGeneration | 544 return ALLOW_DISABLE_IR_GEN ? getTranslator().getFlags().DisableIRGeneration |
539 : false; | 545 : false; |
540 } | 546 } |
541 | 547 |
542 // Generates an error Message with the bit address prefixed to it. | 548 // Generates an error Message with the bit address prefixed to it. |
543 bool Error(const std::string &Message) override { | 549 bool Error(const std::string &Message) override { |
544 uint64_t Bit = Record.GetStartBit() + Context->getHeaderSize() * 8; | 550 uint64_t Bit = Record.GetStartBit() + Context->getHeaderSize() * 8; |
545 std::string Buffer; | 551 std::string Buffer; |
546 raw_string_ostream StrBuf(Buffer); | 552 raw_string_ostream StrBuf(Buffer); |
547 StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8), | 553 StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8), |
548 static_cast<unsigned>(Bit % 8)) << ") " << Message; | 554 static_cast<unsigned>(Bit % 8)) << ") "; |
| 555 // Note: If dump routines have been turned off, the error messages |
| 556 // will not be readable. Hence, replace with simple error. |
| 557 if (ALLOW_DUMP) |
| 558 StrBuf << Message; |
| 559 else |
| 560 StrBuf << "Invalid input record"; |
549 return Context->Error(StrBuf.str()); | 561 return Context->Error(StrBuf.str()); |
550 } | 562 } |
551 | 563 |
552 // Default implementation. Reports that block is unknown and skips | 564 // Default implementation. Reports that block is unknown and skips |
553 // its contents. | 565 // its contents. |
554 bool ParseBlock(unsigned BlockID) override; | 566 bool ParseBlock(unsigned BlockID) override; |
555 | 567 |
556 // Default implementation. Reports that the record is not | 568 // Default implementation. Reports that the record is not |
557 // understood. | 569 // understood. |
558 void ProcessRecord() override; | 570 void ProcessRecord() override; |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 enum VectorIndexCheckValue { | 1399 enum VectorIndexCheckValue { |
1388 VectorIndexNotVector, | 1400 VectorIndexNotVector, |
1389 VectorIndexNotConstant, | 1401 VectorIndexNotConstant, |
1390 VectorIndexNotInRange, | 1402 VectorIndexNotInRange, |
1391 VectorIndexNotI32, | 1403 VectorIndexNotI32, |
1392 VectorIndexValid | 1404 VectorIndexValid |
1393 }; | 1405 }; |
1394 | 1406 |
1395 void dumpVectorIndexCheckValue(raw_ostream &Stream, | 1407 void dumpVectorIndexCheckValue(raw_ostream &Stream, |
1396 VectorIndexCheckValue Value) const { | 1408 VectorIndexCheckValue Value) const { |
| 1409 if (!ALLOW_DUMP) |
| 1410 return; |
1397 switch (Value) { | 1411 switch (Value) { |
1398 default: | 1412 default: |
1399 report_fatal_error("Unknown VectorIndexCheckValue"); | 1413 report_fatal_error("Unknown VectorIndexCheckValue"); |
1400 break; | 1414 break; |
1401 case VectorIndexNotVector: | 1415 case VectorIndexNotVector: |
1402 Stream << "Vector index on non vector"; | 1416 Stream << "Vector index on non vector"; |
1403 break; | 1417 break; |
1404 case VectorIndexNotConstant: | 1418 case VectorIndexNotConstant: |
1405 Stream << "Vector index not integer constant"; | 1419 Stream << "Vector index not integer constant"; |
1406 break; | 1420 break; |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 | 2872 |
2859 if (TopLevelBlocks != 1) { | 2873 if (TopLevelBlocks != 1) { |
2860 errs() << IRFilename | 2874 errs() << IRFilename |
2861 << ": Contains more than one module. Found: " << TopLevelBlocks | 2875 << ": Contains more than one module. Found: " << TopLevelBlocks |
2862 << "\n"; | 2876 << "\n"; |
2863 ErrorStatus = true; | 2877 ErrorStatus = true; |
2864 } | 2878 } |
2865 } | 2879 } |
2866 | 2880 |
2867 } // end of namespace Ice | 2881 } // end of namespace Ice |
OLD | NEW |