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