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

Side by Side Diff: src/IceOperand.h

Issue 339783002: Add support for undef values in ICE IR. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Lower undefs to constant 0 Created 6 years, 6 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.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('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 13 matching lines...) Expand all
24 namespace Ice { 24 namespace Ice {
25 25
26 class Operand { 26 class Operand {
27 public: 27 public:
28 enum OperandKind { 28 enum OperandKind {
29 kConst_Base, 29 kConst_Base,
30 kConstInteger, 30 kConstInteger,
31 kConstFloat, 31 kConstFloat,
32 kConstDouble, 32 kConstDouble,
33 kConstRelocatable, 33 kConstRelocatable,
34 kConstUndef,
34 kConst_Num, 35 kConst_Num,
35 kVariable, 36 kVariable,
36 // Target-specific operand classes use kTarget as the starting 37 // Target-specific operand classes use kTarget as the starting
37 // point for their Kind enum space. 38 // point for their Kind enum space.
38 kTarget 39 kTarget
39 }; 40 };
40 OperandKind getKind() const { return Kind; } 41 OperandKind getKind() const { return Kind; }
41 Type getType() const { return Ty; } 42 Type getType() const { return Ty; }
42 43
43 // Every Operand keeps an array of the Variables referenced in 44 // Every Operand keeps an array of the Variables referenced in
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Name(Name), SuppressMangling(SuppressMangling) {} 200 Name(Name), SuppressMangling(SuppressMangling) {}
200 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; 201 ConstantRelocatable(const ConstantRelocatable &) LLVM_DELETED_FUNCTION;
201 ConstantRelocatable & 202 ConstantRelocatable &
202 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION; 203 operator=(const ConstantRelocatable &) LLVM_DELETED_FUNCTION;
203 virtual ~ConstantRelocatable() {} 204 virtual ~ConstantRelocatable() {}
204 const int64_t Offset; // fixed offset to add 205 const int64_t Offset; // fixed offset to add
205 const IceString Name; // optional for debug/dump 206 const IceString Name; // optional for debug/dump
206 bool SuppressMangling; 207 bool SuppressMangling;
207 }; 208 };
208 209
210 // ConstantUndef represents an unspecified bit pattern.
jvoung (off chromium) 2014/06/17 21:48:53 The comment says it will be an unspecified bit pat
wala 2014/06/18 01:17:46 Agreed; I've updated the comment.
211 class ConstantUndef : public Constant {
212 public:
213 static ConstantUndef *create(GlobalContext *Ctx, Type Ty,
214 uint32_t PoolEntryID) {
215 return new (Ctx->allocate<ConstantUndef>()) ConstantUndef(Ty, PoolEntryID);
216 }
217
218 using Constant::emit;
219 virtual void emit(GlobalContext *Ctx) const {
220 Ostream &Str = Ctx->getStrEmit();
221 Str << "undef";
222 }
223
224 using Constant::dump;
225 virtual void dump(GlobalContext *Ctx) const {
226 Ostream &Str = Ctx->getStrEmit();
227 Str << "undef";
228 }
229
230 static bool classof(const Operand *Operand) {
231 return Operand->getKind() == kConstUndef;
232 }
233
234 private:
235 ConstantUndef(Type Ty, uint32_t PoolEntryID)
236 : Constant(kConstUndef, Ty, PoolEntryID) {}
237 ConstantUndef(const ConstantUndef &) LLVM_DELETED_FUNCTION;
238 ConstantUndef &operator=(const ConstantUndef &) LLVM_DELETED_FUNCTION;
239 virtual ~ConstantUndef() {}
240 };
241
209 // RegWeight is a wrapper for a uint32_t weight value, with a 242 // RegWeight is a wrapper for a uint32_t weight value, with a
210 // special value that represents infinite weight, and an addWeight() 243 // special value that represents infinite weight, and an addWeight()
211 // method that ensures that W+infinity=infinity. 244 // method that ensures that W+infinity=infinity.
212 class RegWeight { 245 class RegWeight {
213 public: 246 public:
214 RegWeight() : Weight(0) {} 247 RegWeight() : Weight(0) {}
215 RegWeight(uint32_t Weight) : Weight(Weight) {} 248 RegWeight(uint32_t Weight) : Weight(Weight) {}
216 const static uint32_t Inf = ~0; // Force regalloc to give a register 249 const static uint32_t Inf = ~0; // Force regalloc to give a register
217 const static uint32_t Zero = 0; // Force regalloc NOT to give a register 250 const static uint32_t Zero = 0; // Force regalloc NOT to give a register
218 void addWeight(uint32_t Delta) { 251 void addWeight(uint32_t Delta) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 Variable *LoVar; 462 Variable *LoVar;
430 Variable *HiVar; 463 Variable *HiVar;
431 // VarsReal (and Operand::Vars) are set up such that Vars[0] == 464 // VarsReal (and Operand::Vars) are set up such that Vars[0] ==
432 // this. 465 // this.
433 Variable *VarsReal[1]; 466 Variable *VarsReal[1];
434 }; 467 };
435 468
436 } // end of namespace Ice 469 } // end of namespace Ice
437 470
438 #endif // SUBZERO_SRC_ICEOPERAND_H 471 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« no previous file with comments | « src/IceGlobalContext.cpp ('k') | src/IceTargetLoweringX8632.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698