OLD | NEW |
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool hasComputedFrame() const { return HasComputedFrame; } | 169 bool hasComputedFrame() const { return HasComputedFrame; } |
169 // Returns true if this function calls a function that has the | 170 // Returns true if this function calls a function that has the |
170 // "returns twice" attribute. | 171 // "returns twice" attribute. |
171 bool callsReturnsTwice() const { return CallsReturnsTwice; } | 172 bool callsReturnsTwice() const { return CallsReturnsTwice; } |
172 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } | 173 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } |
173 int32_t getStackAdjustment() const { return StackAdjustment; } | 174 int32_t getStackAdjustment() const { return StackAdjustment; } |
174 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } | 175 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } |
175 void resetStackAdjustment() { StackAdjustment = 0; } | 176 void resetStackAdjustment() { StackAdjustment = 0; } |
176 SizeT makeNextLabelNumber() { return NextLabelNumber++; } | 177 SizeT makeNextLabelNumber() { return NextLabelNumber++; } |
177 LoweringContext &getContext() { return Context; } | 178 LoweringContext &getContext() { return Context; } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 virtual void doAddressOptStore() {} | 253 virtual void doAddressOptStore() {} |
253 virtual void randomlyInsertNop(float Probability) = 0; | 254 virtual void randomlyInsertNop(float Probability) = 0; |
254 // This gives the target an opportunity to post-process the lowered | 255 // This gives the target an opportunity to post-process the lowered |
255 // expansion before returning. | 256 // expansion before returning. |
256 virtual void postLower() {} | 257 virtual void postLower() {} |
257 | 258 |
258 // Find two-address non-SSA instructions and set the DestNonKillable flag | 259 // Find two-address non-SSA instructions and set the DestNonKillable flag |
259 // to keep liveness analysis consistent. | 260 // to keep liveness analysis consistent. |
260 void inferTwoAddress(); | 261 void inferTwoAddress(); |
261 | 262 |
| 263 // Make a pass over the Cfg to determine which variables need stack slots |
| 264 // and place them in a sorted list (SortedSpilledVariables). Among those, |
| 265 // vars, classify the spill variables as local to the basic block vs |
| 266 // global (multi-block) in order to compute the parameters GlobalsSize |
| 267 // and SpillAreaSizeBytes (represents locals or general vars if the |
| 268 // coalescing of locals is disallowed) along with alignments required |
| 269 // for variables in each area. We rely on accurate VMetadata in order to |
| 270 // classify a variable as global vs local (otherwise the variable is |
| 271 // conservatively global). The in-args should be initialized to 0. |
| 272 // |
| 273 // This is only a pre-pass and the actual stack slot assignment is |
| 274 // handled separately. |
| 275 // |
| 276 // There may be target-specific Variable types, which will be handled |
| 277 // by TargetVarHook. If the TargetVarHook returns true, then the variable |
| 278 // is skipped and not considered with the rest of the spilled variables. |
| 279 void getVarStackSlotParams(VarList &SortedSpilledVariables, |
| 280 llvm::SmallBitVector &RegsUsed, |
| 281 size_t *GlobalsSize, size_t *SpillAreaSizeBytes, |
| 282 uint32_t *SpillAreaAlignmentBytes, |
| 283 uint32_t *LocalsSlotsAlignmentBytes, |
| 284 std::function<bool(Variable *)> TargetVarHook); |
| 285 |
| 286 // Calculate the amount of padding needed to align the local and global |
| 287 // areas to the required alignment. This assumes the globals/locals layout |
| 288 // used by getVarStackSlotParams and assignVarStackSlots. |
| 289 void alignStackSpillAreas(uint32_t SpillAreaStartOffset, |
| 290 uint32_t SpillAreaAlignmentBytes, |
| 291 size_t GlobalsSize, |
| 292 uint32_t LocalsSlotsAlignmentBytes, |
| 293 uint32_t *SpillAreaPaddingBytes, |
| 294 uint32_t *LocalsSlotsPaddingBytes); |
| 295 |
| 296 // Make a pass through the SortedSpilledVariables and actually assign |
| 297 // stack slots. SpillAreaPaddingBytes takes into account stack alignment |
| 298 // padding. The SpillArea starts after that amount of padding. |
| 299 // This matches the scheme in getVarStackSlotParams, where there may |
| 300 // be a separate multi-block global var spill area and a local var |
| 301 // spill area. |
| 302 void assignVarStackSlots(VarList &SortedSpilledVariables, |
| 303 size_t SpillAreaPaddingBytes, |
| 304 size_t SpillAreaSizeBytes, |
| 305 size_t GlobalsAndSubsequentPaddingSize, |
| 306 bool UsesFramePointer); |
| 307 |
| 308 // Sort the variables in Source based on required alignment. |
| 309 // The variables with the largest alignment need are placed in the front |
| 310 // of the Dest list. |
| 311 void sortVarsByAlignment(VarList &Dest, const VarList &Source) const; |
| 312 |
262 // Make a call to an external helper function. | 313 // Make a call to an external helper function. |
263 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, | 314 InstCall *makeHelperCall(const IceString &Name, Variable *Dest, |
264 SizeT MaxSrcs); | 315 SizeT MaxSrcs); |
265 | 316 |
| 317 void |
| 318 _bundle_lock(InstBundleLock::Option BundleOption = InstBundleLock::Opt_None) { |
| 319 Context.insert(InstBundleLock::create(Func, BundleOption)); |
| 320 } |
| 321 void _bundle_unlock() { Context.insert(InstBundleUnlock::create(Func)); } |
| 322 |
266 Cfg *Func; | 323 Cfg *Func; |
267 GlobalContext *Ctx; | 324 GlobalContext *Ctx; |
268 bool HasComputedFrame; | 325 bool HasComputedFrame; |
269 bool CallsReturnsTwice; | 326 bool CallsReturnsTwice; |
270 // StackAdjustment keeps track of the current stack offset from its | 327 // StackAdjustment keeps track of the current stack offset from its |
271 // natural location, as arguments are pushed for a function call. | 328 // natural location, as arguments are pushed for a function call. |
272 int32_t StackAdjustment; | 329 int32_t StackAdjustment; |
273 SizeT NextLabelNumber; | 330 SizeT NextLabelNumber; |
274 LoweringContext Context; | 331 LoweringContext Context; |
275 | 332 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 virtual void lowerConstants() const = 0; | 385 virtual void lowerConstants() const = 0; |
329 | 386 |
330 protected: | 387 protected: |
331 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 388 explicit TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
332 GlobalContext *Ctx; | 389 GlobalContext *Ctx; |
333 }; | 390 }; |
334 | 391 |
335 } // end of namespace Ice | 392 } // end of namespace Ice |
336 | 393 |
337 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 394 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |