Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: src/PNaClTranslator.cpp

Issue 1197863003: Subzero: Reduce the amount of #ifdef'd code. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Cleanup Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTypes.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 protected: 73 protected:
74 // Note: For simple types, the return type of the signature will 74 // Note: For simple types, the return type of the signature will
75 // be used to hold the simple type. 75 // be used to hold the simple type.
76 Ice::FuncSigType Signature; 76 Ice::FuncSigType Signature;
77 77
78 private: 78 private:
79 ExtendedType::TypeKind Kind = Undefined; 79 ExtendedType::TypeKind Kind = Undefined;
80 }; 80 };
81 81
82 Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { 82 Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) {
83 if (!ALLOW_DUMP) 83 if (!Ice::BuildDefs::dump())
84 return Stream; 84 return Stream;
85 Ty.dump(Stream); 85 Ty.dump(Stream);
86 return Stream; 86 return Stream;
87 } 87 }
88 88
89 Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { 89 Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) {
90 if (!ALLOW_DUMP) 90 if (!Ice::BuildDefs::dump())
91 return Stream; 91 return Stream;
92 Stream << "ExtendedType::"; 92 Stream << "ExtendedType::";
93 switch (Kind) { 93 switch (Kind) {
94 case ExtendedType::Undefined: 94 case ExtendedType::Undefined:
95 Stream << "Undefined"; 95 Stream << "Undefined";
96 break; 96 break;
97 case ExtendedType::Simple: 97 case ExtendedType::Simple:
98 Stream << "Simple"; 98 Stream << "Simple";
99 break; 99 break;
100 case ExtendedType::FuncSig: 100 case ExtendedType::FuncSig:
(...skipping 28 matching lines...) Expand all
129 void setReturnType(Ice::Type ReturnType) { 129 void setReturnType(Ice::Type ReturnType) {
130 Signature.setReturnType(ReturnType); 130 Signature.setReturnType(ReturnType);
131 } 131 }
132 void appendArgType(Ice::Type ArgType) { Signature.appendArgType(ArgType); } 132 void appendArgType(Ice::Type ArgType) { Signature.appendArgType(ArgType); }
133 static bool classof(const ExtendedType *Ty) { 133 static bool classof(const ExtendedType *Ty) {
134 return Ty->getKind() == FuncSig; 134 return Ty->getKind() == FuncSig;
135 } 135 }
136 }; 136 };
137 137
138 void ExtendedType::dump(Ice::Ostream &Stream) const { 138 void ExtendedType::dump(Ice::Ostream &Stream) const {
139 if (!ALLOW_DUMP) 139 if (!Ice::BuildDefs::dump())
140 return; 140 return;
141 Stream << Kind; 141 Stream << Kind;
142 switch (Kind) { 142 switch (Kind) {
143 case Simple: { 143 case Simple: {
144 Stream << " " << Signature.getReturnType(); 144 Stream << " " << Signature.getReturnType();
145 break; 145 break;
146 } 146 }
147 case FuncSig: { 147 case FuncSig: {
148 Stream << " " << Signature; 148 Stream << " " << Signature;
149 } 149 }
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 enum VectorIndexCheckValue { 1557 enum VectorIndexCheckValue {
1558 VectorIndexNotVector, 1558 VectorIndexNotVector,
1559 VectorIndexNotConstant, 1559 VectorIndexNotConstant,
1560 VectorIndexNotInRange, 1560 VectorIndexNotInRange,
1561 VectorIndexNotI32, 1561 VectorIndexNotI32,
1562 VectorIndexValid 1562 VectorIndexValid
1563 }; 1563 };
1564 1564
1565 void dumpVectorIndexCheckValue(raw_ostream &Stream, 1565 void dumpVectorIndexCheckValue(raw_ostream &Stream,
1566 VectorIndexCheckValue Value) const { 1566 VectorIndexCheckValue Value) const {
1567 if (!ALLOW_DUMP) 1567 if (!Ice::BuildDefs::dump())
1568 return; 1568 return;
1569 switch (Value) { 1569 switch (Value) {
1570 case VectorIndexNotVector: 1570 case VectorIndexNotVector:
1571 Stream << "Vector index on non vector"; 1571 Stream << "Vector index on non vector";
1572 break; 1572 break;
1573 case VectorIndexNotConstant: 1573 case VectorIndexNotConstant:
1574 Stream << "Vector index not integer constant"; 1574 Stream << "Vector index not integer constant";
1575 break; 1575 break;
1576 case VectorIndexNotInRange: 1576 case VectorIndexNotInRange:
1577 Stream << "Vector index not in range of vector"; 1577 Stream << "Vector index not in range of vector";
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 // (FP->getOperand will create fatal error). 2831 // (FP->getOperand will create fatal error).
2832 if (Index < getFunctionParser()->getNumGlobalIDs()) { 2832 if (Index < getFunctionParser()->getNumGlobalIDs()) {
2833 reportUnableToAssign("instruction", Index, Name); 2833 reportUnableToAssign("instruction", Index, Name);
2834 // TODO(kschimpf) Remove error recovery once implementation complete. 2834 // TODO(kschimpf) Remove error recovery once implementation complete.
2835 return; 2835 return;
2836 } 2836 }
2837 if (isIRGenerationDisabled()) 2837 if (isIRGenerationDisabled())
2838 return; 2838 return;
2839 Ice::Operand *Op = getFunctionParser()->getOperand(Index); 2839 Ice::Operand *Op = getFunctionParser()->getOperand(Index);
2840 if (Ice::Variable *V = dyn_cast<Ice::Variable>(Op)) { 2840 if (Ice::Variable *V = dyn_cast<Ice::Variable>(Op)) {
2841 if (ALLOW_DUMP) { 2841 if (Ice::BuildDefs::dump()) {
2842 std::string Nm(Name.data(), Name.size()); 2842 std::string Nm(Name.data(), Name.size());
2843 V->setName(getFunctionParser()->getFunc(), Nm); 2843 V->setName(getFunctionParser()->getFunc(), Nm);
2844 } 2844 }
2845 } else { 2845 } else {
2846 reportUnableToAssign("variable", Index, Name); 2846 reportUnableToAssign("variable", Index, Name);
2847 } 2847 }
2848 } 2848 }
2849 2849
2850 void FunctionValuesymtabParser::setBbName(NaClBcIndexSize_t Index, 2850 void FunctionValuesymtabParser::setBbName(NaClBcIndexSize_t Index,
2851 StringType &Name) { 2851 StringType &Name) {
2852 if (isIRGenerationDisabled()) 2852 if (isIRGenerationDisabled())
2853 return; 2853 return;
2854 if (Index >= getFunctionParser()->getFunc()->getNumNodes()) { 2854 if (Index >= getFunctionParser()->getFunc()->getNumNodes()) {
2855 reportUnableToAssign("block", Index, Name); 2855 reportUnableToAssign("block", Index, Name);
2856 return; 2856 return;
2857 } 2857 }
2858 std::string Nm(Name.data(), Name.size()); 2858 std::string Nm(Name.data(), Name.size());
2859 if (ALLOW_DUMP) 2859 if (Ice::BuildDefs::dump())
2860 getFunctionParser()->getFunc()->getNodes()[Index]->setName(Nm); 2860 getFunctionParser()->getFunc()->getNodes()[Index]->setName(Nm);
2861 } 2861 }
2862 2862
2863 bool FunctionParser::ParseBlock(unsigned BlockID) { 2863 bool FunctionParser::ParseBlock(unsigned BlockID) {
2864 switch (BlockID) { 2864 switch (BlockID) {
2865 case naclbitc::CONSTANTS_BLOCK_ID: { 2865 case naclbitc::CONSTANTS_BLOCK_ID: {
2866 ConstantsParser Parser(BlockID, this); 2866 ConstantsParser Parser(BlockID, this);
2867 return Parser.ParseThisBlock(); 2867 return Parser.ParseThisBlock();
2868 } 2868 }
2869 case naclbitc::VALUE_SYMTAB_BLOCK_ID: { 2869 case naclbitc::VALUE_SYMTAB_BLOCK_ID: {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
3096 } 3096 }
3097 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { 3097 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) {
3098 ErrStream 3098 ErrStream
3099 << IRFilename 3099 << IRFilename
3100 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; 3100 << ": Bitcode stream should be a multiple of 4 bytes in length.\n";
3101 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); 3101 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes");
3102 } 3102 }
3103 } 3103 }
3104 3104
3105 } // end of namespace Ice 3105 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTypes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698