| 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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs; | 1143 const Ice::TimerStackIdT StackID = Ice::GlobalContext::TSK_Funcs; |
| 1144 Ice::TimerIdT TimerID = 0; | 1144 Ice::TimerIdT TimerID = 0; |
| 1145 const bool TimeThisFunction = getFlags().getTimeEachFunction(); | 1145 const bool TimeThisFunction = getFlags().getTimeEachFunction(); |
| 1146 if (TimeThisFunction) { | 1146 if (TimeThisFunction) { |
| 1147 TimerID = getTranslator().getContext()->getTimerID(StackID, | 1147 TimerID = getTranslator().getContext()->getTimerID(StackID, |
| 1148 FuncDecl->getName()); | 1148 FuncDecl->getName()); |
| 1149 getTranslator().getContext()->pushTimer(TimerID, StackID); | 1149 getTranslator().getContext()->pushTimer(TimerID, StackID); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 if (!isIRGenerationDisabled()) | 1152 if (!isIRGenerationDisabled()) |
| 1153 Func = Ice::Cfg::create(getTranslator().getContext()); | 1153 Func = Ice::Cfg::create(getTranslator().getContext(), |
| 1154 getTranslator().getNextSequenceNumber()); |
| 1154 Ice::Cfg::setCurrentCfg(Func.get()); | 1155 Ice::Cfg::setCurrentCfg(Func.get()); |
| 1155 | 1156 |
| 1156 // TODO(kschimpf) Clean up API to add a function signature to | 1157 // TODO(kschimpf) Clean up API to add a function signature to |
| 1157 // a CFG. | 1158 // a CFG. |
| 1158 const Ice::FuncSigType &Signature = FuncDecl->getSignature(); | 1159 const Ice::FuncSigType &Signature = FuncDecl->getSignature(); |
| 1159 if (isIRGenerationDisabled()) { | 1160 if (isIRGenerationDisabled()) { |
| 1160 CurrentNode = nullptr; | 1161 CurrentNode = nullptr; |
| 1161 for (Ice::Type ArgType : Signature.getArgList()) { | 1162 for (Ice::Type ArgType : Signature.getArgList()) { |
| 1162 (void)ArgType; | 1163 (void)ArgType; |
| 1163 setNextLocalInstIndex(nullptr); | 1164 setNextLocalInstIndex(nullptr); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1178 // the translator function. This is because translation may be | 1179 // the translator function. This is because translation may be |
| 1179 // done asynchronously in a separate thread. | 1180 // done asynchronously in a separate thread. |
| 1180 if (TimeThisFunction) | 1181 if (TimeThisFunction) |
| 1181 getTranslator().getContext()->popTimer(TimerID, StackID); | 1182 getTranslator().getContext()->popTimer(TimerID, StackID); |
| 1182 | 1183 |
| 1183 Ice::Cfg::setCurrentCfg(nullptr); | 1184 Ice::Cfg::setCurrentCfg(nullptr); |
| 1184 // Note: Once any errors have been found, we turn off all | 1185 // Note: Once any errors have been found, we turn off all |
| 1185 // translation of all remaining functions. This allows successive | 1186 // translation of all remaining functions. This allows successive |
| 1186 // parsing errors to be reported, without adding extra checks to | 1187 // parsing errors to be reported, without adding extra checks to |
| 1187 // the translator for such parsing errors. | 1188 // the translator for such parsing errors. |
| 1188 if (Context->getNumErrors() == 0) { | 1189 if (Context->getNumErrors() == 0 && Func) { |
| 1189 getTranslator().translateFcn(std::move(Func)); | 1190 getTranslator().translateFcn(std::move(Func)); |
| 1190 // The translator now has ownership of Func. | 1191 // The translator now has ownership of Func. |
| 1191 } else { | 1192 } else { |
| 1192 Func.reset(); | 1193 Func.reset(); |
| 1193 } | 1194 } |
| 1194 | 1195 |
| 1195 return ParserResult; | 1196 return ParserResult; |
| 1196 } | 1197 } |
| 1197 | 1198 |
| 1198 ~FunctionParser() final {} | 1199 ~FunctionParser() final {} |
| (...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2856 bool GlobalDeclarationNamesAndInitializersInstalled; | 2857 bool GlobalDeclarationNamesAndInitializersInstalled; |
| 2857 | 2858 |
| 2858 // Generates names for unnamed global addresses (i.e. functions and | 2859 // Generates names for unnamed global addresses (i.e. functions and |
| 2859 // global variables). Then lowers global variable declaration | 2860 // global variables). Then lowers global variable declaration |
| 2860 // initializers to the target. May be called multiple times. Only | 2861 // initializers to the target. May be called multiple times. Only |
| 2861 // the first call will do the installation. | 2862 // the first call will do the installation. |
| 2862 void InstallGlobalNamesAndGlobalVarInitializers() { | 2863 void InstallGlobalNamesAndGlobalVarInitializers() { |
| 2863 if (!GlobalDeclarationNamesAndInitializersInstalled) { | 2864 if (!GlobalDeclarationNamesAndInitializersInstalled) { |
| 2864 Context->installGlobalNames(); | 2865 Context->installGlobalNames(); |
| 2865 Context->createValueIDs(); | 2866 Context->createValueIDs(); |
| 2866 std::unique_ptr<Ice::VariableDeclarationList> DeclsPtr = | 2867 getTranslator().lowerGlobals(Context->getGlobalVariables()); |
| 2867 Context->getGlobalVariables(); | |
| 2868 const Ice::VariableDeclarationList &Decls = *DeclsPtr; | |
| 2869 getTranslator().lowerGlobals(Decls); | |
| 2870 GlobalDeclarationNamesAndInitializersInstalled = true; | 2868 GlobalDeclarationNamesAndInitializersInstalled = true; |
| 2871 } | 2869 } |
| 2872 } | 2870 } |
| 2873 bool ParseBlock(unsigned BlockID) override; | 2871 bool ParseBlock(unsigned BlockID) override; |
| 2874 | 2872 |
| 2875 void ExitBlock() override { InstallGlobalNamesAndGlobalVarInitializers(); } | 2873 void ExitBlock() override { InstallGlobalNamesAndGlobalVarInitializers(); } |
| 2876 | 2874 |
| 2877 void ProcessRecord() override; | 2875 void ProcessRecord() override; |
| 2878 }; | 2876 }; |
| 2879 | 2877 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3047 | 3045 |
| 3048 if (TopLevelBlocks != 1) { | 3046 if (TopLevelBlocks != 1) { |
| 3049 errs() << IRFilename | 3047 errs() << IRFilename |
| 3050 << ": Contains more than one module. Found: " << TopLevelBlocks | 3048 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 3051 << "\n"; | 3049 << "\n"; |
| 3052 ErrorStatus.assign(EC_Bitcode); | 3050 ErrorStatus.assign(EC_Bitcode); |
| 3053 } | 3051 } |
| 3054 } | 3052 } |
| 3055 | 3053 |
| 3056 } // end of namespace Ice | 3054 } // end of namespace Ice |
| OLD | NEW |