| 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 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 // True if the last processed instruction was a terminating | 1150 // True if the last processed instruction was a terminating |
| 1151 // instruction. | 1151 // instruction. |
| 1152 bool InstIsTerminating; | 1152 bool InstIsTerminating; |
| 1153 // Upper limit of alignment power allowed by LLVM | 1153 // Upper limit of alignment power allowed by LLVM |
| 1154 static const uint32_t AlignPowerLimit = 29; | 1154 static const uint32_t AlignPowerLimit = 29; |
| 1155 | 1155 |
| 1156 void popTimerIfTimingEachFunction() const { | 1156 void popTimerIfTimingEachFunction() const { |
| 1157 if (ALLOW_DUMP && getFlags().TimeEachFunction) { | 1157 if (ALLOW_DUMP && getFlags().TimeEachFunction) { |
| 1158 getTranslator().getContext()->popTimer( | 1158 getTranslator().getContext()->popTimer( |
| 1159 getTranslator().getContext()->getTimerID( | 1159 getTranslator().getContext()->getTimerID( |
| 1160 Ice::GlobalContext::TSK_Funcs, Func->getFunctionName()), | 1160 Ice::GlobalContext::TSK_Funcs, FuncDecl->getName()), |
| 1161 Ice::GlobalContext::TSK_Funcs); | 1161 Ice::GlobalContext::TSK_Funcs); |
| 1162 } | 1162 } |
| 1163 } | 1163 } |
| 1164 | 1164 |
| 1165 // Extracts the corresponding Alignment to use, given the AlignPower | 1165 // Extracts the corresponding Alignment to use, given the AlignPower |
| 1166 // (i.e. 2**(AlignPower-1), or 0 if AlignPower == 0). InstName is the | 1166 // (i.e. 2**(AlignPower-1), or 0 if AlignPower == 0). InstName is the |
| 1167 // name of the instruction the alignment appears in. | 1167 // name of the instruction the alignment appears in. |
| 1168 void extractAlignment(const char *InstName, uint32_t AlignPower, | 1168 void extractAlignment(const char *InstName, uint32_t AlignPower, |
| 1169 uint32_t &Alignment) { | 1169 uint32_t &Alignment) { |
| 1170 if (AlignPower <= AlignPowerLimit + 1) { | 1170 if (AlignPower <= AlignPowerLimit + 1) { |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1820 if (Ty == Ice::IceType_void) | 1820 if (Ty == Ice::IceType_void) |
| 1821 return; | 1821 return; |
| 1822 Ice::Variable *Var = getNextInstVar(Ty); | 1822 Ice::Variable *Var = getNextInstVar(Ty); |
| 1823 CurrentNode->appendInst(Ice::InstAssign::create(Func, Var, Var)); | 1823 CurrentNode->appendInst(Ice::InstAssign::create(Func, Var, Var)); |
| 1824 } | 1824 } |
| 1825 }; | 1825 }; |
| 1826 | 1826 |
| 1827 void FunctionParser::ExitBlock() { | 1827 void FunctionParser::ExitBlock() { |
| 1828 if (isIRGenerationDisabled()) { | 1828 if (isIRGenerationDisabled()) { |
| 1829 popTimerIfTimingEachFunction(); | 1829 popTimerIfTimingEachFunction(); |
| 1830 delete Func; |
| 1830 return; | 1831 return; |
| 1831 } | 1832 } |
| 1832 // Before translating, check for blocks without instructions, and | 1833 // Before translating, check for blocks without instructions, and |
| 1833 // insert unreachable. This shouldn't happen, but be safe. | 1834 // insert unreachable. This shouldn't happen, but be safe. |
| 1834 unsigned Index = 0; | 1835 unsigned Index = 0; |
| 1835 for (Ice::CfgNode *Node : Func->getNodes()) { | 1836 for (Ice::CfgNode *Node : Func->getNodes()) { |
| 1836 if (Node->getInsts().empty()) { | 1837 if (Node->getInsts().empty()) { |
| 1837 std::string Buffer; | 1838 std::string Buffer; |
| 1838 raw_string_ostream StrBuf(Buffer); | 1839 raw_string_ostream StrBuf(Buffer); |
| 1839 StrBuf << "Basic block " << Index << " contains no instructions"; | 1840 StrBuf << "Basic block " << Index << " contains no instructions"; |
| 1840 Error(StrBuf.str()); | 1841 Error(StrBuf.str()); |
| 1841 // TODO(kschimpf) Remove error recovery once implementation complete. | 1842 // TODO(kschimpf) Remove error recovery once implementation complete. |
| 1842 Node->appendInst(Ice::InstUnreachable::create(Func)); | 1843 Node->appendInst(Ice::InstUnreachable::create(Func)); |
| 1843 } | 1844 } |
| 1844 ++Index; | 1845 ++Index; |
| 1845 } | 1846 } |
| 1846 Func->computePredecessors(); | 1847 Func->computePredecessors(); |
| 1848 // Temporarily end per-function timing, which will be resumed by the |
| 1849 // translator function. This is because translation may be done |
| 1850 // asynchronously in a separate thread. |
| 1851 popTimerIfTimingEachFunction(); |
| 1847 // Note: Once any errors have been found, we turn off all | 1852 // Note: Once any errors have been found, we turn off all |
| 1848 // translation of all remaining functions. This allows use to see | 1853 // translation of all remaining functions. This allows use to see |
| 1849 // multiple errors, without adding extra checks to the translator | 1854 // multiple errors, without adding extra checks to the translator |
| 1850 // for such parsing errors. | 1855 // for such parsing errors. |
| 1851 if (Context->getNumErrors() == 0) | 1856 if (Context->getNumErrors() == 0) |
| 1852 getTranslator().translateFcn(Func); | 1857 getTranslator().translateFcn(Func); |
| 1853 popTimerIfTimingEachFunction(); | |
| 1854 } | 1858 } |
| 1855 | 1859 |
| 1856 void FunctionParser::ReportInvalidBinaryOp(Ice::InstArithmetic::OpKind Op, | 1860 void FunctionParser::ReportInvalidBinaryOp(Ice::InstArithmetic::OpKind Op, |
| 1857 Ice::Type OpTy) { | 1861 Ice::Type OpTy) { |
| 1858 std::string Buffer; | 1862 std::string Buffer; |
| 1859 raw_string_ostream StrBuf(Buffer); | 1863 raw_string_ostream StrBuf(Buffer); |
| 1860 StrBuf << "Invalid operator type for " << Ice::InstArithmetic::getOpName(Op) | 1864 StrBuf << "Invalid operator type for " << Ice::InstArithmetic::getOpName(Op) |
| 1861 << ". Found " << OpTy; | 1865 << ". Found " << OpTy; |
| 1862 Error(StrBuf.str()); | 1866 Error(StrBuf.str()); |
| 1863 } | 1867 } |
| (...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2973 | 2977 |
| 2974 if (TopLevelBlocks != 1) { | 2978 if (TopLevelBlocks != 1) { |
| 2975 errs() << IRFilename | 2979 errs() << IRFilename |
| 2976 << ": Contains more than one module. Found: " << TopLevelBlocks | 2980 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 2977 << "\n"; | 2981 << "\n"; |
| 2978 ErrorStatus.assign(EC_Bitcode); | 2982 ErrorStatus.assign(EC_Bitcode); |
| 2979 } | 2983 } |
| 2980 } | 2984 } |
| 2981 | 2985 |
| 2982 } // end of namespace Ice | 2986 } // end of namespace Ice |
| OLD | NEW |