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

Side by Side Diff: src/IceConverter.cpp

Issue 619893002: Subzero: Auto-awesome iterators. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Use AsmCodeByte instead of uint8_t 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
« no previous file with comments | « src/IceCfgNode.cpp ('k') | src/IceGlobalContext.cpp » ('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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Ice::GlobalContext::getTimerID("llvmConvert"); 63 Ice::GlobalContext::getTimerID("llvmConvert");
64 Ice::TimerMarker T(IDllvmConvert, Ctx); 64 Ice::TimerMarker T(IDllvmConvert, Ctx);
65 VarMap.clear(); 65 VarMap.clear();
66 NodeMap.clear(); 66 NodeMap.clear();
67 Func = new Ice::Cfg(Ctx); 67 Func = new Ice::Cfg(Ctx);
68 Func->setFunctionName(F->getName()); 68 Func->setFunctionName(F->getName());
69 Func->setReturnType(convertToIceType(F->getReturnType())); 69 Func->setReturnType(convertToIceType(F->getReturnType()));
70 Func->setInternal(F->hasInternalLinkage()); 70 Func->setInternal(F->hasInternalLinkage());
71 71
72 // The initial definition/use of each arg is the entry node. 72 // The initial definition/use of each arg is the entry node.
73 for (Function::const_arg_iterator ArgI = F->arg_begin(), 73 for (auto ArgI = F->arg_begin(), ArgE = F->arg_end(); ArgI != ArgE;
74 ArgE = F->arg_end(); 74 ++ArgI) {
75 ArgI != ArgE; ++ArgI) {
76 Func->addArg(mapValueToIceVar(ArgI)); 75 Func->addArg(mapValueToIceVar(ArgI));
77 } 76 }
78 77
79 // Make an initial pass through the block list just to resolve the 78 // Make an initial pass through the block list just to resolve the
80 // blocks in the original linearized order. Otherwise the ICE 79 // blocks in the original linearized order. Otherwise the ICE
81 // linearized order will be affected by branch targets in 80 // linearized order will be affected by branch targets in
82 // terminator instructions. 81 // terminator instructions.
83 for (Function::const_iterator BBI = F->begin(), BBE = F->end(); BBI != BBE; 82 for (const BasicBlock &BBI : *F)
84 ++BBI) { 83 mapBasicBlockToNode(&BBI);
85 mapBasicBlockToNode(BBI); 84 for (const BasicBlock &BBI : *F)
86 } 85 convertBasicBlock(&BBI);
87 for (Function::const_iterator BBI = F->begin(), BBE = F->end(); BBI != BBE;
88 ++BBI) {
89 convertBasicBlock(BBI);
90 }
91 Func->setEntryNode(mapBasicBlockToNode(&F->getEntryBlock())); 86 Func->setEntryNode(mapBasicBlockToNode(&F->getEntryBlock()));
92 Func->computePredecessors(); 87 Func->computePredecessors();
93 88
94 return Func; 89 return Func;
95 } 90 }
96 91
97 // convertConstant() does not use Func or require it to be a valid 92 // convertConstant() does not use Func or require it to be a valid
98 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing 93 // Ice::Cfg pointer. As such, it's suitable for e.g. constructing
99 // global initializers. 94 // global initializers.
100 Ice::Constant *convertConstant(const Constant *Const) { 95 Ice::Constant *convertConstant(const Constant *Const) {
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 552
558 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest); 553 return Ice::InstAlloca::create(Func, ByteCount, Align, Dest);
559 } 554 }
560 555
561 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) { 556 Ice::Inst *convertUnreachableInstruction(const UnreachableInst * /*Inst*/) {
562 return Ice::InstUnreachable::create(Func); 557 return Ice::InstUnreachable::create(Func);
563 } 558 }
564 559
565 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) { 560 Ice::CfgNode *convertBasicBlock(const BasicBlock *BB) {
566 Ice::CfgNode *Node = mapBasicBlockToNode(BB); 561 Ice::CfgNode *Node = mapBasicBlockToNode(BB);
567 for (BasicBlock::const_iterator II = BB->begin(), II_e = BB->end(); 562 for (const Instruction &II : *BB) {
568 II != II_e; ++II) { 563 Ice::Inst *Inst = convertInstruction(&II);
569 Ice::Inst *Inst = convertInstruction(II);
570 Node->appendInst(Inst); 564 Node->appendInst(Inst);
571 } 565 }
572 return Node; 566 return Node;
573 } 567 }
574 568
575 void validateIntrinsicCall(const Ice::InstCall *Call, 569 void validateIntrinsicCall(const Ice::InstCall *Call,
576 const Ice::Intrinsics::FullIntrinsicInfo *I) { 570 const Ice::Intrinsics::FullIntrinsicInfo *I) {
577 Ice::SizeT ArgIndex = 0; 571 Ice::SizeT ArgIndex = 0;
578 switch (I->validateCall(Call, ArgIndex)) { 572 switch (I->validateCall(Call, ArgIndex)) {
579 default: 573 default:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 void Converter::convertToIce() { 619 void Converter::convertToIce() {
626 static TimerIdT IDconvertToIce = GlobalContext::getTimerID("convertToIce"); 620 static TimerIdT IDconvertToIce = GlobalContext::getTimerID("convertToIce");
627 TimerMarker T(IDconvertToIce, Ctx); 621 TimerMarker T(IDconvertToIce, Ctx);
628 nameUnnamedGlobalAddresses(Mod); 622 nameUnnamedGlobalAddresses(Mod);
629 if (!Ctx->getFlags().DisableGlobals) 623 if (!Ctx->getFlags().DisableGlobals)
630 convertGlobals(Mod); 624 convertGlobals(Mod);
631 convertFunctions(); 625 convertFunctions();
632 } 626 }
633 627
634 void Converter::convertFunctions() { 628 void Converter::convertFunctions() {
635 for (Module::const_iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) { 629 for (const Function &I : *Mod) {
636 if (I->empty()) 630 if (I.empty())
637 continue; 631 continue;
638 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext()); 632 LLVM2ICEConverter FunctionConverter(Ctx, Mod->getContext());
639 633
640 Cfg *Fcn = FunctionConverter.convertFunction(I); 634 Cfg *Fcn = FunctionConverter.convertFunction(&I);
641 translateFcn(Fcn); 635 translateFcn(Fcn);
642 } 636 }
643 637
644 emitConstants(); 638 emitConstants();
645 } 639 }
646 640
647 } // end of namespace Ice 641 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.cpp ('k') | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698