| 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 LLVM2ICEGlobalsConverter & | 636 LLVM2ICEGlobalsConverter & |
| 637 operator-(const LLVM2ICEGlobalsConverter &) = delete; | 637 operator-(const LLVM2ICEGlobalsConverter &) = delete; |
| 638 | 638 |
| 639 public: | 639 public: |
| 640 LLVM2ICEGlobalsConverter(Ice::Converter &Converter) | 640 LLVM2ICEGlobalsConverter(Ice::Converter &Converter) |
| 641 : LLVM2ICEConverter(Converter) {} | 641 : LLVM2ICEConverter(Converter) {} |
| 642 | 642 |
| 643 /// Converts global variables, and their initializers into ICE | 643 /// Converts global variables, and their initializers into ICE |
| 644 /// global variable declarations, for module Mod. Puts corresponding | 644 /// global variable declarations, for module Mod. Puts corresponding |
| 645 /// converted declarations into VariableDeclarations. | 645 /// converted declarations into VariableDeclarations. |
| 646 void convertGlobalsToIce( | 646 void convertGlobalsToIce(Module *Mod, |
| 647 Module *Mod, | 647 Ice::VariableDeclarationList &VariableDeclarations); |
| 648 Ice::Translator::VariableDeclarationListType &VariableDeclarations); | |
| 649 | 648 |
| 650 private: | 649 private: |
| 651 // Adds the Initializer to the list of initializers for the Global | 650 // Adds the Initializer to the list of initializers for the Global |
| 652 // variable declaraation. | 651 // variable declaraation. |
| 653 void addGlobalInitializer(Ice::VariableDeclaration &Global, | 652 void addGlobalInitializer(Ice::VariableDeclaration &Global, |
| 654 const Constant *Initializer) { | 653 const Constant *Initializer) { |
| 655 const bool HasOffset = false; | 654 const bool HasOffset = false; |
| 656 const Ice::RelocOffsetT Offset = 0; | 655 const Ice::RelocOffsetT Offset = 0; |
| 657 addGlobalInitializer(Global, Initializer, HasOffset, Offset); | 656 addGlobalInitializer(Global, Initializer, HasOffset, Offset); |
| 658 } | 657 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 674 | 673 |
| 675 std::string Buffer; | 674 std::string Buffer; |
| 676 raw_string_ostream StrBuf(Buffer); | 675 raw_string_ostream StrBuf(Buffer); |
| 677 StrBuf << "Constant not i32 literal: " << *C; | 676 StrBuf << "Constant not i32 literal: " << *C; |
| 678 report_fatal_error(StrBuf.str()); | 677 report_fatal_error(StrBuf.str()); |
| 679 return 0; | 678 return 0; |
| 680 } | 679 } |
| 681 }; | 680 }; |
| 682 | 681 |
| 683 void LLVM2ICEGlobalsConverter::convertGlobalsToIce( | 682 void LLVM2ICEGlobalsConverter::convertGlobalsToIce( |
| 684 Module *Mod, | 683 Module *Mod, Ice::VariableDeclarationList &VariableDeclarations) { |
| 685 Ice::Translator::VariableDeclarationListType &VariableDeclarations) { | |
| 686 for (Module::const_global_iterator I = Mod->global_begin(), | 684 for (Module::const_global_iterator I = Mod->global_begin(), |
| 687 E = Mod->global_end(); | 685 E = Mod->global_end(); |
| 688 I != E; ++I) { | 686 I != E; ++I) { |
| 689 | 687 |
| 690 const GlobalVariable *GV = I; | 688 const GlobalVariable *GV = I; |
| 691 | 689 |
| 692 Ice::GlobalDeclaration *Var = getConverter().getGlobalDeclaration(GV); | 690 Ice::GlobalDeclaration *Var = getConverter().getGlobalDeclaration(GV); |
| 693 Ice::VariableDeclaration *VarDecl = cast<Ice::VariableDeclaration>(Var); | 691 Ice::VariableDeclaration *VarDecl = cast<Ice::VariableDeclaration>(Var); |
| 694 VariableDeclarations.push_back(VarDecl); | 692 VariableDeclarations.push_back(VarDecl); |
| 695 | 693 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 Var->setName(GV->getName()); | 859 Var->setName(GV->getName()); |
| 862 Var->setAlignment(GV->getAlignment()); | 860 Var->setAlignment(GV->getAlignment()); |
| 863 Var->setIsConstant(GV->isConstant()); | 861 Var->setIsConstant(GV->isConstant()); |
| 864 Var->setLinkage(GV->getLinkage()); | 862 Var->setLinkage(GV->getLinkage()); |
| 865 GlobalDeclarationMap[GV] = Var; | 863 GlobalDeclarationMap[GV] = Var; |
| 866 } | 864 } |
| 867 } | 865 } |
| 868 | 866 |
| 869 void Converter::convertGlobals(Module *Mod) { | 867 void Converter::convertGlobals(Module *Mod) { |
| 870 LLVM2ICEGlobalsConverter GlobalsConverter(*this); | 868 LLVM2ICEGlobalsConverter GlobalsConverter(*this); |
| 871 Translator::VariableDeclarationListType VariableDeclarations; | 869 VariableDeclarationList VariableDeclarations; |
| 872 GlobalsConverter.convertGlobalsToIce(Mod, VariableDeclarations); | 870 GlobalsConverter.convertGlobalsToIce(Mod, VariableDeclarations); |
| 873 lowerGlobals(VariableDeclarations); | 871 lowerGlobals(VariableDeclarations); |
| 874 } | 872 } |
| 875 | 873 |
| 876 void Converter::convertFunctions() { | 874 void Converter::convertFunctions() { |
| 877 TimerStackIdT StackID = GlobalContext::TSK_Funcs; | 875 TimerStackIdT StackID = GlobalContext::TSK_Funcs; |
| 878 for (const Function &I : *Mod) { | 876 for (const Function &I : *Mod) { |
| 879 if (I.empty()) | 877 if (I.empty()) |
| 880 continue; | 878 continue; |
| 881 | 879 |
| 882 TimerIdT TimerID = 0; | 880 TimerIdT TimerID = 0; |
| 883 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) { | 881 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) { |
| 884 TimerID = Ctx->getTimerID(StackID, I.getName()); | 882 TimerID = Ctx->getTimerID(StackID, I.getName()); |
| 885 Ctx->pushTimer(TimerID, StackID); | 883 Ctx->pushTimer(TimerID, StackID); |
| 886 } | 884 } |
| 887 LLVM2ICEFunctionConverter FunctionConverter(*this); | 885 LLVM2ICEFunctionConverter FunctionConverter(*this); |
| 888 | 886 |
| 889 Cfg *Fcn = FunctionConverter.convertFunction(&I); | 887 Cfg *Fcn = FunctionConverter.convertFunction(&I); |
| 890 translateFcn(Fcn); | 888 translateFcn(Fcn); |
| 891 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) | 889 if (ALLOW_DUMP && Ctx->getFlags().TimeEachFunction) |
| 892 Ctx->popTimer(TimerID, StackID); | 890 Ctx->popTimer(TimerID, StackID); |
| 893 } | 891 } |
| 894 } | 892 } |
| 895 | 893 |
| 896 } // end of namespace Ice | 894 } // end of namespace Ice |
| OLD | NEW |