Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: src/IceConverter.cpp

Issue 695563006: Subzero: Use a common RelocOffsetType / RelocOffsetT. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: format-diff Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceDefs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 void convertGlobalsToIce( 652 void convertGlobalsToIce(
653 Module *Mod, 653 Module *Mod,
654 Ice::Translator::VariableDeclarationListType &VariableDeclarations); 654 Ice::Translator::VariableDeclarationListType &VariableDeclarations);
655 655
656 private: 656 private:
657 // Adds the Initializer to the list of initializers for the Global 657 // Adds the Initializer to the list of initializers for the Global
658 // variable declaraation. 658 // variable declaraation.
659 void addGlobalInitializer(Ice::VariableDeclaration &Global, 659 void addGlobalInitializer(Ice::VariableDeclaration &Global,
660 const Constant *Initializer) { 660 const Constant *Initializer) {
661 const bool HasOffset = false; 661 const bool HasOffset = false;
662 const Ice::VariableDeclaration::RelocOffsetType Offset = 0; 662 const Ice::RelocOffsetT Offset = 0;
663 addGlobalInitializer(Global, Initializer, HasOffset, Offset); 663 addGlobalInitializer(Global, Initializer, HasOffset, Offset);
664 } 664 }
665 665
666 // Adds Initializer to the list of initializers for Global variable 666 // Adds Initializer to the list of initializers for Global variable
667 // declaration. HasOffset is true only if Initializer is a 667 // declaration. HasOffset is true only if Initializer is a
668 // relocation initializer and Offset should be added to the 668 // relocation initializer and Offset should be added to the
669 // relocation. 669 // relocation.
670 void addGlobalInitializer(Ice::VariableDeclaration &Global, 670 void addGlobalInitializer(Ice::VariableDeclaration &Global,
671 const Constant *Initializer, bool HasOffset, 671 const Constant *Initializer, bool HasOffset,
672 Ice::VariableDeclaration::RelocOffsetType Offset); 672 Ice::RelocOffsetT Offset);
673 673
674 // Converts the given constant C to the corresponding integer 674 // Converts the given constant C to the corresponding integer
675 // literal it contains. 675 // literal it contains.
676 Ice::VariableDeclaration::RelocOffsetType 676 Ice::RelocOffsetT getIntegerLiteralConstant(const Value *C) {
677 getIntegerLiteralConstant(const Value *C) {
678 const auto CI = dyn_cast<ConstantInt>(C); 677 const auto CI = dyn_cast<ConstantInt>(C);
679 if (CI && CI->getType()->isIntegerTy(32)) 678 if (CI && CI->getType()->isIntegerTy(32))
680 return CI->getSExtValue(); 679 return CI->getSExtValue();
681 680
682 std::string Buffer; 681 std::string Buffer;
683 raw_string_ostream StrBuf(Buffer); 682 raw_string_ostream StrBuf(Buffer);
684 StrBuf << "Constant not i32 literal: " << *C; 683 StrBuf << "Constant not i32 literal: " << *C;
685 report_fatal_error(StrBuf.str()); 684 report_fatal_error(StrBuf.str());
686 return 0; 685 return 0;
687 } 686 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 } 727 }
729 } 728 }
730 } else { 729 } else {
731 addGlobalInitializer(*VarDecl, Initializer); 730 addGlobalInitializer(*VarDecl, Initializer);
732 } 731 }
733 } 732 }
734 } 733 }
735 734
736 void LLVM2ICEGlobalsConverter::addGlobalInitializer( 735 void LLVM2ICEGlobalsConverter::addGlobalInitializer(
737 Ice::VariableDeclaration &Global, const Constant *Initializer, 736 Ice::VariableDeclaration &Global, const Constant *Initializer,
738 bool HasOffset, Ice::VariableDeclaration::RelocOffsetType Offset) { 737 bool HasOffset, Ice::RelocOffsetT Offset) {
739 (void)HasOffset; 738 (void)HasOffset;
740 assert(HasOffset || Offset == 0); 739 assert(HasOffset || Offset == 0);
741 740
742 if (const auto CDA = dyn_cast<ConstantDataArray>(Initializer)) { 741 if (const auto CDA = dyn_cast<ConstantDataArray>(Initializer)) {
743 assert(!HasOffset && isa<IntegerType>(CDA->getElementType()) && 742 assert(!HasOffset && isa<IntegerType>(CDA->getElementType()) &&
744 (cast<IntegerType>(CDA->getElementType())->getBitWidth() == 8)); 743 (cast<IntegerType>(CDA->getElementType())->getBitWidth() == 8));
745 Global.addInitializer(new Ice::VariableDeclaration::DataInitializer( 744 Global.addInitializer(new Ice::VariableDeclaration::DataInitializer(
746 CDA->getRawDataValues().data(), CDA->getNumElements())); 745 CDA->getRawDataValues().data(), CDA->getNumElements()));
747 return; 746 return;
748 } 747 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 Cfg *Fcn = FunctionConverter.convertFunction(&I); 897 Cfg *Fcn = FunctionConverter.convertFunction(&I);
899 translateFcn(Fcn); 898 translateFcn(Fcn);
900 if (Ctx->getFlags().TimeEachFunction) 899 if (Ctx->getFlags().TimeEachFunction)
901 Ctx->popTimer(TimerID, StackID); 900 Ctx->popTimer(TimerID, StackID);
902 } 901 }
903 902
904 emitConstants(); 903 emitConstants();
905 } 904 }
906 905
907 } // end of namespace Ice 906 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | src/IceDefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698