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

Side by Side Diff: src/IceOperand.h

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/IceOperand.h - High-level operands -----------*- C++ -*-===// 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- C++ -*-===//
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
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 assert(Func); 79 assert(Func);
80 dump(Func, Func->getContext()->getStrDump()); 80 dump(Func, Func->getContext()->getStrDump());
81 } 81 }
82 void dump(Ostream &Str) const { 82 void dump(Ostream &Str) const {
83 if (BuildDefs::dump()) 83 if (BuildDefs::dump())
84 dump(nullptr, Str); 84 dump(nullptr, Str);
85 } 85 }
86 /// @} 86 /// @}
87 87
88 protected: 88 protected:
89 Operand(OperandKind Kind, Type Ty) : Ty(Ty), Kind(Kind) {} 89 Operand(OperandKind MyKind, Type MyTy) : Ty(MyTy), Kind(MyKind) {}
90 virtual ~Operand() = default; 90 virtual ~Operand() = default;
91 91
92 const Type Ty; 92 const Type Ty;
93 const OperandKind Kind; 93 const OperandKind Kind;
94 /// Vars and NumVars are initialized by the derived class. 94 /// Vars and NumVars are initialized by the derived class.
95 SizeT NumVars = 0; 95 SizeT NumVars = 0;
96 Variable **Vars = nullptr; 96 Variable **Vars = nullptr;
97 }; 97 };
98 98
99 template <class StreamType> 99 template <class StreamType>
(...skipping 27 matching lines...) Expand all
127 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) { 127 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) {
128 (void)Ctx; 128 (void)Ctx;
129 return false; 129 return false;
130 } 130 }
131 131
132 void setShouldBePooled(bool R) { shouldBePooled = R; } 132 void setShouldBePooled(bool R) { shouldBePooled = R; }
133 133
134 bool getShouldBePooled() const { return shouldBePooled; } 134 bool getShouldBePooled() const { return shouldBePooled; }
135 135
136 protected: 136 protected:
137 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) 137 Constant(OperandKind Kind, Type Ty, uint32_t MyPoolEntryID)
138 : Operand(Kind, Ty), PoolEntryID(PoolEntryID), shouldBePooled(false) { 138 : Operand(Kind, Ty), PoolEntryID(MyPoolEntryID), shouldBePooled(false) {
139 Vars = nullptr; 139 Vars = nullptr;
140 NumVars = 0; 140 NumVars = 0;
141 } 141 }
142 /// PoolEntryID is an integer that uniquely identifies the constant 142 /// PoolEntryID is an integer that uniquely identifies the constant
143 /// within its constant pool. It is used for building the constant 143 /// within its constant pool. It is used for building the constant
144 /// pool in the object code and for referencing its entries. 144 /// pool in the object code and for referencing its entries.
145 const uint32_t PoolEntryID; 145 const uint32_t PoolEntryID;
146 /// Whether we should pool this constant. Usually Float/Double and pooled 146 /// Whether we should pool this constant. Usually Float/Double and pooled
147 /// Integers should be flagged true. 147 /// Integers should be flagged true.
148 bool shouldBePooled; 148 bool shouldBePooled;
(...skipping 28 matching lines...) Expand all
177 static bool classof(const Operand *Operand) { 177 static bool classof(const Operand *Operand) {
178 return Operand->getKind() == K; 178 return Operand->getKind() == K;
179 } 179 }
180 180
181 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) override { 181 virtual bool shouldBeRandomizedOrPooled(const GlobalContext *Ctx) override {
182 (void)Ctx; 182 (void)Ctx;
183 return false; 183 return false;
184 } 184 }
185 185
186 private: 186 private:
187 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) 187 ConstantPrimitive(Type Ty, PrimType MyValue, uint32_t PoolEntryID)
188 : Constant(K, Ty, PoolEntryID), Value(Value) {} 188 : Constant(K, Ty, PoolEntryID), Value(MyValue) {}
189 const PrimType Value; 189 const PrimType Value;
190 }; 190 };
191 191
192 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; 192 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32;
193 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; 193 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64;
194 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; 194 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
195 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; 195 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
196 196
197 template <> 197 template <>
198 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { 198 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
(...skipping 19 matching lines...) Expand all
218 218
219 /// RelocatableTuple bundles the parameters that are used to 219 /// RelocatableTuple bundles the parameters that are used to
220 /// construct an ConstantRelocatable. It is done this way so that 220 /// construct an ConstantRelocatable. It is done this way so that
221 /// ConstantRelocatable can fit into the global constant pool 221 /// ConstantRelocatable can fit into the global constant pool
222 /// template mechanism. 222 /// template mechanism.
223 class RelocatableTuple { 223 class RelocatableTuple {
224 RelocatableTuple() = delete; 224 RelocatableTuple() = delete;
225 RelocatableTuple &operator=(const RelocatableTuple &) = delete; 225 RelocatableTuple &operator=(const RelocatableTuple &) = delete;
226 226
227 public: 227 public:
228 RelocatableTuple(const RelocOffsetT Offset, const IceString &Name, 228 RelocatableTuple(const RelocOffsetT MyOffset, const IceString &MyName,
229 bool SuppressMangling) 229 bool MySuppressMangling)
230 : Offset(Offset), Name(Name), SuppressMangling(SuppressMangling) {} 230 : Offset(MyOffset), Name(MyName), SuppressMangling(MySuppressMangling) {}
231 RelocatableTuple(const RelocatableTuple &) = default; 231 RelocatableTuple(const RelocatableTuple &) = default;
232 232
233 const RelocOffsetT Offset; 233 const RelocOffsetT Offset;
234 const IceString Name; 234 const IceString Name;
235 bool SuppressMangling; 235 bool SuppressMangling;
236 }; 236 };
237 237
238 bool operator==(const RelocatableTuple &A, const RelocatableTuple &B); 238 bool operator==(const RelocatableTuple &A, const RelocatableTuple &B);
239 239
240 /// ConstantRelocatable represents a symbolic constant combined with 240 /// ConstantRelocatable represents a symbolic constant combined with
(...skipping 22 matching lines...) Expand all
263 void emitWithoutPrefix(TargetLowering *Target) const; 263 void emitWithoutPrefix(TargetLowering *Target) const;
264 using Constant::dump; 264 using Constant::dump;
265 void dump(const Cfg *Func, Ostream &Str) const override; 265 void dump(const Cfg *Func, Ostream &Str) const override;
266 266
267 static bool classof(const Operand *Operand) { 267 static bool classof(const Operand *Operand) {
268 OperandKind Kind = Operand->getKind(); 268 OperandKind Kind = Operand->getKind();
269 return Kind == kConstRelocatable; 269 return Kind == kConstRelocatable;
270 } 270 }
271 271
272 private: 272 private:
273 ConstantRelocatable(Type Ty, RelocOffsetT Offset, const IceString &Name, 273 ConstantRelocatable(Type Ty, RelocOffsetT MyOffset, const IceString &MyName,
274 bool SuppressMangling, uint32_t PoolEntryID) 274 bool MySuppressMangling, uint32_t PoolEntryID)
275 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), 275 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(MyOffset),
276 Name(Name), SuppressMangling(SuppressMangling) {} 276 Name(MyName), SuppressMangling(MySuppressMangling) {}
277 const RelocOffsetT Offset; /// fixed offset to add 277 const RelocOffsetT Offset; /// fixed offset to add
278 const IceString Name; /// optional for debug/dump 278 const IceString Name; /// optional for debug/dump
279 bool SuppressMangling; 279 bool SuppressMangling;
280 }; 280 };
281 281
282 /// ConstantUndef represents an unspecified bit pattern. Although it is 282 /// ConstantUndef represents an unspecified bit pattern. Although it is
283 /// legal to lower ConstantUndef to any value, backends should try to 283 /// legal to lower ConstantUndef to any value, backends should try to
284 /// make code generation deterministic by lowering ConstantUndefs to 0. 284 /// make code generation deterministic by lowering ConstantUndefs to 0.
285 class ConstantUndef : public Constant { 285 class ConstantUndef : public Constant {
286 ConstantUndef() = delete; 286 ConstantUndef() = delete;
(...skipping 24 matching lines...) Expand all
311 ConstantUndef(Type Ty, uint32_t PoolEntryID) 311 ConstantUndef(Type Ty, uint32_t PoolEntryID)
312 : Constant(kConstUndef, Ty, PoolEntryID) {} 312 : Constant(kConstUndef, Ty, PoolEntryID) {}
313 }; 313 };
314 314
315 /// RegWeight is a wrapper for a uint32_t weight value, with a 315 /// RegWeight is a wrapper for a uint32_t weight value, with a
316 /// special value that represents infinite weight, and an addWeight() 316 /// special value that represents infinite weight, and an addWeight()
317 /// method that ensures that W+infinity=infinity. 317 /// method that ensures that W+infinity=infinity.
318 class RegWeight { 318 class RegWeight {
319 public: 319 public:
320 RegWeight() = default; 320 RegWeight() = default;
321 explicit RegWeight(uint32_t Weight) : Weight(Weight) {} 321 explicit RegWeight(uint32_t MyWeight) : Weight(MyWeight) {}
322 RegWeight(const RegWeight &) = default; 322 RegWeight(const RegWeight &) = default;
323 RegWeight &operator=(const RegWeight &) = default; 323 RegWeight &operator=(const RegWeight &) = default;
324 const static uint32_t Inf = ~0; /// Force regalloc to give a register 324 const static uint32_t Inf = ~0; /// Force regalloc to give a register
325 const static uint32_t Zero = 0; /// Force regalloc NOT to give a register 325 const static uint32_t Zero = 0; /// Force regalloc NOT to give a register
326 void addWeight(uint32_t Delta) { 326 void addWeight(uint32_t Delta) {
327 if (Delta == Inf) 327 if (Delta == Inf)
328 Weight = Inf; 328 Weight = Inf;
329 else if (Weight != Inf) 329 else if (Weight != Inf)
330 Weight += Delta; 330 Weight += Delta;
331 } 331 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 }; 596 };
597 597
598 /// VariablesMetadata analyzes and summarizes the metadata for the 598 /// VariablesMetadata analyzes and summarizes the metadata for the
599 /// complete set of Variables. 599 /// complete set of Variables.
600 class VariablesMetadata { 600 class VariablesMetadata {
601 VariablesMetadata() = delete; 601 VariablesMetadata() = delete;
602 VariablesMetadata(const VariablesMetadata &) = delete; 602 VariablesMetadata(const VariablesMetadata &) = delete;
603 VariablesMetadata &operator=(const VariablesMetadata &) = delete; 603 VariablesMetadata &operator=(const VariablesMetadata &) = delete;
604 604
605 public: 605 public:
606 explicit VariablesMetadata(const Cfg *Func) : Func(Func) {} 606 explicit VariablesMetadata(const Cfg *MyFunc) : Func(MyFunc) {}
607 /// Initialize the state by traversing all instructions/variables in 607 /// Initialize the state by traversing all instructions/variables in
608 /// the CFG. 608 /// the CFG.
609 void init(MetadataKind TrackingKind); 609 void init(MetadataKind TrackingKind);
610 /// Add a single node. This is called by init(), and can be called 610 /// Add a single node. This is called by init(), and can be called
611 /// incrementally from elsewhere, e.g. after edge-splitting. 611 /// incrementally from elsewhere, e.g. after edge-splitting.
612 void addNode(CfgNode *Node); 612 void addNode(CfgNode *Node);
613 /// Returns whether the given Variable is tracked in this object. It 613 /// Returns whether the given Variable is tracked in this object. It
614 /// should only return false if changes were made to the CFG after 614 /// should only return false if changes were made to the CFG after
615 /// running init(), in which case the state is stale and the results 615 /// running init(), in which case the state is stale and the results
616 /// shouldn't be trusted (but it may be OK e.g. for dumping). 616 /// shouldn't be trusted (but it may be OK e.g. for dumping).
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 private: 650 private:
651 const Cfg *Func; 651 const Cfg *Func;
652 MetadataKind Kind; 652 MetadataKind Kind;
653 std::vector<VariableTracking> Metadata; 653 std::vector<VariableTracking> Metadata;
654 const static InstDefList NoDefinitions; 654 const static InstDefList NoDefinitions;
655 }; 655 };
656 656
657 } // end of namespace Ice 657 } // end of namespace Ice
658 658
659 #endif // SUBZERO_SRC_ICEOPERAND_H 659 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« src/IceInst.h ('K') | « src/IceLiveness.h ('k') | src/IceRNG.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698