Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | // WebAssemblyFrameLowering.h - TargetFrameLowering for WebAssembly -*- C++ -*-/ |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// |
| 10 | /// \file |
| 11 | /// \brief This class implements WebAssembly-specific bits of |
| 12 | /// TargetFrameLowering class. |
| 13 | /// |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYFRAMELOWERING_H |
| 17 | #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYFRAMELOWERING_H |
| 18 | |
| 19 | #include "llvm/Target/TargetFrameLowering.h" |
| 20 | |
| 21 | namespace llvm { |
Derek Schuff | 4b3bb21 | 2016-02-23 18:13:07 +0000 | [diff] [blame] | 22 | class MachineFrameInfo; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 23 | |
| 24 | class WebAssemblyFrameLowering final : public TargetFrameLowering { |
Derek Schuff | 3f06329 | 2016-02-11 20:57:09 +0000 | [diff] [blame] | 25 | public: |
Derek Schuff | 770bdfe | 2016-02-23 18:17:46 +0000 | [diff] [blame] | 26 | /// Size of the red zone for the user stack (leaf functions can use this much |
| 27 | /// space below the stack pointer without writing it back to memory). |
| 28 | // TODO: (ABI) Revisit and decide how large it should be. |
Derek Schuff | 4b3bb21 | 2016-02-23 18:13:07 +0000 | [diff] [blame] | 29 | static const size_t RedZoneSize = 128; |
| 30 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 31 | WebAssemblyFrameLowering() |
| 32 | : TargetFrameLowering(StackGrowsDown, /*StackAlignment=*/16, |
| 33 | /*LocalAreaOffset=*/0, |
| 34 | /*TransientStackAlignment=*/16, |
| 35 | /*StackRealignable=*/true) {} |
| 36 | |
Hans Wennborg | e1a2e90 | 2016-03-31 18:33:38 +0000 | [diff] [blame] | 37 | MachineBasicBlock::iterator eliminateCallFramePseudoInstr( |
Derek Schuff | 3f06329 | 2016-02-11 20:57:09 +0000 | [diff] [blame] | 38 | MachineFunction &MF, MachineBasicBlock &MBB, |
| 39 | MachineBasicBlock::iterator I) const override; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 40 | |
| 41 | /// These methods insert prolog and epilog code into the function. |
| 42 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 43 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 44 | |
| 45 | bool hasFP(const MachineFunction &MF) const override; |
| 46 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
Derek Schuff | 4b3bb21 | 2016-02-23 18:13:07 +0000 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | bool needsSP(const MachineFunction &MF, const MachineFrameInfo &MFI) const; |
| 50 | bool needsSPWriteback(const MachineFunction &MF, |
| 51 | const MachineFrameInfo &MFI) const; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 52 | }; |
| 53 | |
Derek Schuff | 3f06329 | 2016-02-11 20:57:09 +0000 | [diff] [blame] | 54 | } // end namespace llvm |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 55 | |
| 56 | #endif |