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

Side by Side Diff: src/IceTargetLowering.h

Issue 672393003: Subzero: Minor refactoring/additions in preparation for phi edge splitting. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Remove deprecated advanceBackward method 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/IceInstX8632.h ('k') | src/IceTargetLowering.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/IceTargetLowering.h - Lowering interface -----*- C++ -*-===// 1 //===- subzero/src/IceTargetLowering.h - Lowering interface -----*- 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 TargetLowering and LoweringContext 10 // This file declares the TargetLowering and LoweringContext
(...skipping 21 matching lines...) Expand all
32 // instructions in a node, and insert new (lowered) instructions at 32 // instructions in a node, and insert new (lowered) instructions at
33 // the current point. Along with the instruction list container and 33 // the current point. Along with the instruction list container and
34 // associated iterators, it holds the current node, which is needed 34 // associated iterators, it holds the current node, which is needed
35 // when inserting new instructions in order to track whether variables 35 // when inserting new instructions in order to track whether variables
36 // are used as single-block or multi-block. 36 // are used as single-block or multi-block.
37 class LoweringContext { 37 class LoweringContext {
38 LoweringContext(const LoweringContext &) = delete; 38 LoweringContext(const LoweringContext &) = delete;
39 LoweringContext &operator=(const LoweringContext &) = delete; 39 LoweringContext &operator=(const LoweringContext &) = delete;
40 40
41 public: 41 public:
42 LoweringContext() : Node(NULL) {} 42 LoweringContext() : Node(NULL), LastInserted(NULL) {}
43 ~LoweringContext() {} 43 ~LoweringContext() {}
44 void init(CfgNode *Node); 44 void init(CfgNode *Node);
45 Inst *getNextInst() const { 45 Inst *getNextInst() const {
46 if (Next == End) 46 if (Next == End)
47 return NULL; 47 return NULL;
48 return *Next; 48 return *Next;
49 } 49 }
50 Inst *getNextInst(InstList::iterator &Iter) const { 50 Inst *getNextInst(InstList::iterator &Iter) const {
51 advanceForward(Iter); 51 advanceForward(Iter);
52 if (Iter == End) 52 if (Iter == End)
53 return NULL; 53 return NULL;
54 return *Iter; 54 return *Iter;
55 } 55 }
56 CfgNode *getNode() const { return Node; } 56 CfgNode *getNode() const { return Node; }
57 bool atEnd() const { return Cur == End; } 57 bool atEnd() const { return Cur == End; }
58 InstList::iterator getCur() const { return Cur; } 58 InstList::iterator getCur() const { return Cur; }
59 InstList::iterator getEnd() const { return End; } 59 InstList::iterator getEnd() const { return End; }
60 // Adaptor to enable range-based for loops. 60 // Adaptor to enable range-based for loops.
61 InstList::iterator begin() const { return getCur(); } 61 InstList::iterator begin() const { return getCur(); }
62 InstList::iterator end() const { return getEnd(); } 62 InstList::iterator end() const { return getEnd(); }
63 void insert(Inst *Inst); 63 void insert(Inst *Inst);
64 Inst *getLastInserted() const; 64 Inst *getLastInserted() const;
65 void advanceCur() { Cur = Next; } 65 void advanceCur() { Cur = Next; }
66 void advanceNext() { advanceForward(Next); } 66 void advanceNext() { advanceForward(Next); }
67 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } 67 void setInsertPoint(const InstList::iterator &Position) { Next = Position; }
68 68
69 private: 69 private:
70 // Node is the argument to Inst::updateVars(). 70 // Node is the argument to Inst::updateVars().
71 CfgNode *Node; 71 CfgNode *Node;
72 Inst *LastInserted;
72 // Cur points to the current instruction being considered. It is 73 // Cur points to the current instruction being considered. It is
73 // guaranteed to point to a non-deleted instruction, or to be End. 74 // guaranteed to point to a non-deleted instruction, or to be End.
74 InstList::iterator Cur; 75 InstList::iterator Cur;
75 // Next doubles as a pointer to the next valid instruction (if any), 76 // Next doubles as a pointer to the next valid instruction (if any),
76 // and the new-instruction insertion point. It is also updated for 77 // and the new-instruction insertion point. It is also updated for
77 // the caller in case the lowering consumes more than one high-level 78 // the caller in case the lowering consumes more than one high-level
78 // instruction. It is guaranteed to point to a non-deleted 79 // instruction. It is guaranteed to point to a non-deleted
79 // instruction after Cur, or to be End. TODO: Consider separating 80 // instruction after Cur, or to be End. TODO: Consider separating
80 // the notion of "next valid instruction" and "new instruction 81 // the notion of "next valid instruction" and "new instruction
81 // insertion point", to avoid confusion when previously-deleted 82 // insertion point", to avoid confusion when previously-deleted
82 // instructions come between the two points. 83 // instructions come between the two points.
83 InstList::iterator Next; 84 InstList::iterator Next;
84 // Begin is a copy of Insts.begin(), used if iterators are moved backward. 85 // Begin is a copy of Insts.begin(), used if iterators are moved backward.
85 InstList::iterator Begin; 86 InstList::iterator Begin;
86 // End is a copy of Insts.end(), used if Next needs to be advanced. 87 // End is a copy of Insts.end(), used if Next needs to be advanced.
87 InstList::iterator End; 88 InstList::iterator End;
88 89
89 void skipDeleted(InstList::iterator &I) const; 90 void skipDeleted(InstList::iterator &I) const;
90 void advanceForward(InstList::iterator &I) const; 91 void advanceForward(InstList::iterator &I) const;
91 void advanceBackward(InstList::iterator &I) const;
92 }; 92 };
93 93
94 class TargetLowering { 94 class TargetLowering {
95 TargetLowering(const TargetLowering &) = delete; 95 TargetLowering(const TargetLowering &) = delete;
96 TargetLowering &operator=(const TargetLowering &) = delete; 96 TargetLowering &operator=(const TargetLowering &) = delete;
97 97
98 public: 98 public:
99 static TargetLowering *createLowering(TargetArch Target, Cfg *Func); 99 static TargetLowering *createLowering(TargetArch Target, Cfg *Func);
100 static Assembler *createAssembler(TargetArch Target, Cfg *Func); 100 static Assembler *createAssembler(TargetArch Target, Cfg *Func);
101 void translate() { 101 void translate() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void lower(); 138 void lower();
139 // Tries to do branch optimization on a single instruction. Returns 139 // Tries to do branch optimization on a single instruction. Returns
140 // true if some optimization was done. 140 // true if some optimization was done.
141 virtual bool doBranchOpt(Inst * /*I*/, const CfgNode * /*NextNode*/) { 141 virtual bool doBranchOpt(Inst * /*I*/, const CfgNode * /*NextNode*/) {
142 return false; 142 return false;
143 } 143 }
144 144
145 // Returns a variable pre-colored to the specified physical 145 // Returns a variable pre-colored to the specified physical
146 // register. This is generally used to get very direct access to 146 // register. This is generally used to get very direct access to
147 // the register such as in the prolog or epilog or for marking 147 // the register such as in the prolog or epilog or for marking
148 // scratch registers as killed by a call. 148 // scratch registers as killed by a call. If a Type is not
149 virtual Variable *getPhysicalRegister(SizeT RegNum) = 0; 149 // provided, a target-specific default type is used.
150 virtual Variable *getPhysicalRegister(SizeT RegNum,
151 Type Ty = IceType_void) = 0;
150 // Returns a printable name for the register. 152 // Returns a printable name for the register.
151 virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0; 153 virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0;
152 154
153 virtual bool hasFramePointer() const { return false; } 155 virtual bool hasFramePointer() const { return false; }
154 virtual SizeT getFrameOrStackReg() const = 0; 156 virtual SizeT getFrameOrStackReg() const = 0;
155 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; 157 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0;
156 virtual SizeT getBundleAlignLog2Bytes() const = 0; 158 virtual SizeT getBundleAlignLog2Bytes() const = 0;
157 virtual llvm::ArrayRef<AsmCodeByte> getNonExecBundlePadding() const = 0; 159 virtual llvm::ArrayRef<AsmCodeByte> getNonExecBundlePadding() const = 0;
158 bool hasComputedFrame() const { return HasComputedFrame; } 160 bool hasComputedFrame() const { return HasComputedFrame; }
159 bool shouldDoNopInsertion() const; 161 bool shouldDoNopInsertion() const;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 virtual void lower(const VariableDeclaration &Var) = 0; 257 virtual void lower(const VariableDeclaration &Var) = 0;
256 258
257 protected: 259 protected:
258 TargetGlobalInitLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 260 TargetGlobalInitLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
259 GlobalContext *Ctx; 261 GlobalContext *Ctx;
260 }; 262 };
261 263
262 } // end of namespace Ice 264 } // end of namespace Ice
263 265
264 #endif // SUBZERO_SRC_ICETARGETLOWERING_H 266 #endif // SUBZERO_SRC_ICETARGETLOWERING_H
OLDNEW
« no previous file with comments | « src/IceInstX8632.h ('k') | src/IceTargetLowering.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698