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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 // optimized to an unconditional branch. | 314 // optimized to an unconditional branch. |
315 static InstBr *create(Cfg *Func, Operand *Source, CfgNode *TargetTrue, | 315 static InstBr *create(Cfg *Func, Operand *Source, CfgNode *TargetTrue, |
316 CfgNode *TargetFalse) { | 316 CfgNode *TargetFalse) { |
317 return new (Func->allocate<InstBr>()) | 317 return new (Func->allocate<InstBr>()) |
318 InstBr(Func, Source, TargetTrue, TargetFalse); | 318 InstBr(Func, Source, TargetTrue, TargetFalse); |
319 } | 319 } |
320 // Create an unconditional branch. | 320 // Create an unconditional branch. |
321 static InstBr *create(Cfg *Func, CfgNode *Target) { | 321 static InstBr *create(Cfg *Func, CfgNode *Target) { |
322 return new (Func->allocate<InstBr>()) InstBr(Func, Target); | 322 return new (Func->allocate<InstBr>()) InstBr(Func, Target); |
323 } | 323 } |
324 bool isUnconditional() const { return getTargetTrue() == NULL; } | 324 bool isUnconditional() const { return getTargetTrue() == nullptr; } |
325 Operand *getCondition() const { | 325 Operand *getCondition() const { |
326 assert(!isUnconditional()); | 326 assert(!isUnconditional()); |
327 return getSrc(0); | 327 return getSrc(0); |
328 } | 328 } |
329 CfgNode *getTargetTrue() const { return TargetTrue; } | 329 CfgNode *getTargetTrue() const { return TargetTrue; } |
330 CfgNode *getTargetFalse() const { return TargetFalse; } | 330 CfgNode *getTargetFalse() const { return TargetFalse; } |
331 CfgNode *getTargetUnconditional() const { | 331 CfgNode *getTargetUnconditional() const { |
332 assert(isUnconditional()); | 332 assert(isUnconditional()); |
333 return getTargetFalse(); | 333 return getTargetFalse(); |
334 } | 334 } |
335 NodeList getTerminatorEdges() const override; | 335 NodeList getTerminatorEdges() const override; |
336 bool isUnconditionalBranch() const override { return isUnconditional(); } | 336 bool isUnconditionalBranch() const override { return isUnconditional(); } |
337 bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; | 337 bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; |
338 void dump(const Cfg *Func) const override; | 338 void dump(const Cfg *Func) const override; |
339 static bool classof(const Inst *Inst) { return Inst->getKind() == Br; } | 339 static bool classof(const Inst *Inst) { return Inst->getKind() == Br; } |
340 | 340 |
341 private: | 341 private: |
342 // Conditional branch | 342 // Conditional branch |
343 InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse); | 343 InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse); |
344 // Unconditional branch | 344 // Unconditional branch |
345 InstBr(Cfg *Func, CfgNode *Target); | 345 InstBr(Cfg *Func, CfgNode *Target); |
346 ~InstBr() override {} | 346 ~InstBr() override {} |
347 | 347 |
348 CfgNode *TargetFalse; // Doubles as unconditional branch target | 348 CfgNode *TargetFalse; // Doubles as unconditional branch target |
349 CfgNode *TargetTrue; // NULL if unconditional branch | 349 CfgNode *TargetTrue; // nullptr if unconditional branch |
350 }; | 350 }; |
351 | 351 |
352 // Call instruction. The call target is captured as getSrc(0), and | 352 // Call instruction. The call target is captured as getSrc(0), and |
353 // arg I is captured as getSrc(I+1). | 353 // arg I is captured as getSrc(I+1). |
354 class InstCall : public InstHighLevel { | 354 class InstCall : public InstHighLevel { |
355 InstCall(const InstCall &) = delete; | 355 InstCall(const InstCall &) = delete; |
356 InstCall &operator=(const InstCall &) = delete; | 356 InstCall &operator=(const InstCall &) = delete; |
357 | 357 |
358 public: | 358 public: |
359 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, | 359 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 }; | 608 }; |
609 | 609 |
610 // Ret instruction. The return value is captured in getSrc(0), but if | 610 // Ret instruction. The return value is captured in getSrc(0), but if |
611 // there is no return value (void-type function), then | 611 // there is no return value (void-type function), then |
612 // getSrcSize()==0 and hasRetValue()==false. | 612 // getSrcSize()==0 and hasRetValue()==false. |
613 class InstRet : public InstHighLevel { | 613 class InstRet : public InstHighLevel { |
614 InstRet(const InstRet &) = delete; | 614 InstRet(const InstRet &) = delete; |
615 InstRet &operator=(const InstRet &) = delete; | 615 InstRet &operator=(const InstRet &) = delete; |
616 | 616 |
617 public: | 617 public: |
618 static InstRet *create(Cfg *Func, Operand *RetValue = NULL) { | 618 static InstRet *create(Cfg *Func, Operand *RetValue = nullptr) { |
619 return new (Func->allocate<InstRet>()) InstRet(Func, RetValue); | 619 return new (Func->allocate<InstRet>()) InstRet(Func, RetValue); |
620 } | 620 } |
621 bool hasRetValue() const { return getSrcSize(); } | 621 bool hasRetValue() const { return getSrcSize(); } |
622 Operand *getRetValue() const { | 622 Operand *getRetValue() const { |
623 assert(hasRetValue()); | 623 assert(hasRetValue()); |
624 return getSrc(0); | 624 return getSrc(0); |
625 } | 625 } |
626 NodeList getTerminatorEdges() const override { return NodeList(); } | 626 NodeList getTerminatorEdges() const override { return NodeList(); } |
627 void dump(const Cfg *Func) const override; | 627 void dump(const Cfg *Func) const override; |
628 static bool classof(const Inst *Inst) { return Inst->getKind() == Ret; } | 628 static bool classof(const Inst *Inst) { return Inst->getKind() == Ret; } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // It's generally useful to set the optional source operand to be the | 753 // It's generally useful to set the optional source operand to be the |
754 // dest variable of the instruction that actually produces the FakeDef | 754 // dest variable of the instruction that actually produces the FakeDef |
755 // dest. Otherwise, the original instruction could be dead-code | 755 // dest. Otherwise, the original instruction could be dead-code |
756 // eliminated if its dest operand is unused, and therefore the FakeDef | 756 // eliminated if its dest operand is unused, and therefore the FakeDef |
757 // dest wouldn't be properly initialized. | 757 // dest wouldn't be properly initialized. |
758 class InstFakeDef : public InstHighLevel { | 758 class InstFakeDef : public InstHighLevel { |
759 InstFakeDef(const InstFakeDef &) = delete; | 759 InstFakeDef(const InstFakeDef &) = delete; |
760 InstFakeDef &operator=(const InstFakeDef &) = delete; | 760 InstFakeDef &operator=(const InstFakeDef &) = delete; |
761 | 761 |
762 public: | 762 public: |
763 static InstFakeDef *create(Cfg *Func, Variable *Dest, Variable *Src = NULL) { | 763 static InstFakeDef *create(Cfg *Func, Variable *Dest, |
| 764 Variable *Src = nullptr) { |
764 return new (Func->allocate<InstFakeDef>()) InstFakeDef(Func, Dest, Src); | 765 return new (Func->allocate<InstFakeDef>()) InstFakeDef(Func, Dest, Src); |
765 } | 766 } |
766 void emit(const Cfg *Func) const override; | 767 void emit(const Cfg *Func) const override; |
767 void emitIAS(const Cfg * /* Func */) const override {} | 768 void emitIAS(const Cfg * /* Func */) const override {} |
768 void dump(const Cfg *Func) const override; | 769 void dump(const Cfg *Func) const override; |
769 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; } | 770 static bool classof(const Inst *Inst) { return Inst->getKind() == FakeDef; } |
770 | 771 |
771 private: | 772 private: |
772 InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src); | 773 InstFakeDef(Cfg *Func, Variable *Dest, Variable *Src); |
773 ~InstFakeDef() override {} | 774 ~InstFakeDef() override {} |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 static void noteHead(Ice::Inst *, Ice::Inst *) {} | 865 static void noteHead(Ice::Inst *, Ice::Inst *) {} |
865 void deleteNode(Ice::Inst *) {} | 866 void deleteNode(Ice::Inst *) {} |
866 | 867 |
867 private: | 868 private: |
868 mutable ilist_half_node<Ice::Inst> Sentinel; | 869 mutable ilist_half_node<Ice::Inst> Sentinel; |
869 }; | 870 }; |
870 | 871 |
871 } // end of namespace llvm | 872 } // end of namespace llvm |
872 | 873 |
873 #endif // SUBZERO_SRC_ICEINST_H | 874 #endif // SUBZERO_SRC_ICEINST_H |
OLD | NEW |