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