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 /// \file | 10 /// \file |
11 /// \brief Declares the TargetLowering, LoweringContext, and TargetDataLowering | 11 /// \brief Declares the TargetLowering, LoweringContext, and TargetDataLowering |
12 /// classes. | 12 /// classes. |
13 /// | 13 /// |
14 /// TargetLowering is an abstract class used to drive the translation/lowering | 14 /// TargetLowering is an abstract class used to drive the translation/lowering |
15 /// process. LoweringContext maintains a context for lowering each instruction, | 15 /// process. LoweringContext maintains a context for lowering each instruction, |
16 /// offering conveniences such as iterating over non-deleted instructions. | 16 /// offering conveniences such as iterating over non-deleted instructions. |
17 /// TargetDataLowering is an abstract class used to drive the lowering/emission | 17 /// TargetDataLowering is an abstract class used to drive the lowering/emission |
18 /// of global initializers, external global declarations, and internal constant | 18 /// of global initializers, external global declarations, and internal constant |
19 /// pools. | 19 /// pools. |
20 /// | 20 /// |
21 //===----------------------------------------------------------------------===// | 21 //===----------------------------------------------------------------------===// |
22 | 22 |
23 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H | 23 #ifndef SUBZERO_SRC_ICETARGETLOWERING_H |
24 #define SUBZERO_SRC_ICETARGETLOWERING_H | 24 #define SUBZERO_SRC_ICETARGETLOWERING_H |
25 | 25 |
| 26 #include "IceDefs.h" |
| 27 #include "IceBitVector.h" |
26 #include "IceCfgNode.h" | 28 #include "IceCfgNode.h" |
27 #include "IceDefs.h" | |
28 #include "IceInst.h" // for the names of the Inst subtypes | 29 #include "IceInst.h" // for the names of the Inst subtypes |
29 #include "IceOperand.h" | 30 #include "IceOperand.h" |
30 #include "IceTypes.h" | 31 #include "IceTypes.h" |
31 | 32 |
32 #include <utility> | 33 #include <utility> |
33 | 34 |
34 namespace Ice { | 35 namespace Ice { |
35 | 36 |
36 // UnimplementedError is defined as a macro so that we can get actual line | 37 // UnimplementedError is defined as a macro so that we can get actual line |
37 // numbers. | 38 // numbers. |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 enum RegSet { | 267 enum RegSet { |
267 RegSet_None = 0, | 268 RegSet_None = 0, |
268 RegSet_CallerSave = 1 << 0, | 269 RegSet_CallerSave = 1 << 0, |
269 RegSet_CalleeSave = 1 << 1, | 270 RegSet_CalleeSave = 1 << 1, |
270 RegSet_StackPointer = 1 << 2, | 271 RegSet_StackPointer = 1 << 2, |
271 RegSet_FramePointer = 1 << 3, | 272 RegSet_FramePointer = 1 << 3, |
272 RegSet_All = ~RegSet_None | 273 RegSet_All = ~RegSet_None |
273 }; | 274 }; |
274 using RegSetMask = uint32_t; | 275 using RegSetMask = uint32_t; |
275 | 276 |
276 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, | 277 virtual SmallBitVector getRegisterSet(RegSetMask Include, |
277 RegSetMask Exclude) const = 0; | 278 RegSetMask Exclude) const = 0; |
278 /// Get the set of physical registers available for the specified Variable's | 279 /// Get the set of physical registers available for the specified Variable's |
279 /// register class, applying register restrictions from the command line. | 280 /// register class, applying register restrictions from the command line. |
280 virtual const llvm::SmallBitVector & | 281 virtual const SmallBitVector & |
281 getRegistersForVariable(const Variable *Var) const = 0; | 282 getRegistersForVariable(const Variable *Var) const = 0; |
282 /// Get the set of *all* physical registers available for the specified | 283 /// Get the set of *all* physical registers available for the specified |
283 /// Variable's register class, *not* applying register restrictions from the | 284 /// Variable's register class, *not* applying register restrictions from the |
284 /// command line. | 285 /// command line. |
285 virtual const llvm::SmallBitVector & | 286 virtual const SmallBitVector & |
286 getAllRegistersForVariable(const Variable *Var) const = 0; | 287 getAllRegistersForVariable(const Variable *Var) const = 0; |
287 virtual const llvm::SmallBitVector &getAliasesForRegister(RegNumT) const = 0; | 288 virtual const SmallBitVector &getAliasesForRegister(RegNumT) const = 0; |
288 | 289 |
289 void regAlloc(RegAllocKind Kind); | 290 void regAlloc(RegAllocKind Kind); |
290 | 291 |
291 virtual void | 292 virtual void |
292 makeRandomRegisterPermutation(llvm::SmallVectorImpl<RegNumT> &Permutation, | 293 makeRandomRegisterPermutation(llvm::SmallVectorImpl<RegNumT> &Permutation, |
293 const llvm::SmallBitVector &ExcludeRegisters, | 294 const SmallBitVector &ExcludeRegisters, |
294 uint64_t Salt) const = 0; | 295 uint64_t Salt) const = 0; |
295 | 296 |
296 /// Get the minimum number of clusters required for a jump table to be | 297 /// Get the minimum number of clusters required for a jump table to be |
297 /// considered. | 298 /// considered. |
298 virtual SizeT getMinJumpTableSize() const = 0; | 299 virtual SizeT getMinJumpTableSize() const = 0; |
299 virtual void emitJumpTable(const Cfg *Func, | 300 virtual void emitJumpTable(const Cfg *Func, |
300 const InstJumpTable *JumpTable) const = 0; | 301 const InstJumpTable *JumpTable) const = 0; |
301 | 302 |
302 virtual void emitVariable(const Variable *Var) const = 0; | 303 virtual void emitVariable(const Variable *Var) const = 0; |
303 | 304 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 359 |
359 private: | 360 private: |
360 TargetLowering *const Target; | 361 TargetLowering *const Target; |
361 const bool NeedSandboxing; | 362 const bool NeedSandboxing; |
362 }; | 363 }; |
363 | 364 |
364 explicit TargetLowering(Cfg *Func); | 365 explicit TargetLowering(Cfg *Func); |
365 // Applies command line filters to TypeToRegisterSet array. | 366 // Applies command line filters to TypeToRegisterSet array. |
366 static void | 367 static void |
367 filterTypeToRegisterSet(GlobalContext *Ctx, int32_t NumRegs, | 368 filterTypeToRegisterSet(GlobalContext *Ctx, int32_t NumRegs, |
368 llvm::SmallBitVector TypeToRegisterSet[], | 369 SmallBitVector TypeToRegisterSet[], |
369 size_t TypeToRegisterSetSize, | 370 size_t TypeToRegisterSetSize, |
370 std::function<IceString(RegNumT)> getRegName, | 371 std::function<IceString(RegNumT)> getRegName, |
371 std::function<IceString(RegClass)> getRegClassName); | 372 std::function<IceString(RegClass)> getRegClassName); |
372 virtual void lowerAlloca(const InstAlloca *Instr) = 0; | 373 virtual void lowerAlloca(const InstAlloca *Instr) = 0; |
373 virtual void lowerArithmetic(const InstArithmetic *Instr) = 0; | 374 virtual void lowerArithmetic(const InstArithmetic *Instr) = 0; |
374 virtual void lowerAssign(const InstAssign *Instr) = 0; | 375 virtual void lowerAssign(const InstAssign *Instr) = 0; |
375 virtual void lowerBr(const InstBr *Instr) = 0; | 376 virtual void lowerBr(const InstBr *Instr) = 0; |
376 virtual void lowerCall(const InstCall *Instr) = 0; | 377 virtual void lowerCall(const InstCall *Instr) = 0; |
377 virtual void lowerCast(const InstCast *Instr) = 0; | 378 virtual void lowerCast(const InstCast *Instr) = 0; |
378 virtual void lowerFcmp(const InstFcmp *Instr) = 0; | 379 virtual void lowerFcmp(const InstFcmp *Instr) = 0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 /// global vs local (otherwise the variable is conservatively global). The | 423 /// global vs local (otherwise the variable is conservatively global). The |
423 /// in-args should be initialized to 0. | 424 /// in-args should be initialized to 0. |
424 /// | 425 /// |
425 /// This is only a pre-pass and the actual stack slot assignment is handled | 426 /// This is only a pre-pass and the actual stack slot assignment is handled |
426 /// separately. | 427 /// separately. |
427 /// | 428 /// |
428 /// There may be target-specific Variable types, which will be handled by | 429 /// There may be target-specific Variable types, which will be handled by |
429 /// TargetVarHook. If the TargetVarHook returns true, then the variable is | 430 /// TargetVarHook. If the TargetVarHook returns true, then the variable is |
430 /// skipped and not considered with the rest of the spilled variables. | 431 /// skipped and not considered with the rest of the spilled variables. |
431 void getVarStackSlotParams(VarList &SortedSpilledVariables, | 432 void getVarStackSlotParams(VarList &SortedSpilledVariables, |
432 llvm::SmallBitVector &RegsUsed, | 433 SmallBitVector &RegsUsed, size_t *GlobalsSize, |
433 size_t *GlobalsSize, size_t *SpillAreaSizeBytes, | 434 size_t *SpillAreaSizeBytes, |
434 uint32_t *SpillAreaAlignmentBytes, | 435 uint32_t *SpillAreaAlignmentBytes, |
435 uint32_t *LocalsSlotsAlignmentBytes, | 436 uint32_t *LocalsSlotsAlignmentBytes, |
436 std::function<bool(Variable *)> TargetVarHook); | 437 std::function<bool(Variable *)> TargetVarHook); |
437 | 438 |
438 /// Calculate the amount of padding needed to align the local and global areas | 439 /// Calculate the amount of padding needed to align the local and global areas |
439 /// to the required alignment. This assumes the globals/locals layout used by | 440 /// to the required alignment. This assumes the globals/locals layout used by |
440 /// getVarStackSlotParams and assignVarStackSlots. | 441 /// getVarStackSlotParams and assignVarStackSlots. |
441 void alignStackSpillAreas(uint32_t SpillAreaStartOffset, | 442 void alignStackSpillAreas(uint32_t SpillAreaStartOffset, |
442 uint32_t SpillAreaAlignmentBytes, | 443 uint32_t SpillAreaAlignmentBytes, |
443 size_t GlobalsSize, | 444 size_t GlobalsSize, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 virtual void lower() {} | 655 virtual void lower() {} |
655 | 656 |
656 protected: | 657 protected: |
657 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 658 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
658 GlobalContext *Ctx; | 659 GlobalContext *Ctx; |
659 }; | 660 }; |
660 | 661 |
661 } // end of namespace Ice | 662 } // end of namespace Ice |
662 | 663 |
663 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 664 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |