1 // WebAssemblyFrameLowering.h - TargetFrameLowering for WebAssembly -*- C++ -*-/
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This class implements WebAssembly-specific bits of
12 /// TargetFrameLowering class.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYFRAMELOWERING_H
17 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYFRAMELOWERING_H
19 #include "llvm/Target/TargetFrameLowering.h"
22 class MachineFrameInfo;
24 class WebAssemblyFrameLowering final : public TargetFrameLowering {
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.
29 static const size_t RedZoneSize = 128;
31 WebAssemblyFrameLowering()
32 : TargetFrameLowering(StackGrowsDown, /*StackAlignment=*/16,
33 /*LocalAreaOffset=*/0,
34 /*TransientStackAlignment=*/16,
35 /*StackRealignable=*/true) {}
37 MachineBasicBlock::iterator eliminateCallFramePseudoInstr(
38 MachineFunction &MF, MachineBasicBlock &MBB,
39 MachineBasicBlock::iterator I) const override;
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;
45 bool hasFP(const MachineFunction &MF) const override;
46 bool hasReservedCallFrame(const MachineFunction &MF) const override;
49 bool hasBP(const MachineFunction &MF) const;
50 bool needsSP(const MachineFunction &MF, const MachineFrameInfo &MFI) const;
51 bool needsSPWriteback(const MachineFunction &MF,
52 const MachineFrameInfo &MFI) const;
55 } // end namespace llvm