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 29 matching lines...) Expand all Loading... |
40 // signature. Note that an extended type is undefined on construction. | 40 // signature. Note that an extended type is undefined on construction. |
41 // Use methods setAsSimpleType and setAsFuncSigType to define | 41 // Use methods setAsSimpleType and setAsFuncSigType to define |
42 // the extended type. | 42 // the extended type. |
43 class ExtendedType { | 43 class ExtendedType { |
44 ExtendedType &operator=(const ExtendedType &Ty) = delete; | 44 ExtendedType &operator=(const ExtendedType &Ty) = delete; |
45 | 45 |
46 public: | 46 public: |
47 /// Discriminator for LLVM-style RTTI. | 47 /// Discriminator for LLVM-style RTTI. |
48 enum TypeKind { Undefined, Simple, FuncSig }; | 48 enum TypeKind { Undefined, Simple, FuncSig }; |
49 | 49 |
50 ExtendedType() : Kind(Undefined) {} | 50 ExtendedType() = default; |
51 ExtendedType(const ExtendedType &Ty) = default; | 51 ExtendedType(const ExtendedType &Ty) = default; |
52 | 52 |
53 virtual ~ExtendedType() {} | 53 virtual ~ExtendedType() = default; |
54 | 54 |
55 ExtendedType::TypeKind getKind() const { return Kind; } | 55 ExtendedType::TypeKind getKind() const { return Kind; } |
56 void dump(Ice::Ostream &Stream) const; | 56 void dump(Ice::Ostream &Stream) const; |
57 | 57 |
58 /// Changes the extended type to a simple type with the given | 58 /// Changes the extended type to a simple type with the given |
59 /// value. | 59 /// value. |
60 void setAsSimpleType(Ice::Type Ty) { | 60 void setAsSimpleType(Ice::Type Ty) { |
61 assert(Kind == Undefined); | 61 assert(Kind == Undefined); |
62 Kind = Simple; | 62 Kind = Simple; |
63 Signature.setReturnType(Ty); | 63 Signature.setReturnType(Ty); |
64 } | 64 } |
65 | 65 |
66 /// Changes the extended type to an (empty) function signature type. | 66 /// Changes the extended type to an (empty) function signature type. |
67 void setAsFunctionType() { | 67 void setAsFunctionType() { |
68 assert(Kind == Undefined); | 68 assert(Kind == Undefined); |
69 Kind = FuncSig; | 69 Kind = FuncSig; |
70 } | 70 } |
71 | 71 |
72 protected: | 72 protected: |
73 // Note: For simple types, the return type of the signature will | 73 // Note: For simple types, the return type of the signature will |
74 // be used to hold the simple type. | 74 // be used to hold the simple type. |
75 Ice::FuncSigType Signature; | 75 Ice::FuncSigType Signature; |
76 | 76 |
77 private: | 77 private: |
78 ExtendedType::TypeKind Kind; | 78 ExtendedType::TypeKind Kind = Undefined; |
79 }; | 79 }; |
80 | 80 |
81 Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { | 81 Ice::Ostream &operator<<(Ice::Ostream &Stream, const ExtendedType &Ty) { |
82 if (!ALLOW_DUMP) | 82 if (!ALLOW_DUMP) |
83 return Stream; | 83 return Stream; |
84 Ty.dump(Stream); | 84 Ty.dump(Stream); |
85 return Stream; | 85 return Stream; |
86 } | 86 } |
87 | 87 |
88 Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { | 88 Ice::Ostream &operator<<(Ice::Ostream &Stream, ExtendedType::TypeKind Kind) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 TopLevelParser() = delete; | 158 TopLevelParser() = delete; |
159 TopLevelParser(const TopLevelParser &) = delete; | 159 TopLevelParser(const TopLevelParser &) = delete; |
160 TopLevelParser &operator=(const TopLevelParser &) = delete; | 160 TopLevelParser &operator=(const TopLevelParser &) = delete; |
161 | 161 |
162 public: | 162 public: |
163 typedef std::vector<Ice::FunctionDeclaration *> FunctionDeclarationListType; | 163 typedef std::vector<Ice::FunctionDeclaration *> FunctionDeclarationListType; |
164 | 164 |
165 TopLevelParser(Ice::Translator &Translator, NaClBitstreamCursor &Cursor, | 165 TopLevelParser(Ice::Translator &Translator, NaClBitstreamCursor &Cursor, |
166 Ice::ErrorCode &ErrorStatus) | 166 Ice::ErrorCode &ErrorStatus) |
167 : NaClBitcodeParser(Cursor), Translator(Translator), | 167 : NaClBitcodeParser(Cursor), Translator(Translator), |
168 ErrorStatus(ErrorStatus), NumErrors(0), NextDefiningFunctionID(0), | 168 ErrorStatus(ErrorStatus), |
169 VariableDeclarations(new Ice::VariableDeclarationList()), | 169 VariableDeclarations(new Ice::VariableDeclarationList()) {} |
170 BlockParser(nullptr) {} | |
171 | 170 |
172 ~TopLevelParser() override {} | 171 ~TopLevelParser() override {} |
173 | 172 |
174 Ice::Translator &getTranslator() const { return Translator; } | 173 Ice::Translator &getTranslator() const { return Translator; } |
175 | 174 |
176 void setBlockParser(BlockParserBaseClass *NewBlockParser) { | 175 void setBlockParser(BlockParserBaseClass *NewBlockParser) { |
177 BlockParser = NewBlockParser; | 176 BlockParser = NewBlockParser; |
178 } | 177 } |
179 | 178 |
180 /// Generates error with given Message, occurring at BitPosition | 179 /// Generates error with given Message, occurring at BitPosition |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 VariableDeclarations->size() <= ValueIDConstants.size()); | 336 VariableDeclarations->size() <= ValueIDConstants.size()); |
338 return std::move(VariableDeclarations); | 337 return std::move(VariableDeclarations); |
339 } | 338 } |
340 | 339 |
341 private: | 340 private: |
342 // The translator associated with the parser. | 341 // The translator associated with the parser. |
343 Ice::Translator &Translator; | 342 Ice::Translator &Translator; |
344 // The exit status that should be set to true if an error occurs. | 343 // The exit status that should be set to true if an error occurs. |
345 Ice::ErrorCode &ErrorStatus; | 344 Ice::ErrorCode &ErrorStatus; |
346 // The number of errors reported. | 345 // The number of errors reported. |
347 unsigned NumErrors; | 346 unsigned NumErrors = 0; |
348 // The types associated with each type ID. | 347 // The types associated with each type ID. |
349 std::vector<ExtendedType> TypeIDValues; | 348 std::vector<ExtendedType> TypeIDValues; |
350 // The set of functions (prototype and defined). | 349 // The set of functions (prototype and defined). |
351 FunctionDeclarationListType FunctionDeclarationList; | 350 FunctionDeclarationListType FunctionDeclarationList; |
352 // The ID of the next possible defined function ID in | 351 // The ID of the next possible defined function ID in |
353 // FunctionDeclarationList. FunctionDeclarationList is filled | 352 // FunctionDeclarationList. FunctionDeclarationList is filled |
354 // first. It's the set of functions (either defined or isproto). Then | 353 // first. It's the set of functions (either defined or isproto). Then |
355 // function definitions are encountered/parsed and | 354 // function definitions are encountered/parsed and |
356 // NextDefiningFunctionID is incremented to track the next | 355 // NextDefiningFunctionID is incremented to track the next |
357 // actually-defined function. | 356 // actually-defined function. |
358 size_t NextDefiningFunctionID; | 357 size_t NextDefiningFunctionID = 0; |
359 // The set of global variables. | 358 // The set of global variables. |
360 std::unique_ptr<Ice::VariableDeclarationList> VariableDeclarations; | 359 std::unique_ptr<Ice::VariableDeclarationList> VariableDeclarations; |
361 // Relocatable constants associated with global declarations. | 360 // Relocatable constants associated with global declarations. |
362 std::vector<Ice::Constant *> ValueIDConstants; | 361 std::vector<Ice::Constant *> ValueIDConstants; |
363 // Error recovery value to use when getFuncSigTypeByID fails. | 362 // Error recovery value to use when getFuncSigTypeByID fails. |
364 Ice::FuncSigType UndefinedFuncSigType; | 363 Ice::FuncSigType UndefinedFuncSigType; |
365 // The block parser currently being applied. Used for error | 364 // The block parser currently being applied. Used for error |
366 // reporting. | 365 // reporting. |
367 BlockParserBaseClass *BlockParser; | 366 BlockParserBaseClass *BlockParser = nullptr; |
368 | 367 |
369 bool ParseBlock(unsigned BlockID) override; | 368 bool ParseBlock(unsigned BlockID) override; |
370 | 369 |
371 // Gets extended type associated with the given index, assuming the | 370 // Gets extended type associated with the given index, assuming the |
372 // extended type is of the WantedKind. Generates error message if | 371 // extended type is of the WantedKind. Generates error message if |
373 // corresponding extended type of WantedKind can't be found, and | 372 // corresponding extended type of WantedKind can't be found, and |
374 // returns nullptr. | 373 // returns nullptr. |
375 ExtendedType *getTypeByIDAsKind(unsigned ID, | 374 ExtendedType *getTypeByIDAsKind(unsigned ID, |
376 ExtendedType::TypeKind WantedKind) { | 375 ExtendedType::TypeKind WantedKind) { |
377 ExtendedType *Ty = nullptr; | 376 ExtendedType *Ty = nullptr; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 | 718 |
720 // Class to parse a types block. | 719 // Class to parse a types block. |
721 class TypesParser : public BlockParserBaseClass { | 720 class TypesParser : public BlockParserBaseClass { |
722 TypesParser() = delete; | 721 TypesParser() = delete; |
723 TypesParser(const TypesParser &) = delete; | 722 TypesParser(const TypesParser &) = delete; |
724 TypesParser &operator=(const TypesParser &) = delete; | 723 TypesParser &operator=(const TypesParser &) = delete; |
725 | 724 |
726 public: | 725 public: |
727 TypesParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) | 726 TypesParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) |
728 : BlockParserBaseClass(BlockID, EnclosingParser), | 727 : BlockParserBaseClass(BlockID, EnclosingParser), |
729 Timer(Ice::TimerStack::TT_parseTypes, getTranslator().getContext()), | 728 Timer(Ice::TimerStack::TT_parseTypes, getTranslator().getContext()) {} |
730 NextTypeId(0) {} | |
731 | 729 |
732 ~TypesParser() override {} | 730 ~TypesParser() override {} |
733 | 731 |
734 private: | 732 private: |
735 Ice::TimerMarker Timer; | 733 Ice::TimerMarker Timer; |
736 // The type ID that will be associated with the next type defining | 734 // The type ID that will be associated with the next type defining |
737 // record in the types block. | 735 // record in the types block. |
738 unsigned NextTypeId; | 736 unsigned NextTypeId = 0; |
739 | 737 |
740 void ProcessRecord() override; | 738 void ProcessRecord() override; |
741 | 739 |
742 const char *getBlockName() const override { return "type"; } | 740 const char *getBlockName() const override { return "type"; } |
743 | 741 |
744 void setNextTypeIDAsSimpleType(Ice::Type Ty) { | 742 void setNextTypeIDAsSimpleType(Ice::Type Ty) { |
745 Context->getTypeByIDForDefining(NextTypeId++)->setAsSimpleType(Ty); | 743 Context->getTypeByIDForDefining(NextTypeId++)->setAsSimpleType(Ty); |
746 } | 744 } |
747 }; | 745 }; |
748 | 746 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 /// corresponding initializers). | 897 /// corresponding initializers). |
900 class GlobalsParser : public BlockParserBaseClass { | 898 class GlobalsParser : public BlockParserBaseClass { |
901 GlobalsParser() = delete; | 899 GlobalsParser() = delete; |
902 GlobalsParser(const GlobalsParser &) = delete; | 900 GlobalsParser(const GlobalsParser &) = delete; |
903 GlobalsParser &operator=(const GlobalsParser &) = delete; | 901 GlobalsParser &operator=(const GlobalsParser &) = delete; |
904 | 902 |
905 public: | 903 public: |
906 GlobalsParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) | 904 GlobalsParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) |
907 : BlockParserBaseClass(BlockID, EnclosingParser), | 905 : BlockParserBaseClass(BlockID, EnclosingParser), |
908 Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()), | 906 Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()), |
909 InitializersNeeded(0), NextGlobalID(0), | |
910 DummyGlobalVar(Ice::VariableDeclaration::create()), | 907 DummyGlobalVar(Ice::VariableDeclaration::create()), |
911 CurGlobalVar(DummyGlobalVar) {} | 908 CurGlobalVar(DummyGlobalVar) {} |
912 | 909 |
913 ~GlobalsParser() final {} | 910 ~GlobalsParser() final {} |
914 | 911 |
915 const char *getBlockName() const override { return "globals"; } | 912 const char *getBlockName() const override { return "globals"; } |
916 | 913 |
917 private: | 914 private: |
918 Ice::TimerMarker Timer; | 915 Ice::TimerMarker Timer; |
919 // Keeps track of how many initializers are expected for the global variable | 916 // Keeps track of how many initializers are expected for the global variable |
920 // declaration being built. | 917 // declaration being built. |
921 unsigned InitializersNeeded; | 918 unsigned InitializersNeeded = 0; |
922 | 919 |
923 // The index of the next global variable declaration. | 920 // The index of the next global variable declaration. |
924 unsigned NextGlobalID; | 921 unsigned NextGlobalID = 0; |
925 | 922 |
926 // Dummy global variable declaration to guarantee CurGlobalVar is | 923 // Dummy global variable declaration to guarantee CurGlobalVar is |
927 // always defined (allowing code to not need to check if | 924 // always defined (allowing code to not need to check if |
928 // CurGlobalVar is nullptr). | 925 // CurGlobalVar is nullptr). |
929 Ice::VariableDeclaration *DummyGlobalVar; | 926 Ice::VariableDeclaration *DummyGlobalVar; |
930 | 927 |
931 // Holds the current global variable declaration being built. | 928 // Holds the current global variable declaration being built. |
932 Ice::VariableDeclaration *CurGlobalVar; | 929 Ice::VariableDeclaration *CurGlobalVar; |
933 | 930 |
934 void ExitBlock() override { | 931 void ExitBlock() override { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 /// Parses function blocks in the bitcode file. | 1115 /// Parses function blocks in the bitcode file. |
1119 class FunctionParser : public BlockParserBaseClass { | 1116 class FunctionParser : public BlockParserBaseClass { |
1120 FunctionParser() = delete; | 1117 FunctionParser() = delete; |
1121 FunctionParser(const FunctionParser &) = delete; | 1118 FunctionParser(const FunctionParser &) = delete; |
1122 FunctionParser &operator=(const FunctionParser &) = delete; | 1119 FunctionParser &operator=(const FunctionParser &) = delete; |
1123 | 1120 |
1124 public: | 1121 public: |
1125 FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) | 1122 FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser) |
1126 : BlockParserBaseClass(BlockID, EnclosingParser), | 1123 : BlockParserBaseClass(BlockID, EnclosingParser), |
1127 Timer(Ice::TimerStack::TT_parseFunctions, getTranslator().getContext()), | 1124 Timer(Ice::TimerStack::TT_parseFunctions, getTranslator().getContext()), |
1128 Func(nullptr), CurrentBbIndex(0), | 1125 Func(nullptr), FcnId(Context->getNextFunctionBlockValueID()), |
1129 FcnId(Context->getNextFunctionBlockValueID()), | |
1130 FuncDecl(Context->getFunctionByID(FcnId)), | 1126 FuncDecl(Context->getFunctionByID(FcnId)), |
1131 CachedNumGlobalValueIDs(Context->getNumGlobalIDs()), | 1127 CachedNumGlobalValueIDs(Context->getNumGlobalIDs()), |
1132 NextLocalInstIndex(Context->getNumGlobalIDs()), | 1128 NextLocalInstIndex(Context->getNumGlobalIDs()) {} |
1133 InstIsTerminating(false) {} | |
1134 | 1129 |
1135 bool convertFunction() { | 1130 bool convertFunction() { |
1136 const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs; | 1131 const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs; |
1137 Ice::TimerIdT TimerID = 0; | 1132 Ice::TimerIdT TimerID = 0; |
1138 const bool TimeThisFunction = getFlags().getTimeEachFunction(); | 1133 const bool TimeThisFunction = getFlags().getTimeEachFunction(); |
1139 if (TimeThisFunction) { | 1134 if (TimeThisFunction) { |
1140 TimerID = getTranslator().getContext()->getTimerID(StackID, | 1135 TimerID = getTranslator().getContext()->getTimerID(StackID, |
1141 FuncDecl->getName()); | 1136 FuncDecl->getName()); |
1142 getTranslator().getContext()->pushTimer(TimerID, StackID); | 1137 getTranslator().getContext()->pushTimer(TimerID, StackID); |
1143 } | 1138 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 Fatal(StrBuf.str()); | 1221 Fatal(StrBuf.str()); |
1227 } | 1222 } |
1228 return Op; | 1223 return Op; |
1229 } | 1224 } |
1230 | 1225 |
1231 private: | 1226 private: |
1232 Ice::TimerMarker Timer; | 1227 Ice::TimerMarker Timer; |
1233 // The corresponding ICE function defined by the function block. | 1228 // The corresponding ICE function defined by the function block. |
1234 std::unique_ptr<Ice::Cfg> Func; | 1229 std::unique_ptr<Ice::Cfg> Func; |
1235 // The index to the current basic block being built. | 1230 // The index to the current basic block being built. |
1236 uint32_t CurrentBbIndex; | 1231 uint32_t CurrentBbIndex = 0; |
1237 // The basic block being built. | 1232 // The basic block being built. |
1238 Ice::CfgNode *CurrentNode; | 1233 Ice::CfgNode *CurrentNode = nullptr; |
1239 // The ID for the function. | 1234 // The ID for the function. |
1240 unsigned FcnId; | 1235 unsigned FcnId; |
1241 // The corresponding function declaration. | 1236 // The corresponding function declaration. |
1242 Ice::FunctionDeclaration *FuncDecl; | 1237 Ice::FunctionDeclaration *FuncDecl; |
1243 // Holds the dividing point between local and global absolute value indices. | 1238 // Holds the dividing point between local and global absolute value indices. |
1244 uint32_t CachedNumGlobalValueIDs; | 1239 uint32_t CachedNumGlobalValueIDs; |
1245 // Holds operands local to the function block, based on indices | 1240 // Holds operands local to the function block, based on indices |
1246 // defined in the bitcode file. | 1241 // defined in the bitcode file. |
1247 std::vector<Ice::Operand *> LocalOperands; | 1242 std::vector<Ice::Operand *> LocalOperands; |
1248 // Holds the index within LocalOperands corresponding to the next | 1243 // Holds the index within LocalOperands corresponding to the next |
1249 // instruction that generates a value. | 1244 // instruction that generates a value. |
1250 uint32_t NextLocalInstIndex; | 1245 uint32_t NextLocalInstIndex; |
1251 // True if the last processed instruction was a terminating | 1246 // True if the last processed instruction was a terminating |
1252 // instruction. | 1247 // instruction. |
1253 bool InstIsTerminating; | 1248 bool InstIsTerminating = false; |
1254 // Upper limit of alignment power allowed by LLVM | 1249 // Upper limit of alignment power allowed by LLVM |
1255 static const uint32_t AlignPowerLimit = 29; | 1250 static const uint32_t AlignPowerLimit = 29; |
1256 | 1251 |
1257 // Extracts the corresponding Alignment to use, given the AlignPower | 1252 // Extracts the corresponding Alignment to use, given the AlignPower |
1258 // (i.e. 2**(AlignPower-1), or 0 if AlignPower == 0). InstName is the | 1253 // (i.e. 2**(AlignPower-1), or 0 if AlignPower == 0). InstName is the |
1259 // name of the instruction the alignment appears in. | 1254 // name of the instruction the alignment appears in. |
1260 void extractAlignment(const char *InstName, uint32_t AlignPower, | 1255 void extractAlignment(const char *InstName, uint32_t AlignPower, |
1261 uint32_t &Alignment) { | 1256 uint32_t &Alignment) { |
1262 if (AlignPower <= AlignPowerLimit + 1) { | 1257 if (AlignPower <= AlignPowerLimit + 1) { |
1263 Alignment = (1 << AlignPower) >> 1; | 1258 Alignment = (1 << AlignPower) >> 1; |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 /// Parses constants within a function block. | 2594 /// Parses constants within a function block. |
2600 class ConstantsParser : public BlockParserBaseClass { | 2595 class ConstantsParser : public BlockParserBaseClass { |
2601 ConstantsParser() = delete; | 2596 ConstantsParser() = delete; |
2602 ConstantsParser(const ConstantsParser &) = delete; | 2597 ConstantsParser(const ConstantsParser &) = delete; |
2603 ConstantsParser &operator=(const ConstantsParser &) = delete; | 2598 ConstantsParser &operator=(const ConstantsParser &) = delete; |
2604 | 2599 |
2605 public: | 2600 public: |
2606 ConstantsParser(unsigned BlockID, FunctionParser *FuncParser) | 2601 ConstantsParser(unsigned BlockID, FunctionParser *FuncParser) |
2607 : BlockParserBaseClass(BlockID, FuncParser), | 2602 : BlockParserBaseClass(BlockID, FuncParser), |
2608 Timer(Ice::TimerStack::TT_parseConstants, getTranslator().getContext()), | 2603 Timer(Ice::TimerStack::TT_parseConstants, getTranslator().getContext()), |
2609 FuncParser(FuncParser), NextConstantType(Ice::IceType_void) {} | 2604 FuncParser(FuncParser) {} |
2610 | 2605 |
2611 ~ConstantsParser() override {} | 2606 ~ConstantsParser() override {} |
2612 | 2607 |
2613 const char *getBlockName() const override { return "constants"; } | 2608 const char *getBlockName() const override { return "constants"; } |
2614 | 2609 |
2615 private: | 2610 private: |
2616 Ice::TimerMarker Timer; | 2611 Ice::TimerMarker Timer; |
2617 // The parser of the function block this constants block appears in. | 2612 // The parser of the function block this constants block appears in. |
2618 FunctionParser *FuncParser; | 2613 FunctionParser *FuncParser; |
2619 // The type to use for succeeding constants. | 2614 // The type to use for succeeding constants. |
2620 Ice::Type NextConstantType; | 2615 Ice::Type NextConstantType = Ice::IceType_void; |
2621 | 2616 |
2622 void ProcessRecord() override; | 2617 void ProcessRecord() override; |
2623 | 2618 |
2624 Ice::GlobalContext *getContext() { return getTranslator().getContext(); } | 2619 Ice::GlobalContext *getContext() { return getTranslator().getContext(); } |
2625 | 2620 |
2626 // Returns true if the type to use for succeeding constants is defined. | 2621 // Returns true if the type to use for succeeding constants is defined. |
2627 // If false, also generates an error message. | 2622 // If false, also generates an error message. |
2628 bool isValidNextConstantType() { | 2623 bool isValidNextConstantType() { |
2629 if (NextConstantType != Ice::IceType_void) | 2624 if (NextConstantType != Ice::IceType_void) |
2630 return true; | 2625 return true; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 /// Parses the module block in the bitcode file. | 2809 /// Parses the module block in the bitcode file. |
2815 class ModuleParser : public BlockParserBaseClass { | 2810 class ModuleParser : public BlockParserBaseClass { |
2816 ModuleParser() = delete; | 2811 ModuleParser() = delete; |
2817 ModuleParser(const ModuleParser &) = delete; | 2812 ModuleParser(const ModuleParser &) = delete; |
2818 ModuleParser &operator=(const ModuleParser &) = delete; | 2813 ModuleParser &operator=(const ModuleParser &) = delete; |
2819 | 2814 |
2820 public: | 2815 public: |
2821 ModuleParser(unsigned BlockID, TopLevelParser *Context) | 2816 ModuleParser(unsigned BlockID, TopLevelParser *Context) |
2822 : BlockParserBaseClass(BlockID, Context), | 2817 : BlockParserBaseClass(BlockID, Context), |
2823 Timer(Ice::TimerStack::TT_parseModule, | 2818 Timer(Ice::TimerStack::TT_parseModule, |
2824 Context->getTranslator().getContext()), | 2819 Context->getTranslator().getContext()) {} |
2825 GlobalDeclarationNamesAndInitializersInstalled(false) {} | |
2826 | 2820 |
2827 ~ModuleParser() override {} | 2821 ~ModuleParser() override {} |
2828 | 2822 |
2829 const char *getBlockName() const override { return "module"; } | 2823 const char *getBlockName() const override { return "module"; } |
2830 | 2824 |
2831 private: | 2825 private: |
2832 Ice::TimerMarker Timer; | 2826 Ice::TimerMarker Timer; |
2833 // True if we have already installed names for unnamed global declarations, | 2827 // True if we have already installed names for unnamed global declarations, |
2834 // and have generated global constant initializers. | 2828 // and have generated global constant initializers. |
2835 bool GlobalDeclarationNamesAndInitializersInstalled; | 2829 bool GlobalDeclarationNamesAndInitializersInstalled = false; |
2836 | 2830 |
2837 // Generates names for unnamed global addresses (i.e. functions and | 2831 // Generates names for unnamed global addresses (i.e. functions and |
2838 // global variables). Then lowers global variable declaration | 2832 // global variables). Then lowers global variable declaration |
2839 // initializers to the target. May be called multiple times. Only | 2833 // initializers to the target. May be called multiple times. Only |
2840 // the first call will do the installation. | 2834 // the first call will do the installation. |
2841 void InstallGlobalNamesAndGlobalVarInitializers() { | 2835 void InstallGlobalNamesAndGlobalVarInitializers() { |
2842 if (!GlobalDeclarationNamesAndInitializersInstalled) { | 2836 if (!GlobalDeclarationNamesAndInitializersInstalled) { |
2843 Context->installGlobalNames(); | 2837 Context->installGlobalNames(); |
2844 Context->createValueIDs(); | 2838 Context->createValueIDs(); |
2845 getTranslator().lowerGlobals(Context->getGlobalVariables()); | 2839 getTranslator().lowerGlobals(Context->getGlobalVariables()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3026 } | 3020 } |
3027 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3021 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
3028 ErrStream | 3022 ErrStream |
3029 << IRFilename | 3023 << IRFilename |
3030 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; | 3024 << ": Bitcode stream should be a multiple of 4 bytes in length.\n"; |
3031 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); | 3025 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); |
3032 } | 3026 } |
3033 } | 3027 } |
3034 | 3028 |
3035 } // end of namespace Ice | 3029 } // end of namespace Ice |
OLD | NEW |