OLD | NEW |
1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// | 1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===// |
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 LLVM to ICE converter. | 10 // This file implements the LLVM to ICE converter. |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 VariableDeclarations.push_back(VarDecl); | 709 VariableDeclarations.push_back(VarDecl); |
710 | 710 |
711 if (!GV->hasInternalLinkage() && GV->hasInitializer()) { | 711 if (!GV->hasInternalLinkage() && GV->hasInitializer()) { |
712 std::string Buffer; | 712 std::string Buffer; |
713 raw_string_ostream StrBuf(Buffer); | 713 raw_string_ostream StrBuf(Buffer); |
714 StrBuf << "Can't define external global declaration: " << GV->getName(); | 714 StrBuf << "Can't define external global declaration: " << GV->getName(); |
715 report_fatal_error(StrBuf.str()); | 715 report_fatal_error(StrBuf.str()); |
716 } | 716 } |
717 | 717 |
718 if (!GV->hasInitializer()) { | 718 if (!GV->hasInitializer()) { |
719 if (Ctx->getFlags().AllowUninitializedGlobals) | 719 if (Ctx->getFlags().getAllowUninitializedGlobals()) |
720 continue; | 720 continue; |
721 else { | 721 else { |
722 std::string Buffer; | 722 std::string Buffer; |
723 raw_string_ostream StrBuf(Buffer); | 723 raw_string_ostream StrBuf(Buffer); |
724 StrBuf << "Global declaration missing initializer: " << GV->getName(); | 724 StrBuf << "Global declaration missing initializer: " << GV->getName(); |
725 report_fatal_error(StrBuf.str()); | 725 report_fatal_error(StrBuf.str()); |
726 } | 726 } |
727 } | 727 } |
728 | 728 |
729 const Constant *Initializer = GV->getInitializer(); | 729 const Constant *Initializer = GV->getInitializer(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 raw_string_ostream StrBuf(Buffer); | 794 raw_string_ostream StrBuf(Buffer); |
795 StrBuf << "Unhandled global initializer: " << Initializer; | 795 StrBuf << "Unhandled global initializer: " << Initializer; |
796 report_fatal_error(StrBuf.str()); | 796 report_fatal_error(StrBuf.str()); |
797 } | 797 } |
798 | 798 |
799 } // end of anonymous namespace | 799 } // end of anonymous namespace |
800 | 800 |
801 namespace Ice { | 801 namespace Ice { |
802 | 802 |
803 void Converter::nameUnnamedGlobalVariables(Module *Mod) { | 803 void Converter::nameUnnamedGlobalVariables(Module *Mod) { |
804 const IceString &GlobalPrefix = Flags.DefaultGlobalPrefix; | 804 const IceString &GlobalPrefix = Flags.getDefaultGlobalPrefix(); |
805 if (GlobalPrefix.empty()) | 805 if (GlobalPrefix.empty()) |
806 return; | 806 return; |
807 uint32_t NameIndex = 0; | 807 uint32_t NameIndex = 0; |
808 for (auto V = Mod->global_begin(), E = Mod->global_end(); V != E; ++V) { | 808 for (auto V = Mod->global_begin(), E = Mod->global_end(); V != E; ++V) { |
809 if (!V->hasName()) { | 809 if (!V->hasName()) { |
810 V->setName(createUnnamedName(GlobalPrefix, NameIndex)); | 810 V->setName(createUnnamedName(GlobalPrefix, NameIndex)); |
811 ++NameIndex; | 811 ++NameIndex; |
812 } else { | 812 } else { |
813 checkIfUnnamedNameSafe(V->getName(), "global", GlobalPrefix); | 813 checkIfUnnamedNameSafe(V->getName(), "global", GlobalPrefix); |
814 } | 814 } |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
818 void Converter::nameUnnamedFunctions(Module *Mod) { | 818 void Converter::nameUnnamedFunctions(Module *Mod) { |
819 const IceString &FunctionPrefix = Flags.DefaultFunctionPrefix; | 819 const IceString &FunctionPrefix = Flags.getDefaultFunctionPrefix(); |
820 if (FunctionPrefix.empty()) | 820 if (FunctionPrefix.empty()) |
821 return; | 821 return; |
822 uint32_t NameIndex = 0; | 822 uint32_t NameIndex = 0; |
823 for (Function &F : *Mod) { | 823 for (Function &F : *Mod) { |
824 if (!F.hasName()) { | 824 if (!F.hasName()) { |
825 F.setName(createUnnamedName(FunctionPrefix, NameIndex)); | 825 F.setName(createUnnamedName(FunctionPrefix, NameIndex)); |
826 ++NameIndex; | 826 ++NameIndex; |
827 } else { | 827 } else { |
828 checkIfUnnamedNameSafe(F.getName(), "function", FunctionPrefix); | 828 checkIfUnnamedNameSafe(F.getName(), "function", FunctionPrefix); |
829 } | 829 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 lowerGlobals(VariableDeclarations); | 888 lowerGlobals(VariableDeclarations); |
889 } | 889 } |
890 | 890 |
891 void Converter::convertFunctions() { | 891 void Converter::convertFunctions() { |
892 const TimerStackIdT StackID = GlobalContext::TSK_Funcs; | 892 const TimerStackIdT StackID = GlobalContext::TSK_Funcs; |
893 for (const Function &I : *Mod) { | 893 for (const Function &I : *Mod) { |
894 if (I.empty()) | 894 if (I.empty()) |
895 continue; | 895 continue; |
896 | 896 |
897 TimerIdT TimerID = 0; | 897 TimerIdT TimerID = 0; |
898 const bool TimeThisFunction = | 898 const bool TimeThisFunction = Ctx->getFlags().getTimeEachFunction(); |
899 ALLOW_DUMP && Ctx->getFlags().TimeEachFunction; | |
900 if (TimeThisFunction) { | 899 if (TimeThisFunction) { |
901 TimerID = Ctx->getTimerID(StackID, I.getName()); | 900 TimerID = Ctx->getTimerID(StackID, I.getName()); |
902 Ctx->pushTimer(TimerID, StackID); | 901 Ctx->pushTimer(TimerID, StackID); |
903 } | 902 } |
904 LLVM2ICEFunctionConverter FunctionConverter(*this); | 903 LLVM2ICEFunctionConverter FunctionConverter(*this); |
905 FunctionConverter.convertFunction(&I); | 904 FunctionConverter.convertFunction(&I); |
906 if (TimeThisFunction) | 905 if (TimeThisFunction) |
907 Ctx->popTimer(TimerID, StackID); | 906 Ctx->popTimer(TimerID, StackID); |
908 } | 907 } |
909 } | 908 } |
910 | 909 |
911 } // end of namespace Ice | 910 } // end of namespace Ice |
OLD | NEW |