| 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 /// \file | 10 /// \file |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 LLVM2ICEGlobalsConverter::convertGlobalsToIce(Module *Mod) { | 699 LLVM2ICEGlobalsConverter::convertGlobalsToIce(Module *Mod) { |
| 700 std::unique_ptr<Ice::VariableDeclarationList> VariableDeclarations( | 700 std::unique_ptr<Ice::VariableDeclarationList> VariableDeclarations( |
| 701 new Ice::VariableDeclarationList); | 701 new Ice::VariableDeclarationList); |
| 702 for (Module::const_global_iterator I = Mod->global_begin(), | 702 for (Module::const_global_iterator I = Mod->global_begin(), |
| 703 E = Mod->global_end(); | 703 E = Mod->global_end(); |
| 704 I != E; ++I) { | 704 I != E; ++I) { |
| 705 | 705 |
| 706 const GlobalVariable *GV = I; | 706 const GlobalVariable *GV = I; |
| 707 | 707 |
| 708 Ice::GlobalDeclaration *Var = getConverter().getGlobalDeclaration(GV); | 708 Ice::GlobalDeclaration *Var = getConverter().getGlobalDeclaration(GV); |
| 709 Ice::VariableDeclaration *VarDecl = cast<Ice::VariableDeclaration>(Var); | 709 auto *VarDecl = cast<Ice::VariableDeclaration>(Var); |
| 710 VariableDeclarations->push_back(VarDecl); | 710 VariableDeclarations->push_back(VarDecl); |
| 711 | 711 |
| 712 if (!GV->hasInternalLinkage() && GV->hasInitializer()) { | 712 if (!GV->hasInternalLinkage() && GV->hasInitializer()) { |
| 713 std::string Buffer; | 713 std::string Buffer; |
| 714 raw_string_ostream StrBuf(Buffer); | 714 raw_string_ostream StrBuf(Buffer); |
| 715 StrBuf << "Can't define external global declaration: " << GV->getName(); | 715 StrBuf << "Can't define external global declaration: " << GV->getName(); |
| 716 report_fatal_error(StrBuf.str()); | 716 report_fatal_error(StrBuf.str()); |
| 717 } | 717 } |
| 718 | 718 |
| 719 if (!GV->hasInitializer()) { | 719 if (!GV->hasInitializer()) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 // Install function declarations. | 857 // Install function declarations. |
| 858 for (const Function &Func : *Mod) { | 858 for (const Function &Func : *Mod) { |
| 859 FuncSigType Signature; | 859 FuncSigType Signature; |
| 860 FunctionType *FuncType = Func.getFunctionType(); | 860 FunctionType *FuncType = Func.getFunctionType(); |
| 861 Signature.setReturnType( | 861 Signature.setReturnType( |
| 862 Converter.convertToIceType(FuncType->getReturnType())); | 862 Converter.convertToIceType(FuncType->getReturnType())); |
| 863 for (size_t I = 0; I < FuncType->getNumParams(); ++I) { | 863 for (size_t I = 0; I < FuncType->getNumParams(); ++I) { |
| 864 Signature.appendArgType( | 864 Signature.appendArgType( |
| 865 Converter.convertToIceType(FuncType->getParamType(I))); | 865 Converter.convertToIceType(FuncType->getParamType(I))); |
| 866 } | 866 } |
| 867 FunctionDeclaration *IceFunc = FunctionDeclaration::create( | 867 auto *IceFunc = FunctionDeclaration::create( |
| 868 Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty()); | 868 Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty()); |
| 869 IceFunc->setName(Func.getName()); | 869 IceFunc->setName(Func.getName()); |
| 870 if (!IceFunc->verifyLinkageCorrect(Ctx)) { | 870 if (!IceFunc->verifyLinkageCorrect(Ctx)) { |
| 871 std::string Buffer; | 871 std::string Buffer; |
| 872 raw_string_ostream StrBuf(Buffer); | 872 raw_string_ostream StrBuf(Buffer); |
| 873 StrBuf << "Function " << IceFunc->getName() | 873 StrBuf << "Function " << IceFunc->getName() |
| 874 << " has incorrect linkage: " << IceFunc->getLinkageName(); | 874 << " has incorrect linkage: " << IceFunc->getLinkageName(); |
| 875 if (IceFunc->isExternal()) | 875 if (IceFunc->isExternal()) |
| 876 StrBuf << "\n Use flag -allow-externally-defined-symbols to override"; | 876 StrBuf << "\n Use flag -allow-externally-defined-symbols to override"; |
| 877 report_fatal_error(StrBuf.str()); | 877 report_fatal_error(StrBuf.str()); |
| 878 } | 878 } |
| 879 GlobalDeclarationMap[&Func] = IceFunc; | 879 GlobalDeclarationMap[&Func] = IceFunc; |
| 880 } | 880 } |
| 881 // Install global variable declarations. | 881 // Install global variable declarations. |
| 882 for (Module::const_global_iterator I = Mod->global_begin(), | 882 for (Module::const_global_iterator I = Mod->global_begin(), |
| 883 E = Mod->global_end(); | 883 E = Mod->global_end(); |
| 884 I != E; ++I) { | 884 I != E; ++I) { |
| 885 const GlobalVariable *GV = I; | 885 const GlobalVariable *GV = I; |
| 886 VariableDeclaration *Var = VariableDeclaration::create(Ctx); | 886 auto *Var = VariableDeclaration::create(Ctx); |
| 887 Var->setName(GV->getName()); | 887 Var->setName(GV->getName()); |
| 888 Var->setAlignment(GV->getAlignment()); | 888 Var->setAlignment(GV->getAlignment()); |
| 889 Var->setIsConstant(GV->isConstant()); | 889 Var->setIsConstant(GV->isConstant()); |
| 890 Var->setLinkage(GV->getLinkage()); | 890 Var->setLinkage(GV->getLinkage()); |
| 891 if (!Var->verifyLinkageCorrect(Ctx)) { | 891 if (!Var->verifyLinkageCorrect(Ctx)) { |
| 892 std::string Buffer; | 892 std::string Buffer; |
| 893 raw_string_ostream StrBuf(Buffer); | 893 raw_string_ostream StrBuf(Buffer); |
| 894 StrBuf << "Global " << Var->getName() | 894 StrBuf << "Global " << Var->getName() |
| 895 << " has incorrect linkage: " << Var->getLinkageName(); | 895 << " has incorrect linkage: " << Var->getLinkageName(); |
| 896 if (Var->isExternal()) | 896 if (Var->isExternal()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 918 Ctx->pushTimer(TimerID, StackID); | 918 Ctx->pushTimer(TimerID, StackID); |
| 919 } | 919 } |
| 920 LLVM2ICEFunctionConverter FunctionConverter(*this); | 920 LLVM2ICEFunctionConverter FunctionConverter(*this); |
| 921 FunctionConverter.convertFunction(&I); | 921 FunctionConverter.convertFunction(&I); |
| 922 if (TimeThisFunction) | 922 if (TimeThisFunction) |
| 923 Ctx->popTimer(TimerID, StackID); | 923 Ctx->popTimer(TimerID, StackID); |
| 924 } | 924 } |
| 925 } | 925 } |
| 926 | 926 |
| 927 } // end of namespace Ice | 927 } // end of namespace Ice |
| OLD | NEW |