1 //===-- WebAssemblyFrameLowering.cpp - WebAssembly Frame Lowering ----------==//
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 file contains the WebAssembly implementation of
12 /// TargetFrameLowering class.
14 /// On WebAssembly, there aren't a lot of things to do here. There are no
15 /// callee-saved registers to save, and no spill slots.
17 /// The stack grows downward.
19 //===----------------------------------------------------------------------===//
21 #include "WebAssemblyFrameLowering.h"
22 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
23 #include "WebAssemblyInstrInfo.h"
24 #include "WebAssemblyMachineFunctionInfo.h"
25 #include "WebAssemblySubtarget.h"
26 #include "WebAssemblyTargetMachine.h"
27 #include "llvm/CodeGen/MachineFrameInfo.h"
28 #include "llvm/CodeGen/MachineFunction.h"
29 #include "llvm/CodeGen/MachineInstrBuilder.h"
30 #include "llvm/CodeGen/MachineModuleInfo.h"
31 #include "llvm/CodeGen/MachineRegisterInfo.h"
32 #include "llvm/Support/Debug.h"
35 #define DEBUG_TYPE "wasm-frame-info"
37 // TODO: Implement a red zone?
39 /// Return true if the specified function should have a dedicated frame pointer
41 bool WebAssemblyFrameLowering::hasFP(const MachineFunction &MF) const {
42 llvm_unreachable("TODO: implement hasFP");
45 /// Under normal circumstances, when a frame pointer is not required, we reserve
46 /// argument space for call sites in the function immediately on entry to the
47 /// current function. This eliminates the need for add/sub sp brackets around
48 /// call sites. Returns true if the call frame is included as part of the stack
50 bool WebAssemblyFrameLowering::hasReservedCallFrame(
51 const MachineFunction &MF) const {
52 return !MF.getFrameInfo()->hasVarSizedObjects();
55 void WebAssemblyFrameLowering::eliminateCallFramePseudoInstr(
56 MachineFunction &MF, MachineBasicBlock &MBB,
57 MachineBasicBlock::iterator I) const {
58 llvm_unreachable("TODO: implement eliminateCallFramePseudoInstr");
61 void WebAssemblyFrameLowering::emitPrologue(MachineFunction &MF,
62 MachineBasicBlock &MBB) const {
63 llvm_unreachable("TODO: implement emitPrologue");
66 void WebAssemblyFrameLowering::emitEpilogue(MachineFunction &MF,
67 MachineBasicBlock &MBB) const {
68 llvm_unreachable("TODO: implement emitEpilogue");
71 void WebAssemblyFrameLowering::processFunctionBeforeCalleeSavedScan(
72 MachineFunction &MF, RegScavenger *RS) const {
73 llvm_unreachable("TODO: implement processFunctionBeforeCalleeSavedScan");