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

Side by Side Diff: src/IceCfgNode.cpp

Issue 1221643012: Subzero: Add -Wshadow to the build. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 5 years, 5 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/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 /// This file implements the CfgNode class, including the complexities 11 /// This file implements the CfgNode class, including the complexities
12 /// of instruction insertion and in-edge calculation. 12 /// of 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 "IceLiveness.h" 22 #include "IceLiveness.h"
23 #include "IceOperand.h" 23 #include "IceOperand.h"
24 #include "IceTargetLowering.h" 24 #include "IceTargetLowering.h"
25 25
26 namespace Ice { 26 namespace Ice {
27 27
28 CfgNode::CfgNode(Cfg *Func, SizeT LabelNumber) 28 CfgNode::CfgNode(Cfg *MyFunc, SizeT LabelNumber)
29 : Func(Func), Number(LabelNumber) {} 29 : Func(MyFunc), Number(LabelNumber) {}
30 30
31 // Returns the name the node was created with. If no name was given, 31 // Returns the name the node was created with. If no name was given,
32 // it synthesizes a (hopefully) unique name. 32 // it synthesizes a (hopefully) unique name.
33 IceString CfgNode::getName() const { 33 IceString CfgNode::getName() const {
34 if (NameIndex >= 0) 34 if (NameIndex >= 0)
35 return Func->getIdentifierName(NameIndex); 35 return Func->getIdentifierName(NameIndex);
36 return "__" + std::to_string(getIndex()); 36 return "__" + std::to_string(getIndex());
37 } 37 }
38 38
39 // Adds an instruction to either the Phi list or the regular 39 // Adds an instruction to either the Phi list or the regular
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 if (Variable *Src = llvm::dyn_cast<Variable>(I->getSrc(S))) { 876 if (Variable *Src = llvm::dyn_cast<Variable>(I->getSrc(S))) {
877 if (!Src->hasReg()) 877 if (!Src->hasReg())
878 Func->getContext()->statsUpdateSpills(); 878 Func->getContext()->statsUpdateSpills();
879 } 879 }
880 } 880 }
881 } 881 }
882 } 882 }
883 883
884 } // end of anonymous namespace 884 } // end of anonymous namespace
885 885
886 void CfgNode::emit(Cfg *Func) const { 886 void CfgNode::emit() const {
887 if (!BuildDefs::dump()) 887 if (!BuildDefs::dump())
888 return; 888 return;
889 Func->setCurrentNode(this); 889 Func->setCurrentNode(this);
890 Ostream &Str = Func->getContext()->getStrEmit(); 890 Ostream &Str = Func->getContext()->getStrEmit();
891 Liveness *Liveness = Func->getLiveness(); 891 Liveness *Liveness = Func->getLiveness();
892 bool DecorateAsm = 892 bool DecorateAsm =
893 Liveness && Func->getContext()->getFlags().getDecorateAsm(); 893 Liveness && Func->getContext()->getFlags().getDecorateAsm();
894 Str << getAsmName() << ":\n"; 894 Str << getAsmName() << ":\n";
895 // LiveRegCount keeps track of the number of currently live 895 // LiveRegCount keeps track of the number of currently live
896 // variables that each register is assigned to. Normally that would 896 // variables that each register is assigned to. Normally that would
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 } 939 }
940 940
941 // Helper class for emitIAS(). 941 // Helper class for emitIAS().
942 namespace { 942 namespace {
943 class BundleEmitHelper { 943 class BundleEmitHelper {
944 BundleEmitHelper() = delete; 944 BundleEmitHelper() = delete;
945 BundleEmitHelper(const BundleEmitHelper &) = delete; 945 BundleEmitHelper(const BundleEmitHelper &) = delete;
946 BundleEmitHelper &operator=(const BundleEmitHelper &) = delete; 946 BundleEmitHelper &operator=(const BundleEmitHelper &) = delete;
947 947
948 public: 948 public:
949 BundleEmitHelper(Assembler *Asm, TargetLowering *Target, 949 BundleEmitHelper(Assembler *MyAsm, TargetLowering *MyTarget,
950 const InstList &Insts) 950 const InstList &Insts)
951 : Asm(Asm), Target(Target), End(Insts.end()), BundleLockStart(End), 951 : Asm(MyAsm), Target(MyTarget), End(Insts.end()), BundleLockStart(End),
952 BundleSize(1 << Asm->getBundleAlignLog2Bytes()), 952 BundleSize(1 << Asm->getBundleAlignLog2Bytes()),
953 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {} 953 BundleMaskLo(BundleSize - 1), BundleMaskHi(~BundleMaskLo) {}
954 // Check whether we're currently within a bundle_lock region. 954 // Check whether we're currently within a bundle_lock region.
955 bool isInBundleLockRegion() const { return BundleLockStart != End; } 955 bool isInBundleLockRegion() const { return BundleLockStart != End; }
956 // Check whether the current bundle_lock region has the align_to_end 956 // Check whether the current bundle_lock region has the align_to_end
957 // option. 957 // option.
958 bool isAlignToEnd() const { 958 bool isAlignToEnd() const {
959 assert(isInBundleLockRegion()); 959 assert(isInBundleLockRegion());
960 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() == 960 return llvm::cast<InstBundleLock>(getBundleLockStart())->getOption() ==
961 InstBundleLock::Opt_AlignToEnd; 961 InstBundleLock::Opt_AlignToEnd;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 // Masking with BundleMaskLo identifies an address's bundle offset. 1049 // Masking with BundleMaskLo identifies an address's bundle offset.
1050 const intptr_t BundleMaskLo; 1050 const intptr_t BundleMaskLo;
1051 // Masking with BundleMaskHi identifies an address's bundle. 1051 // Masking with BundleMaskHi identifies an address's bundle.
1052 const intptr_t BundleMaskHi; 1052 const intptr_t BundleMaskHi;
1053 intptr_t SizeSnapshotPre = 0; 1053 intptr_t SizeSnapshotPre = 0;
1054 intptr_t SizeSnapshotPost = 0; 1054 intptr_t SizeSnapshotPost = 0;
1055 }; 1055 };
1056 1056
1057 } // end of anonymous namespace 1057 } // end of anonymous namespace
1058 1058
1059 void CfgNode::emitIAS(Cfg *Func) const { 1059 void CfgNode::emitIAS() const {
1060 Func->setCurrentNode(this); 1060 Func->setCurrentNode(this);
1061 Assembler *Asm = Func->getAssembler<>(); 1061 Assembler *Asm = Func->getAssembler<>();
1062 // TODO(stichnot): When sandboxing, defer binding the node label 1062 // TODO(stichnot): When sandboxing, defer binding the node label
1063 // until just before the first instruction is emitted, to reduce the 1063 // until just before the first instruction is emitted, to reduce the
1064 // chance that a padding nop is a branch target. 1064 // chance that a padding nop is a branch target.
1065 Asm->bindCfgNodeLabel(getIndex()); 1065 Asm->bindCfgNodeLabel(getIndex());
1066 for (const Inst &I : Phis) { 1066 for (const Inst &I : Phis) {
1067 if (I.isDeleted()) 1067 if (I.isDeleted())
1068 continue; 1068 continue;
1069 // Emitting a Phi instruction should cause an error. 1069 // Emitting a Phi instruction should cause an error.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 Helper.leaveBundleLockRegion(); 1157 Helper.leaveBundleLockRegion();
1158 } 1158 }
1159 } 1159 }
1160 1160
1161 // Don't allow bundle locking across basic blocks, to keep the 1161 // Don't allow bundle locking across basic blocks, to keep the
1162 // backtracking mechanism simple. 1162 // backtracking mechanism simple.
1163 assert(!Helper.isInBundleLockRegion()); 1163 assert(!Helper.isInBundleLockRegion());
1164 assert(!Retrying); 1164 assert(!Retrying);
1165 } 1165 }
1166 1166
1167 void CfgNode::dump(Cfg *Func) const { 1167 void CfgNode::dump() const {
1168 if (!BuildDefs::dump()) 1168 if (!BuildDefs::dump())
1169 return; 1169 return;
1170 Func->setCurrentNode(this); 1170 Func->setCurrentNode(this);
1171 Ostream &Str = Func->getContext()->getStrDump(); 1171 Ostream &Str = Func->getContext()->getStrDump();
1172 Liveness *Liveness = Func->getLiveness(); 1172 Liveness *Liveness = Func->getLiveness();
1173 if (Func->isVerbose(IceV_Instructions)) { 1173 if (Func->isVerbose(IceV_Instructions)) {
1174 Str << getName() << ":\n"; 1174 Str << getName() << ":\n";
1175 } 1175 }
1176 // Dump list of predecessor nodes. 1176 // Dump list of predecessor nodes.
1177 if (Func->isVerbose(IceV_Preds) && !InEdges.empty()) { 1177 if (Func->isVerbose(IceV_Preds) && !InEdges.empty()) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 InstIntrinsicCall *Inst = InstIntrinsicCall::create( 1268 InstIntrinsicCall *Inst = InstIntrinsicCall::create(
1269 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info); 1269 Func, 5, Func->makeVariable(IceType_i64), RMWI64Name, Info->Info);
1270 Inst->addArg(AtomicRMWOp); 1270 Inst->addArg(AtomicRMWOp);
1271 Inst->addArg(Counter); 1271 Inst->addArg(Counter);
1272 Inst->addArg(One); 1272 Inst->addArg(One);
1273 Inst->addArg(OrderAcquireRelease); 1273 Inst->addArg(OrderAcquireRelease);
1274 Insts.push_front(Inst); 1274 Insts.push_front(Inst);
1275 } 1275 }
1276 1276
1277 } // end of namespace Ice 1277 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfgNode.h ('k') | src/IceClFlags.cpp » ('j') | src/IceConverter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698