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

Side by Side Diff: src/IceInst.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
« no previous file with comments | « src/IceCfgNode.cpp ('k') | src/IceInst.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/IceInst.h - High-level instructions ----------*- C++ -*-===// 1 //===- subzero/src/IceInst.h - High-level instructions ----------*- 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 Inst class and its target-independent 10 // This file declares the Inst class and its target-independent
(...skipping 12 matching lines...) Expand all
23 23
24 // TODO: The Cfg structure, and instructions in particular, need to be 24 // TODO: The Cfg structure, and instructions in particular, need to be
25 // validated for things like valid operand types, valid branch 25 // validated for things like valid operand types, valid branch
26 // targets, proper ordering of Phi and non-Phi instructions, etc. 26 // targets, proper ordering of Phi and non-Phi instructions, etc.
27 // Most of the validity checking will be done in the bitcode reader. 27 // Most of the validity checking will be done in the bitcode reader.
28 // We need a list of everything that should be validated, and tests 28 // We need a list of everything that should be validated, and tests
29 // for each. 29 // for each.
30 30
31 namespace Ice { 31 namespace Ice {
32 32
33 // Base instruction class for ICE. Inst has two subclasses:
34 // InstHighLevel and InstTarget. High-level ICE instructions inherit
35 // from InstHighLevel, and low-level (target-specific) ICE
36 // instructions inherit from InstTarget.
33 class Inst { 37 class Inst {
34 public: 38 public:
35 enum InstKind { 39 enum InstKind {
36 // Arbitrary (alphabetical) order, except put Unreachable first. 40 // Arbitrary (alphabetical) order, except put Unreachable first.
37 Unreachable, 41 Unreachable,
38 Alloca, 42 Alloca,
39 Arithmetic, 43 Arithmetic,
40 Assign, // not part of LLVM/PNaCl bitcode 44 Assign, // not part of LLVM/PNaCl bitcode
41 Br, 45 Br,
42 Call, 46 Call,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 100
97 void livenessLightweight(Cfg *Func, llvm::BitVector &Live); 101 void livenessLightweight(Cfg *Func, llvm::BitVector &Live);
98 void liveness(InstNumberT InstNumber, llvm::BitVector &Live, 102 void liveness(InstNumberT InstNumber, llvm::BitVector &Live,
99 Liveness *Liveness, const CfgNode *Node); 103 Liveness *Liveness, const CfgNode *Node);
100 104
101 // Get the number of native instructions that this instruction 105 // Get the number of native instructions that this instruction
102 // ultimately emits. By default, high-level instructions don't 106 // ultimately emits. By default, high-level instructions don't
103 // result in any native instructions, and a target-specific 107 // result in any native instructions, and a target-specific
104 // instruction results in a single native instruction. 108 // instruction results in a single native instruction.
105 virtual uint32_t getEmitInstCount() const { return 0; } 109 virtual uint32_t getEmitInstCount() const { return 0; }
106 virtual void emit(const Cfg *Func) const; 110 virtual void emit(const Cfg *Func) const = 0;
107 virtual void emitIAS(const Cfg *Func) const; 111 virtual void emitIAS(const Cfg *Func) const = 0;
108 virtual void dump(const Cfg *Func) const; 112 virtual void dump(const Cfg *Func) const;
109 virtual void dumpExtras(const Cfg *Func) const; 113 virtual void dumpExtras(const Cfg *Func) const;
110 void dumpDecorated(const Cfg *Func) const; 114 void dumpDecorated(const Cfg *Func) const;
111 void emitSources(const Cfg *Func) const; 115 void emitSources(const Cfg *Func) const;
112 void dumpSources(const Cfg *Func) const; 116 void dumpSources(const Cfg *Func) const;
113 void dumpDest(const Cfg *Func) const; 117 void dumpDest(const Cfg *Func) const;
114 virtual bool isRedundantAssign() const { return false; } 118 virtual bool isRedundantAssign() const { return false; }
115 119
116 virtual ~Inst() {} 120 virtual ~Inst() {}
117 121
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Only the first CHAR_BIT * sizeof(LREndedBits) variables are 162 // Only the first CHAR_BIT * sizeof(LREndedBits) variables are
159 // tracked this way. 163 // tracked this way.
160 typedef uint32_t LREndedBits; // only first 32 src operands tracked, sorry 164 typedef uint32_t LREndedBits; // only first 32 src operands tracked, sorry
161 LREndedBits LiveRangesEnded; 165 LREndedBits LiveRangesEnded;
162 166
163 private: 167 private:
164 Inst(const Inst &) LLVM_DELETED_FUNCTION; 168 Inst(const Inst &) LLVM_DELETED_FUNCTION;
165 Inst &operator=(const Inst &) LLVM_DELETED_FUNCTION; 169 Inst &operator=(const Inst &) LLVM_DELETED_FUNCTION;
166 }; 170 };
167 171
172 class InstHighLevel : public Inst {
173 InstHighLevel(const InstHighLevel &) LLVM_DELETED_FUNCTION;
174 InstHighLevel &operator=(const InstHighLevel &) LLVM_DELETED_FUNCTION;
175
176 protected:
177 InstHighLevel(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest)
178 : Inst(Func, Kind, MaxSrcs, Dest) {}
179 void emit(const Cfg * /*Func*/) const override {
180 llvm_unreachable("emit() called on a non-lowered instruction");
181 }
182 void emitIAS(const Cfg * /*Func*/) const override {
183 llvm_unreachable("emitIAS() called on a non-lowered instruction");
184 }
185 ~InstHighLevel() override {}
186 };
187
168 // Alloca instruction. This captures the size in bytes as getSrc(0), 188 // Alloca instruction. This captures the size in bytes as getSrc(0),
169 // and the required alignment in bytes. The alignment must be either 189 // and the required alignment in bytes. The alignment must be either
170 // 0 (no alignment required) or a power of 2. 190 // 0 (no alignment required) or a power of 2.
171 class InstAlloca : public Inst { 191 class InstAlloca : public InstHighLevel {
172 public: 192 public:
173 static InstAlloca *create(Cfg *Func, Operand *ByteCount, 193 static InstAlloca *create(Cfg *Func, Operand *ByteCount,
174 uint32_t AlignInBytes, Variable *Dest) { 194 uint32_t AlignInBytes, Variable *Dest) {
175 return new (Func->allocateInst<InstAlloca>()) 195 return new (Func->allocateInst<InstAlloca>())
176 InstAlloca(Func, ByteCount, AlignInBytes, Dest); 196 InstAlloca(Func, ByteCount, AlignInBytes, Dest);
177 } 197 }
178 uint32_t getAlignInBytes() const { return AlignInBytes; } 198 uint32_t getAlignInBytes() const { return AlignInBytes; }
179 Operand *getSizeInBytes() const { return getSrc(0); } 199 Operand *getSizeInBytes() const { return getSrc(0); }
180 virtual void dump(const Cfg *Func) const; 200 void dump(const Cfg *Func) const override;
181 static bool classof(const Inst *Inst) { return Inst->getKind() == Alloca; } 201 static bool classof(const Inst *Inst) { return Inst->getKind() == Alloca; }
182 202
183 private: 203 private:
184 InstAlloca(Cfg *Func, Operand *ByteCount, uint32_t AlignInBytes, 204 InstAlloca(Cfg *Func, Operand *ByteCount, uint32_t AlignInBytes,
185 Variable *Dest); 205 Variable *Dest);
186 InstAlloca(const InstAlloca &) LLVM_DELETED_FUNCTION; 206 InstAlloca(const InstAlloca &) LLVM_DELETED_FUNCTION;
187 InstAlloca &operator=(const InstAlloca &) LLVM_DELETED_FUNCTION; 207 InstAlloca &operator=(const InstAlloca &) LLVM_DELETED_FUNCTION;
188 virtual ~InstAlloca() {} 208 ~InstAlloca() override {}
189 const uint32_t AlignInBytes; 209 const uint32_t AlignInBytes;
190 }; 210 };
191 211
192 // Binary arithmetic instruction. The source operands are captured in 212 // Binary arithmetic instruction. The source operands are captured in
193 // getSrc(0) and getSrc(1). 213 // getSrc(0) and getSrc(1).
194 class InstArithmetic : public Inst { 214 class InstArithmetic : public InstHighLevel {
195 public: 215 public:
196 enum OpKind { 216 enum OpKind {
197 #define X(tag, str, commutative) tag, 217 #define X(tag, str, commutative) tag,
198 ICEINSTARITHMETIC_TABLE 218 ICEINSTARITHMETIC_TABLE
199 #undef X 219 #undef X
200 _num 220 _num
201 }; 221 };
202 222
203 static InstArithmetic *create(Cfg *Func, OpKind Op, Variable *Dest, 223 static InstArithmetic *create(Cfg *Func, OpKind Op, Variable *Dest,
204 Operand *Source1, Operand *Source2) { 224 Operand *Source1, Operand *Source2) {
205 return new (Func->allocateInst<InstArithmetic>()) 225 return new (Func->allocateInst<InstArithmetic>())
206 InstArithmetic(Func, Op, Dest, Source1, Source2); 226 InstArithmetic(Func, Op, Dest, Source1, Source2);
207 } 227 }
208 OpKind getOp() const { return Op; } 228 OpKind getOp() const { return Op; }
209 static const char *getOpName(OpKind Op); 229 static const char *getOpName(OpKind Op);
210 bool isCommutative() const; 230 bool isCommutative() const;
211 virtual void dump(const Cfg *Func) const; 231 void dump(const Cfg *Func) const override;
212 static bool classof(const Inst *Inst) { 232 static bool classof(const Inst *Inst) {
213 return Inst->getKind() == Arithmetic; 233 return Inst->getKind() == Arithmetic;
214 } 234 }
215 235
216 private: 236 private:
217 InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, Operand *Source1, 237 InstArithmetic(Cfg *Func, OpKind Op, Variable *Dest, Operand *Source1,
218 Operand *Source2); 238 Operand *Source2);
219 InstArithmetic(const InstArithmetic &) LLVM_DELETED_FUNCTION; 239 InstArithmetic(const InstArithmetic &) LLVM_DELETED_FUNCTION;
220 InstArithmetic &operator=(const InstArithmetic &) LLVM_DELETED_FUNCTION; 240 InstArithmetic &operator=(const InstArithmetic &) LLVM_DELETED_FUNCTION;
221 virtual ~InstArithmetic() {} 241 ~InstArithmetic() override {}
222 242
223 const OpKind Op; 243 const OpKind Op;
224 }; 244 };
225 245
226 // Assignment instruction. The source operand is captured in 246 // Assignment instruction. The source operand is captured in
227 // getSrc(0). This is not part of the LLVM bitcode, but is a useful 247 // getSrc(0). This is not part of the LLVM bitcode, but is a useful
228 // abstraction for some of the lowering. E.g., if Phi instruction 248 // abstraction for some of the lowering. E.g., if Phi instruction
229 // lowering happens before target lowering, or for representing an 249 // lowering happens before target lowering, or for representing an
230 // Inttoptr instruction, or as an intermediate step for lowering a 250 // Inttoptr instruction, or as an intermediate step for lowering a
231 // Load instruction. 251 // Load instruction.
232 class InstAssign : public Inst { 252 class InstAssign : public InstHighLevel {
233 public: 253 public:
234 static InstAssign *create(Cfg *Func, Variable *Dest, Operand *Source) { 254 static InstAssign *create(Cfg *Func, Variable *Dest, Operand *Source) {
235 return new (Func->allocateInst<InstAssign>()) 255 return new (Func->allocateInst<InstAssign>())
236 InstAssign(Func, Dest, Source); 256 InstAssign(Func, Dest, Source);
237 } 257 }
238 virtual bool isSimpleAssign() const { return true; } 258 bool isSimpleAssign() const override { return true; }
239 virtual void dump(const Cfg *Func) const; 259 void dump(const Cfg *Func) const override;
240 static bool classof(const Inst *Inst) { return Inst->getKind() == Assign; } 260 static bool classof(const Inst *Inst) { return Inst->getKind() == Assign; }
241 261
242 private: 262 private:
243 InstAssign(Cfg *Func, Variable *Dest, Operand *Source); 263 InstAssign(Cfg *Func, Variable *Dest, Operand *Source);
244 InstAssign(const InstAssign &) LLVM_DELETED_FUNCTION; 264 InstAssign(const InstAssign &) LLVM_DELETED_FUNCTION;
245 InstAssign &operator=(const InstAssign &) LLVM_DELETED_FUNCTION; 265 InstAssign &operator=(const InstAssign &) LLVM_DELETED_FUNCTION;
246 virtual ~InstAssign() {} 266 ~InstAssign() override {}
247 }; 267 };
248 268
249 // Branch instruction. This represents both conditional and 269 // Branch instruction. This represents both conditional and
250 // unconditional branches. 270 // unconditional branches.
251 class InstBr : public Inst { 271 class InstBr : public InstHighLevel {
252 public: 272 public:
253 // Create a conditional branch. If TargetTrue==TargetFalse, it is 273 // Create a conditional branch. If TargetTrue==TargetFalse, it is
254 // optimized to an unconditional branch. 274 // optimized to an unconditional branch.
255 static InstBr *create(Cfg *Func, Operand *Source, CfgNode *TargetTrue, 275 static InstBr *create(Cfg *Func, Operand *Source, CfgNode *TargetTrue,
256 CfgNode *TargetFalse) { 276 CfgNode *TargetFalse) {
257 return new (Func->allocateInst<InstBr>()) 277 return new (Func->allocateInst<InstBr>())
258 InstBr(Func, Source, TargetTrue, TargetFalse); 278 InstBr(Func, Source, TargetTrue, TargetFalse);
259 } 279 }
260 // Create an unconditional branch. 280 // Create an unconditional branch.
261 static InstBr *create(Cfg *Func, CfgNode *Target) { 281 static InstBr *create(Cfg *Func, CfgNode *Target) {
262 return new (Func->allocateInst<InstBr>()) InstBr(Func, Target); 282 return new (Func->allocateInst<InstBr>()) InstBr(Func, Target);
263 } 283 }
264 bool isUnconditional() const { return getTargetTrue() == NULL; } 284 bool isUnconditional() const { return getTargetTrue() == NULL; }
265 Operand *getCondition() const { 285 Operand *getCondition() const {
266 assert(!isUnconditional()); 286 assert(!isUnconditional());
267 return getSrc(0); 287 return getSrc(0);
268 } 288 }
269 CfgNode *getTargetTrue() const { return TargetTrue; } 289 CfgNode *getTargetTrue() const { return TargetTrue; }
270 CfgNode *getTargetFalse() const { return TargetFalse; } 290 CfgNode *getTargetFalse() const { return TargetFalse; }
271 CfgNode *getTargetUnconditional() const { 291 CfgNode *getTargetUnconditional() const {
272 assert(isUnconditional()); 292 assert(isUnconditional());
273 return getTargetFalse(); 293 return getTargetFalse();
274 } 294 }
275 virtual NodeList getTerminatorEdges() const; 295 NodeList getTerminatorEdges() const override;
276 virtual void dump(const Cfg *Func) const; 296 void dump(const Cfg *Func) const override;
277 static bool classof(const Inst *Inst) { return Inst->getKind() == Br; } 297 static bool classof(const Inst *Inst) { return Inst->getKind() == Br; }
278 298
279 private: 299 private:
280 // Conditional branch 300 // Conditional branch
281 InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse); 301 InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse);
282 // Unconditional branch 302 // Unconditional branch
283 InstBr(Cfg *Func, CfgNode *Target); 303 InstBr(Cfg *Func, CfgNode *Target);
284 InstBr(const InstBr &) LLVM_DELETED_FUNCTION; 304 InstBr(const InstBr &) LLVM_DELETED_FUNCTION;
285 InstBr &operator=(const InstBr &) LLVM_DELETED_FUNCTION; 305 InstBr &operator=(const InstBr &) LLVM_DELETED_FUNCTION;
286 virtual ~InstBr() {} 306 ~InstBr() override {}
287 307
288 CfgNode *const TargetFalse; // Doubles as unconditional branch target 308 CfgNode *const TargetFalse; // Doubles as unconditional branch target
289 CfgNode *const TargetTrue; // NULL if unconditional branch 309 CfgNode *const TargetTrue; // NULL if unconditional branch
290 }; 310 };
291 311
292 // Call instruction. The call target is captured as getSrc(0), and 312 // Call instruction. The call target is captured as getSrc(0), and
293 // arg I is captured as getSrc(I+1). 313 // arg I is captured as getSrc(I+1).
294 class InstCall : public Inst { 314 class InstCall : public InstHighLevel {
295 public: 315 public:
296 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, 316 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest,
297 Operand *CallTarget, bool HasTailCall) { 317 Operand *CallTarget, bool HasTailCall) {
298 // Set HasSideEffects to true so that the call instruction can't be 318 // Set HasSideEffects to true so that the call instruction can't be
299 // dead-code eliminated. IntrinsicCalls can override this if the 319 // dead-code eliminated. IntrinsicCalls can override this if the
300 // particular intrinsic is deletable and has no side-effects. 320 // particular intrinsic is deletable and has no side-effects.
301 const bool HasSideEffects = true; 321 const bool HasSideEffects = true;
302 const InstKind Kind = Inst::Call; 322 const InstKind Kind = Inst::Call;
303 return new (Func->allocateInst<InstCall>()) InstCall( 323 return new (Func->allocateInst<InstCall>()) InstCall(
304 Func, NumArgs, Dest, CallTarget, HasTailCall, HasSideEffects, Kind); 324 Func, NumArgs, Dest, CallTarget, HasTailCall, HasSideEffects, Kind);
305 } 325 }
306 void addArg(Operand *Arg) { addSource(Arg); } 326 void addArg(Operand *Arg) { addSource(Arg); }
307 Operand *getCallTarget() const { return getSrc(0); } 327 Operand *getCallTarget() const { return getSrc(0); }
308 Operand *getArg(SizeT I) const { return getSrc(I + 1); } 328 Operand *getArg(SizeT I) const { return getSrc(I + 1); }
309 SizeT getNumArgs() const { return getSrcSize() - 1; } 329 SizeT getNumArgs() const { return getSrcSize() - 1; }
310 bool isTailcall() const { return HasTailCall; } 330 bool isTailcall() const { return HasTailCall; }
311 virtual void dump(const Cfg *Func) const; 331 void dump(const Cfg *Func) const;
312 static bool classof(const Inst *Inst) { return Inst->getKind() == Call; } 332 static bool classof(const Inst *Inst) { return Inst->getKind() == Call; }
313 Type getReturnType() const; 333 Type getReturnType() const;
314 334
315 protected: 335 protected:
316 InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget, 336 InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget,
317 bool HasTailCall, bool HasSideEff, InstKind Kind) 337 bool HasTailCall, bool HasSideEff, InstKind Kind)
318 : Inst(Func, Kind, NumArgs + 1, Dest), 338 : InstHighLevel(Func, Kind, NumArgs + 1, Dest), HasTailCall(HasTailCall) {
319 HasTailCall(HasTailCall) {
320 HasSideEffects = HasSideEff; 339 HasSideEffects = HasSideEff;
321 addSource(CallTarget); 340 addSource(CallTarget);
322 } 341 }
323 virtual ~InstCall() {} 342 ~InstCall() override {}
324 343
325 private: 344 private:
326 bool HasTailCall; 345 bool HasTailCall;
327 InstCall(const InstCall &) LLVM_DELETED_FUNCTION; 346 InstCall(const InstCall &) LLVM_DELETED_FUNCTION;
328 InstCall &operator=(const InstCall &) LLVM_DELETED_FUNCTION; 347 InstCall &operator=(const InstCall &) LLVM_DELETED_FUNCTION;
329 }; 348 };
330 349
331 // Cast instruction (a.k.a. conversion operation). 350 // Cast instruction (a.k.a. conversion operation).
332 class InstCast : public Inst { 351 class InstCast : public InstHighLevel {
333 public: 352 public:
334 enum OpKind { 353 enum OpKind {
335 #define X(tag, str) tag, 354 #define X(tag, str) tag,
336 ICEINSTCAST_TABLE 355 ICEINSTCAST_TABLE
337 #undef X 356 #undef X
338 _num 357 _num
339 }; 358 };
340 359
341 static InstCast *create(Cfg *Func, OpKind CastKind, Variable *Dest, 360 static InstCast *create(Cfg *Func, OpKind CastKind, Variable *Dest,
342 Operand *Source) { 361 Operand *Source) {
343 return new (Func->allocateInst<InstCast>()) 362 return new (Func->allocateInst<InstCast>())
344 InstCast(Func, CastKind, Dest, Source); 363 InstCast(Func, CastKind, Dest, Source);
345 } 364 }
346 OpKind getCastKind() const { return CastKind; } 365 OpKind getCastKind() const { return CastKind; }
347 virtual void dump(const Cfg *Func) const; 366 void dump(const Cfg *Func) const override;
348 static bool classof(const Inst *Inst) { return Inst->getKind() == Cast; } 367 static bool classof(const Inst *Inst) { return Inst->getKind() == Cast; }
349 368
350 private: 369 private:
351 InstCast(Cfg *Func, OpKind CastKind, Variable *Dest, Operand *Source); 370 InstCast(Cfg *Func, OpKind CastKind, Variable *Dest, Operand *Source);
352 InstCast(const InstCast &) LLVM_DELETED_FUNCTION; 371 InstCast(const InstCast &) LLVM_DELETED_FUNCTION;
353 InstCast &operator=(const InstCast &) LLVM_DELETED_FUNCTION; 372 InstCast &operator=(const InstCast &) LLVM_DELETED_FUNCTION;
354 virtual ~InstCast() {} 373 ~InstCast() override {}
355 const OpKind CastKind; 374 const OpKind CastKind;
356 }; 375 };
357 376
358 // ExtractElement instruction. 377 // ExtractElement instruction.
359 class InstExtractElement : public Inst { 378 class InstExtractElement : public InstHighLevel {
360 public: 379 public:
361 static InstExtractElement *create(Cfg *Func, Variable *Dest, Operand *Source1, 380 static InstExtractElement *create(Cfg *Func, Variable *Dest, Operand *Source1,
362 Operand *Source2) { 381 Operand *Source2) {
363 return new (Func->allocateInst<InstExtractElement>()) 382 return new (Func->allocateInst<InstExtractElement>())
364 InstExtractElement(Func, Dest, Source1, Source2); 383 InstExtractElement(Func, Dest, Source1, Source2);
365 } 384 }
366 385
367 virtual void dump(const Cfg *Func) const; 386 void dump(const Cfg *Func) const override;
368 static bool classof(const Inst *Inst) { 387 static bool classof(const Inst *Inst) {
369 return Inst->getKind() == ExtractElement; 388 return Inst->getKind() == ExtractElement;
370 } 389 }
371 390
372 private: 391 private:
373 InstExtractElement(Cfg *Func, Variable *Dest, Operand *Source1, 392 InstExtractElement(Cfg *Func, Variable *Dest, Operand *Source1,
374 Operand *Source2); 393 Operand *Source2);
375 InstExtractElement(const InstExtractElement &) LLVM_DELETED_FUNCTION; 394 InstExtractElement(const InstExtractElement &) LLVM_DELETED_FUNCTION;
376 InstExtractElement & 395 InstExtractElement &
377 operator=(const InstExtractElement &) LLVM_DELETED_FUNCTION; 396 operator=(const InstExtractElement &) LLVM_DELETED_FUNCTION;
378 virtual ~InstExtractElement() {} 397 ~InstExtractElement() override {}
379 }; 398 };
380 399
381 // Floating-point comparison instruction. The source operands are 400 // Floating-point comparison instruction. The source operands are
382 // captured in getSrc(0) and getSrc(1). 401 // captured in getSrc(0) and getSrc(1).
383 class InstFcmp : public Inst { 402 class InstFcmp : public InstHighLevel {
384 public: 403 public:
385 enum FCond { 404 enum FCond {
386 #define X(tag, str) tag, 405 #define X(tag, str) tag,
387 ICEINSTFCMP_TABLE 406 ICEINSTFCMP_TABLE
388 #undef X 407 #undef X
389 _num 408 _num
390 }; 409 };
391 410
392 static InstFcmp *create(Cfg *Func, FCond Condition, Variable *Dest, 411 static InstFcmp *create(Cfg *Func, FCond Condition, Variable *Dest,
393 Operand *Source1, Operand *Source2) { 412 Operand *Source1, Operand *Source2) {
394 return new (Func->allocateInst<InstFcmp>()) 413 return new (Func->allocateInst<InstFcmp>())
395 InstFcmp(Func, Condition, Dest, Source1, Source2); 414 InstFcmp(Func, Condition, Dest, Source1, Source2);
396 } 415 }
397 FCond getCondition() const { return Condition; } 416 FCond getCondition() const { return Condition; }
398 virtual void dump(const Cfg *Func) const; 417 void dump(const Cfg *Func) const override;
399 static bool classof(const Inst *Inst) { return Inst->getKind() == Fcmp; } 418 static bool classof(const Inst *Inst) { return Inst->getKind() == Fcmp; }
400 419
401 private: 420 private:
402 InstFcmp(Cfg *Func, FCond Condition, Variable *Dest, Operand *Source1, 421 InstFcmp(Cfg *Func, FCond Condition, Variable *Dest, Operand *Source1,
403 Operand *Source2); 422 Operand *Source2);
404 InstFcmp(const InstFcmp &) LLVM_DELETED_FUNCTION; 423 InstFcmp(const InstFcmp &) LLVM_DELETED_FUNCTION;
405 InstFcmp &operator=(const InstFcmp &) LLVM_DELETED_FUNCTION; 424 InstFcmp &operator=(const InstFcmp &) LLVM_DELETED_FUNCTION;
406 virtual ~InstFcmp() {} 425 ~InstFcmp() override {}
407 const FCond Condition; 426 const FCond Condition;
408 }; 427 };
409 428
410 // Integer comparison instruction. The source operands are captured 429 // Integer comparison instruction. The source operands are captured
411 // in getSrc(0) and getSrc(1). 430 // in getSrc(0) and getSrc(1).
412 class InstIcmp : public Inst { 431 class InstIcmp : public InstHighLevel {
413 public: 432 public:
414 enum ICond { 433 enum ICond {
415 #define X(tag, str) tag, 434 #define X(tag, str) tag,
416 ICEINSTICMP_TABLE 435 ICEINSTICMP_TABLE
417 #undef X 436 #undef X
418 _num 437 _num
419 }; 438 };
420 439
421 static InstIcmp *create(Cfg *Func, ICond Condition, Variable *Dest, 440 static InstIcmp *create(Cfg *Func, ICond Condition, Variable *Dest,
422 Operand *Source1, Operand *Source2) { 441 Operand *Source1, Operand *Source2) {
423 return new (Func->allocateInst<InstIcmp>()) 442 return new (Func->allocateInst<InstIcmp>())
424 InstIcmp(Func, Condition, Dest, Source1, Source2); 443 InstIcmp(Func, Condition, Dest, Source1, Source2);
425 } 444 }
426 ICond getCondition() const { return Condition; } 445 ICond getCondition() const { return Condition; }
427 virtual void dump(const Cfg *Func) const; 446 void dump(const Cfg *Func) const override;
428 static bool classof(const Inst *Inst) { return Inst->getKind() == Icmp; } 447 static bool classof(const Inst *Inst) { return Inst->getKind() == Icmp; }
429 448
430 private: 449 private:
431 InstIcmp(Cfg *Func, ICond Condition, Variable *Dest, Operand *Source1, 450 InstIcmp(Cfg *Func, ICond Condition, Variable *Dest, Operand *Source1,
432 Operand *Source2); 451 Operand *Source2);
433 InstIcmp(const InstIcmp &) LLVM_DELETED_FUNCTION; 452 InstIcmp(const InstIcmp &) LLVM_DELETED_FUNCTION;
434 InstIcmp &operator=(const InstIcmp &) LLVM_DELETED_FUNCTION; 453 InstIcmp &operator=(const InstIcmp &) LLVM_DELETED_FUNCTION;
435 virtual ~InstIcmp() {} 454 ~InstIcmp() override {}
436 const ICond Condition; 455 const ICond Condition;
437 }; 456 };
438 457
439 // InsertElement instruction. 458 // InsertElement instruction.
440 class InstInsertElement : public Inst { 459 class InstInsertElement : public InstHighLevel {
441 public: 460 public:
442 static InstInsertElement *create(Cfg *Func, Variable *Dest, Operand *Source1, 461 static InstInsertElement *create(Cfg *Func, Variable *Dest, Operand *Source1,
443 Operand *Source2, Operand *Source3) { 462 Operand *Source2, Operand *Source3) {
444 return new (Func->allocateInst<InstInsertElement>()) 463 return new (Func->allocateInst<InstInsertElement>())
445 InstInsertElement(Func, Dest, Source1, Source2, Source3); 464 InstInsertElement(Func, Dest, Source1, Source2, Source3);
446 } 465 }
447 466
448 virtual void dump(const Cfg *Func) const; 467 void dump(const Cfg *Func) const override;
449 static bool classof(const Inst *Inst) { 468 static bool classof(const Inst *Inst) {
450 return Inst->getKind() == InsertElement; 469 return Inst->getKind() == InsertElement;
451 } 470 }
452 471
453 private: 472 private:
454 InstInsertElement(Cfg *Func, Variable *Dest, Operand *Source1, 473 InstInsertElement(Cfg *Func, Variable *Dest, Operand *Source1,
455 Operand *Source2, Operand *Source3); 474 Operand *Source2, Operand *Source3);
456 InstInsertElement(const InstInsertElement &) LLVM_DELETED_FUNCTION; 475 InstInsertElement(const InstInsertElement &) LLVM_DELETED_FUNCTION;
457 InstInsertElement &operator=(const InstInsertElement &) LLVM_DELETED_FUNCTION; 476 InstInsertElement &operator=(const InstInsertElement &) LLVM_DELETED_FUNCTION;
458 virtual ~InstInsertElement() {} 477 ~InstInsertElement() override {}
459 }; 478 };
460 479
461 // Call to an intrinsic function. The call target is captured as getSrc(0), 480 // Call to an intrinsic function. The call target is captured as getSrc(0),
462 // and arg I is captured as getSrc(I+1). 481 // and arg I is captured as getSrc(I+1).
463 class InstIntrinsicCall : public InstCall { 482 class InstIntrinsicCall : public InstCall {
464 public: 483 public:
465 static InstIntrinsicCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, 484 static InstIntrinsicCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest,
466 Operand *CallTarget, 485 Operand *CallTarget,
467 const Intrinsics::IntrinsicInfo &Info) { 486 const Intrinsics::IntrinsicInfo &Info) {
468 return new (Func->allocateInst<InstIntrinsicCall>()) 487 return new (Func->allocateInst<InstIntrinsicCall>())
469 InstIntrinsicCall(Func, NumArgs, Dest, CallTarget, Info); 488 InstIntrinsicCall(Func, NumArgs, Dest, CallTarget, Info);
470 } 489 }
471 static bool classof(const Inst *Inst) { 490 static bool classof(const Inst *Inst) {
472 return Inst->getKind() == IntrinsicCall; 491 return Inst->getKind() == IntrinsicCall;
473 } 492 }
474 493
475 Intrinsics::IntrinsicInfo getIntrinsicInfo() const { return Info; } 494 Intrinsics::IntrinsicInfo getIntrinsicInfo() const { return Info; }
476 495
477 private: 496 private:
478 InstIntrinsicCall(Cfg *Func, SizeT NumArgs, Variable *Dest, 497 InstIntrinsicCall(Cfg *Func, SizeT NumArgs, Variable *Dest,
479 Operand *CallTarget, const Intrinsics::IntrinsicInfo &Info) 498 Operand *CallTarget, const Intrinsics::IntrinsicInfo &Info)
480 : InstCall(Func, NumArgs, Dest, CallTarget, false, Info.HasSideEffects, 499 : InstCall(Func, NumArgs, Dest, CallTarget, false, Info.HasSideEffects,
481 Inst::IntrinsicCall), 500 Inst::IntrinsicCall),
482 Info(Info) {} 501 Info(Info) {}
483 InstIntrinsicCall(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION; 502 InstIntrinsicCall(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION;
484 InstIntrinsicCall &operator=(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION; 503 InstIntrinsicCall &operator=(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION;
485 virtual ~InstIntrinsicCall() {} 504 ~InstIntrinsicCall() override {}
486 const Intrinsics::IntrinsicInfo Info; 505 const Intrinsics::IntrinsicInfo Info;
487 }; 506 };
488 507
489 // Load instruction. The source address is captured in getSrc(0). 508 // Load instruction. The source address is captured in getSrc(0).
490 class InstLoad : public Inst { 509 class InstLoad : public InstHighLevel {
491 public: 510 public:
492 static InstLoad *create(Cfg *Func, Variable *Dest, Operand *SourceAddr, 511 static InstLoad *create(Cfg *Func, Variable *Dest, Operand *SourceAddr,
493 uint32_t align = 1) { 512 uint32_t align = 1) {
494 // TODO(kschimpf) Stop ignoring alignment specification. 513 // TODO(kschimpf) Stop ignoring alignment specification.
495 (void)align; 514 (void)align;
496 return new (Func->allocateInst<InstLoad>()) 515 return new (Func->allocateInst<InstLoad>())
497 InstLoad(Func, Dest, SourceAddr); 516 InstLoad(Func, Dest, SourceAddr);
498 } 517 }
499 Operand *getSourceAddress() const { return getSrc(0); } 518 Operand *getSourceAddress() const { return getSrc(0); }
500 virtual void dump(const Cfg *Func) const; 519 void dump(const Cfg *Func) const override;
501 static bool classof(const Inst *Inst) { return Inst->getKind() == Load; } 520 static bool classof(const Inst *Inst) { return Inst->getKind() == Load; }
502 521
503 private: 522 private:
504 InstLoad(Cfg *Func, Variable *Dest, Operand *SourceAddr); 523 InstLoad(Cfg *Func, Variable *Dest, Operand *SourceAddr);
505 InstLoad(const InstLoad &) LLVM_DELETED_FUNCTION; 524 InstLoad(const InstLoad &) LLVM_DELETED_FUNCTION;
506 InstLoad &operator=(const InstLoad &) LLVM_DELETED_FUNCTION; 525 InstLoad &operator=(const InstLoad &) LLVM_DELETED_FUNCTION;
507 virtual ~InstLoad() {} 526 ~InstLoad() override {}
508 }; 527 };
509 528
510 // Phi instruction. For incoming edge I, the node is Labels[I] and 529 // Phi instruction. For incoming edge I, the node is Labels[I] and
511 // the Phi source operand is getSrc(I). 530 // the Phi source operand is getSrc(I).
512 class InstPhi : public Inst { 531 class InstPhi : public InstHighLevel {
513 public: 532 public:
514 static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) { 533 static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) {
515 return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest); 534 return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest);
516 } 535 }
517 void addArgument(Operand *Source, CfgNode *Label); 536 void addArgument(Operand *Source, CfgNode *Label);
518 Operand *getOperandForTarget(CfgNode *Target) const; 537 Operand *getOperandForTarget(CfgNode *Target) const;
519 void livenessPhiOperand(llvm::BitVector &Live, CfgNode *Target, 538 void livenessPhiOperand(llvm::BitVector &Live, CfgNode *Target,
520 Liveness *Liveness); 539 Liveness *Liveness);
521 Inst *lower(Cfg *Func); 540 Inst *lower(Cfg *Func);
522 virtual void dump(const Cfg *Func) const; 541 void dump(const Cfg *Func) const override;
523 static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; } 542 static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; }
524 543
525 private: 544 private:
526 InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest); 545 InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest);
527 InstPhi(const InstPhi &) LLVM_DELETED_FUNCTION; 546 InstPhi(const InstPhi &) LLVM_DELETED_FUNCTION;
528 InstPhi &operator=(const InstPhi &) LLVM_DELETED_FUNCTION; 547 InstPhi &operator=(const InstPhi &) LLVM_DELETED_FUNCTION;
529 virtual void destroy(Cfg *Func) { 548 void destroy(Cfg *Func) override {
530 Func->deallocateArrayOf<CfgNode *>(Labels); 549 Func->deallocateArrayOf<CfgNode *>(Labels);
531 Inst::destroy(Func); 550 Inst::destroy(Func);
532 } 551 }
533 virtual ~InstPhi() {} 552 ~InstPhi() override {}
534 553
535 // Labels[] duplicates the InEdges[] information in the enclosing 554 // Labels[] duplicates the InEdges[] information in the enclosing
536 // CfgNode, but the Phi instruction is created before InEdges[] 555 // CfgNode, but the Phi instruction is created before InEdges[]
537 // is available, so it's more complicated to share the list. 556 // is available, so it's more complicated to share the list.
538 CfgNode **Labels; 557 CfgNode **Labels;
539 }; 558 };
540 559
541 // Ret instruction. The return value is captured in getSrc(0), but if 560 // Ret instruction. The return value is captured in getSrc(0), but if
542 // there is no return value (void-type function), then 561 // there is no return value (void-type function), then
543 // getSrcSize()==0 and hasRetValue()==false. 562 // getSrcSize()==0 and hasRetValue()==false.
544 class InstRet : public Inst { 563 class InstRet : public InstHighLevel {
545 public: 564 public:
546 static InstRet *create(Cfg *Func, Operand *RetValue = NULL) { 565 static InstRet *create(Cfg *Func, Operand *RetValue = NULL) {
547 return new (Func->allocateInst<InstRet>()) InstRet(Func, RetValue); 566 return new (Func->allocateInst<InstRet>()) InstRet(Func, RetValue);
548 } 567 }
549 bool hasRetValue() const { return getSrcSize(); } 568 bool hasRetValue() const { return getSrcSize(); }
550 Operand *getRetValue() const { 569 Operand *getRetValue() const {
551 assert(hasRetValue()); 570 assert(hasRetValue());
552 return getSrc(0); 571 return getSrc(0);
553 } 572 }
554 virtual NodeList getTerminatorEdges() const { return NodeList(); } 573 NodeList getTerminatorEdges() const override { return NodeList(); }
555 virtual void dump(const Cfg *Func) const; 574 void dump(const Cfg *Func) const override;
556 static bool classof(const Inst *Inst) { return Inst->getKind() == Ret; } 575 static bool classof(const Inst *Inst) { return Inst->getKind() == Ret; }
557 576
558 private: 577 private:
559 InstRet(Cfg *Func, Operand *RetValue); 578 InstRet(Cfg *Func, Operand *RetValue);
560 InstRet(const InstRet &) LLVM_DELETED_FUNCTION; 579 InstRet(const InstRet &) LLVM_DELETED_FUNCTION;
561 InstRet &operator=(const InstRet &) LLVM_DELETED_FUNCTION; 580 InstRet &operator=(const InstRet &) LLVM_DELETED_FUNCTION;
562 virtual ~InstRet() {} 581 ~InstRet() override {}
563 }; 582 };
564 583
565 // Select instruction. The condition, true, and false operands are captured. 584 // Select instruction. The condition, true, and false operands are captured.
566 class InstSelect : public Inst { 585 class InstSelect : public InstHighLevel {
567 public: 586 public:
568 static InstSelect *create(Cfg *Func, Variable *Dest, Operand *Condition, 587 static InstSelect *create(Cfg *Func, Variable *Dest, Operand *Condition,
569 Operand *SourceTrue, Operand *SourceFalse) { 588 Operand *SourceTrue, Operand *SourceFalse) {
570 return new (Func->allocateInst<InstSelect>()) 589 return new (Func->allocateInst<InstSelect>())
571 InstSelect(Func, Dest, Condition, SourceTrue, SourceFalse); 590 InstSelect(Func, Dest, Condition, SourceTrue, SourceFalse);
572 } 591 }
573 Operand *getCondition() const { return getSrc(0); } 592 Operand *getCondition() const { return getSrc(0); }
574 Operand *getTrueOperand() const { return getSrc(1); } 593 Operand *getTrueOperand() const { return getSrc(1); }
575 Operand *getFalseOperand() const { return getSrc(2); } 594 Operand *getFalseOperand() const { return getSrc(2); }
576 virtual void dump(const Cfg *Func) const; 595 void dump(const Cfg *Func) const override;
577 static bool classof(const Inst *Inst) { return Inst->getKind() == Select; } 596 static bool classof(const Inst *Inst) { return Inst->getKind() == Select; }
578 597
579 private: 598 private:
580 InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, Operand *Source1, 599 InstSelect(Cfg *Func, Variable *Dest, Operand *Condition, Operand *Source1,
581 Operand *Source2); 600 Operand *Source2);
582 InstSelect(const InstSelect &) LLVM_DELETED_FUNCTION; 601 InstSelect(const InstSelect &) LLVM_DELETED_FUNCTION;
583 InstSelect &operator=(const InstSelect &) LLVM_DELETED_FUNCTION; 602 InstSelect &operator=(const InstSelect &) LLVM_DELETED_FUNCTION;
584 virtual ~InstSelect() {} 603 ~InstSelect() override {}
585 }; 604 };
586 605
587 // Store instruction. The address operand is captured, along with the 606 // Store instruction. The address operand is captured, along with the
588 // data operand to be stored into the address. 607 // data operand to be stored into the address.
589 class InstStore : public Inst { 608 class InstStore : public InstHighLevel {
590 public: 609 public:
591 static InstStore *create(Cfg *Func, Operand *Data, Operand *Addr, 610 static InstStore *create(Cfg *Func, Operand *Data, Operand *Addr,
592 uint32_t align = 1) { 611 uint32_t align = 1) {
593 // TODO(kschimpf) Stop ignoring alignment specification. 612 // TODO(kschimpf) Stop ignoring alignment specification.
594 (void)align; 613 (void)align;
595 return new (Func->allocateInst<InstStore>()) InstStore(Func, Data, Addr); 614 return new (Func->allocateInst<InstStore>()) InstStore(Func, Data, Addr);
596 } 615 }
597 Operand *getAddr() const { return getSrc(1); } 616 Operand *getAddr() const { return getSrc(1); }
598 Operand *getData() const { return getSrc(0); } 617 Operand *getData() const { return getSrc(0); }
599 virtual void dump(const Cfg *Func) const; 618 void dump(const Cfg *Func) const override;
600 static bool classof(const Inst *Inst) { return Inst->getKind() == Store; } 619 static bool classof(const Inst *Inst) { return Inst->getKind() == Store; }
601 620
602 private: 621 private:
603 InstStore(Cfg *Func, Operand *Data, Operand *Addr); 622 InstStore(Cfg *Func, Operand *Data, Operand *Addr);
604 InstStore(const InstStore &) LLVM_DELETED_FUNCTION; 623 InstStore(const InstStore &) LLVM_DELETED_FUNCTION;
605 InstStore &operator=(const InstStore &) LLVM_DELETED_FUNCTION; 624 InstStore &operator=(const InstStore &) LLVM_DELETED_FUNCTION;
606 virtual ~InstStore() {} 625 ~InstStore() override {}
607 }; 626 };
608 627
609 // Switch instruction. The single source operand is captured as 628 // Switch instruction. The single source operand is captured as
610 // getSrc(0). 629 // getSrc(0).
611 class InstSwitch : public Inst { 630 class InstSwitch : public InstHighLevel {
612 public: 631 public:
613 static InstSwitch *create(Cfg *Func, SizeT NumCases, Operand *Source, 632 static InstSwitch *create(Cfg *Func, SizeT NumCases, Operand *Source,
614 CfgNode *LabelDefault) { 633 CfgNode *LabelDefault) {
615 return new (Func->allocateInst<InstSwitch>()) 634 return new (Func->allocateInst<InstSwitch>())
616 InstSwitch(Func, NumCases, Source, LabelDefault); 635 InstSwitch(Func, NumCases, Source, LabelDefault);
617 } 636 }
618 Operand *getComparison() const { return getSrc(0); } 637 Operand *getComparison() const { return getSrc(0); }
619 CfgNode *getLabelDefault() const { return LabelDefault; } 638 CfgNode *getLabelDefault() const { return LabelDefault; }
620 SizeT getNumCases() const { return NumCases; } 639 SizeT getNumCases() const { return NumCases; }
621 uint64_t getValue(SizeT I) const { 640 uint64_t getValue(SizeT I) const {
622 assert(I < NumCases); 641 assert(I < NumCases);
623 return Values[I]; 642 return Values[I];
624 } 643 }
625 CfgNode *getLabel(SizeT I) const { 644 CfgNode *getLabel(SizeT I) const {
626 assert(I < NumCases); 645 assert(I < NumCases);
627 return Labels[I]; 646 return Labels[I];
628 } 647 }
629 void addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label); 648 void addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label);
630 virtual NodeList getTerminatorEdges() const; 649 NodeList getTerminatorEdges() const override;
631 virtual void dump(const Cfg *Func) const; 650 void dump(const Cfg *Func) const override;
632 static bool classof(const Inst *Inst) { return Inst->getKind() == Switch; } 651 static bool classof(const Inst *Inst) { return Inst->getKind() == Switch; }
633 652
634 private: 653 private:
635 InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, CfgNode *LabelDefault); 654 InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, CfgNode *LabelDefault);
636 InstSwitch(const InstSwitch &) LLVM_DELETED_FUNCTION; 655 InstSwitch(const InstSwitch &) LLVM_DELETED_FUNCTION;
637 InstSwitch &operator=(const InstSwitch &) LLVM_DELETED_FUNCTION; 656 InstSwitch &operator=(const InstSwitch &) LLVM_DELETED_FUNCTION;
638 virtual void destroy(Cfg *Func) { 657 void destroy(Cfg *Func) override {
639 Func->deallocateArrayOf<uint64_t>(Values); 658 Func->deallocateArrayOf<uint64_t>(Values);
640 Func->deallocateArrayOf<CfgNode *>(Labels); 659 Func->deallocateArrayOf<CfgNode *>(Labels);
641 Inst::destroy(Func); 660 Inst::destroy(Func);
642 } 661 }
643 virtual ~InstSwitch() {} 662 ~InstSwitch() override {}
644 663
645 CfgNode *LabelDefault; 664 CfgNode *LabelDefault;
646 SizeT NumCases; // not including the default case 665 SizeT NumCases; // not including the default case
647 uint64_t *Values; // size is NumCases 666 uint64_t *Values; // size is NumCases
648 CfgNode **Labels; // size is NumCases 667 CfgNode **Labels; // size is NumCases
649 }; 668 };
650 669
651 // Unreachable instruction. This is a terminator instruction with no 670 // Unreachable instruction. This is a terminator instruction with no
652 // operands. 671 // operands.
653 class InstUnreachable : public Inst { 672 class InstUnreachable : public InstHighLevel {
654 public: 673 public:
655 static InstUnreachable *create(Cfg *Func) { 674 static InstUnreachable *create(Cfg *Func) {
656 return new (Func->allocateInst<InstUnreachable>()) InstUnreachable(Func); 675 return new (Func->allocateInst<InstUnreachable>()) InstUnreachable(Func);
657 } 676 }
658 virtual NodeList getTerminatorEdges() const { return NodeList(); } 677 NodeList getTerminatorEdges() const override { return NodeList(); }
659 virtual void dump(const Cfg *Func) const; 678 void dump(const Cfg *Func) const override;
660 static bool classof(const Inst *Inst) { 679 static bool classof(const Inst *Inst) {
661 return Inst->getKind() == Unreachable; 680 return Inst->getKind() == Unreachable;
662 } 681 }
663 682
664 private: 683 private:
665 InstUnreachable(Cfg *Func); 684 InstUnreachable(Cfg *Func);
666 InstUnreachable(const InstUnreachable &) LLVM_DELETED_FUNCTION; 685 InstUnreachable(const InstUnreachable &) LLVM_DELETED_FUNCTION;
667 InstUnreachable &operator=(const InstUnreachable &) LLVM_DELETED_FUNCTION; 686 InstUnreachable &operator=(const InstUnreachable &) LLVM_DELETED_FUNCTION;
668 virtual ~InstUnreachable() {} 687 ~InstUnreachable() override {}
669 }; 688 };
670 689
671 // FakeDef instruction. This creates a fake definition of a variable, 690 // FakeDef instruction. This creates a fake definition of a variable,
672 // which is how we represent the case when an instruction produces 691 // which is how we represent the case when an instruction produces
673 // multiple results. This doesn't happen with high-level ICE 692 // multiple results. This doesn't happen with high-level ICE
674 // instructions, but might with lowered instructions. For example, 693 // instructions, but might with lowered instructions. For example,
675 // this would be a way to represent condition flags being modified by 694 // this would be a way to represent condition flags being modified by
676 // an instruction. 695 // an instruction.
677 // 696 //
678 // It's generally useful to set the optional source operand to be the 697 // It's generally useful to set the optional source operand to be the
679 // dest variable of the instruction that actually produces the FakeDef 698 // dest variable of the instruction that actually produces the FakeDef
680 // dest. Otherwise, the original instruction could be dead-code 699 // dest. Otherwise, the original instruction could be dead-code
681 // eliminated if its dest operand is unused, and therefore the FakeDef 700 // eliminated if its dest operand is unused, and therefore the FakeDef
682 // dest wouldn't be properly initialized. 701 // dest wouldn't be properly initialized.
683 class InstFakeDef : public Inst { 702 class InstFakeDef : public InstHighLevel {
684 public: 703 public:
685 static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) { 704 static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) {
686 return new (Func->allocateInst<InstFakeDef>()) InstFakeDef(Func, Dest, Src); 705 return new (Func->allocateInst<InstFakeDef>()) InstFakeDef(Func, Dest, Src);
687 } 706 }
688 virtual void emit(const Cfg *Func) const; 707 void emit(const Cfg *Func) const override;
689 virtual void dump(const Cfg *Func) const; 708 void emitIAS(const Cfg *Func) const override { emit(Func); }
709 void dump(const Cfg *Func) const override;
690 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; } 710 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; }
691 711
692 private: 712 private:
693 InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src); 713 InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src);
694 InstFakeDef(const InstFakeDef &) LLVM_DELETED_FUNCTION; 714 InstFakeDef(const InstFakeDef &) LLVM_DELETED_FUNCTION;
695 InstFakeDef &operator=(const InstFakeDef &) LLVM_DELETED_FUNCTION; 715 InstFakeDef &operator=(const InstFakeDef &) LLVM_DELETED_FUNCTION;
696 virtual ~InstFakeDef() {} 716 ~InstFakeDef() override {}
697 }; 717 };
698 718
699 // FakeUse instruction. This creates a fake use of a variable, to 719 // FakeUse instruction. This creates a fake use of a variable, to
700 // keep the instruction that produces that variable from being 720 // keep the instruction that produces that variable from being
701 // dead-code eliminated. This is useful in a variety of lowering 721 // dead-code eliminated. This is useful in a variety of lowering
702 // situations. The FakeUse instruction has no dest, so it can itself 722 // situations. The FakeUse instruction has no dest, so it can itself
703 // never be dead-code eliminated. 723 // never be dead-code eliminated.
704 class InstFakeUse : public Inst { 724 class InstFakeUse : public InstHighLevel {
705 public: 725 public:
706 static InstFakeUse *create(Cfg *Func, Variable *Src) { 726 static InstFakeUse *create(Cfg *Func, Variable *Src) {
707 return new (Func->allocateInst<InstFakeUse>()) InstFakeUse(Func, Src); 727 return new (Func->allocateInst<InstFakeUse>()) InstFakeUse(Func, Src);
708 } 728 }
709 virtual void emit(const Cfg *Func) const; 729 void emit(const Cfg *Func) const override;
710 virtual void dump(const Cfg *Func) const; 730 void emitIAS(const Cfg *Func) const override { emit(Func); }
731 void dump(const Cfg *Func) const override;
711 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeUse; } 732 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeUse; }
712 733
713 private: 734 private:
714 InstFakeUse(Cfg *Func, Variable *Src); 735 InstFakeUse(Cfg *Func, Variable *Src);
715 InstFakeUse(const InstFakeUse &) LLVM_DELETED_FUNCTION; 736 InstFakeUse(const InstFakeUse &) LLVM_DELETED_FUNCTION;
716 InstFakeUse &operator=(const InstFakeUse &) LLVM_DELETED_FUNCTION; 737 InstFakeUse &operator=(const InstFakeUse &) LLVM_DELETED_FUNCTION;
717 virtual ~InstFakeUse() {} 738 ~InstFakeUse() override {}
718 }; 739 };
719 740
720 // FakeKill instruction. This "kills" a set of variables by adding a 741 // FakeKill instruction. This "kills" a set of variables by adding a
721 // trivial live range at this instruction to each variable. The 742 // trivial live range at this instruction to each variable. The
722 // primary use is to indicate that scratch registers are killed after 743 // primary use is to indicate that scratch registers are killed after
723 // a call, so that the register allocator won't assign a scratch 744 // a call, so that the register allocator won't assign a scratch
724 // register to a variable whose live range spans a call. 745 // register to a variable whose live range spans a call.
725 // 746 //
726 // The FakeKill instruction also holds a pointer to the instruction 747 // The FakeKill instruction also holds a pointer to the instruction
727 // that kills the set of variables, so that if that linked instruction 748 // that kills the set of variables, so that if that linked instruction
728 // gets dead-code eliminated, the FakeKill instruction will as well. 749 // gets dead-code eliminated, the FakeKill instruction will as well.
729 class InstFakeKill : public Inst { 750 class InstFakeKill : public InstHighLevel {
730 public: 751 public:
731 static InstFakeKill *create(Cfg *Func, const VarList &KilledRegs, 752 static InstFakeKill *create(Cfg *Func, const VarList &KilledRegs,
732 const Inst *Linked) { 753 const Inst *Linked) {
733 return new (Func->allocateInst<InstFakeKill>()) 754 return new (Func->allocateInst<InstFakeKill>())
734 InstFakeKill(Func, KilledRegs, Linked); 755 InstFakeKill(Func, KilledRegs, Linked);
735 } 756 }
736 const Inst *getLinked() const { return Linked; } 757 const Inst *getLinked() const { return Linked; }
737 virtual void emit(const Cfg *Func) const; 758 void emit(const Cfg *Func) const override;
738 virtual void dump(const Cfg *Func) const; 759 void emitIAS(const Cfg *Func) const override { emit(Func); }
jvoung (off chromium) 2014/09/26 16:13:49 At some point we will have to rely on dump to noti
Jim Stichnoth 2014/09/26 16:27:23 Now that you mention it, there's not much reason t
760 void dump(const Cfg *Func) const override;
739 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeKill; } 761 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeKill; }
740 762
741 private: 763 private:
742 InstFakeKill(Cfg *Func, const VarList &KilledRegs, const Inst *Linked); 764 InstFakeKill(Cfg *Func, const VarList &KilledRegs, const Inst *Linked);
743 InstFakeKill(const InstFakeKill &) LLVM_DELETED_FUNCTION; 765 InstFakeKill(const InstFakeKill &) LLVM_DELETED_FUNCTION;
744 InstFakeKill &operator=(const InstFakeKill &) LLVM_DELETED_FUNCTION; 766 InstFakeKill &operator=(const InstFakeKill &) LLVM_DELETED_FUNCTION;
745 virtual ~InstFakeKill() {} 767 ~InstFakeKill() override {}
746 768
747 // This instruction is ignored if Linked->isDeleted() is true. 769 // This instruction is ignored if Linked->isDeleted() is true.
748 const Inst *Linked; 770 const Inst *Linked;
749 }; 771 };
750 772
751 // The Target instruction is the base class for all target-specific 773 // The Target instruction is the base class for all target-specific
752 // instructions. 774 // instructions.
753 class InstTarget : public Inst { 775 class InstTarget : public Inst {
776 InstTarget(const InstTarget &) LLVM_DELETED_FUNCTION;
777 InstTarget &operator=(const InstTarget &) LLVM_DELETED_FUNCTION;
778
754 public: 779 public:
755 virtual uint32_t getEmitInstCount() const { return 1; } 780 uint32_t getEmitInstCount() const override { return 1; }
756 virtual void emit(const Cfg *Func) const = 0; 781 void dump(const Cfg *Func) const override;
757 virtual void dump(const Cfg *Func) const;
758 virtual void dumpExtras(const Cfg *Func) const;
759 static bool classof(const Inst *Inst) { return Inst->getKind() >= Target; } 782 static bool classof(const Inst *Inst) { return Inst->getKind() >= Target; }
760 783
761 protected: 784 protected:
762 InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) 785 InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest)
763 : Inst(Func, Kind, MaxSrcs, Dest) { 786 : Inst(Func, Kind, MaxSrcs, Dest) {
764 assert(Kind >= Target); 787 assert(Kind >= Target);
765 } 788 }
766 InstTarget(const InstTarget &) LLVM_DELETED_FUNCTION; 789 void emitIAS(const Cfg *Func) const override { emit(Func); }
767 InstTarget &operator=(const InstTarget &) LLVM_DELETED_FUNCTION; 790 ~InstTarget() override {}
768 virtual ~InstTarget() {}
769 }; 791 };
770 792
771 } // end of namespace Ice 793 } // end of namespace Ice
772 794
773 #endif // SUBZERO_SRC_ICEINST_H 795 #endif // SUBZERO_SRC_ICEINST_H
OLDNEW
« no previous file with comments | « src/IceCfgNode.cpp ('k') | src/IceInst.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698