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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, | 186 virtual llvm::SmallBitVector getRegisterSet(RegSetMask Include, |
187 RegSetMask Exclude) const = 0; | 187 RegSetMask Exclude) const = 0; |
188 virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const = 0; | 188 virtual const llvm::SmallBitVector &getRegisterSetForType(Type Ty) const = 0; |
189 void regAlloc(RegAllocKind Kind); | 189 void regAlloc(RegAllocKind Kind); |
190 | 190 |
191 virtual void makeRandomRegisterPermutation( | 191 virtual void makeRandomRegisterPermutation( |
192 llvm::SmallVectorImpl<int32_t> &Permutation, | 192 llvm::SmallVectorImpl<int32_t> &Permutation, |
193 const llvm::SmallBitVector &ExcludeRegisters) const = 0; | 193 const llvm::SmallBitVector &ExcludeRegisters) const = 0; |
194 | 194 |
| 195 // Save/restore any mutable state for the situation where code |
| 196 // emission needs multiple passes, such as sandboxing or relaxation. |
| 197 // Subclasses may provide their own implementation, but should be |
| 198 // sure to also call the parent class's methods. |
| 199 virtual void snapshotEmitState() { |
| 200 SnapshotStackAdjustment = StackAdjustment; |
| 201 } |
| 202 virtual void rollbackEmitState() { |
| 203 StackAdjustment = SnapshotStackAdjustment; |
| 204 } |
| 205 |
195 virtual void emitVariable(const Variable *Var) const = 0; | 206 virtual void emitVariable(const Variable *Var) const = 0; |
196 | 207 |
197 // Performs target-specific argument lowering. | 208 // Performs target-specific argument lowering. |
198 virtual void lowerArguments() = 0; | 209 virtual void lowerArguments() = 0; |
199 | 210 |
200 virtual void addProlog(CfgNode *Node) = 0; | 211 virtual void addProlog(CfgNode *Node) = 0; |
201 virtual void addEpilog(CfgNode *Node) = 0; | 212 virtual void addEpilog(CfgNode *Node) = 0; |
202 | 213 |
203 virtual ~TargetLowering() {} | 214 virtual ~TargetLowering() {} |
204 | 215 |
(...skipping 27 matching lines...) Expand all Loading... |
232 | 243 |
233 Cfg *Func; | 244 Cfg *Func; |
234 GlobalContext *Ctx; | 245 GlobalContext *Ctx; |
235 const bool RandomizeRegisterAllocation; | 246 const bool RandomizeRegisterAllocation; |
236 bool HasComputedFrame; | 247 bool HasComputedFrame; |
237 bool CallsReturnsTwice; | 248 bool CallsReturnsTwice; |
238 // StackAdjustment keeps track of the current stack offset from its | 249 // StackAdjustment keeps track of the current stack offset from its |
239 // natural location, as arguments are pushed for a function call. | 250 // natural location, as arguments are pushed for a function call. |
240 int32_t StackAdjustment; | 251 int32_t StackAdjustment; |
241 LoweringContext Context; | 252 LoweringContext Context; |
| 253 |
| 254 private: |
| 255 int32_t SnapshotStackAdjustment; |
242 }; | 256 }; |
243 | 257 |
244 // TargetDataLowering is used for "lowering" data including initializers | 258 // TargetDataLowering is used for "lowering" data including initializers |
245 // for global variables, and the internal constant pools. It is separated | 259 // for global variables, and the internal constant pools. It is separated |
246 // out from TargetLowering because it does not require a Cfg. | 260 // out from TargetLowering because it does not require a Cfg. |
247 class TargetDataLowering { | 261 class TargetDataLowering { |
248 TargetDataLowering() = delete; | 262 TargetDataLowering() = delete; |
249 TargetDataLowering(const TargetDataLowering &) = delete; | 263 TargetDataLowering(const TargetDataLowering &) = delete; |
250 TargetDataLowering &operator=(const TargetDataLowering &) = delete; | 264 TargetDataLowering &operator=(const TargetDataLowering &) = delete; |
251 | 265 |
252 public: | 266 public: |
253 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); | 267 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); |
254 virtual ~TargetDataLowering(); | 268 virtual ~TargetDataLowering(); |
255 | 269 |
256 virtual void | 270 virtual void |
257 lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const = 0; | 271 lowerGlobals(std::unique_ptr<VariableDeclarationList> Vars) const = 0; |
258 virtual void lowerConstants() const = 0; | 272 virtual void lowerConstants() const = 0; |
259 | 273 |
260 protected: | 274 protected: |
261 TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 275 TargetDataLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
262 GlobalContext *Ctx; | 276 GlobalContext *Ctx; |
263 }; | 277 }; |
264 | 278 |
265 } // end of namespace Ice | 279 } // end of namespace Ice |
266 | 280 |
267 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 281 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
OLD | NEW |