Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
Line
Count
Source
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
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYFRAMELOWERING_H
16
#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYFRAMELOWERING_H
17
18
#include "llvm/CodeGen/TargetFrameLowering.h"
19
20
namespace llvm {
21
class MachineFrameInfo;
22
23
class WebAssemblyFrameLowering final : public TargetFrameLowering {
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;
30
31
  WebAssemblyFrameLowering()
32
      : TargetFrameLowering(StackGrowsDown, /*StackAlignment=*/16,
33
                            /*LocalAreaOffset=*/0,
34
                            /*TransientStackAlignment=*/16,
35
546
                            /*StackRealignable=*/true) {}
36
37
  MachineBasicBlock::iterator
38
  eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
39
                                MachineBasicBlock::iterator I) const override;
40
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;
44
45
  bool hasFP(const MachineFunction &MF) const override;
46
  bool hasReservedCallFrame(const MachineFunction &MF) const override;
47
48
  bool needsPrologForEH(const MachineFunction &MF) const;
49
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;
55
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
};
62
63
} // end namespace llvm
64
65
#endif