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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 610813002: Subzero: Rewrite the pass timing infrastructure. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Make the optimized overlaps() implementation actually correct Created 6 years, 2 months 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
OLDNEW
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
11 // translator. 11 // translator.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "PNaClTranslator.h"
16 #include "IceCfg.h" 15 #include "IceCfg.h"
17 #include "IceCfgNode.h" 16 #include "IceCfgNode.h"
18 #include "IceClFlags.h" 17 #include "IceClFlags.h"
19 #include "IceDefs.h" 18 #include "IceDefs.h"
20 #include "IceInst.h" 19 #include "IceInst.h"
21 #include "IceOperand.h" 20 #include "IceOperand.h"
22 #include "IceTypeConverter.h" 21 #include "IceTypeConverter.h"
22 #include "PNaClTranslator.h"
23 #include "llvm/Analysis/NaCl/PNaClABIProps.h" 23 #include "llvm/Analysis/NaCl/PNaClABIProps.h"
24 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h" 24 #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h"
25 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h" 25 #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h"
26 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" 26 #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h"
27 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" 27 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
28 #include "llvm/IR/Constants.h" 28 #include "llvm/IR/Constants.h"
29 #include "llvm/IR/DataLayout.h" 29 #include "llvm/IR/DataLayout.h"
30 #include "llvm/IR/LLVMContext.h" 30 #include "llvm/IR/LLVMContext.h"
31 #include "llvm/IR/Module.h" 31 #include "llvm/IR/Module.h"
32 #include "llvm/Support/Format.h" 32 #include "llvm/Support/Format.h"
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 Func->setInternal(LLVMFunc->hasInternalLinkage()); 845 Func->setInternal(LLVMFunc->hasInternalLinkage());
846 CurrentNode = InstallNextBasicBlock(); 846 CurrentNode = InstallNextBasicBlock();
847 Func->setEntryNode(CurrentNode); 847 Func->setEntryNode(CurrentNode);
848 for (Function::const_arg_iterator ArgI = LLVMFunc->arg_begin(), 848 for (Function::const_arg_iterator ArgI = LLVMFunc->arg_begin(),
849 ArgE = LLVMFunc->arg_end(); 849 ArgE = LLVMFunc->arg_end();
850 ArgI != ArgE; ++ArgI) { 850 ArgI != ArgE; ++ArgI) {
851 Func->addArg(getNextInstVar(Context->convertToIceType(ArgI->getType()))); 851 Func->addArg(getNextInstVar(Context->convertToIceType(ArgI->getType())));
852 } 852 }
853 } 853 }
854 854
855 ~FunctionParser() override; 855 ~FunctionParser() override {};
856 856
857 // Set the next constant ID to the given constant C. 857 // Set the next constant ID to the given constant C.
858 void setNextConstantID(Ice::Constant *C) { 858 void setNextConstantID(Ice::Constant *C) {
859 setOperand(NextLocalInstIndex++, C); 859 setOperand(NextLocalInstIndex++, C);
860 } 860 }
861 861
862 private: 862 private:
863 // Timer for reading function bitcode and converting to ICE.
864 Ice::Timer TConvert;
865 // The corresponding ICE function defined by the function block. 863 // The corresponding ICE function defined by the function block.
866 Ice::Cfg *Func; 864 Ice::Cfg *Func;
867 // The index to the current basic block being built. 865 // The index to the current basic block being built.
868 uint32_t CurrentBbIndex; 866 uint32_t CurrentBbIndex;
869 // The basic block being built. 867 // The basic block being built.
870 Ice::CfgNode *CurrentNode; 868 Ice::CfgNode *CurrentNode;
871 // The ID for the function. 869 // The ID for the function.
872 unsigned FcnId; 870 unsigned FcnId;
873 // The corresponding LLVM function. 871 // The corresponding LLVM function.
874 Function *LLVMFunc; 872 Function *LLVMFunc;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 return true; 1367 return true;
1370 case naclbitc::FCMP_TRUE: 1368 case naclbitc::FCMP_TRUE:
1371 Cond = Ice::InstFcmp::True; 1369 Cond = Ice::InstFcmp::True;
1372 return true; 1370 return true;
1373 default: 1371 default:
1374 return false; 1372 return false;
1375 } 1373 }
1376 } 1374 }
1377 }; 1375 };
1378 1376
1379 FunctionParser::~FunctionParser() {
1380 if (getFlags().SubzeroTimingEnabled) {
1381 errs() << "[Subzero timing] Convert function " << Func->getFunctionName()
1382 << ": " << TConvert.getElapsedSec() << " sec\n";
1383 }
1384 }
1385
1386 void FunctionParser::ReportInvalidBinopOpcode(unsigned Opcode, Ice::Type Ty) { 1377 void FunctionParser::ReportInvalidBinopOpcode(unsigned Opcode, Ice::Type Ty) {
1387 std::string Buffer; 1378 std::string Buffer;
1388 raw_string_ostream StrBuf(Buffer); 1379 raw_string_ostream StrBuf(Buffer);
1389 StrBuf << "Binary opcode " << Opcode << "not understood for type " << Ty; 1380 StrBuf << "Binary opcode " << Opcode << "not understood for type " << Ty;
1390 Error(StrBuf.str()); 1381 Error(StrBuf.str());
1391 } 1382 }
1392 1383
1393 void FunctionParser::ExitBlock() { 1384 void FunctionParser::ExitBlock() {
1394 // Before translating, check for blocks without instructions, and 1385 // Before translating, check for blocks without instructions, and
1395 // insert unreachable. This shouldn't happen, but be safe. 1386 // insert unreachable. This shouldn't happen, but be safe.
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 2421
2431 if (TopLevelBlocks != 1) { 2422 if (TopLevelBlocks != 1) {
2432 errs() << IRFilename 2423 errs() << IRFilename
2433 << ": Contains more than one module. Found: " << TopLevelBlocks 2424 << ": Contains more than one module. Found: " << TopLevelBlocks
2434 << "\n"; 2425 << "\n";
2435 ErrorStatus = true; 2426 ErrorStatus = true;
2436 } 2427 }
2437 } 2428 }
2438 2429
2439 } // end of namespace Ice 2430 } // end of namespace Ice
OLDNEW
« src/IceOperand.cpp ('K') | « src/IceTranslator.cpp ('k') | src/llvm2ice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698