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

Side by Side Diff: src/IceTargetLowering.h

Issue 1216963007: Doxygenize the documentation comments (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 5 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
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, LoweringContext, and 10 // This file declares the TargetLowering, LoweringContext, and
(...skipping 10 matching lines...) Expand all
21 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H 21 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H
22 #define SUBZERO_SRC_ICETARGETLOWERING_H 22 #define SUBZERO_SRC_ICETARGETLOWERING_H
23 23
24 #include "IceDefs.h" 24 #include "IceDefs.h"
25 #include "IceInst.h" // for the names of the Inst subtypes 25 #include "IceInst.h" // for the names of the Inst subtypes
26 #include "IceOperand.h" 26 #include "IceOperand.h"
27 #include "IceTypes.h" 27 #include "IceTypes.h"
28 28
29 namespace Ice { 29 namespace Ice {
30 30
31 // LoweringContext makes it easy to iterate through non-deleted 31 /// LoweringContext makes it easy to iterate through non-deleted
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() = default; 42 LoweringContext() = default;
43 ~LoweringContext() = default; 43 ~LoweringContext() = default;
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)
(...skipping 12 matching lines...) Expand all
59 InstList::iterator getNext() const { return Next; } 59 InstList::iterator getNext() const { return Next; }
60 InstList::iterator getEnd() const { return End; } 60 InstList::iterator getEnd() const { return End; }
61 void insert(Inst *Inst); 61 void insert(Inst *Inst);
62 Inst *getLastInserted() const; 62 Inst *getLastInserted() const;
63 void advanceCur() { Cur = Next; } 63 void advanceCur() { Cur = Next; }
64 void advanceNext() { advanceForward(Next); } 64 void advanceNext() { advanceForward(Next); }
65 void rewind(); 65 void rewind();
66 void setInsertPoint(const InstList::iterator &Position) { Next = Position; } 66 void setInsertPoint(const InstList::iterator &Position) { Next = Position; }
67 67
68 private: 68 private:
69 // Node is the argument to Inst::updateVars(). 69 /// Node is the argument to Inst::updateVars().
70 CfgNode *Node = nullptr; 70 CfgNode *Node = nullptr;
71 Inst *LastInserted = nullptr; 71 Inst *LastInserted = nullptr;
72 // Cur points to the current instruction being considered. It is 72 /// Cur points to the current instruction being considered. It is
73 // guaranteed to point to a non-deleted instruction, or to be End. 73 /// guaranteed to point to a non-deleted instruction, or to be End.
74 InstList::iterator Cur; 74 InstList::iterator Cur;
75 // Next doubles as a pointer to the next valid instruction (if any), 75 /// Next doubles as a pointer to the next valid instruction (if any),
76 // and the new-instruction insertion point. It is also updated for 76 /// and the new-instruction insertion point. It is also updated for
77 // the caller in case the lowering consumes more than one high-level 77 /// the caller in case the lowering consumes more than one high-level
78 // instruction. It is guaranteed to point to a non-deleted 78 /// instruction. It is guaranteed to point to a non-deleted
79 // instruction after Cur, or to be End. TODO: Consider separating 79 /// instruction after Cur, or to be End. TODO: Consider separating
80 // the notion of "next valid instruction" and "new instruction 80 /// the notion of "next valid instruction" and "new instruction
81 // insertion point", to avoid confusion when previously-deleted 81 /// insertion point", to avoid confusion when previously-deleted
82 // instructions come between the two points. 82 /// instructions come between the two points.
83 InstList::iterator Next; 83 InstList::iterator Next;
84 // Begin is a copy of Insts.begin(), used if iterators are moved backward. 84 /// Begin is a copy of Insts.begin(), used if iterators are moved backward.
85 InstList::iterator Begin; 85 InstList::iterator Begin;
86 // End is a copy of Insts.end(), used if Next needs to be advanced. 86 /// End is a copy of Insts.end(), used if Next needs to be advanced.
87 InstList::iterator End; 87 InstList::iterator End;
88 88
89 void skipDeleted(InstList::iterator &I) const; 89 void skipDeleted(InstList::iterator &I) const;
90 void advanceForward(InstList::iterator &I) const; 90 void advanceForward(InstList::iterator &I) const;
91 }; 91 };
92 92
93 class TargetLowering { 93 class TargetLowering {
94 TargetLowering() = delete; 94 TargetLowering() = delete;
95 TargetLowering(const TargetLowering &) = delete; 95 TargetLowering(const TargetLowering &) = delete;
96 TargetLowering &operator=(const TargetLowering &) = delete; 96 TargetLowering &operator=(const TargetLowering &) = delete;
(...skipping 25 matching lines...) Expand all
122 virtual void translateO0() { 122 virtual void translateO0() {
123 Func->setError("Target doesn't specify O0 lowering steps."); 123 Func->setError("Target doesn't specify O0 lowering steps.");
124 } 124 }
125 virtual void translateO1() { 125 virtual void translateO1() {
126 Func->setError("Target doesn't specify O1 lowering steps."); 126 Func->setError("Target doesn't specify O1 lowering steps.");
127 } 127 }
128 virtual void translateO2() { 128 virtual void translateO2() {
129 Func->setError("Target doesn't specify O2 lowering steps."); 129 Func->setError("Target doesn't specify O2 lowering steps.");
130 } 130 }
131 131
132 // Tries to do address mode optimization on a single instruction. 132 /// Tries to do address mode optimization on a single instruction.
133 void doAddressOpt(); 133 void doAddressOpt();
134 // Randomly insert NOPs. 134 /// Randomly insert NOPs.
135 void doNopInsertion(); 135 void doNopInsertion();
136 // Lowers a single non-Phi instruction. 136 /// Lowers a single non-Phi instruction.
137 void lower(); 137 void lower();
138 // Does preliminary lowering of the set of Phi instructions in the 138 /// Does preliminary lowering of the set of Phi instructions in the
139 // current node. The main intention is to do what's needed to keep 139 /// current node. The main intention is to do what's needed to keep
140 // the unlowered Phi instructions consistent with the lowered 140 /// the unlowered Phi instructions consistent with the lowered
141 // non-Phi instructions, e.g. to lower 64-bit operands on a 32-bit 141 /// non-Phi instructions, e.g. to lower 64-bit operands on a 32-bit
142 // target. 142 /// target.
143 virtual void prelowerPhis() {} 143 virtual void prelowerPhis() {}
144 // Lowers a list of "parallel" assignment instructions representing 144 /// Lowers a list of "parallel" assignment instructions representing
145 // a topological sort of the Phi instructions. 145 /// a topological sort of the Phi instructions.
146 virtual void lowerPhiAssignments(CfgNode *Node, 146 virtual void lowerPhiAssignments(CfgNode *Node,
147 const AssignList &Assignments) = 0; 147 const AssignList &Assignments) = 0;
148 // Tries to do branch optimization on a single instruction. Returns 148 /// Tries to do branch optimization on a single instruction. Returns
149 // true if some optimization was done. 149 /// true if some optimization was done.
150 virtual bool doBranchOpt(Inst * /*I*/, const CfgNode * /*NextNode*/) { 150 virtual bool doBranchOpt(Inst * /*I*/, const CfgNode * /*NextNode*/) {
151 return false; 151 return false;
152 } 152 }
153 153
154 virtual SizeT getNumRegisters() const = 0; 154 virtual SizeT getNumRegisters() const = 0;
155 // Returns a variable pre-colored to the specified physical 155 /// Returns a variable pre-colored to the specified physical
156 // register. This is generally used to get very direct access to 156 /// register. This is generally used to get very direct access to
157 // the register such as in the prolog or epilog or for marking 157 /// the register such as in the prolog or epilog or for marking
158 // scratch registers as killed by a call. If a Type is not 158 /// scratch registers as killed by a call. If a Type is not
159 // provided, a target-specific default type is used. 159 /// provided, a target-specific default type is used.
160 virtual Variable *getPhysicalRegister(SizeT RegNum, 160 virtual Variable *getPhysicalRegister(SizeT RegNum,
161 Type Ty = IceType_void) = 0; 161 Type Ty = IceType_void) = 0;
162 // Returns a printable name for the register. 162 /// Returns a printable name for the register.
163 virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0; 163 virtual IceString getRegName(SizeT RegNum, Type Ty) const = 0;
164 164
165 virtual bool hasFramePointer() const { return false; } 165 virtual bool hasFramePointer() const { return false; }
166 virtual SizeT getFrameOrStackReg() const = 0; 166 virtual SizeT getFrameOrStackReg() const = 0;
167 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0; 167 virtual size_t typeWidthInBytesOnStack(Type Ty) const = 0;
168 168
169 bool hasComputedFrame() const { return HasComputedFrame; } 169 bool hasComputedFrame() const { return HasComputedFrame; }
170 // Returns true if this function calls a function that has the 170 /// Returns true if this function calls a function that has the
171 // "returns twice" attribute. 171 /// "returns twice" attribute.
172 bool callsReturnsTwice() const { return CallsReturnsTwice; } 172 bool callsReturnsTwice() const { return CallsReturnsTwice; }
173 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } 173 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; }
174 int32_t getStackAdjustment() const { return StackAdjustment; } 174 int32_t getStackAdjustment() const { return StackAdjustment; }
175 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } 175 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; }
176 void resetStackAdjustment() { StackAdjustment = 0; } 176 void resetStackAdjustment() { StackAdjustment = 0; }
177 SizeT makeNextLabelNumber() { return NextLabelNumber++; } 177 SizeT makeNextLabelNumber() { return NextLabelNumber++; }
178 LoweringContext &getContext() { return Context; } 178 LoweringContext &getContext() { return Context; }
179 179
180 enum RegSet { 180 enum RegSet {
181 RegSet_None = 0, 181 RegSet_None = 0,
182 RegSet_CallerSave = 1 << 0, 182 RegSet_CallerSave = 1 << 0,
183 RegSet_CalleeSave = 1 << 1, 183 RegSet_CalleeSave = 1 << 1,
184 RegSet_StackPointer = 1 << 2, 184 RegSet_StackPointer = 1 << 2,
185 RegSet_FramePointer = 1 << 3, 185 RegSet_FramePointer = 1 << 3,
186 RegSet_All = ~RegSet_None 186 RegSet_All = ~RegSet_None
187 }; 187 };
188 typedef uint32_t RegSetMask; 188 typedef uint32_t RegSetMask;
189 189
190 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, 190 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include,
191 RegSetMask Exclude) const = 0; 191 RegSetMask Exclude) const = 0;
192 virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const = 0; 192 virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const = 0;
193 void regAlloc(RegAllocKind Kind); 193 void regAlloc(RegAllocKind Kind);
194 194
195 virtual void makeRandomRegisterPermutation( 195 virtual void makeRandomRegisterPermutation(
196 llvm::SmallVectorImpl<int32_t> &Permutation, 196 llvm::SmallVectorImpl<int32_t> &Permutation,
197 const llvm::SmallBitVector &ExcludeRegisters) const = 0; 197 const llvm::SmallBitVector &ExcludeRegisters) const = 0;
198 198
199 // Save/restore any mutable state for the situation where code 199 /// Save/restore any mutable state for the situation where code
200 // emission needs multiple passes, such as sandboxing or relaxation. 200 /// emission needs multiple passes, such as sandboxing or relaxation.
201 // Subclasses may provide their own implementation, but should be 201 /// Subclasses may provide their own implementation, but should be
202 // sure to also call the parent class's methods. 202 /// sure to also call the parent class's methods.
203 virtual void snapshotEmitState() { 203 virtual void snapshotEmitState() {
204 SnapshotStackAdjustment = StackAdjustment; 204 SnapshotStackAdjustment = StackAdjustment;
205 } 205 }
206 virtual void rollbackEmitState() { 206 virtual void rollbackEmitState() {
207 StackAdjustment = SnapshotStackAdjustment; 207 StackAdjustment = SnapshotStackAdjustment;
208 } 208 }
209 209
210 virtual void emitVariable(const Variable *Var) const = 0; 210 virtual void emitVariable(const Variable *Var) const = 0;
211 211
212 void emitWithoutPrefix(const ConstantRelocatable *CR) const; 212 void emitWithoutPrefix(const ConstantRelocatable *CR) const;
213 void emit(const ConstantRelocatable *CR) const; 213 void emit(const ConstantRelocatable *CR) const;
214 virtual const char *getConstantPrefix() const = 0; 214 virtual const char *getConstantPrefix() const = 0;
215 215
216 virtual void emit(const ConstantUndef *C) const = 0; 216 virtual void emit(const ConstantUndef *C) const = 0;
217 virtual void emit(const ConstantInteger32 *C) const = 0; 217 virtual void emit(const ConstantInteger32 *C) const = 0;
218 virtual void emit(const ConstantInteger64 *C) const = 0; 218 virtual void emit(const ConstantInteger64 *C) const = 0;
219 virtual void emit(const ConstantFloat *C) const = 0; 219 virtual void emit(const ConstantFloat *C) const = 0;
220 virtual void emit(const ConstantDouble *C) const = 0; 220 virtual void emit(const ConstantDouble *C) const = 0;
221 221
222 // Performs target-specific argument lowering. 222 /// Performs target-specific argument lowering.
223 virtual void lowerArguments() = 0; 223 virtual void lowerArguments() = 0;
224 224
225 virtual void initNodeForLowering(CfgNode *) {} 225 virtual void initNodeForLowering(CfgNode *) {}
226 virtual void addProlog(CfgNode *Node) = 0; 226 virtual void addProlog(CfgNode *Node) = 0;
227 virtual void addEpilog(CfgNode *Node) = 0; 227 virtual void addEpilog(CfgNode *Node) = 0;
228 228
229 virtual ~TargetLowering() = default; 229 virtual ~TargetLowering() = default;
230 230
231 protected: 231 protected:
232 explicit TargetLowering(Cfg *Func); 232 explicit TargetLowering(Cfg *Func);
(...skipping 13 matching lines...) Expand all
246 virtual void lowerRet(const InstRet *Inst) = 0; 246 virtual void lowerRet(const InstRet *Inst) = 0;
247 virtual void lowerSelect(const InstSelect *Inst) = 0; 247 virtual void lowerSelect(const InstSelect *Inst) = 0;
248 virtual void lowerStore(const InstStore *Inst) = 0; 248 virtual void lowerStore(const InstStore *Inst) = 0;
249 virtual void lowerSwitch(const InstSwitch *Inst) = 0; 249 virtual void lowerSwitch(const InstSwitch *Inst) = 0;
250 virtual void lowerUnreachable(const InstUnreachable *Inst) = 0; 250 virtual void lowerUnreachable(const InstUnreachable *Inst) = 0;
251 virtual void lowerOther(const Inst *Instr); 251 virtual void lowerOther(const Inst *Instr);
252 252
253 virtual void doAddressOptLoad() {} 253 virtual void doAddressOptLoad() {}
254 virtual void doAddressOptStore() {} 254 virtual void doAddressOptStore() {}
255 virtual void randomlyInsertNop(float Probability) = 0; 255 virtual void randomlyInsertNop(float Probability) = 0;
256 // This gives the target an opportunity to post-process the lowered 256 /// This gives the target an opportunity to post-process the lowered
257 // expansion before returning. 257 /// expansion before returning.
258 virtual void postLower() {} 258 virtual void postLower() {}
259 259
260 // Find two-address non-SSA instructions and set the DestNonKillable flag 260 /// Find two-address non-SSA instructions and set the DestNonKillable flag
261 // to keep liveness analysis consistent. 261 /// to keep liveness analysis consistent.
262 void inferTwoAddress(); 262 void inferTwoAddress();
263 263
264 // Make a pass over the Cfg to determine which variables need stack slots 264 /// Make a pass over the Cfg to determine which variables need stack slots
265 // and place them in a sorted list (SortedSpilledVariables). Among those, 265 /// and place them in a sorted list (SortedSpilledVariables). Among those,
266 // vars, classify the spill variables as local to the basic block vs 266 /// vars, classify the spill variables as local to the basic block vs
267 // global (multi-block) in order to compute the parameters GlobalsSize 267 /// global (multi-block) in order to compute the parameters GlobalsSize
268 // and SpillAreaSizeBytes (represents locals or general vars if the 268 /// and SpillAreaSizeBytes (represents locals or general vars if the
269 // coalescing of locals is disallowed) along with alignments required 269 /// coalescing of locals is disallowed) along with alignments required
270 // for variables in each area. We rely on accurate VMetadata in order to 270 /// for variables in each area. We rely on accurate VMetadata in order to
271 // classify a variable as global vs local (otherwise the variable is 271 /// classify a variable as global vs local (otherwise the variable is
272 // conservatively global). The in-args should be initialized to 0. 272 /// conservatively global). The in-args should be initialized to 0.
273 // 273 ///
274 // This is only a pre-pass and the actual stack slot assignment is 274 /// This is only a pre-pass and the actual stack slot assignment is
275 // handled separately. 275 /// handled separately.
276 // 276 ///
277 // There may be target-specific Variable types, which will be handled 277 /// There may be target-specific Variable types, which will be handled
278 // by TargetVarHook. If the TargetVarHook returns true, then the variable 278 /// by TargetVarHook. If the TargetVarHook returns true, then the variable
279 // is skipped and not considered with the rest of the spilled variables. 279 /// is skipped and not considered with the rest of the spilled variables.
280 void getVarStackSlotParams(VarList &SortedSpilledVariables, 280 void getVarStackSlotParams(VarList &SortedSpilledVariables,
281 llvm::SmallBitVector &RegsUsed, 281 llvm::SmallBitVector &RegsUsed,
282 size_t *GlobalsSize, size_t *SpillAreaSizeBytes, 282 size_t *GlobalsSize, size_t *SpillAreaSizeBytes,
283 uint32_t *SpillAreaAlignmentBytes, 283 uint32_t *SpillAreaAlignmentBytes,
284 uint32_t *LocalsSlotsAlignmentBytes, 284 uint32_t *LocalsSlotsAlignmentBytes,
285 std::function<bool(Variable *)> TargetVarHook); 285 std::function<bool(Variable *)> TargetVarHook);
286 286
287 // Calculate the amount of padding needed to align the local and global 287 /// Calculate the amount of padding needed to align the local and global
288 // areas to the required alignment. This assumes the globals/locals layout 288 /// areas to the required alignment. This assumes the globals/locals layout
289 // used by getVarStackSlotParams and assignVarStackSlots. 289 /// used by getVarStackSlotParams and assignVarStackSlots.
290 void alignStackSpillAreas(uint32_t SpillAreaStartOffset, 290 void alignStackSpillAreas(uint32_t SpillAreaStartOffset,
291 uint32_t SpillAreaAlignmentBytes, 291 uint32_t SpillAreaAlignmentBytes,
292 size_t GlobalsSize, 292 size_t GlobalsSize,
293 uint32_t LocalsSlotsAlignmentBytes, 293 uint32_t LocalsSlotsAlignmentBytes,
294 uint32_t *SpillAreaPaddingBytes, 294 uint32_t *SpillAreaPaddingBytes,
295 uint32_t *LocalsSlotsPaddingBytes); 295 uint32_t *LocalsSlotsPaddingBytes);
296 296
297 // Make a pass through the SortedSpilledVariables and actually assign 297 /// Make a pass through the SortedSpilledVariables and actually assign
298 // stack slots. SpillAreaPaddingBytes takes into account stack alignment 298 /// stack slots. SpillAreaPaddingBytes takes into account stack alignment
299 // padding. The SpillArea starts after that amount of padding. 299 /// padding. The SpillArea starts after that amount of padding.
300 // This matches the scheme in getVarStackSlotParams, where there may 300 /// This matches the scheme in getVarStackSlotParams, where there may
301 // be a separate multi-block global var spill area and a local var 301 /// be a separate multi-block global var spill area and a local var
302 // spill area. 302 /// spill area.
303 void assignVarStackSlots(VarList &SortedSpilledVariables, 303 void assignVarStackSlots(VarList &SortedSpilledVariables,
304 size_t SpillAreaPaddingBytes, 304 size_t SpillAreaPaddingBytes,
305 size_t SpillAreaSizeBytes, 305 size_t SpillAreaSizeBytes,
306 size_t GlobalsAndSubsequentPaddingSize, 306 size_t GlobalsAndSubsequentPaddingSize,
307 bool UsesFramePointer); 307 bool UsesFramePointer);
308 308
309 // Sort the variables in Source based on required alignment. 309 /// Sort the variables in Source based on required alignment.
310 // The variables with the largest alignment need are placed in the front 310 /// The variables with the largest alignment need are placed in the front
311 // of the Dest list. 311 /// of the Dest list.
312 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const; 312 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const;
313 313
314 // Make a call to an external helper function. 314 /// Make a call to an external helper function.
315 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, 315 InstCall *makeHelperCall(const IceString &Name, Variable *Dest,
316 SizeT MaxSrcs); 316 SizeT MaxSrcs);
317 317
318 void 318 void
319 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) { 319 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) {
320 Context.insert(InstBundleLock::create(Func, BundleOption)); 320 Context.insert(InstBundleLock::create(Func, BundleOption));
321 } 321 }
322 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); } 322 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); }
323 323
324 Cfg *Func; 324 Cfg *Func;
325 GlobalContext *Ctx; 325 GlobalContext *Ctx;
326 bool HasComputedFrame = false; 326 bool HasComputedFrame = false;
327 bool CallsReturnsTwice = false; 327 bool CallsReturnsTwice = false;
328 // StackAdjustment keeps track of the current stack offset from its 328 /// StackAdjustment keeps track of the current stack offset from its
329 // natural location, as arguments are pushed for a function call. 329 /// natural location, as arguments are pushed for a function call.
330 int32_t StackAdjustment = 0; 330 int32_t StackAdjustment = 0;
331 SizeT NextLabelNumber = 0; 331 SizeT NextLabelNumber = 0;
332 LoweringContext Context; 332 LoweringContext Context;
333 333
334 // Runtime helper function names 334 // Runtime helper function names
335 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; 335 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16";
336 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; 336 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8";
337 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; 337 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1";
338 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; 338 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1";
339 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; 339 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2";
(...skipping 22 matching lines...) Expand all
362 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32"; 362 const static constexpr char *H_uitofp_i32_f32 = "__Sz_uitofp_i32_f32";
363 const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64"; 363 const static constexpr char *H_uitofp_i32_f64 = "__Sz_uitofp_i32_f64";
364 const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32"; 364 const static constexpr char *H_uitofp_i64_f32 = "__Sz_uitofp_i64_f32";
365 const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64"; 365 const static constexpr char *H_uitofp_i64_f64 = "__Sz_uitofp_i64_f64";
366 const static constexpr char *H_urem_i64 = "__umoddi3"; 366 const static constexpr char *H_urem_i64 = "__umoddi3";
367 367
368 private: 368 private:
369 int32_t SnapshotStackAdjustment = 0; 369 int32_t SnapshotStackAdjustment = 0;
370 }; 370 };
371 371
372 // TargetDataLowering is used for "lowering" data including initializers 372 /// TargetDataLowering is used for "lowering" data including initializers
373 // for global variables, and the internal constant pools. It is separated 373 /// for global variables, and the internal constant pools. It is separated
374 // out from TargetLowering because it does not require a Cfg. 374 /// out from TargetLowering because it does not require a Cfg.
375 class TargetDataLowering { 375 class TargetDataLowering {
376 TargetDataLowering() = delete; 376 TargetDataLowering() = delete;
377 TargetDataLowering(const TargetDataLowering &) = delete; 377 TargetDataLowering(const TargetDataLowering &) = delete;
378 TargetDataLowering &operator=(const TargetDataLowering &) = delete; 378 TargetDataLowering &operator=(const TargetDataLowering &) = delete;
379 379
380 public: 380 public:
381 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); 381 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx);
382 virtual ~TargetDataLowering(); 382 virtual ~TargetDataLowering();
383 383
384 virtual void lowerGlobals(const VariableDeclarationList &Vars, 384 virtual void lowerGlobals(const VariableDeclarationList &Vars,
385 const IceString &SectionSuffix) = 0; 385 const IceString &SectionSuffix) = 0;
386 virtual void lowerConstants() = 0; 386 virtual void lowerConstants() = 0;
387 387
388 protected: 388 protected:
389 void emitGlobal(const VariableDeclaration &Var, 389 void emitGlobal(const VariableDeclaration &Var,
390 const IceString &SectionSuffix); 390 const IceString &SectionSuffix);
391 391
392 // For now, we assume .long is the right directive for emitting 4 byte 392 /// For now, we assume .long is the right directive for emitting 4 byte
393 // emit global relocations. However, LLVM MIPS usually uses .4byte instead. 393 /// emit global relocations. However, LLVM MIPS usually uses .4byte instead.
394 // Perhaps there is some difference when the location is unaligned. 394 /// Perhaps there is some difference when the location is unaligned.
395 static const char *getEmit32Directive() { return ".long"; } 395 static const char *getEmit32Directive() { return ".long"; }
396 396
397 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 397 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
398 GlobalContext *Ctx; 398 GlobalContext *Ctx;
399 }; 399 };
400 400
401 // TargetHeaderLowering is used to "lower" the header of an output file. 401 /// TargetHeaderLowering is used to "lower" the header of an output file.
402 // It writes out the target-specific header attributes. E.g., for ARM 402 /// It writes out the target-specific header attributes. E.g., for ARM
403 // this writes out the build attributes (float ABI, etc.). 403 /// this writes out the build attributes (float ABI, etc.).
404 class TargetHeaderLowering { 404 class TargetHeaderLowering {
405 TargetHeaderLowering() = delete; 405 TargetHeaderLowering() = delete;
406 TargetHeaderLowering(const TargetHeaderLowering &) = delete; 406 TargetHeaderLowering(const TargetHeaderLowering &) = delete;
407 TargetHeaderLowering &operator=(const TargetHeaderLowering &) = delete; 407 TargetHeaderLowering &operator=(const TargetHeaderLowering &) = delete;
408 408
409 public: 409 public:
410 static std::unique_ptr<TargetHeaderLowering> 410 static std::unique_ptr<TargetHeaderLowering>
411 createLowering(GlobalContext *Ctx); 411 createLowering(GlobalContext *Ctx);
412 virtual ~TargetHeaderLowering(); 412 virtual ~TargetHeaderLowering();
413 413
414 virtual void lower() {} 414 virtual void lower() {}
415 415
416 protected: 416 protected:
417 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} 417 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {}
418 GlobalContext *Ctx; 418 GlobalContext *Ctx;
419 }; 419 };
420 420
421 } // end of namespace Ice 421 } // end of namespace Ice
422 422
423 #endif // SUBZERO_SRC_ICETARGETLOWERING_H 423 #endif // SUBZERO_SRC_ICETARGETLOWERING_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698