blob: cb3b011aeb8cd0e2007727c98c7641de3d351f93 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001// 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
21namespace llvm {
Derek Schuff4b3bb212016-02-23 18:13:07 +000022class MachineFrameInfo;
Dan Gohman10e730a2015-06-29 23:51:55 +000023
24class WebAssemblyFrameLowering final : public TargetFrameLowering {
Derek Schuff3f063292016-02-11 20:57:09 +000025 public:
Derek Schuff4b3bb212016-02-23 18:13:07 +000026 static const size_t RedZoneSize = 128;
27
Dan Gohman10e730a2015-06-29 23:51:55 +000028 WebAssemblyFrameLowering()
29 : TargetFrameLowering(StackGrowsDown, /*StackAlignment=*/16,
30 /*LocalAreaOffset=*/0,
31 /*TransientStackAlignment=*/16,
32 /*StackRealignable=*/true) {}
33
Derek Schuff3f063292016-02-11 20:57:09 +000034 void eliminateCallFramePseudoInstr(
35 MachineFunction &MF, MachineBasicBlock &MBB,
36 MachineBasicBlock::iterator I) const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000037
38 /// These methods insert prolog and epilog code into the function.
39 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
40 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
41
42 bool hasFP(const MachineFunction &MF) const override;
43 bool hasReservedCallFrame(const MachineFunction &MF) const override;
Derek Schuff4b3bb212016-02-23 18:13:07 +000044
45 private:
46 bool needsSP(const MachineFunction &MF, const MachineFrameInfo &MFI) const;
47 bool needsSPWriteback(const MachineFunction &MF,
48 const MachineFrameInfo &MFI) const;
Dan Gohman10e730a2015-06-29 23:51:55 +000049};
50
Derek Schuff3f063292016-02-11 20:57:09 +000051} // end namespace llvm
Dan Gohman10e730a2015-06-29 23:51:55 +000052
53#endif