LLVM  10.0.0svn
Go to the documentation of this file.
1 // WebAssemblyFrameLowering.h - TargetFrameLowering for WebAssembly -*- C++ -*-/
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This class implements WebAssembly-specific bits of
11 /// TargetFrameLowering class.
12 ///
13 //===----------------------------------------------------------------------===//
20 namespace llvm {
21 class MachineFrameInfo;
24 public:
25  /// Size of the red zone for the user stack (leaf functions can use this much
26  /// space below the stack pointer without writing it back to __stack_pointer
27  /// global).
28  // TODO: (ABI) Revisit and decide how large it should be.
29  static const size_t RedZoneSize = 128;
32  : TargetFrameLowering(StackGrowsDown, /*StackAlignment=*/Align(16),
33  /*LocalAreaOffset=*/0,
34  /*TransientStackAlignment=*/Align(16),
35  /*StackRealignable=*/true) {}
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;
48  bool needsPrologForEH(const MachineFunction &MF) const;
50  /// Write SP back to __stack_pointer global.
51  void writeSPToGlobal(unsigned SrcReg, MachineFunction &MF,
52  MachineBasicBlock &MBB,
53  MachineBasicBlock::iterator &InsertStore,
54  const DebugLoc &DL) const;
56 private:
57  bool hasBP(const MachineFunction &MF) const;
58  bool needsSPForLocalFrame(const MachineFunction &MF) const;
59  bool needsSP(const MachineFunction &MF) const;
60  bool needsSPWriteback(const MachineFunction &MF) const;
61 };
63 } // end namespace llvm
65 #endif
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
These methods insert prolog and epilog code into the function.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A debug info location.
Definition: DebugLoc.h:33
bool hasFP(const MachineFunction &MF) const override
Return true if the specified function should have a dedicated frame pointer register.
block Block Frequency true
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
bool needsPrologForEH(const MachineFunction &MF) const
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
void writeSPToGlobal(unsigned SrcReg, MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator &InsertStore, const DebugLoc &DL) const
Write SP back to __stack_pointer global.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
Information about stack frame layout on the target.
static const size_t RedZoneSize
Size of the red zone for the user stack (leaf functions can use this much space below the stack point...
#define I(x, y, z)
Definition: MD5.cpp:58
bool hasReservedCallFrame(const MachineFunction &MF) const override
Under normal circumstances, when a frame pointer is not required, we reserve argument space for call ...