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

Side by Side Diff: src/IceInst.h

Issue 652633002: Subzero: Improve performance of liveness analysis and live range construction. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove TODO 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/IceDefs.h ('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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 FakeDef, // not part of LLVM/PNaCl bitcode 59 FakeDef, // not part of LLVM/PNaCl bitcode
60 FakeUse, // not part of LLVM/PNaCl bitcode 60 FakeUse, // not part of LLVM/PNaCl bitcode
61 FakeKill, // not part of LLVM/PNaCl bitcode 61 FakeKill, // not part of LLVM/PNaCl bitcode
62 Target // target-specific low-level ICE 62 Target // target-specific low-level ICE
63 // Anything >= Target is an InstTarget subclass. 63 // Anything >= Target is an InstTarget subclass.
64 }; 64 };
65 InstKind getKind() const { return Kind; } 65 InstKind getKind() const { return Kind; }
66 66
67 InstNumberT getNumber() const { return Number; } 67 InstNumberT getNumber() const { return Number; }
68 void renumber(Cfg *Func); 68 void renumber(Cfg *Func);
69 static const InstNumberT NumberDeleted = -1; 69 enum { NumberDeleted = -1, NumberSentinel = 0 };
70 static const InstNumberT NumberSentinel = 0;
71 70
72 bool isDeleted() const { return Deleted; } 71 bool isDeleted() const { return Deleted; }
73 void setDeleted() { Deleted = true; } 72 void setDeleted() { Deleted = true; }
74 void deleteIfDead(); 73 void deleteIfDead();
75 74
76 bool hasSideEffects() const { return HasSideEffects; } 75 bool hasSideEffects() const { return HasSideEffects; }
77 76
77 bool isDestNonKillable() const { return IsDestNonKillable; }
78 void setDestNonKillable() { IsDestNonKillable = true; }
79
78 Variable *getDest() const { return Dest; } 80 Variable *getDest() const { return Dest; }
79 81
80 SizeT getSrcSize() const { return NumSrcs; } 82 SizeT getSrcSize() const { return NumSrcs; }
81 Operand *getSrc(SizeT I) const { 83 Operand *getSrc(SizeT I) const {
82 assert(I < getSrcSize()); 84 assert(I < getSrcSize());
83 return Srcs[I]; 85 return Srcs[I];
84 } 86 }
85 87
86 bool isLastUse(const Operand *Src) const; 88 bool isLastUse(const Operand *Src) const;
87 89
88 // Returns a list of out-edges corresponding to a terminator 90 // Returns a list of out-edges corresponding to a terminator
89 // instruction, which is the last instruction of the block. 91 // instruction, which is the last instruction of the block.
90 virtual NodeList getTerminatorEdges() const { 92 virtual NodeList getTerminatorEdges() const {
91 // All valid terminator instructions override this method. For 93 // All valid terminator instructions override this method. For
92 // the default implementation, we assert in case some CfgNode 94 // the default implementation, we assert in case some CfgNode
93 // is constructed without a terminator instruction at the end. 95 // is constructed without a terminator instruction at the end.
94 llvm_unreachable( 96 llvm_unreachable(
95 "getTerminatorEdges() called on a non-terminator instruction"); 97 "getTerminatorEdges() called on a non-terminator instruction");
96 return NodeList(); 98 return NodeList();
97 } 99 }
98 100
99 virtual bool isSimpleAssign() const { return false; } 101 virtual bool isSimpleAssign() const { return false; }
100 102
101 void livenessLightweight(Cfg *Func, llvm::BitVector &Live); 103 void livenessLightweight(Cfg *Func, LivenessBV &Live);
102 void liveness(InstNumberT InstNumber, llvm::BitVector &Live, 104 void liveness(InstNumberT InstNumber, LivenessBV &Live, Liveness *Liveness,
103 Liveness *Liveness, const CfgNode *Node); 105 LiveBeginEndMap *LiveBegin, LiveBeginEndMap *LiveEnd);
104 106
105 // Get the number of native instructions that this instruction 107 // Get the number of native instructions that this instruction
106 // ultimately emits. By default, high-level instructions don't 108 // ultimately emits. By default, high-level instructions don't
107 // result in any native instructions, and a target-specific 109 // result in any native instructions, and a target-specific
108 // instruction results in a single native instruction. 110 // instruction results in a single native instruction.
109 virtual uint32_t getEmitInstCount() const { return 0; } 111 virtual uint32_t getEmitInstCount() const { return 0; }
110 virtual void emit(const Cfg *Func) const = 0; 112 virtual void emit(const Cfg *Func) const = 0;
111 virtual void emitIAS(const Cfg *Func) const = 0; 113 virtual void emitIAS(const Cfg *Func) const = 0;
112 virtual void dump(const Cfg *Func) const; 114 virtual void dump(const Cfg *Func) const;
113 virtual void dumpExtras(const Cfg *Func) const; 115 virtual void dumpExtras(const Cfg *Func) const;
(...skipping 25 matching lines...) Expand all
139 // Number is the instruction number for describing live ranges. 141 // Number is the instruction number for describing live ranges.
140 InstNumberT Number; 142 InstNumberT Number;
141 // Deleted means irrevocably deleted. 143 // Deleted means irrevocably deleted.
142 bool Deleted; 144 bool Deleted;
143 // Dead means pending deletion after liveness analysis converges. 145 // Dead means pending deletion after liveness analysis converges.
144 bool Dead; 146 bool Dead;
145 // HasSideEffects means the instruction is something like a function 147 // HasSideEffects means the instruction is something like a function
146 // call or a volatile load that can't be removed even if its Dest 148 // call or a volatile load that can't be removed even if its Dest
147 // variable is not live. 149 // variable is not live.
148 bool HasSideEffects; 150 bool HasSideEffects;
151 // IsDestNonKillable means that liveness analysis shouldn't consider
152 // this instruction to kill the Dest variable. This is used when
153 // lowering produces two assignments to the same variable.
154 bool IsDestNonKillable;
149 155
150 Variable *Dest; 156 Variable *Dest;
151 const SizeT MaxSrcs; // only used for assert 157 const SizeT MaxSrcs; // only used for assert
152 SizeT NumSrcs; 158 SizeT NumSrcs;
153 Operand **Srcs; 159 Operand **Srcs;
154 160
155 // LiveRangesEnded marks which Variables' live ranges end in this 161 // LiveRangesEnded marks which Variables' live ranges end in this
156 // instruction. An instruction can have an arbitrary number of 162 // instruction. An instruction can have an arbitrary number of
157 // source operands (e.g. a call instruction), and each source 163 // source operands (e.g. a call instruction), and each source
158 // operand can contain 0 or 1 Variable (and target-specific operands 164 // operand can contain 0 or 1 Variable (and target-specific operands
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 533
528 // Phi instruction. For incoming edge I, the node is Labels[I] and 534 // Phi instruction. For incoming edge I, the node is Labels[I] and
529 // the Phi source operand is getSrc(I). 535 // the Phi source operand is getSrc(I).
530 class InstPhi : public InstHighLevel { 536 class InstPhi : public InstHighLevel {
531 public: 537 public:
532 static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) { 538 static InstPhi *create(Cfg *Func, SizeT MaxSrcs, Variable *Dest) {
533 return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest); 539 return new (Func->allocateInst<InstPhi>()) InstPhi(Func, MaxSrcs, Dest);
534 } 540 }
535 void addArgument(Operand *Source, CfgNode *Label); 541 void addArgument(Operand *Source, CfgNode *Label);
536 Operand *getOperandForTarget(CfgNode *Target) const; 542 Operand *getOperandForTarget(CfgNode *Target) const;
537 void livenessPhiOperand(llvm::BitVector &Live, CfgNode *Target, 543 void livenessPhiOperand(LivenessBV &Live, CfgNode *Target,
538 Liveness *Liveness); 544 Liveness *Liveness);
539 Inst *lower(Cfg *Func); 545 Inst *lower(Cfg *Func);
540 void dump(const Cfg *Func) const override; 546 void dump(const Cfg *Func) const override;
541 static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; } 547 static bool classof(const Inst *Inst) { return Inst->getKind() == Phi; }
542 548
543 private: 549 private:
544 InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest); 550 InstPhi(Cfg *Func, SizeT MaxSrcs, Variable *Dest);
545 InstPhi(const InstPhi &) = delete; 551 InstPhi(const InstPhi &) = delete;
546 InstPhi &operator=(const InstPhi &) = delete; 552 InstPhi &operator=(const InstPhi &) = delete;
547 void destroy(Cfg *Func) override { 553 void destroy(Cfg *Func) override {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 : Inst(Func, Kind, MaxSrcs, Dest) { 791 : Inst(Func, Kind, MaxSrcs, Dest) {
786 assert(Kind >= Target); 792 assert(Kind >= Target);
787 } 793 }
788 void emitIAS(const Cfg *Func) const override { emit(Func); } 794 void emitIAS(const Cfg *Func) const override { emit(Func); }
789 ~InstTarget() override {} 795 ~InstTarget() override {}
790 }; 796 };
791 797
792 } // end of namespace Ice 798 } // end of namespace Ice
793 799
794 #endif // SUBZERO_SRC_ICEINST_H 800 #endif // SUBZERO_SRC_ICEINST_H
OLDNEW
« no previous file with comments | « src/IceDefs.h ('k') | src/IceInst.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698