OLD | NEW |
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 }; | 152 }; |
153 | 153 |
154 /// ConstantPrimitive<> wraps a primitive type. | 154 /// ConstantPrimitive<> wraps a primitive type. |
155 template <typename T, Operand::OperandKind K> | 155 template <typename T, Operand::OperandKind K> |
156 class ConstantPrimitive : public Constant { | 156 class ConstantPrimitive : public Constant { |
157 ConstantPrimitive() = delete; | 157 ConstantPrimitive() = delete; |
158 ConstantPrimitive(const ConstantPrimitive &) = delete; | 158 ConstantPrimitive(const ConstantPrimitive &) = delete; |
159 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete; | 159 ConstantPrimitive &operator=(const ConstantPrimitive &) = delete; |
160 | 160 |
161 public: | 161 public: |
162 typedef T PrimType; | 162 using PrimType = T; |
163 | 163 |
164 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, PrimType Value, | 164 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, PrimType Value, |
165 uint32_t PoolEntryID) { | 165 uint32_t PoolEntryID) { |
166 assert(!Ctx->isIRGenerationDisabled() && | 166 assert(!Ctx->isIRGenerationDisabled() && |
167 "Attempt to build primitive constant when IR generation disabled"); | 167 "Attempt to build primitive constant when IR generation disabled"); |
168 return new (Ctx->allocate<ConstantPrimitive>()) | 168 return new (Ctx->allocate<ConstantPrimitive>()) |
169 ConstantPrimitive(Ty, Value, PoolEntryID); | 169 ConstantPrimitive(Ty, Value, PoolEntryID); |
170 } | 170 } |
171 PrimType getValue() const { return Value; } | 171 PrimType getValue() const { return Value; } |
172 using Constant::emit; | 172 using Constant::emit; |
(...skipping 12 matching lines...) Expand all Loading... |
185 (void)Ctx; | 185 (void)Ctx; |
186 return false; | 186 return false; |
187 } | 187 } |
188 | 188 |
189 private: | 189 private: |
190 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) | 190 ConstantPrimitive(Type Ty, PrimType Value, uint32_t PoolEntryID) |
191 : Constant(K, Ty, PoolEntryID), Value(Value) {} | 191 : Constant(K, Ty, PoolEntryID), Value(Value) {} |
192 const PrimType Value; | 192 const PrimType Value; |
193 }; | 193 }; |
194 | 194 |
195 typedef ConstantPrimitive<int32_t, Operand::kConstInteger32> ConstantInteger32; | 195 using ConstantInteger32 = ConstantPrimitive<int32_t, Operand::kConstInteger32>; |
196 typedef ConstantPrimitive<int64_t, Operand::kConstInteger64> ConstantInteger64; | 196 using ConstantInteger64 = ConstantPrimitive<int64_t, Operand::kConstInteger64>; |
197 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; | 197 using ConstantFloat = ConstantPrimitive<float, Operand::kConstFloat>; |
198 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; | 198 using ConstantDouble = ConstantPrimitive<double, Operand::kConstDouble>; |
199 | 199 |
200 template <> | 200 template <> |
201 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { | 201 inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { |
202 if (!BuildDefs::dump()) | 202 if (!BuildDefs::dump()) |
203 return; | 203 return; |
204 if (getType() == IceType_i1) | 204 if (getType() == IceType_i1) |
205 Str << (getValue() ? "true" : "false"); | 205 Str << (getValue() ? "true" : "false"); |
206 else | 206 else |
207 Str << static_cast<int32_t>(getValue()); | 207 Str << static_cast<int32_t>(getValue()); |
208 } | 208 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 InstNumberT getEnd() const { | 380 InstNumberT getEnd() const { |
381 return Range.empty() ? -1 : Range.rbegin()->second; | 381 return Range.empty() ? -1 : Range.rbegin()->second; |
382 } | 382 } |
383 | 383 |
384 void untrim() { TrimmedBegin = Range.begin(); } | 384 void untrim() { TrimmedBegin = Range.begin(); } |
385 void trim(InstNumberT Lower); | 385 void trim(InstNumberT Lower); |
386 | 386 |
387 void dump(Ostream &Str) const; | 387 void dump(Ostream &Str) const; |
388 | 388 |
389 private: | 389 private: |
390 typedef std::pair<InstNumberT, InstNumberT> RangeElementType; | 390 using RangeElementType = std::pair<InstNumberT, InstNumberT>; |
391 /// RangeType is arena-allocated from the Cfg's allocator. | 391 /// RangeType is arena-allocated from the Cfg's allocator. |
392 typedef std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>> | 392 using RangeType = |
393 RangeType; | 393 std::vector<RangeElementType, CfgLocalAllocator<RangeElementType>>; |
394 RangeType Range; | 394 RangeType Range; |
395 /// TrimmedBegin is an optimization for the overlaps() computation. | 395 /// TrimmedBegin is an optimization for the overlaps() computation. |
396 /// Since the linear-scan algorithm always calls it as overlaps(Cur) | 396 /// Since the linear-scan algorithm always calls it as overlaps(Cur) |
397 /// and Cur advances monotonically according to live range start, we | 397 /// and Cur advances monotonically according to live range start, we |
398 /// can optimize overlaps() by ignoring all segments that end before | 398 /// can optimize overlaps() by ignoring all segments that end before |
399 /// the start of Cur's range. The linear-scan code enables this by | 399 /// the start of Cur's range. The linear-scan code enables this by |
400 /// calling trim() on the ranges of interest as Cur advances. Note | 400 /// calling trim() on the ranges of interest as Cur advances. Note |
401 /// that linear-scan also has to initialize TrimmedBegin at the | 401 /// that linear-scan also has to initialize TrimmedBegin at the |
402 /// beginning by calling untrim(). | 402 /// beginning by calling untrim(). |
403 RangeType::const_iterator TrimmedBegin; | 403 RangeType::const_iterator TrimmedBegin; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == | 553 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == |
554 /// this. | 554 /// this. |
555 Variable *VarsReal[1]; | 555 Variable *VarsReal[1]; |
556 }; | 556 }; |
557 | 557 |
558 enum MetadataKind { | 558 enum MetadataKind { |
559 VMK_Uses, /// Track only uses, not defs | 559 VMK_Uses, /// Track only uses, not defs |
560 VMK_SingleDefs, /// Track uses+defs, but only record single def | 560 VMK_SingleDefs, /// Track uses+defs, but only record single def |
561 VMK_All /// Track uses+defs, including full def list | 561 VMK_All /// Track uses+defs, including full def list |
562 }; | 562 }; |
563 typedef std::vector<const Inst *, CfgLocalAllocator<const Inst *>> InstDefList; | 563 using InstDefList = std::vector<const Inst *, CfgLocalAllocator<const Inst *>>; |
564 | 564 |
565 /// VariableTracking tracks the metadata for a single variable. It is | 565 /// VariableTracking tracks the metadata for a single variable. It is |
566 /// only meant to be used internally by VariablesMetadata. | 566 /// only meant to be used internally by VariablesMetadata. |
567 class VariableTracking { | 567 class VariableTracking { |
568 VariableTracking &operator=(const VariableTracking &) = delete; | 568 VariableTracking &operator=(const VariableTracking &) = delete; |
569 | 569 |
570 public: | 570 public: |
571 enum MultiDefState { | 571 enum MultiDefState { |
572 // TODO(stichnot): Consider using just a simple counter. | 572 // TODO(stichnot): Consider using just a simple counter. |
573 MDS_Unknown, | 573 MDS_Unknown, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 private: | 659 private: |
660 const Cfg *Func; | 660 const Cfg *Func; |
661 MetadataKind Kind; | 661 MetadataKind Kind; |
662 std::vector<VariableTracking> Metadata; | 662 std::vector<VariableTracking> Metadata; |
663 const static InstDefList NoDefinitions; | 663 const static InstDefList NoDefinitions; |
664 }; | 664 }; |
665 | 665 |
666 } // end of namespace Ice | 666 } // end of namespace Ice |
667 | 667 |
668 #endif // SUBZERO_SRC_ICEOPERAND_H | 668 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |