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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1838753002: Subzero: Remove IceString. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes 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/IceClFlags.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 LabelNumber) 29 CfgNode::CfgNode(Cfg *Func, SizeT Number) : Func(Func), Number(Number) {
30 : Func(Func), Number(LabelNumber), LabelNumber(LabelNumber) {} 30 if (BuildDefs::dump()) {
31 31 Name =
32 // Returns the name the node was created with. If no name was given, it 32 NodeString::createWithString(Func, "__" + std::to_string(getIndex()));
33 // synthesizes a (hopefully) unique name. 33 } else {
34 IceString CfgNode::getName() const { 34 Name = NodeString::createWithoutString(Func);
35 if (NameIndex >= 0) 35 }
36 return Func->getIdentifierName(NameIndex);
37 return "__" + std::to_string(LabelNumber);
38 } 36 }
39 37
40 // Adds an instruction to either the Phi list or the regular instruction list. 38 // Adds an instruction to either the Phi list or the regular instruction list.
41 // Validates that all Phis are added before all regular instructions. 39 // Validates that all Phis are added before all regular instructions.
42 void CfgNode::appendInst(Inst *Instr) { 40 void CfgNode::appendInst(Inst *Instr) {
43 ++InstCountEstimate; 41 ++InstCountEstimate;
44 if (auto *Phi = llvm::dyn_cast<InstPhi>(Instr)) { 42 if (auto *Phi = llvm::dyn_cast<InstPhi>(Instr)) {
45 if (!Insts.empty()) { 43 if (!Insts.empty()) {
46 Func->setError("Phi instruction added to the middle of a block"); 44 Func->setError("Phi instruction added to the middle of a block");
47 return; 45 return;
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 if (!First) 1419 if (!First)
1422 Str << ", "; 1420 Str << ", ";
1423 First = false; 1421 First = false;
1424 Str << "%" << I->getName(); 1422 Str << "%" << I->getName();
1425 } 1423 }
1426 Str << "\n"; 1424 Str << "\n";
1427 } 1425 }
1428 } 1426 }
1429 1427
1430 void CfgNode::profileExecutionCount(VariableDeclaration *Var) { 1428 void CfgNode::profileExecutionCount(VariableDeclaration *Var) {
1431 constexpr char RMW_I64[] = "llvm.nacl.atomic.rmw.i64"; 1429 GlobalContext *Ctx = Func->getContext();
1432 1430 GlobalString RMW_I64 = Ctx->getGlobalString("llvm.nacl.atomic.rmw.i64");
1433 GlobalContext *Context = Func->getContext();
1434 1431
1435 bool BadIntrinsic = false; 1432 bool BadIntrinsic = false;
1436 const Intrinsics::FullIntrinsicInfo *Info = 1433 const Intrinsics::FullIntrinsicInfo *Info =
1437 Context->getIntrinsicsInfo().find(RMW_I64, BadIntrinsic); 1434 Ctx->getIntrinsicsInfo().find(RMW_I64, BadIntrinsic);
1438 assert(!BadIntrinsic); 1435 assert(!BadIntrinsic);
1439 assert(Info != nullptr); 1436 assert(Info != nullptr);
1440 1437
1441 Operand *RMWI64Name = Context->getConstantExternSym(RMW_I64); 1438 Operand *RMWI64Name = Ctx->getConstantExternSym(RMW_I64);
1442 constexpr RelocOffsetT Offset = 0; 1439 constexpr RelocOffsetT Offset = 0;
1443 Constant *Counter = Context->getConstantSym(Offset, Var->getName()); 1440 Constant *Counter = Ctx->getConstantSym(Offset, Var->getName());
1444 Constant *AtomicRMWOp = Context->getConstantInt32(Intrinsics::AtomicAdd); 1441 Constant *AtomicRMWOp = Ctx->getConstantInt32(Intrinsics::AtomicAdd);
1445 Constant *One = Context->getConstantInt64(1); 1442 Constant *One = Ctx->getConstantInt64(1);
1446 Constant *OrderAcquireRelease = 1443 Constant *OrderAcquireRelease =
1447 Context->getConstantInt32(Intrinsics::MemoryOrderAcquireRelease); 1444 Ctx->getConstantInt32(Intrinsics::MemoryOrderAcquireRelease);
1448 1445
1449 auto *Instr = InstIntrinsicCall::create( 1446 auto *Instr = InstIntrinsicCall::create(
1450 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1447 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1451 Instr->addArg(AtomicRMWOp); 1448 Instr->addArg(AtomicRMWOp);
1452 Instr->addArg(Counter); 1449 Instr->addArg(Counter);
1453 Instr->addArg(One); 1450 Instr->addArg(One);
1454 Instr->addArg(OrderAcquireRelease); 1451 Instr->addArg(OrderAcquireRelease);
1455 Insts.push_front(Instr); 1452 Insts.push_front(Instr);
1456 } 1453 }
1457 1454
1458 } // end of namespace Ice 1455 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceClFlags.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698