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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1866463002: Subzero: Improve non-MINIMAL string performance. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 years, 8 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.h ('k') | src/IceInst.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/IceCfgNode.cpp - Basic block (node) implementation -----===// 1 //===- subzero/src/IceCfgNode.cpp - Basic block (node) implementation -----===//
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
11 /// \brief Implements the CfgNode class, including the complexities of 11 /// \brief Implements the CfgNode class, including the complexities of
12 /// instruction insertion and in-edge calculation. 12 /// instruction insertion and in-edge calculation.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "IceCfgNode.h" 16 #include "IceCfgNode.h"
17 17
18 #include "IceAssembler.h" 18 #include "IceAssembler.h"
19 #include "IceCfg.h" 19 #include "IceCfg.h"
20 #include "IceGlobalInits.h" 20 #include "IceGlobalInits.h"
21 #include "IceInst.h" 21 #include "IceInst.h"
22 #include "IceInstVarIter.h" 22 #include "IceInstVarIter.h"
23 #include "IceLiveness.h" 23 #include "IceLiveness.h"
24 #include "IceOperand.h" 24 #include "IceOperand.h"
25 #include "IceTargetLowering.h" 25 #include "IceTargetLowering.h"
26 26
27 namespace Ice { 27 namespace Ice {
28 28
29 CfgNode::CfgNode(Cfg *Func, SizeT Number) : Func(Func), Number(Number) {
30 if (BuildDefs::dump()) {
31 Name =
32 NodeString::createWithString(Func, "__" + std::to_string(getIndex()));
33 } else {
34 Name = NodeString::createWithoutString(Func);
35 }
36 }
37
38 // Adds an instruction to either the Phi list or the regular instruction list. 29 // Adds an instruction to either the Phi list or the regular instruction list.
39 // Validates that all Phis are added before all regular instructions. 30 // Validates that all Phis are added before all regular instructions.
40 void CfgNode::appendInst(Inst *Instr, bool AllowPhisAnywhere) { 31 void CfgNode::appendInst(Inst *Instr, bool AllowPhisAnywhere) {
41 ++InstCountEstimate; 32 ++InstCountEstimate;
42 33
43 if (BuildDefs::wasm()) { 34 if (BuildDefs::wasm()) {
44 if (llvm::isa<InstSwitch>(Instr) || llvm::isa<InstBr>(Instr)) { 35 if (llvm::isa<InstSwitch>(Instr) || llvm::isa<InstBr>(Instr)) {
45 for (auto *N : Instr->getTerminatorEdges()) { 36 for (auto *N : Instr->getTerminatorEdges()) {
46 N->addInEdge(this); 37 N->addInEdge(this);
47 addOutEdge(N); 38 addOutEdge(N);
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 Str << "Live range errors in the following block:\n"; 781 Str << "Live range errors in the following block:\n";
791 dump(Func); 782 dump(Func);
792 } 783 }
793 for (auto Start = MapBegin.begin(); 784 for (auto Start = MapBegin.begin();
794 (Start = std::adjacent_find(Start, MapBegin.end(), ComparePair)) != 785 (Start = std::adjacent_find(Start, MapBegin.end(), ComparePair)) !=
795 MapBegin.end(); 786 MapBegin.end();
796 ++Start) { 787 ++Start) {
797 auto Next = Start + 1; 788 auto Next = Start + 1;
798 Str << "Duplicate LR begin, block " << getName() << ", instructions " 789 Str << "Duplicate LR begin, block " << getName() << ", instructions "
799 << Start->second << " & " << Next->second << ", variable " 790 << Start->second << " & " << Next->second << ", variable "
800 << Liveness->getVariable(Start->first, this)->getName(Func) << "\n"; 791 << Liveness->getVariable(Start->first, this)->getName() << "\n";
801 } 792 }
802 for (auto Start = MapEnd.begin(); 793 for (auto Start = MapEnd.begin();
803 (Start = std::adjacent_find(Start, MapEnd.end(), ComparePair)) != 794 (Start = std::adjacent_find(Start, MapEnd.end(), ComparePair)) !=
804 MapEnd.end(); 795 MapEnd.end();
805 ++Start) { 796 ++Start) {
806 auto Next = Start + 1; 797 auto Next = Start + 1;
807 Str << "Duplicate LR end, block " << getName() << ", instructions " 798 Str << "Duplicate LR end, block " << getName() << ", instructions "
808 << Start->second << " & " << Next->second << ", variable " 799 << Start->second << " & " << Next->second << ", variable "
809 << Liveness->getVariable(Start->first, this)->getName(Func) << "\n"; 800 << Liveness->getVariable(Start->first, this)->getName() << "\n";
810 } 801 }
811 } 802 }
812 803
813 return false; 804 return false;
814 } 805 }
815 806
816 // Once basic liveness is complete, compute actual live ranges. It is assumed 807 // Once basic liveness is complete, compute actual live ranges. It is assumed
817 // that within a single basic block, a live range begins at most once and ends 808 // that within a single basic block, a live range begins at most once and ends
818 // at most once. This is certainly true for pure SSA form. It is also true once 809 // at most once. This is certainly true for pure SSA form. It is also true once
819 // phis are lowered, since each assignment to the phi-based temporary is in a 810 // phis are lowered, since each assignment to the phi-based temporary is in a
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 Str << "\n"; 1386 Str << "\n";
1396 } 1387 }
1397 // Dump the live-in variables. 1388 // Dump the live-in variables.
1398 if (Func->isVerbose(IceV_Liveness)) { 1389 if (Func->isVerbose(IceV_Liveness)) {
1399 if (Liveness != nullptr && !Liveness->getLiveIn(this).empty()) { 1390 if (Liveness != nullptr && !Liveness->getLiveIn(this).empty()) {
1400 const LivenessBV &LiveIn = Liveness->getLiveIn(this); 1391 const LivenessBV &LiveIn = Liveness->getLiveIn(this);
1401 Str << " // LiveIn:"; 1392 Str << " // LiveIn:";
1402 for (SizeT i = 0; i < LiveIn.size(); ++i) { 1393 for (SizeT i = 0; i < LiveIn.size(); ++i) {
1403 if (LiveIn[i]) { 1394 if (LiveIn[i]) {
1404 Variable *Var = Liveness->getVariable(i, this); 1395 Variable *Var = Liveness->getVariable(i, this);
1405 Str << " %" << Var->getName(Func); 1396 Str << " %" << Var->getName();
1406 if (Func->isVerbose(IceV_RegOrigins) && Var->hasReg()) { 1397 if (Func->isVerbose(IceV_RegOrigins) && Var->hasReg()) {
1407 Str << ":" 1398 Str << ":"
1408 << Func->getTarget()->getRegName(Var->getRegNum(), 1399 << Func->getTarget()->getRegName(Var->getRegNum(),
1409 Var->getType()); 1400 Var->getType());
1410 } 1401 }
1411 } 1402 }
1412 } 1403 }
1413 Str << "\n"; 1404 Str << "\n";
1414 } 1405 }
1415 } 1406 }
1416 // Dump each instruction. 1407 // Dump each instruction.
1417 if (Func->isVerbose(IceV_Instructions)) { 1408 if (Func->isVerbose(IceV_Instructions)) {
1418 for (const Inst &I : Phis) 1409 for (const Inst &I : Phis)
1419 I.dumpDecorated(Func); 1410 I.dumpDecorated(Func);
1420 for (const Inst &I : Insts) 1411 for (const Inst &I : Insts)
1421 I.dumpDecorated(Func); 1412 I.dumpDecorated(Func);
1422 } 1413 }
1423 // Dump the live-out variables. 1414 // Dump the live-out variables.
1424 if (Func->isVerbose(IceV_Liveness)) { 1415 if (Func->isVerbose(IceV_Liveness)) {
1425 if (Liveness != nullptr && !Liveness->getLiveOut(this).empty()) { 1416 if (Liveness != nullptr && !Liveness->getLiveOut(this).empty()) {
1426 const LivenessBV &LiveOut = Liveness->getLiveOut(this); 1417 const LivenessBV &LiveOut = Liveness->getLiveOut(this);
1427 Str << " // LiveOut:"; 1418 Str << " // LiveOut:";
1428 for (SizeT i = 0; i < LiveOut.size(); ++i) { 1419 for (SizeT i = 0; i < LiveOut.size(); ++i) {
1429 if (LiveOut[i]) { 1420 if (LiveOut[i]) {
1430 Variable *Var = Liveness->getVariable(i, this); 1421 Variable *Var = Liveness->getVariable(i, this);
1431 Str << " %" << Var->getName(Func); 1422 Str << " %" << Var->getName();
1432 if (Func->isVerbose(IceV_RegOrigins) && Var->hasReg()) { 1423 if (Func->isVerbose(IceV_RegOrigins) && Var->hasReg()) {
1433 Str << ":" 1424 Str << ":"
1434 << Func->getTarget()->getRegName(Var->getRegNum(), 1425 << Func->getTarget()->getRegName(Var->getRegNum(),
1435 Var->getType()); 1426 Var->getType());
1436 } 1427 }
1437 } 1428 }
1438 } 1429 }
1439 Str << "\n"; 1430 Str << "\n";
1440 } 1431 }
1441 } 1432 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 auto *Instr = InstIntrinsicCall::create( 1465 auto *Instr = InstIntrinsicCall::create(
1475 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1466 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1476 Instr->addArg(AtomicRMWOp); 1467 Instr->addArg(AtomicRMWOp);
1477 Instr->addArg(Counter); 1468 Instr->addArg(Counter);
1478 Instr->addArg(One); 1469 Instr->addArg(One);
1479 Instr->addArg(OrderAcquireRelease); 1470 Instr->addArg(OrderAcquireRelease);
1480 Insts.push_front(Instr); 1471 Insts.push_front(Instr);
1481 } 1472 }
1482 1473
1483 } // end of namespace Ice 1474 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceInst.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698