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