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

Side by Side Diff: src/IceInst.h

Issue 205613002: Initial skeleton of Subzero. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Introduce IceGlobalContext, and rearrange other things around that Created 6 years, 8 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
(Empty)
1 //===- subzero/src/IceInst.h - High-level instructions ----------*- C++ -*-===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the IceInst class and its target-independent
11 // subclasses, which represent the high-level Vanilla ICE instructions
12 // and map roughly 1:1 to LLVM instructions.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef SUBZERO_SRC_ICEINST_H
17 #define SUBZERO_SRC_ICEINST_H
18
19 #include "IceDefs.h"
20 #include "IceTypes.h"
21
22 class IceInst {
23 public:
24 enum InstKind {
25 Alloca,
26 Arithmetic,
27 Assign, // not part of LLVM/PNaCl bitcode
28 Br,
29 Call,
30 Cast,
31 Fcmp,
32 Icmp,
33 Load,
34 Phi,
35 Ret,
36 Select,
37 Store,
38 Switch,
39 Unreachable
JF 2014/04/16 01:27:32 I'd put Unreachable as InstKind 0.
Jim Stichnoth 2014/04/21 20:26:40 Done.
40 };
41 InstKind getKind() const { return Kind; }
42
43 int32_t getNumber() const { return Number; }
44
45 bool isDeleted() const { return Deleted; }
46 void setDeleted() { Deleted = true; }
47
48 bool hasSideEffects() const { return HasSideEffects; }
49
50 IceVariable *getDest() const { return Dest; }
51
52 uint32_t getSrcSize() const { return NumSrcs; }
53 IceOperand *getSrc(uint32_t I) const {
54 assert(I < getSrcSize());
55 return Srcs[I];
56 }
57
58 // Returns a list of out-edges corresponding to a terminator
59 // instruction, which is the last instruction of the block.
60 virtual IceNodeList getTerminatorEdges() const {
61 assert(0);
JF 2014/04/16 01:27:32 ?
Jim Stichnoth 2014/04/21 20:26:40 Jan had the same comment. :) Added a comment to e
JF 2014/04/23 03:51:28 llvm_unreachable would be better for this.
Jim Stichnoth 2014/04/26 15:02:11 Done.
62 return IceNodeList();
63 }
64
65 // Updates the status of the IceVariables contained within the
66 // instruction. In particular, it marks where the Dest variable is
67 // first assigned, and it tracks whether variables are live across
68 // basic blocks, i.e. used in a different block from their definition.
69 void updateVars(IceCfgNode *Node);
70
71 virtual void dump(const IceCfg *Cfg) const;
72 void dumpDecorated(const IceCfg *Cfg) const;
73 void dumpSources(const IceCfg *Cfg) const;
74 void dumpDest(const IceCfg *Cfg) const;
75
76 virtual ~IceInst() {}
JF 2014/04/16 01:27:32 Srcs doesn't get deleted? You should also probabl
Jim Stichnoth 2014/04/21 20:26:40 Done.
77
78 protected:
79 IceInst(IceCfg *Cfg, InstKind Kind, uint32_t MaxSrcs, IceVariable *Dest);
80 void addSource(IceOperand *Src) {
81 assert(Src);
82 assert(NumSrcs < MaxSrcs);
83 Srcs[NumSrcs++] = Src;
84 }
85
86 const InstKind Kind;
87 // Number is the instruction number for describing live ranges.
88 int32_t Number;
89 // Deleted means irrevocably deleted.
90 bool Deleted;
91 // HasSideEffects means the instruction is something like a function
92 // call or a volatile load that can't be removed even if its Dest
93 // variable is not live.
94 bool HasSideEffects;
JF 2014/04/16 01:27:32 Having this in every Inst seems silly when it's a
Jim Stichnoth 2014/04/21 20:26:40 It's not purely computable from the instruction ki
95
96 IceVariable *Dest;
97 const uint32_t MaxSrcs; // only used for assert
JF 2014/04/16 01:27:32 size_t
Jim Stichnoth 2014/04/21 20:26:40 Changed this and many other instances of uint32_t
98 uint32_t NumSrcs;
99 IceOperand **Srcs;
JF 2014/04/16 01:27:32 The ideal here would be to use C's zero-sized arra
Jim Stichnoth 2014/04/21 20:26:40 I don't want IceInst or IceOperand to hold any con
100
101 private:
102 IceInst(const IceInst &) LLVM_DELETED_FUNCTION;
103 IceInst &operator=(const IceInst &) LLVM_DELETED_FUNCTION;
104 };
105
106 template <> IceOstream &operator<<(IceOstream &Str, const IceInst &I);
JF 2014/04/16 01:27:32 I think you want this template specialization in I
Jim Stichnoth 2014/04/21 20:26:40 Actually that wasn't supposed to be there anymore.
107
108 // Alloca instruction. This captures the size in bytes as getSrc(0),
109 // and the alignment.
JF 2014/04/16 01:27:32 Are there any special meanings for alignment? What
Jim Stichnoth 2014/04/21 20:26:40 This is just the alignment from the LLVM bitcode,
JF 2014/04/23 03:51:28 Could you add a comment to this code that explains
Jim Stichnoth 2014/04/26 15:02:11 Done.
110 class IceInstAlloca : public IceInst {
111 public:
112 static IceInstAlloca *create(IceCfg *Cfg, IceOperand *ByteCount,
113 uint32_t Align, IceVariable *Dest) {
114 return new (Cfg->allocateInst<IceInstAlloca>())
115 IceInstAlloca(Cfg, ByteCount, Align, Dest);
116 }
117 uint32_t getAlign() const { return Align; }
118 virtual void dump(const IceCfg *Cfg) const;
119 static bool classof(const IceInst *Inst) { return Inst->getKind() == Alloca; }
JF 2014/04/16 01:27:32 This could also be auto-defined (albeit not declar
Jim Stichnoth 2014/04/21 20:26:40 True, except in the next CL, we add "Target" to en
JF 2014/04/23 03:51:28 I see. Maybe, but probably not worth it.
Jim Stichnoth 2014/04/26 15:02:11 OK, deferring this for now.
120
121 private:
122 IceInstAlloca(IceCfg *Cfg, IceOperand *ByteCount, uint32_t Align,
123 IceVariable *Dest);
124 IceInstAlloca(const IceInstAlloca &) LLVM_DELETED_FUNCTION;
125 IceInstAlloca &operator=(const IceInstAlloca &) LLVM_DELETED_FUNCTION;
126 const uint32_t Align;
127 };
128
129 // Binary arithmetic instruction. The source operands are captured in
130 // getSrc(0) and getSrc(1).
131 class IceInstArithmetic : public IceInst {
132 public:
133 enum OpKind {
134 // Ordered by http://llvm.org/docs/LangRef.html#binary-operations
JF 2014/04/16 01:27:32 Why does the order matter? Is the goal to match th
Jim Stichnoth 2014/04/21 20:26:40 Order doesn't matter, comment removed.
135 Add,
136 Fadd,
137 Sub,
138 Fsub,
139 Mul,
140 Fmul,
141 Udiv,
142 Sdiv,
143 Fdiv,
144 Urem,
145 Srem,
146 Frem,
147 // Ordered by http://llvm.org/docs/LangRef.html#bitwise-binary-operations
148 Shl,
149 Lshr,
150 Ashr,
151 And,
152 Or,
153 Xor
154 };
155 static IceInstArithmetic *create(IceCfg *Cfg, OpKind Op, IceVariable *Dest,
156 IceOperand *Source1, IceOperand *Source2) {
157 return new (Cfg->allocateInst<IceInstArithmetic>())
158 IceInstArithmetic(Cfg, Op, Dest, Source1, Source2);
JF 2014/04/16 01:27:32 Do the operand types necessarily match?
Jim Stichnoth 2014/04/21 20:26:40 Right now, I'm only doing the most haphazard of st
JF 2014/04/23 03:51:28 Good point, probably the reader, but I'm not sure
Jim Stichnoth 2014/04/26 15:02:11 Done. TODO added to the top of this file.
159 }
160 OpKind getOp() const { return Op; }
161 bool isCommutative() const;
162 virtual void dump(const IceCfg *Cfg) const;
163 static bool classof(const IceInst *Inst) {
164 return Inst->getKind() == Arithmetic;
165 }
166
167 private:
168 IceInstArithmetic(IceCfg *Cfg, OpKind Op, IceVariable *Dest,
169 IceOperand *Source1, IceOperand *Source2);
170 IceInstArithmetic(const IceInstArithmetic &) LLVM_DELETED_FUNCTION;
171 IceInstArithmetic &operator=(const IceInstArithmetic &) LLVM_DELETED_FUNCTION;
172
173 const OpKind Op;
174 };
175
176 // Assignment instruction. The source operand is captured in
177 // getSrc(0). This is not part of the LLVM bitcode, but is a useful
178 // abstraction for some of the lowering. E.g., if Phi instruction
179 // lowering happens before target lowering, or for representing an
180 // Inttoptr instruction, or as an intermediate step for lowering a
181 // Load instruction.
182 class IceInstAssign : public IceInst {
183 public:
184 static IceInstAssign *create(IceCfg *Cfg, IceVariable *Dest,
185 IceOperand *Source) {
186 return new (Cfg->allocateInst<IceInstAssign>())
187 IceInstAssign(Cfg, Dest, Source);
188 }
189 virtual void dump(const IceCfg *Cfg) const;
190 static bool classof(const IceInst *Inst) { return Inst->getKind() == Assign; }
191
192 private:
193 IceInstAssign(IceCfg *Cfg, IceVariable *Dest, IceOperand *Source);
194 IceInstAssign(const IceInstAssign &) LLVM_DELETED_FUNCTION;
195 IceInstAssign &operator=(const IceInstAssign &) LLVM_DELETED_FUNCTION;
196 };
197
198 // Branch instruction. This represents both conditional and
199 // unconditional branches.
JF 2014/04/16 01:27:32 The implementation says that True==False means unc
Jim Stichnoth 2014/04/21 20:26:40 Done.
200 class IceInstBr : public IceInst {
201 public:
202 static IceInstBr *create(IceCfg *Cfg, IceOperand *Source,
203 IceCfgNode *TargetTrue, IceCfgNode *TargetFalse) {
204 return new (Cfg->allocateInst<IceInstBr>())
205 IceInstBr(Cfg, Source, TargetTrue, TargetFalse);
206 }
207 static IceInstBr *create(IceCfg *Cfg, IceCfgNode *Target) {
208 return new (Cfg->allocateInst<IceInstBr>()) IceInstBr(Cfg, Target);
209 }
210 bool isUnconditional() const { return getTargetTrue() == NULL; }
211 IceCfgNode *getTargetTrue() const { return TargetTrue; }
212 IceCfgNode *getTargetFalse() const { return TargetFalse; }
213 IceCfgNode *getTargetUnconditional() const {
214 assert(isUnconditional());
215 return getTargetFalse();
216 }
217 virtual IceNodeList getTerminatorEdges() const;
218 virtual void dump(const IceCfg *Cfg) const;
219 static bool classof(const IceInst *Inst) { return Inst->getKind() == Br; }
220
221 private:
222 // Conditional branch
223 IceInstBr(IceCfg *Cfg, IceOperand *Source, IceCfgNode *TargetTrue,
224 IceCfgNode *TargetFalse);
225 // Unconditional branch
226 IceInstBr(IceCfg *Cfg, IceCfgNode *Target);
227 IceInstBr(const IceInstBr &) LLVM_DELETED_FUNCTION;
228 IceInstBr &operator=(const IceInstBr &) LLVM_DELETED_FUNCTION;
229
230 IceCfgNode *const TargetFalse; // Doubles as unconditional branch target
231 IceCfgNode *const TargetTrue; // NULL if unconditional branch
232 };
233
234 // Call instruction. The call target is captured as getSrc(0), and
235 // arg I is captured as getSrc(I+1).
236 class IceInstCall : public IceInst {
237 public:
238 static IceInstCall *create(IceCfg *Cfg, uint32_t NumArgs, IceVariable *Dest,
239 IceOperand *CallTarget, bool Tail) {
JF 2014/04/16 01:27:32 Explain Tail: is it actually tailcall, or LLVM's w
Jim Stichnoth 2014/04/21 20:26:40 Done. (It's the weird LLVM tail marker.)
240 return new (Cfg->allocateInst<IceInstCall>())
241 IceInstCall(Cfg, NumArgs, Dest, CallTarget, Tail);
242 }
243 void addArg(IceOperand *Arg) { addSource(Arg); }
244 IceOperand *getCallTarget() const { return getSrc(0); }
245 IceOperand *getArg(uint32_t I) const { return getSrc(I + 1); }
246 uint32_t getNumArgs() const { return getSrcSize() - 1; }
247 bool isTail() const { return Tail; }
248 virtual void dump(const IceCfg *Cfg) const;
249 static bool classof(const IceInst *Inst) { return Inst->getKind() == Call; }
250
251 private:
252 IceInstCall(IceCfg *Cfg, uint32_t NumArgs, IceVariable *Dest,
253 IceOperand *CallTarget, bool Tail)
254 : IceInst(Cfg, IceInst::Call, NumArgs + 1, Dest), Tail(Tail) {
255 // Set HasSideEffects so that the call instruction can't be
256 // dead-code eliminated. Don't set this for a deletable intrinsic
257 // call.
258 HasSideEffects = true;
259 addSource(CallTarget);
260 }
261 IceInstCall(const IceInstCall &) LLVM_DELETED_FUNCTION;
262 IceInstCall &operator=(const IceInstCall &) LLVM_DELETED_FUNCTION;
263 const bool Tail;
264 };
265
266 // Cast instruction (a.k.a. conversion operation).
267 class IceInstCast : public IceInst {
268 public:
269 enum OpKind {
270 // Ordered by http://llvm.org/docs/LangRef.html#conversion-operations
JF 2014/04/16 01:27:32 Ditto on ordering.
Jim Stichnoth 2014/04/21 20:26:40 Done.
271 Trunc,
272 Zext,
273 Sext,
274 Fptrunc,
275 Fpext,
276 Fptoui,
277 Fptosi,
278 Uitofp,
279 Sitofp,
280 Bitcast
281 };
282 static IceInstCast *create(IceCfg *Cfg, OpKind CastKind, IceVariable *Dest,
283 IceOperand *Source) {
284 return new (Cfg->allocateInst<IceInstCast>())
285 IceInstCast(Cfg, CastKind, Dest, Source);
286 }
287 OpKind getCastKind() const { return CastKind; }
288 virtual void dump(const IceCfg *Cfg) const;
289 static bool classof(const IceInst *Inst) { return Inst->getKind() == Cast; }
290
291 private:
292 IceInstCast(IceCfg *Cfg, OpKind CastKind, IceVariable *Dest,
293 IceOperand *Source);
294 IceInstCast(const IceInstCast &) LLVM_DELETED_FUNCTION;
295 IceInstCast &operator=(const IceInstCast &) LLVM_DELETED_FUNCTION;
296 OpKind CastKind;
JF 2014/04/16 01:27:32 const, to keep with the other classes.
Jim Stichnoth 2014/04/21 20:26:40 Done.
297 };
298
299 // Floating-point comparison instruction. The source operands are
300 // captured in getSrc(0) and getSrc(1).
301 class IceInstFcmp : public IceInst {
302 public:
303 enum FCond {
304 // Ordered by http://llvm.org/docs/LangRef.html#id254
JF 2014/04/16 01:27:32 Ditto.
Jim Stichnoth 2014/04/21 20:26:40 Done.
305 False,
306 Oeq,
307 Ogt,
308 Oge,
309 Olt,
310 Ole,
311 One,
312 Ord,
313 Ueq,
314 Ugt,
315 Uge,
316 Ult,
317 Ule,
318 Une,
319 Uno,
320 True
321 };
322 static IceInstFcmp *create(IceCfg *Cfg, FCond Condition, IceVariable *Dest,
323 IceOperand *Source1, IceOperand *Source2) {
324 return new (Cfg->allocateInst<IceInstFcmp>())
325 IceInstFcmp(Cfg, Condition, Dest, Source1, Source2);
JF 2014/04/16 01:27:32 Do the operand types necessarily match?
Jim Stichnoth 2014/04/21 20:26:40 Ditto.
326 }
327 FCond getCondition() const { return Condition; }
328 virtual void dump(const IceCfg *Cfg) const;
329 static bool classof(const IceInst *Inst) { return Inst->getKind() == Fcmp; }
330
331 private:
332 IceInstFcmp(IceCfg *Cfg, FCond Condition, IceVariable *Dest,
333 IceOperand *Source1, IceOperand *Source2);
334 IceInstFcmp(const IceInstFcmp &) LLVM_DELETED_FUNCTION;
335 IceInstFcmp &operator=(const IceInstFcmp &) LLVM_DELETED_FUNCTION;
336 FCond Condition;
JF 2014/04/16 01:27:32 const, to keep with the other classes.
Jim Stichnoth 2014/04/21 20:26:40 Done.
337 };
338
339 // Integer comparison instruction. The source operands are captured
340 // in getSrc(0) and getSrc(1).
341 class IceInstIcmp : public IceInst {
342 public:
343 enum ICond {
344 // Ordered by http://llvm.org/docs/LangRef.html#id249
JF 2014/04/16 01:27:32 Ditto.
Jim Stichnoth 2014/04/21 20:26:40 Done.
345 Eq,
346 Ne,
347 Ugt,
348 Uge,
349 Ult,
350 Ule,
351 Sgt,
352 Sge,
353 Slt,
354 Sle
355 };
356 static IceInstIcmp *create(IceCfg *Cfg, ICond Condition, IceVariable *Dest,
357 IceOperand *Source1, IceOperand *Source2) {
358 return new (Cfg->allocateInst<IceInstIcmp>())
359 IceInstIcmp(Cfg, Condition, Dest, Source1, Source2);
JF 2014/04/16 01:27:32 Do the operand types necessarily match?
Jim Stichnoth 2014/04/21 20:26:40 Ditto.
360 }
361 ICond getCondition() const { return Condition; }
362 virtual void dump(const IceCfg *Cfg) const;
363 static bool classof(const IceInst *Inst) { return Inst->getKind() == Icmp; }
364
365 private:
366 IceInstIcmp(IceCfg *Cfg, ICond Condition, IceVariable *Dest,
367 IceOperand *Source1, IceOperand *Source2);
368 IceInstIcmp(const IceInstIcmp &) LLVM_DELETED_FUNCTION;
369 IceInstIcmp &operator=(const IceInstIcmp &) LLVM_DELETED_FUNCTION;
370 ICond Condition;
JF 2014/04/16 01:27:32 const, to keep with the other classes.
Jim Stichnoth 2014/04/21 20:26:40 Done.
371 };
372
373 // Load instruction. The source address is captured in getSrc(0);
JF 2014/04/16 01:27:32 Could you infer alignment? We guarantee that FP is
Jim Stichnoth 2014/04/21 20:26:40 True, the target lowering can probably make use of
374 class IceInstLoad : public IceInst {
375 public:
376 static IceInstLoad *create(IceCfg *Cfg, IceVariable *Dest,
377 IceOperand *SourceAddr) {
378 return new (Cfg->allocateInst<IceInstLoad>())
379 IceInstLoad(Cfg, Dest, SourceAddr);
380 }
381 virtual void dump(const IceCfg *Cfg) const;
382 static bool classof(const IceInst *Inst) { return Inst->getKind() == Load; }
383
384 private:
385 IceInstLoad(IceCfg *Cfg, IceVariable *Dest, IceOperand *SourceAddr);
386 IceInstLoad(const IceInstLoad &) LLVM_DELETED_FUNCTION;
387 IceInstLoad &operator=(const IceInstLoad &) LLVM_DELETED_FUNCTION;
388 };
389
390 // Phi instruction. For incoming edge I, the node is Labels[I] and
391 // the Phi source operand is getSrc(I).
392 class IceInstPhi : public IceInst {
393 public:
394 static IceInstPhi *create(IceCfg *Cfg, uint32_t MaxSrcs, IceVariable *Dest) {
395 return new (Cfg->allocateInst<IceInstPhi>()) IceInstPhi(Cfg, MaxSrcs, Dest);
396 }
397 void addArgument(IceOperand *Source, IceCfgNode *Label);
398 virtual void dump(const IceCfg *Cfg) const;
399 static bool classof(const IceInst *Inst) { return Inst->getKind() == Phi; }
400
401 private:
402 IceInstPhi(IceCfg *Cfg, uint32_t MaxSrcs, IceVariable *Dest);
403 IceInstPhi(const IceInstPhi &) LLVM_DELETED_FUNCTION;
404 IceInstPhi &operator=(const IceInstPhi &) LLVM_DELETED_FUNCTION;
405 // Labels[] duplicates the InEdges[] information in the enclosing
406 // IceCfgNode, but the Phi instruction is created before InEdges[]
407 // is available, so it's more complicated to share the list.
408 IceCfgNode **Labels;
JF 2014/04/16 01:27:32 dtor that deletes Labels.
Jim Stichnoth 2014/04/21 20:26:40 Done.
409 };
410
411 // Ret instruction. The return value is captured in getSrc(0), but if
412 // there is no return value (void-type function), then
413 // getSrcSize()==0.
JF 2014/04/16 01:27:32 Create an isVoid method that does this, so code re
Jim Stichnoth 2014/04/21 20:26:40 Done - hasRetValue().
414 class IceInstRet : public IceInst {
415 public:
416 static IceInstRet *create(IceCfg *Cfg, IceOperand *Source = NULL) {
JF 2014/04/16 01:27:32 Source is kind of a bad name here (and in the impl
Jim Stichnoth 2014/04/21 20:26:40 Done - Source==>RetValue.
417 return new (Cfg->allocateInst<IceInstRet>()) IceInstRet(Cfg, Source);
418 }
419 virtual IceNodeList getTerminatorEdges() const { return IceNodeList(); }
420 virtual void dump(const IceCfg *Cfg) const;
421 static bool classof(const IceInst *Inst) { return Inst->getKind() == Ret; }
422
423 private:
424 IceInstRet(IceCfg *Cfg, IceOperand *Source);
425 IceInstRet(const IceInstRet &) LLVM_DELETED_FUNCTION;
426 IceInstRet &operator=(const IceInstRet &) LLVM_DELETED_FUNCTION;
427 };
428
429 // Select instruction. The condition, true, and false operands are captured.
430 class IceInstSelect : public IceInst {
431 public:
432 static IceInstSelect *create(IceCfg *Cfg, IceVariable *Dest,
433 IceOperand *Condition, IceOperand *SourceTrue,
434 IceOperand *SourceFalse) {
435 return new (Cfg->allocateInst<IceInstSelect>())
436 IceInstSelect(Cfg, Dest, Condition, SourceTrue, SourceFalse);
JF 2014/04/16 01:27:32 Do the operand's type necessarily match?
Jim Stichnoth 2014/04/21 20:26:40 Ditto.
437 }
438 IceOperand *getCondition() const { return getSrc(0); }
439 IceOperand *getTrueOperand() const { return getSrc(1); }
440 IceOperand *getFalseOperand() const { return getSrc(2); }
441 virtual void dump(const IceCfg *Cfg) const;
442 static bool classof(const IceInst *Inst) { return Inst->getKind() == Select; }
443
444 private:
445 IceInstSelect(IceCfg *Cfg, IceVariable *Dest, IceOperand *Condition,
446 IceOperand *Source1, IceOperand *Source2);
447 IceInstSelect(const IceInstSelect &) LLVM_DELETED_FUNCTION;
448 IceInstSelect &operator=(const IceInstSelect &) LLVM_DELETED_FUNCTION;
449 };
450
451 // Store instruction. The address operand is captured, along with the
452 // data operand to be stored into the address.
453 class IceInstStore : public IceInst {
454 public:
455 static IceInstStore *create(IceCfg *Cfg, IceOperand *Data, IceOperand *Addr) {
456 return new (Cfg->allocateInst<IceInstStore>())
457 IceInstStore(Cfg, Data, Addr);
458 }
459 IceOperand *getAddr() const { return getSrc(1); }
460 IceOperand *getData() const { return getSrc(0); }
461 virtual void dump(const IceCfg *Cfg) const;
462 static bool classof(const IceInst *Inst) { return Inst->getKind() == Store; }
463
464 private:
465 IceInstStore(IceCfg *Cfg, IceOperand *Data, IceOperand *Addr);
466 IceInstStore(const IceInstStore &) LLVM_DELETED_FUNCTION;
467 IceInstStore &operator=(const IceInstStore &) LLVM_DELETED_FUNCTION;
468 };
469
470 // Switch instruction. The single source operand is captured as
471 // getSrc(0).
472 class IceInstSwitch : public IceInst {
473 public:
474 static IceInstSwitch *create(IceCfg *Cfg, uint32_t NumCases,
475 IceOperand *Source, IceCfgNode *LabelDefault) {
476 return new (Cfg->allocateInst<IceInstSwitch>())
477 IceInstSwitch(Cfg, NumCases, Source, LabelDefault);
478 }
479 IceCfgNode *getLabelDefault() const { return LabelDefault; }
480 uint32_t getNumCases() const { return NumCases; }
481 uint64_t getValue(uint32_t I) const {
482 assert(I < NumCases);
483 return Values[I];
484 }
485 IceCfgNode *getLabel(uint32_t I) const {
486 assert(I < NumCases);
487 return Labels[I];
488 }
489 void addBranch(uint32_t CaseIndex, uint64_t Value, IceCfgNode *Label);
490 virtual IceNodeList getTerminatorEdges() const;
491 virtual void dump(const IceCfg *Cfg) const;
492 static bool classof(const IceInst *Inst) { return Inst->getKind() == Switch; }
493
494 private:
495 IceInstSwitch(IceCfg *Cfg, uint32_t NumCases, IceOperand *Source,
496 IceCfgNode *LabelDefault);
497 IceInstSwitch(const IceInstSwitch &) LLVM_DELETED_FUNCTION;
498 IceInstSwitch &operator=(const IceInstSwitch &) LLVM_DELETED_FUNCTION;
499 IceCfgNode *LabelDefault;
JF 2014/04/16 01:27:32 Why not put default at the start of Labels? It wo
Jim Stichnoth 2014/04/21 20:26:40 It shortens getTerminatorEdges() by 1 line, but ne
500 uint32_t NumCases; // not including the default case
501 uint64_t *Values; // size is NumCases
502 IceCfgNode **Labels; // size is NumCases
JF 2014/04/16 01:27:32 dtor that deletes Values and Labels.
Jim Stichnoth 2014/04/21 20:26:40 Done.
503 };
504
505 // Unreachable instruction. This is a terminator instruction with no
506 // operands.
507 class IceInstUnreachable : public IceInst {
508 public:
509 static IceInstUnreachable *create(IceCfg *Cfg) {
510 return new (Cfg->allocateInst<IceInstUnreachable>())
511 IceInstUnreachable(Cfg);
512 }
513 virtual IceNodeList getTerminatorEdges() const { return IceNodeList(); }
514 virtual void dump(const IceCfg *Cfg) const;
515 static bool classof(const IceInst *Inst) {
516 return Inst->getKind() == Unreachable;
517 }
518
519 private:
520 IceInstUnreachable(IceCfg *Cfg);
521 IceInstUnreachable(const IceInstUnreachable &) LLVM_DELETED_FUNCTION;
522 IceInstUnreachable &
523 operator=(const IceInstUnreachable &) LLVM_DELETED_FUNCTION;
524 };
525
526 #endif // SUBZERO_SRC_ICEINST_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698