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

Side by Side Diff: src/IceOperand.h

Issue 512933006: LLVM 3.5 merge: Subzero (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 6 years, 3 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/IceGlobalContext.h ('k') | src/IceTranslator.h » ('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/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // object's destructor should delete this object. Generally, 70 // object's destructor should delete this object. Generally,
71 // constants are pooled globally, variables are pooled per-CFG, and 71 // constants are pooled globally, variables are pooled per-CFG, and
72 // target-specific operands are not pooled. 72 // target-specific operands are not pooled.
73 virtual bool isPooled() const { return false; } 73 virtual bool isPooled() const { return false; }
74 74
75 virtual ~Operand() {} 75 virtual ~Operand() {}
76 76
77 protected: 77 protected:
78 Operand(OperandKind Kind, Type Ty) 78 Operand(OperandKind Kind, Type Ty)
79 : Ty(Ty), Kind(Kind), NumVars(0), Vars(NULL) {} 79 : Ty(Ty), Kind(Kind), NumVars(0), Vars(NULL) {}
80 Operand(Operand &&O) = default;
80 81
81 const Type Ty; 82 const Type Ty;
82 const OperandKind Kind; 83 const OperandKind Kind;
83 // Vars and NumVars are initialized by the derived class. 84 // Vars and NumVars are initialized by the derived class.
84 SizeT NumVars; 85 SizeT NumVars;
85 Variable **Vars; 86 Variable **Vars;
86 87
87 private: 88 private:
88 Operand(const Operand &) LLVM_DELETED_FUNCTION; 89 Operand(const Operand &) LLVM_DELETED_FUNCTION;
89 Operand &operator=(const Operand &) LLVM_DELETED_FUNCTION; 90 Operand &operator=(const Operand &) LLVM_DELETED_FUNCTION;
(...skipping 19 matching lines...) Expand all
109 OperandKind Kind = Operand->getKind(); 110 OperandKind Kind = Operand->getKind();
110 return Kind >= kConst_Base && Kind <= kConst_Num; 111 return Kind >= kConst_Base && Kind <= kConst_Num;
111 } 112 }
112 113
113 protected: 114 protected:
114 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID) 115 Constant(OperandKind Kind, Type Ty, uint32_t PoolEntryID)
115 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) { 116 : Operand(Kind, Ty), PoolEntryID(PoolEntryID) {
116 Vars = NULL; 117 Vars = NULL;
117 NumVars = 0; 118 NumVars = 0;
118 } 119 }
120 Constant(Constant &&C) = default;
119 virtual ~Constant() {} 121 virtual ~Constant() {}
120 // PoolEntryID is an integer that uniquely identifies the constant 122 // PoolEntryID is an integer that uniquely identifies the constant
121 // within its constant pool. It is used for building the constant 123 // within its constant pool. It is used for building the constant
122 // pool in the object code and for referencing its entries. 124 // pool in the object code and for referencing its entries.
123 const uint32_t PoolEntryID; 125 const uint32_t PoolEntryID;
124 126
125 private: 127 private:
126 Constant(const Constant &) LLVM_DELETED_FUNCTION; 128 Constant(const Constant &) LLVM_DELETED_FUNCTION;
127 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION; 129 Constant &operator=(const Constant &) LLVM_DELETED_FUNCTION;
128 }; 130 };
129 131
130 // ConstantPrimitive<> wraps a primitive type. 132 // ConstantPrimitive<> wraps a primitive type.
131 template <typename T, Operand::OperandKind K> 133 template <typename T, Operand::OperandKind K>
132 class ConstantPrimitive : public Constant { 134 class ConstantPrimitive : public Constant {
133 public: 135 public:
134 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value, 136 static ConstantPrimitive *create(GlobalContext *Ctx, Type Ty, T Value,
135 uint32_t PoolEntryID) { 137 uint32_t PoolEntryID) {
136 return new (Ctx->allocate<ConstantPrimitive>()) 138 return new (Ctx->allocate<ConstantPrimitive>())
137 ConstantPrimitive(Ty, Value, PoolEntryID); 139 ConstantPrimitive(Ty, Value, PoolEntryID);
138 } 140 }
141 ConstantPrimitive(ConstantPrimitive &&C) = default;
139 T getValue() const { return Value; } 142 T getValue() const { return Value; }
140 using Constant::emit; 143 using Constant::emit;
141 // The target needs to implement this for each ConstantPrimitive 144 // The target needs to implement this for each ConstantPrimitive
142 // specialization. 145 // specialization.
143 virtual void emit(GlobalContext *Ctx) const; 146 virtual void emit(GlobalContext *Ctx) const;
144 using Constant::dump; 147 using Constant::dump;
145 virtual void dump(const Cfg *, Ostream &Str) const { Str << getValue(); } 148 virtual void dump(const Cfg *, Ostream &Str) const { Str << getValue(); }
146 149
147 static bool classof(const Operand *Operand) { 150 static bool classof(const Operand *Operand) {
148 return Operand->getKind() == K; 151 return Operand->getKind() == K;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // ConstantRelocatable represents a symbolic constant combined with 202 // ConstantRelocatable represents a symbolic constant combined with
200 // a fixed offset. 203 // a fixed offset.
201 class ConstantRelocatable : public Constant { 204 class ConstantRelocatable : public Constant {
202 public: 205 public:
203 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty, 206 static ConstantRelocatable *create(GlobalContext *Ctx, Type Ty,
204 const RelocatableTuple &Tuple, 207 const RelocatableTuple &Tuple,
205 uint32_t PoolEntryID) { 208 uint32_t PoolEntryID) {
206 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable( 209 return new (Ctx->allocate<ConstantRelocatable>()) ConstantRelocatable(
207 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID); 210 Ty, Tuple.Offset, Tuple.Name, Tuple.SuppressMangling, PoolEntryID);
208 } 211 }
212 ConstantRelocatable(ConstantRelocatable &&C) = default;
209 int64_t getOffset() const { return Offset; } 213 int64_t getOffset() const { return Offset; }
210 IceString getName() const { return Name; } 214 IceString getName() const { return Name; }
211 void setSuppressMangling(bool Value) { SuppressMangling = Value; } 215 void setSuppressMangling(bool Value) { SuppressMangling = Value; }
212 bool getSuppressMangling() const { return SuppressMangling; } 216 bool getSuppressMangling() const { return SuppressMangling; }
213 using Constant::emit; 217 using Constant::emit;
214 using Constant::dump; 218 using Constant::dump;
215 virtual void emit(GlobalContext *Ctx) const; 219 virtual void emit(GlobalContext *Ctx) const;
216 virtual void dump(const Cfg *Func, Ostream &Str) const; 220 virtual void dump(const Cfg *Func, Ostream &Str) const;
217 221
218 static bool classof(const Operand *Operand) { 222 static bool classof(const Operand *Operand) {
(...skipping 17 matching lines...) Expand all
236 240
237 // ConstantUndef represents an unspecified bit pattern. Although it is 241 // ConstantUndef represents an unspecified bit pattern. Although it is
238 // legal to lower ConstantUndef to any value, backends should try to 242 // legal to lower ConstantUndef to any value, backends should try to
239 // make code generation deterministic by lowering ConstantUndefs to 0. 243 // make code generation deterministic by lowering ConstantUndefs to 0.
240 class ConstantUndef : public Constant { 244 class ConstantUndef : public Constant {
241 public: 245 public:
242 static ConstantUndef *create(GlobalContext *Ctx, Type Ty, 246 static ConstantUndef *create(GlobalContext *Ctx, Type Ty,
243 uint32_t PoolEntryID) { 247 uint32_t PoolEntryID) {
244 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID); 248 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID);
245 } 249 }
250 ConstantUndef(ConstantUndef &&C) = default;
246 251
247 using Constant::emit; 252 using Constant::emit;
248 using Constant::dump; 253 using Constant::dump;
249 // The target needs to implement this. 254 // The target needs to implement this.
250 virtual void emit(GlobalContext *Ctx) const; 255 virtual void emit(GlobalContext *Ctx) const;
251 virtual void dump(const Cfg *, Ostream &Str) const { Str << "undef"; } 256 virtual void dump(const Cfg *, Ostream &Str) const { Str << "undef"; }
252 257
253 static bool classof(const Operand *Operand) { 258 static bool classof(const Operand *Operand) {
254 return Operand->getKind() == kConstUndef; 259 return Operand->getKind() == kConstUndef;
255 } 260 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 class Variable : public Operand { 350 class Variable : public Operand {
346 Variable(const Variable &) LLVM_DELETED_FUNCTION; 351 Variable(const Variable &) LLVM_DELETED_FUNCTION;
347 Variable &operator=(const Variable &) LLVM_DELETED_FUNCTION; 352 Variable &operator=(const Variable &) LLVM_DELETED_FUNCTION;
348 353
349 public: 354 public:
350 static Variable *create(Cfg *Func, Type Ty, SizeT Index, 355 static Variable *create(Cfg *Func, Type Ty, SizeT Index,
351 const IceString &Name) { 356 const IceString &Name) {
352 return new (Func->allocate<Variable>()) 357 return new (Func->allocate<Variable>())
353 Variable(kVariable, Ty, Index, Name); 358 Variable(kVariable, Ty, Index, Name);
354 } 359 }
360 Variable(Variable &&V) = default;
355 361
356 SizeT getIndex() const { return Number; } 362 SizeT getIndex() const { return Number; }
357 IceString getName() const; 363 IceString getName() const;
358 void setName(IceString &NewName) { 364 void setName(IceString &NewName) {
359 // Make sure that the name can only be set once. 365 // Make sure that the name can only be set once.
360 assert(Name.empty()); 366 assert(Name.empty());
361 Name = NewName; 367 Name = NewName;
362 } 368 }
363 369
364 bool getIsArg() const { return IsArgument; } 370 bool getIsArg() const { return IsArgument; }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 private: 539 private:
534 const Cfg *Func; 540 const Cfg *Func;
535 std::vector<VariableTracking> Metadata; 541 std::vector<VariableTracking> Metadata;
536 VariablesMetadata(const VariablesMetadata &) LLVM_DELETED_FUNCTION; 542 VariablesMetadata(const VariablesMetadata &) LLVM_DELETED_FUNCTION;
537 VariablesMetadata &operator=(const VariablesMetadata &) LLVM_DELETED_FUNCTION; 543 VariablesMetadata &operator=(const VariablesMetadata &) LLVM_DELETED_FUNCTION;
538 }; 544 };
539 545
540 } // end of namespace Ice 546 } // end of namespace Ice
541 547
542 #endif // SUBZERO_SRC_ICEOPERAND_H 548 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceTranslator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698