| 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 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 bool hasComputedFrame() const { return HasComputedFrame; } | 171 bool hasComputedFrame() const { return HasComputedFrame; } |
| 172 /// Returns true if this function calls a function that has the | 172 /// Returns true if this function calls a function that has the |
| 173 /// "returns twice" attribute. | 173 /// "returns twice" attribute. |
| 174 bool callsReturnsTwice() const { return CallsReturnsTwice; } | 174 bool callsReturnsTwice() const { return CallsReturnsTwice; } |
| 175 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } | 175 void setCallsReturnsTwice(bool RetTwice) { CallsReturnsTwice = RetTwice; } |
| 176 int32_t getStackAdjustment() const { return StackAdjustment; } | 176 int32_t getStackAdjustment() const { return StackAdjustment; } |
| 177 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } | 177 void updateStackAdjustment(int32_t Offset) { StackAdjustment += Offset; } |
| 178 void resetStackAdjustment() { StackAdjustment = 0; } | 178 void resetStackAdjustment() { StackAdjustment = 0; } |
| 179 SizeT makeNextLabelNumber() { return NextLabelNumber++; } | 179 SizeT makeNextLabelNumber() { return NextLabelNumber++; } |
| 180 SizeT makeNextJumpTableNumber() { return NextJumpTableNumber++; } |
| 180 LoweringContext &getContext() { return Context; } | 181 LoweringContext &getContext() { return Context; } |
| 181 | 182 |
| 182 enum RegSet { | 183 enum RegSet { |
| 183 RegSet_None = 0, | 184 RegSet_None = 0, |
| 184 RegSet_CallerSave = 1 << 0, | 185 RegSet_CallerSave = 1 << 0, |
| 185 RegSet_CalleeSave = 1 << 1, | 186 RegSet_CalleeSave = 1 << 1, |
| 186 RegSet_StackPointer = 1 << 2, | 187 RegSet_StackPointer = 1 << 2, |
| 187 RegSet_FramePointer = 1 << 3, | 188 RegSet_FramePointer = 1 << 3, |
| 188 RegSet_All = ~RegSet_None | 189 RegSet_All = ~RegSet_None |
| 189 }; | 190 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 205 virtual void snapshotEmitState() { | 206 virtual void snapshotEmitState() { |
| 206 SnapshotStackAdjustment = StackAdjustment; | 207 SnapshotStackAdjustment = StackAdjustment; |
| 207 } | 208 } |
| 208 virtual void rollbackEmitState() { | 209 virtual void rollbackEmitState() { |
| 209 StackAdjustment = SnapshotStackAdjustment; | 210 StackAdjustment = SnapshotStackAdjustment; |
| 210 } | 211 } |
| 211 | 212 |
| 212 /// Get the minimum number of clusters required for a jump table to be | 213 /// Get the minimum number of clusters required for a jump table to be |
| 213 /// considered. | 214 /// considered. |
| 214 virtual SizeT getMinJumpTableSize() const = 0; | 215 virtual SizeT getMinJumpTableSize() const = 0; |
| 216 virtual void emitJumpTable(const Cfg *Func, |
| 217 const InstJumpTable *JumpTable) const = 0; |
| 215 | 218 |
| 216 virtual void emitVariable(const Variable *Var) const = 0; | 219 virtual void emitVariable(const Variable *Var) const = 0; |
| 217 | 220 |
| 218 void emitWithoutPrefix(const ConstantRelocatable *CR) const; | 221 void emitWithoutPrefix(const ConstantRelocatable *CR) const; |
| 219 void emit(const ConstantRelocatable *CR) const; | 222 void emit(const ConstantRelocatable *CR) const; |
| 220 virtual const char *getConstantPrefix() const = 0; | 223 virtual const char *getConstantPrefix() const = 0; |
| 221 | 224 |
| 222 virtual void emit(const ConstantUndef *C) const = 0; | 225 virtual void emit(const ConstantUndef *C) const = 0; |
| 223 virtual void emit(const ConstantInteger32 *C) const = 0; | 226 virtual void emit(const ConstantInteger32 *C) const = 0; |
| 224 virtual void emit(const ConstantInteger64 *C) const = 0; | 227 virtual void emit(const ConstantInteger64 *C) const = 0; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 } | 334 } |
| 332 | 335 |
| 333 Cfg *Func; | 336 Cfg *Func; |
| 334 GlobalContext *Ctx; | 337 GlobalContext *Ctx; |
| 335 bool HasComputedFrame = false; | 338 bool HasComputedFrame = false; |
| 336 bool CallsReturnsTwice = false; | 339 bool CallsReturnsTwice = false; |
| 337 /// StackAdjustment keeps track of the current stack offset from its | 340 /// StackAdjustment keeps track of the current stack offset from its |
| 338 /// natural location, as arguments are pushed for a function call. | 341 /// natural location, as arguments are pushed for a function call. |
| 339 int32_t StackAdjustment = 0; | 342 int32_t StackAdjustment = 0; |
| 340 SizeT NextLabelNumber = 0; | 343 SizeT NextLabelNumber = 0; |
| 344 SizeT NextJumpTableNumber = 0; |
| 341 LoweringContext Context; | 345 LoweringContext Context; |
| 342 | 346 |
| 343 // Runtime helper function names | 347 // Runtime helper function names |
| 344 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; | 348 const static constexpr char *H_bitcast_16xi1_i16 = "__Sz_bitcast_16xi1_i16"; |
| 345 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; | 349 const static constexpr char *H_bitcast_8xi1_i8 = "__Sz_bitcast_8xi1_i8"; |
| 346 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; | 350 const static constexpr char *H_bitcast_i16_16xi1 = "__Sz_bitcast_i16_16xi1"; |
| 347 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; | 351 const static constexpr char *H_bitcast_i8_8xi1 = "__Sz_bitcast_i8_8xi1"; |
| 348 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; | 352 const static constexpr char *H_call_ctpop_i32 = "__popcountsi2"; |
| 349 const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; | 353 const static constexpr char *H_call_ctpop_i64 = "__popcountdi2"; |
| 350 const static constexpr char *H_call_longjmp = "longjmp"; | 354 const static constexpr char *H_call_longjmp = "longjmp"; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 TargetDataLowering(const TargetDataLowering &) = delete; | 394 TargetDataLowering(const TargetDataLowering &) = delete; |
| 391 TargetDataLowering &operator=(const TargetDataLowering &) = delete; | 395 TargetDataLowering &operator=(const TargetDataLowering &) = delete; |
| 392 | 396 |
| 393 public: | 397 public: |
| 394 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); | 398 static std::unique_ptr<TargetDataLowering> createLowering(GlobalContext *Ctx); |
| 395 virtual ~TargetDataLowering(); | 399 virtual ~TargetDataLowering(); |
| 396 | 400 |
| 397 virtual void lowerGlobals(const VariableDeclarationList &Vars, | 401 virtual void lowerGlobals(const VariableDeclarationList &Vars, |
| 398 const IceString &SectionSuffix) = 0; | 402 const IceString &SectionSuffix) = 0; |
| 399 virtual void lowerConstants() = 0; | 403 virtual void lowerConstants() = 0; |
| 404 virtual void lowerJumpTables() = 0; |
| 400 | 405 |
| 401 protected: | 406 protected: |
| 402 void emitGlobal(const VariableDeclaration &Var, | 407 void emitGlobal(const VariableDeclaration &Var, |
| 403 const IceString &SectionSuffix); | 408 const IceString &SectionSuffix); |
| 404 | 409 |
| 405 /// For now, we assume .long is the right directive for emitting 4 byte | 410 /// For now, we assume .long is the right directive for emitting 4 byte |
| 406 /// emit global relocations. However, LLVM MIPS usually uses .4byte instead. | 411 /// emit global relocations. However, LLVM MIPS usually uses .4byte instead. |
| 407 /// Perhaps there is some difference when the location is unaligned. | 412 /// Perhaps there is some difference when the location is unaligned. |
| 408 static const char *getEmit32Directive() { return ".long"; } | 413 static const char *getEmit32Directive() { return ".long"; } |
| 409 | 414 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 427 virtual void lower() {} | 432 virtual void lower() {} |
| 428 | 433 |
| 429 protected: | 434 protected: |
| 430 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} | 435 explicit TargetHeaderLowering(GlobalContext *Ctx) : Ctx(Ctx) {} |
| 431 GlobalContext *Ctx; | 436 GlobalContext *Ctx; |
| 432 }; | 437 }; |
| 433 | 438 |
| 434 } // end of namespace Ice | 439 } // end of namespace Ice |
| 435 | 440 |
| 436 #endif // SUBZERO_SRC_ICETARGETLOWERING_H | 441 #endif // SUBZERO_SRC_ICETARGETLOWERING_H |
| OLD | NEW |