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

Side by Side Diff: src/IceConverter.cpp

Issue 610813002: Subzero: Rewrite the pass timing infrastructure. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Bug fixes and performance improvements 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/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.
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 #include "IceConverter.h"
15
16 #include "IceCfg.h" 14 #include "IceCfg.h"
17 #include "IceCfgNode.h" 15 #include "IceCfgNode.h"
18 #include "IceClFlags.h" 16 #include "IceClFlags.h"
17 #include "IceConverter.h"
19 #include "IceDefs.h" 18 #include "IceDefs.h"
20 #include "IceGlobalContext.h" 19 #include "IceGlobalContext.h"
21 #include "IceInst.h" 20 #include "IceInst.h"
22 #include "IceOperand.h" 21 #include "IceOperand.h"
23 #include "IceTargetLowering.h" 22 #include "IceTargetLowering.h"
24 #include "IceTypes.h" 23 #include "IceTypes.h"
25 #include "IceTypeConverter.h" 24 #include "IceTypeConverter.h"
26 25
27 #include "llvm/IR/Constant.h" 26 #include "llvm/IR/Constant.h"
28 #include "llvm/IR/Constants.h" 27 #include "llvm/IR/Constants.h"
(...skipping 24 matching lines...) Expand all
53 // https://developers.google.com/native-client/dev/reference/pnacl-bitcode-abi 52 // https://developers.google.com/native-client/dev/reference/pnacl-bitcode-abi
54 // If not, all kinds of assertions may fire. 53 // If not, all kinds of assertions may fire.
55 // 54 //
56 class LLVM2ICEConverter { 55 class LLVM2ICEConverter {
57 public: 56 public:
58 LLVM2ICEConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext) 57 LLVM2ICEConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext)
59 : Ctx(Ctx), Func(NULL), TypeConverter(LLVMContext) {} 58 : Ctx(Ctx), Func(NULL), TypeConverter(LLVMContext) {}
60 59
61 // Caller is expected to delete the returned Ice::Cfg object. 60 // Caller is expected to delete the returned Ice::Cfg object.
62 Ice::Cfg *convertFunction(const Function *F) { 61 Ice::Cfg *convertFunction(const Function *F) {
62 Ice::TimerMarker T("llvmConvert", Ctx);
63 VarMap.clear(); 63 VarMap.clear();
64 NodeMap.clear(); 64 NodeMap.clear();
65 Func = new Ice::Cfg(Ctx); 65 Func = new Ice::Cfg(Ctx);
66 Func->setFunctionName(F->getName()); 66 Func->setFunctionName(F->getName());
67 Func->setReturnType(convertToIceType(F->getReturnType())); 67 Func->setReturnType(convertToIceType(F->getReturnType()));
68 Func->setInternal(F->hasInternalLinkage()); 68 Func->setInternal(F->hasInternalLinkage());
69 69
70 // The initial definition/use of each arg is the entry node. 70 // The initial definition/use of each arg is the entry node.
71 for (Function::const_arg_iterator ArgI = F->arg_begin(), 71 for (Function::const_arg_iterator ArgI = F->arg_begin(),
72 ArgE = F->arg_end(); 72 ArgE = F->arg_end();
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 std::map<const Value *, Ice::Variable *> VarMap; 614 std::map<const Value *, Ice::Variable *> VarMap;
615 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap; 615 std::map<const BasicBlock *, Ice::CfgNode *> NodeMap;
616 Ice::TypeConverter TypeConverter; 616 Ice::TypeConverter TypeConverter;
617 }; 617 };
618 618
619 } // end of anonymous namespace 619 } // end of anonymous namespace
620 620
621 namespace Ice { 621 namespace Ice {
622 622
623 void Converter::convertToIce() { 623 void Converter::convertToIce() {
624 TimerMarker T("convertToIce", Ctx);
624 nameUnnamedGlobalAddresses(Mod); 625 nameUnnamedGlobalAddresses(Mod);
625 if (!Ctx->getFlags().DisableGlobals) 626 if (!Ctx->getFlags().DisableGlobals)
626 convertGlobals(Mod); 627 convertGlobals(Mod);
627 convertFunctions(); 628 convertFunctions();
628 } 629 }
629 630
630 void Converter::convertFunctions() { 631 void Converter::convertFunctions() {
631 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { 632 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
632 if (I->empty()) 633 if (I->empty())
633 continue; 634 continue;
634 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); 635 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext());
635 636
636 Timer TConvert; 637 Timer TConvert;
637 Cfg *Fcn = FunctionConverter.convertFunction(I); 638 Cfg *Fcn = FunctionConverter.convertFunction(I);
638 if (Ctx->getFlags().SubzeroTimingEnabled) {
639 std::cerr << "[Subzero timing] Convert function "
640 << Fcn->getFunctionName() << ": " << TConvert.getElapsedSec()
641 << " sec\n";
642 }
643 translateFcn(Fcn); 639 translateFcn(Fcn);
644 } 640 }
645 641
646 emitConstants(); 642 emitConstants();
647 } 643 }
648 644
649 } // end of namespace Ice 645 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698