Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 // Returns a list of out-edges corresponding to a terminator | 93 // Returns a list of out-edges corresponding to a terminator |
| 94 // instruction, which is the last instruction of the block. | 94 // instruction, which is the last instruction of the block. |
| 95 virtual NodeList getTerminatorEdges() const { | 95 virtual NodeList getTerminatorEdges() const { |
| 96 // All valid terminator instructions override this method. For | 96 // All valid terminator instructions override this method. For |
| 97 // the default implementation, we assert in case some CfgNode | 97 // the default implementation, we assert in case some CfgNode |
| 98 // is constructed without a terminator instruction at the end. | 98 // is constructed without a terminator instruction at the end. |
| 99 llvm_unreachable( | 99 llvm_unreachable( |
| 100 "getTerminatorEdges() called on a non-terminator instruction"); | 100 "getTerminatorEdges() called on a non-terminator instruction"); |
| 101 return NodeList(); | 101 return NodeList(); |
| 102 } | 102 } |
| 103 virtual bool isUnconditionalBranch() const { return false; } | |
| 104 // If the instruction is a branch-type instruction with OldNode as a | |
| 105 // target, repoint it to NewNode and return true, otherwise return | |
| 106 // false. Only repoint one instance, even if the instruction has | |
| 107 // multiple instances of OldNode as a target. | |
| 108 virtual bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) { | |
| 109 (void)OldNode; | |
| 110 (void)NewNode; | |
| 111 return false; | |
| 112 } | |
| 103 | 113 |
| 104 virtual bool isSimpleAssign() const { return false; } | 114 virtual bool isSimpleAssign() const { return false; } |
| 105 | 115 |
| 106 void livenessLightweight(Cfg *Func, LivenessBV &Live); | 116 void livenessLightweight(Cfg *Func, LivenessBV &Live); |
| 107 void liveness(InstNumberT InstNumber, LivenessBV &Live, Liveness *Liveness, | 117 bool liveness(InstNumberT InstNumber, LivenessBV &Live, Liveness *Liveness, |
|
jvoung (off chromium)
2014/10/27 22:12:21
document the meaning of the "bool" return value of
Jim Stichnoth
2014/10/28 01:20:14
I had documented it in the .cpp file, so I moved t
| |
| 108 LiveBeginEndMap *LiveBegin, LiveBeginEndMap *LiveEnd); | 118 LiveBeginEndMap *LiveBegin, LiveBeginEndMap *LiveEnd); |
| 109 | 119 |
| 110 // Get the number of native instructions that this instruction | 120 // Get the number of native instructions that this instruction |
| 111 // ultimately emits. By default, high-level instructions don't | 121 // ultimately emits. By default, high-level instructions don't |
| 112 // result in any native instructions, and a target-specific | 122 // result in any native instructions, and a target-specific |
| 113 // instruction results in a single native instruction. | 123 // instruction results in a single native instruction. |
| 114 virtual uint32_t getEmitInstCount() const { return 0; } | 124 virtual uint32_t getEmitInstCount() const { return 0; } |
| 115 virtual void emit(const Cfg *Func) const = 0; | 125 virtual void emit(const Cfg *Func) const = 0; |
| 116 virtual void emitIAS(const Cfg *Func) const = 0; | 126 virtual void emitIAS(const Cfg *Func) const = 0; |
| 117 virtual void dump(const Cfg *Func) const; | 127 virtual void dump(const Cfg *Func) const; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 assert(!isUnconditional()); | 307 assert(!isUnconditional()); |
| 298 return getSrc(0); | 308 return getSrc(0); |
| 299 } | 309 } |
| 300 CfgNode *getTargetTrue() const { return TargetTrue; } | 310 CfgNode *getTargetTrue() const { return TargetTrue; } |
| 301 CfgNode *getTargetFalse() const { return TargetFalse; } | 311 CfgNode *getTargetFalse() const { return TargetFalse; } |
| 302 CfgNode *getTargetUnconditional() const { | 312 CfgNode *getTargetUnconditional() const { |
| 303 assert(isUnconditional()); | 313 assert(isUnconditional()); |
| 304 return getTargetFalse(); | 314 return getTargetFalse(); |
| 305 } | 315 } |
| 306 NodeList getTerminatorEdges() const override; | 316 NodeList getTerminatorEdges() const override; |
| 317 bool isUnconditionalBranch() const override { return isUnconditional(); } | |
| 318 bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; | |
| 307 void dump(const Cfg *Func) const override; | 319 void dump(const Cfg *Func) const override; |
| 308 static bool classof(const Inst *Inst) { return Inst->getKind() == Br; } | 320 static bool classof(const Inst *Inst) { return Inst->getKind() == Br; } |
| 309 | 321 |
| 310 private: | 322 private: |
| 311 // Conditional branch | 323 // Conditional branch |
| 312 InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse); | 324 InstBr(Cfg *Func, Operand *Source, CfgNode *TargetTrue, CfgNode *TargetFalse); |
| 313 // Unconditional branch | 325 // Unconditional branch |
| 314 InstBr(Cfg *Func, CfgNode *Target); | 326 InstBr(Cfg *Func, CfgNode *Target); |
| 315 ~InstBr() override {} | 327 ~InstBr() override {} |
| 316 | 328 |
| 317 CfgNode *const TargetFalse; // Doubles as unconditional branch target | 329 CfgNode *TargetFalse; // Doubles as unconditional branch target |
| 318 CfgNode *const TargetTrue; // NULL if unconditional branch | 330 CfgNode *TargetTrue; // NULL if unconditional branch |
| 319 }; | 331 }; |
| 320 | 332 |
| 321 // Call instruction. The call target is captured as getSrc(0), and | 333 // Call instruction. The call target is captured as getSrc(0), and |
| 322 // arg I is captured as getSrc(I+1). | 334 // arg I is captured as getSrc(I+1). |
| 323 class InstCall : public InstHighLevel { | 335 class InstCall : public InstHighLevel { |
| 324 InstCall(const InstCall &) = delete; | 336 InstCall(const InstCall &) = delete; |
| 325 InstCall &operator=(const InstCall &) = delete; | 337 InstCall &operator=(const InstCall &) = delete; |
| 326 | 338 |
| 327 public: | 339 public: |
| 328 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, | 340 static InstCall *create(Cfg *Func, SizeT NumArgs, Variable *Dest, |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 uint64_t getValue(SizeT I) const { | 676 uint64_t getValue(SizeT I) const { |
| 665 assert(I < NumCases); | 677 assert(I < NumCases); |
| 666 return Values[I]; | 678 return Values[I]; |
| 667 } | 679 } |
| 668 CfgNode *getLabel(SizeT I) const { | 680 CfgNode *getLabel(SizeT I) const { |
| 669 assert(I < NumCases); | 681 assert(I < NumCases); |
| 670 return Labels[I]; | 682 return Labels[I]; |
| 671 } | 683 } |
| 672 void addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label); | 684 void addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label); |
| 673 NodeList getTerminatorEdges() const override; | 685 NodeList getTerminatorEdges() const override; |
| 686 bool repointEdge(CfgNode *OldNode, CfgNode *NewNode) override; | |
| 674 void dump(const Cfg *Func) const override; | 687 void dump(const Cfg *Func) const override; |
| 675 static bool classof(const Inst *Inst) { return Inst->getKind() == Switch; } | 688 static bool classof(const Inst *Inst) { return Inst->getKind() == Switch; } |
| 676 | 689 |
| 677 private: | 690 private: |
| 678 InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, CfgNode *LabelDefault); | 691 InstSwitch(Cfg *Func, SizeT NumCases, Operand *Source, CfgNode *LabelDefault); |
| 679 void destroy(Cfg *Func) override { | 692 void destroy(Cfg *Func) override { |
| 680 Func->deallocateArrayOf<uint64_t>(Values); | 693 Func->deallocateArrayOf<uint64_t>(Values); |
| 681 Func->deallocateArrayOf<CfgNode *>(Labels); | 694 Func->deallocateArrayOf<CfgNode *>(Labels); |
| 682 Inst::destroy(Func); | 695 Inst::destroy(Func); |
| 683 } | 696 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 811 InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) | 824 InstTarget(Cfg *Func, InstKind Kind, SizeT MaxSrcs, Variable *Dest) |
| 812 : Inst(Func, Kind, MaxSrcs, Dest) { | 825 : Inst(Func, Kind, MaxSrcs, Dest) { |
| 813 assert(Kind >= Target); | 826 assert(Kind >= Target); |
| 814 } | 827 } |
| 815 ~InstTarget() override {} | 828 ~InstTarget() override {} |
| 816 }; | 829 }; |
| 817 | 830 |
| 818 } // end of namespace Ice | 831 } // end of namespace Ice |
| 819 | 832 |
| 820 #endif // SUBZERO_SRC_ICEINST_H | 833 #endif // SUBZERO_SRC_ICEINST_H |
| OLD | NEW |