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

Side by Side Diff: src/IceOperand.h

Issue 605123002: Subzero: Use 'override' as appropriate for C++11. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Insert InstHighLevel into the Inst hierarchy Created 6 years, 2 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 // This file declares the Operand class and its target-independent 10 // This file declares the Operand class and its target-independent
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 Op.dump(Str); 95 Op.dump(Str);
96 return Str; 96 return Str;
97 } 97 }
98 98
99 // Constant is the abstract base class for constants. All 99 // Constant is the abstract base class for constants. All
100 // constants are allocated from a global arena and are pooled. 100 // constants are allocated from a global arena and are pooled.
101 class Constant : public Operand { 101 class Constant : public Operand {
102 public: 102 public:
103 uint32_t getPoolEntryID() const { return PoolEntryID; } 103 uint32_t getPoolEntryID() const { return PoolEntryID; }
104 using Operand::dump; 104 using Operand::dump;
105 virtual void emit(const Cfg *Func) const { emit(Func->getContext()); } 105 void emit(const Cfg *Func) const override { emit(Func->getContext()); }
106 virtual void emit(GlobalContext *Ctx) const = 0; 106 virtual void emit(GlobalContext *Ctx) const = 0;
107 virtual void dump(const Cfg *Func, Ostream &Str) const = 0; 107 void dump(const Cfg *Func, Ostream &Str) const = 0;
108 108
109 static bool classof(const Operand *Operand) { 109 static bool classof(const Operand *Operand) {
110 OperandKind Kind = Operand->getKind(); 110 OperandKind Kind = Operand->getKind();
111 return Kind >= kConst_Base && Kind <= kConst_Num; 111 return Kind >= kConst_Base && Kind <= kConst_Num;
112 } 112 }
113 113
114 protected: 114 protected:
115 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) 115 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID)
116 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { 116 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) {
117 Vars = NULL; 117 Vars = NULL;
118 NumVars = 0; 118 NumVars = 0;
119 } 119 }
120 virtual ~Constant() {} 120 ~Constant() override {}
121 // PoolEntryID is an integer that uniquely identifies the constant 121 // PoolEntryID is an integer that uniquely identifies the constant
122 // within its constant pool. It is used for building the constant 122 // within its constant pool. It is used for building the constant
123 // pool in the object code and for referencing its entries. 123 // pool in the object code and for referencing its entries.
124 const uint32_t PoolEntryID; 124 const uint32_t PoolEntryID;
125 125
126 private: 126 private:
127 Constant(const Constant &) LLVM_DELETED_FUNCTION; 127 Constant(const Constant &) LLVM_DELETED_FUNCTION;
128 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; 128 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION;
129 }; 129 };
130 130
131 // ConstantPrimitive<> wraps a primitive type. 131 // ConstantPrimitive<> wraps a primitive type.
132 template <typename T, Operand::OperandKind K> 132 template <typename T, Operand::OperandKind K>
133 class ConstantPrimitive : public Constant { 133 class ConstantPrimitive : public Constant {
134 public: 134 public:
135 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, 135 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value,
136 uint32_t PoolEntryID) { 136 uint32_t PoolEntryID) {
137 return new (Ctx->allocate<ConstantPrimitive>()) 137 return new (Ctx->allocate<ConstantPrimitive>())
138 ConstantPrimitive(Ty, Value, PoolEntryID); 138 ConstantPrimitive(Ty, Value, PoolEntryID);
139 } 139 }
140 T getValue() const { return Value; } 140 T getValue() const { return Value; }
141 using Constant::emit; 141 using Constant::emit;
142 // The target needs to implement this for each ConstantPrimitive 142 // The target needs to implement this for each ConstantPrimitive
143 // specialization. 143 // specialization.
144 virtual void emit(GlobalContext *Ctx) const; 144 void emit(GlobalContext *Ctx) const override;
145 using Constant::dump; 145 using Constant::dump;
146 virtual void dump(const Cfg *, Ostream &Str) const { Str << getValue(); } 146 void dump(const Cfg *, Ostream &Str) const override { Str << getValue(); }
147 147
148 static bool classof(const Operand *Operand) { 148 static bool classof(const Operand *Operand) {
149 return Operand->getKind() == K; 149 return Operand->getKind() == K;
150 } 150 }
151 151
152 private: 152 private:
153 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID) 153 ConstantPrimitive(Type Ty, T Value, uint32_t PoolEntryID)
154 : Constant(K, Ty, PoolEntryID), Value(Value) {} 154 : Constant(K, Ty, PoolEntryID), Value(Value) {}
155 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; 155 ConstantPrimitive(const ConstantPrimitive &) LLVM_DELETED_FUNCTION;
156 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION; 156 ConstantPrimitive &operator=(const ConstantPrimitive &) LLVM_DELETED_FUNCTION;
157 virtual ~ConstantPrimitive() {} 157 ~ConstantPrimitive() override {}
158 const T Value; 158 const T Value;
159 }; 159 };
160 160
161 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32; 161 typedef ConstantPrimitive<uint32_t, Operand::kConstInteger32> ConstantInteger32;
162 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64; 162 typedef ConstantPrimitive<uint64_t, Operand::kConstInteger64> ConstantInteger64;
163 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat; 163 typedef ConstantPrimitive<float, Operand::kConstFloat> ConstantFloat;
164 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble; 164 typedef ConstantPrimitive<double, Operand::kConstDouble> ConstantDouble;
165 165
166 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const { 166 template <> inline void ConstantInteger32::dump(const Cfg *, Ostream &Str) const {
167 if (getType() == IceType_i1) 167 if (getType() == IceType_i1)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 uint32_t PoolEntryID) { 206 uint32_t PoolEntryID) {
207 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( 207 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable(
208 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); 208 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID);
209 } 209 }
210 int64_t getOffset() const { return Offset; } 210 int64_t getOffset() const { return Offset; }
211 IceString getName() const { return Name; } 211 IceString getName() const { return Name; }
212 void setSuppressMangling(bool Value) { SuppressMangling = Value; } 212 void setSuppressMangling(bool Value) { SuppressMangling = Value; }
213 bool getSuppressMangling() const { return SuppressMangling; } 213 bool getSuppressMangling() const { return SuppressMangling; }
214 using Constant::emit; 214 using Constant::emit;
215 using Constant::dump; 215 using Constant::dump;
216 virtual void emit(GlobalContext *Ctx) const; 216 void emit(GlobalContext *Ctx) const override;
217 virtual void dump(const Cfg *Func, Ostream &Str) const; 217 void dump(const Cfg *Func, Ostream &Str) const override;
218 218
219 static bool classof(const Operand *Operand) { 219 static bool classof(const Operand *Operand) {
220 OperandKind Kind = Operand->getKind(); 220 OperandKind Kind = Operand->getKind();
221 return Kind == kConstRelocatable; 221 return Kind == kConstRelocatable;
222 } 222 }
223 223
224 private: 224 private:
225 ConstantRelocatable(Type Ty, int64_t Offset, const IceString &Name, 225 ConstantRelocatable(Type Ty, int64_t Offset, const IceString &Name,
226 bool SuppressMangling, uint32_t PoolEntryID) 226 bool SuppressMangling, uint32_t PoolEntryID)
227 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset), 227 : Constant(kConstRelocatable, Ty, PoolEntryID), Offset(Offset),
228 Name(Name), SuppressMangling(SuppressMangling) {} 228 Name(Name), SuppressMangling(SuppressMangling) {}
229 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; 229 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION;
230 ConstantRelocatable & 230 ConstantRelocatable &
231 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; 231 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION;
232 virtual ~ConstantRelocatable() {} 232 ~ConstantRelocatable() override {}
233 const int64_t Offset; // fixed offset to add 233 const int64_t Offset; // fixed offset to add
234 const IceString Name; // optional for debug/dump 234 const IceString Name; // optional for debug/dump
235 bool SuppressMangling; 235 bool SuppressMangling;
236 }; 236 };
237 237
238 // ConstantUndef represents an unspecified bit pattern. Although it is 238 // ConstantUndef represents an unspecified bit pattern. Although it is
239 // legal to lower ConstantUndef to any value, backends should try to 239 // legal to lower ConstantUndef to any value, backends should try to
240 // make code generation deterministic by lowering ConstantUndefs to 0. 240 // make code generation deterministic by lowering ConstantUndefs to 0.
241 class ConstantUndef : public Constant { 241 class ConstantUndef : public Constant {
242 public: 242 public:
243 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, 243 static ConstantUndef *create(GlobalContext *Ctx, Type Ty,
244 uint32_t PoolEntryID) { 244 uint32_t PoolEntryID) {
245 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); 245 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID);
246 } 246 }
247 247
248 using Constant::emit; 248 using Constant::emit;
249 using Constant::dump; 249 using Constant::dump;
250 // The target needs to implement this. 250 // The target needs to implement this.
251 virtual void emit(GlobalContext *Ctx) const; 251 void emit(GlobalContext *Ctx) const override;
252 virtual void dump(const Cfg *, Ostream &Str) const { Str << "undef"; } 252 void dump(const Cfg *, Ostream &Str) const override { Str << "undef"; }
253 253
254 static bool classof(const Operand *Operand) { 254 static bool classof(const Operand *Operand) {
255 return Operand->getKind() == kConstUndef; 255 return Operand->getKind() == kConstUndef;
256 } 256 }
257 257
258 private: 258 private:
259 ConstantUndef(Type Ty, uint32_t PoolEntryID) 259 ConstantUndef(Type Ty, uint32_t PoolEntryID)
260 : Constant(kConstUndef, Ty, PoolEntryID) {} 260 : Constant(kConstUndef, Ty, PoolEntryID) {}
261 ConstantUndef(const ConstantUndef &) LLVM_DELETED_FUNCTION; 261 ConstantUndef(const ConstantUndef &) LLVM_DELETED_FUNCTION;
262 ConstantUndef &operator=(const ConstantUndef &) LLVM_DELETED_FUNCTION; 262 ConstantUndef &operator=(const ConstantUndef &) LLVM_DELETED_FUNCTION;
263 virtual ~ConstantUndef() {} 263 ~ConstantUndef() override {}
264 }; 264 };
265 265
266 // RegWeight is a wrapper for a uint32_t weight value, with a 266 // RegWeight is a wrapper for a uint32_t weight value, with a
267 // special value that represents infinite weight, and an addWeight() 267 // special value that represents infinite weight, and an addWeight()
268 // method that ensures that W+infinity=infinity. 268 // method that ensures that W+infinity=infinity.
269 class RegWeight { 269 class RegWeight {
270 public: 270 public:
271 RegWeight() : Weight(0) {} 271 RegWeight() : Weight(0) {}
272 RegWeight(uint32_t Weight) : Weight(Weight) {} 272 RegWeight(uint32_t Weight) : Weight(Weight) {}
273 const static uint32_t Inf = ~0; // Force regalloc to give a register 273 const static uint32_t Inf = ~0; // Force regalloc to give a register
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 LoVar = Lo; 408 LoVar = Lo;
409 HiVar = Hi; 409 HiVar = Hi;
410 } 410 }
411 // Creates a temporary copy of the variable with a different type. 411 // Creates a temporary copy of the variable with a different type.
412 // Used primarily for syntactic correctness of textual assembly 412 // Used primarily for syntactic correctness of textual assembly
413 // emission. Note that only basic information is copied, in 413 // emission. Note that only basic information is copied, in
414 // particular not DefInst, IsArgument, Weight, LoVar, HiVar, 414 // particular not DefInst, IsArgument, Weight, LoVar, HiVar,
415 // VarsReal. 415 // VarsReal.
416 Variable asType(Type Ty); 416 Variable asType(Type Ty);
417 417
418 virtual void emit(const Cfg *Func) const; 418 void emit(const Cfg *Func) const override;
419 using Operand::dump; 419 using Operand::dump;
420 virtual void dump(const Cfg *Func, Ostream &Str) const; 420 void dump(const Cfg *Func, Ostream &Str) const override;
421 421
422 static bool classof(const Operand *Operand) { 422 static bool classof(const Operand *Operand) {
423 OperandKind Kind = Operand->getKind(); 423 OperandKind Kind = Operand->getKind();
424 return Kind >= kVariable && Kind <= kVariable_Num; 424 return Kind >= kVariable && Kind <= kVariable_Num;
425 } 425 }
426 426
427 // The destructor is public because of the asType() method. 427 // The destructor is public because of the asType() method.
428 virtual ~Variable() {} 428 ~Variable() override {}
429 429
430 protected: 430 protected:
431 Variable(OperandKind K, Type Ty, SizeT Index, const IceString &Name) 431 Variable(OperandKind K, Type Ty, SizeT Index, const IceString &Name)
432 : Operand(K, Ty), Number(Index), Name(Name), IsArgument(false), 432 : Operand(K, Ty), Number(Index), Name(Name), IsArgument(false),
433 IsImplicitArgument(false), StackOffset(0), RegNum(NoRegister), 433 IsImplicitArgument(false), StackOffset(0), RegNum(NoRegister),
434 RegNumTmp(NoRegister), Weight(1), LoVar(NULL), HiVar(NULL) { 434 RegNumTmp(NoRegister), Weight(1), LoVar(NULL), HiVar(NULL) {
435 Vars = VarsReal; 435 Vars = VarsReal;
436 Vars[0] = this; 436 Vars[0] = this;
437 NumVars = 1; 437 NumVars = 1;
438 } 438 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 const Cfg *Func; 560 const Cfg *Func;
561 std::vector<VariableTracking> Metadata; 561 std::vector<VariableTracking> Metadata;
562 const static InstDefList NoDefinitions; 562 const static InstDefList NoDefinitions;
563 VariablesMetadata(const VariablesMetadata &) LLVM_DELETED_FUNCTION; 563 VariablesMetadata(const VariablesMetadata &) LLVM_DELETED_FUNCTION;
564 VariablesMetadata &operator=(const VariablesMetadata &) LLVM_DELETED_FUNCTION; 564 VariablesMetadata &operator=(const VariablesMetadata &) LLVM_DELETED_FUNCTION;
565 }; 565 };
566 566
567 } // end of namespace Ice 567 } // end of namespace Ice
568 568
569 #endif // SUBZERO_SRC_ICEOPERAND_H 569 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« src/IceInst.h ('K') | « src/IceInstX8632.h ('k') | src/IceTargetLoweringX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698