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