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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
289 | 289 |
290 CfgNode *const TargetFalse; // Doubles as unconditional branch target | 290 CfgNode *const TargetFalse; // Doubles as unconditional branch target |
291 CfgNode *const TargetTrue; // NULL if unconditional branch | 291 CfgNode *const TargetTrue; // NULL if unconditional branch |
292 }; | 292 }; |
293 | 293 |
294 // Call instruction. The call target is captured as getSrc(0), and | 294 // Call instruction. The call target is captured as getSrc(0), and |
295 // arg I is captured as getSrc(I+1). | 295 // arg I is captured as getSrc(I+1). |
296 class InstCall : public Inst { | 296 class InstCall : public Inst { |
297 public: | 297 public: |
298 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, | 298 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, |
299 Operand *CallTarget) { | 299 Operand *CallTarget, bool hasTailCall = false) { |
Jim Stichnoth
2014/09/18 21:41:54
Can you make this a non-default argument? I think
Karl
2014/09/18 22:01:50
Done.
| |
300 // Set HasSideEffects to true so that the call instruction can't be | 300 // Set HasSideEffects to true so that the call instruction can't be |
301 // dead-code eliminated. IntrinsicCalls can override this if the | 301 // dead-code eliminated. IntrinsicCalls can override this if the |
302 // particular intrinsic is deletable and has no side-effects. | 302 // particular intrinsic is deletable and has no side-effects. |
303 const bool HasSideEffects = true; | 303 const bool HasSideEffects = true; |
304 const InstKind Kind = Inst::Call; | 304 const InstKind Kind = Inst::Call; |
305 return new (Func->allocateInst<InstCall>()) | 305 return new (Func->allocateInst<InstCall>()) InstCall( |
306 InstCall(Func, NumArgs, Dest, CallTarget, HasSideEffects, Kind); | 306 Func, NumArgs, Dest, CallTarget, hasTailCall, HasSideEffects, Kind); |
307 } | 307 } |
308 void addArg(Operand *Arg) { addSource(Arg); } | 308 void addArg(Operand *Arg) { addSource(Arg); } |
309 Operand *getCallTarget() const { return getSrc(0); } | 309 Operand *getCallTarget() const { return getSrc(0); } |
310 Operand *getArg(SizeT I) const { return getSrc(I + 1); } | 310 Operand *getArg(SizeT I) const { return getSrc(I + 1); } |
311 SizeT getNumArgs() const { return getSrcSize() - 1; } | 311 SizeT getNumArgs() const { return getSrcSize() - 1; } |
312 bool isTailcall() const { return hasTailCall; } | |
312 virtual void dump(const Cfg *Func) const; | 313 virtual void dump(const Cfg *Func) const; |
313 static bool classof(const Inst *Inst) { return Inst->getKind() == Call; } | 314 static bool classof(const Inst *Inst) { return Inst->getKind() == Call; } |
315 Type getReturnType() const; | |
314 | 316 |
315 protected: | 317 protected: |
316 InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget, | 318 InstCall(Cfg *Func, SizeT NumArgs, Variable *Dest, Operand *CallTarget, |
317 bool HasSideEff, InstKind Kind) | 319 bool HasTailCl, bool HasSideEff, InstKind Kind) |
jvoung (off chromium)
2014/09/18 22:04:46
nit: I think we might as well just make the argume
Karl
2014/09/19 20:29:51
I agree with using HasTailCall. Changing field bac
| |
318 : Inst(Func, Kind, NumArgs + 1, Dest) { | 320 : Inst(Func, Kind, NumArgs + 1, Dest) { |
321 hasTailCall = HasTailCl; | |
319 HasSideEffects = HasSideEff; | 322 HasSideEffects = HasSideEff; |
320 addSource(CallTarget); | 323 addSource(CallTarget); |
321 } | 324 } |
322 virtual ~InstCall() {} | 325 virtual ~InstCall() {} |
323 | 326 |
324 private: | 327 private: |
328 bool hasTailCall; | |
Jim Stichnoth
2014/09/18 21:41:54
Capitalize per LLVM convention.
Also, small nit -
Karl
2014/09/18 22:01:50
Done.
| |
325 InstCall(const InstCall &) LLVM_DELETED_FUNCTION; | 329 InstCall(const InstCall &) LLVM_DELETED_FUNCTION; |
326 InstCall &operator=(const InstCall &) LLVM_DELETED_FUNCTION; | 330 InstCall &operator=(const InstCall &) LLVM_DELETED_FUNCTION; |
327 }; | 331 }; |
328 | 332 |
329 // Cast instruction (a.k.a. conversion operation). | 333 // Cast instruction (a.k.a. conversion operation). |
330 class InstCast : public Inst { | 334 class InstCast : public Inst { |
331 public: | 335 public: |
332 enum OpKind { | 336 enum OpKind { |
333 #define X(tag, str) tag, | 337 #define X(tag, str) tag, |
334 ICEINSTCAST_TABLE | 338 ICEINSTCAST_TABLE |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 } | 472 } |
469 static bool classof(const Inst *Inst) { | 473 static bool classof(const Inst *Inst) { |
470 return Inst->getKind() == IntrinsicCall; | 474 return Inst->getKind() == IntrinsicCall; |
471 } | 475 } |
472 | 476 |
473 Intrinsics::IntrinsicInfo getIntrinsicInfo() const { return Info; } | 477 Intrinsics::IntrinsicInfo getIntrinsicInfo() const { return Info; } |
474 | 478 |
475 private: | 479 private: |
476 InstIntrinsicCall(Cfg *Func, SizeT NumArgs, Variable *Dest, | 480 InstIntrinsicCall(Cfg *Func, SizeT NumArgs, Variable *Dest, |
477 Operand *CallTarget, const Intrinsics::IntrinsicInfo &Info) | 481 Operand *CallTarget, const Intrinsics::IntrinsicInfo &Info) |
478 : InstCall(Func, NumArgs, Dest, CallTarget, Info.HasSideEffects, | 482 : InstCall(Func, NumArgs, Dest, CallTarget, false, Info.HasSideEffects, |
479 Inst::IntrinsicCall), | 483 Inst::IntrinsicCall), |
480 Info(Info) {} | 484 Info(Info) {} |
481 InstIntrinsicCall(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION; | 485 InstIntrinsicCall(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION; |
482 InstIntrinsicCall &operator=(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION; | 486 InstIntrinsicCall &operator=(const InstIntrinsicCall &) LLVM_DELETED_FUNCTION; |
483 virtual ~InstIntrinsicCall() {} | 487 virtual ~InstIntrinsicCall() {} |
484 const Intrinsics::IntrinsicInfo Info; | 488 const Intrinsics::IntrinsicInfo Info; |
485 }; | 489 }; |
486 | 490 |
487 // Load instruction. The source address is captured in getSrc(0). | 491 // Load instruction. The source address is captured in getSrc(0). |
488 class InstLoad : public Inst { | 492 class InstLoad : public Inst { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
762 assert(Kind >= Target); | 766 assert(Kind >= Target); |
763 } | 767 } |
764 InstTarget(const InstTarget &) LLVM_DELETED_FUNCTION; | 768 InstTarget(const InstTarget &) LLVM_DELETED_FUNCTION; |
765 InstTarget &operator=(const InstTarget &) LLVM_DELETED_FUNCTION; | 769 InstTarget &operator=(const InstTarget &) LLVM_DELETED_FUNCTION; |
766 virtual ~InstTarget() {} | 770 virtual ~InstTarget() {} |
767 }; | 771 }; |
768 | 772 |
769 } // end of namespace Ice | 773 } // end of namespace Ice |
770 | 774 |
771 #endif // SUBZERO_SRC_ICEINST_H | 775 #endif // SUBZERO_SRC_ICEINST_H |
OLD | NEW |