aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/M68k/M68kMachineFunction.h
blob: 5760bdd4b9e3d5ebaf13136925f48698871851b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//===-- M68kMachineFunctionInfo.h - M68k private data ---------*- C++ -*-=//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file declares the M68k specific subclass of MachineFunctionInfo.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_TARGET_M68K_M68KMACHINEFUNCTION_H
#define LLVM_LIB_TARGET_M68K_M68KMACHINEFUNCTION_H

#include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Support/MachineValueType.h"

namespace llvm {

class M68kMachineFunctionInfo : public MachineFunctionInfo {
  MachineFunction &MF;

  /// Non-zero if the function has base pointer and makes call to
  /// llvm.eh.sjlj.setjmp. When non-zero, the value is a displacement from the
  /// frame pointer to a slot where the base pointer is stashed.
  signed char RestoreBasePointerOffset = 0;

  /// Size of the callee-saved register portion of the stack frame in bytes.
  unsigned CalleeSavedFrameSize = 0;

  /// Number of bytes function pops on return (in addition to the space used by
  /// the return address).  Used on windows platform for stdcall & fastcall
  /// name decoration
  unsigned BytesToPopOnReturn = 0;

  /// FrameIndex for return slot.
  int ReturnAddrIndex = 0;

  /// The number of bytes by which return address stack slot is moved as the
  /// result of tail call optimization.
  int TailCallReturnAddrDelta = 0;

  /// keeps track of the virtual register initialized for use as the global
  /// base register. This is used for PIC in some PIC relocation models.
  unsigned GlobalBaseReg = 0;

  /// FrameIndex for start of varargs area.
  int VarArgsFrameIndex = 0;

  /// Keeps track of whether this function uses sequences of pushes to pass
  /// function parameters.
  bool HasPushSequences = false;

  /// Some subtargets require that sret lowering includes
  /// returning the value of the returned struct in a register. This field
  /// holds the virtual register into which the sret argument is passed.
  unsigned SRetReturnReg = 0;

  /// A list of virtual and physical registers that must be forwarded to every
  /// musttail call.
  SmallVector<ForwardedRegister, 1> ForwardedMustTailRegParms;

  /// The number of bytes on stack consumed by the arguments being passed on
  /// the stack.
  unsigned ArgumentStackSize = 0;

public:
  explicit M68kMachineFunctionInfo(MachineFunction &MF) : MF(MF) {}

  bool getRestoreBasePointer() const { return RestoreBasePointerOffset != 0; }
  void setRestoreBasePointer(const MachineFunction *MF);
  int getRestoreBasePointerOffset() const { return RestoreBasePointerOffset; }

  unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; }
  void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; }

  unsigned getBytesToPopOnReturn() const { return BytesToPopOnReturn; }
  void setBytesToPopOnReturn(unsigned bytes) { BytesToPopOnReturn = bytes; }

  int getRAIndex() const { return ReturnAddrIndex; }
  void setRAIndex(int Index) { ReturnAddrIndex = Index; }

  int getTCReturnAddrDelta() const { return TailCallReturnAddrDelta; }
  void setTCReturnAddrDelta(int delta) { TailCallReturnAddrDelta = delta; }

  unsigned getGlobalBaseReg() const { return GlobalBaseReg; }
  void setGlobalBaseReg(unsigned Reg) { GlobalBaseReg = Reg; }

  int getVarArgsFrameIndex() const { return VarArgsFrameIndex; }
  void setVarArgsFrameIndex(int Index) { VarArgsFrameIndex = Index; }

  bool getHasPushSequences() const { return HasPushSequences; }
  void setHasPushSequences(bool HasPush) { HasPushSequences = HasPush; }

  unsigned getSRetReturnReg() const { return SRetReturnReg; }
  void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }

  unsigned getArgumentStackSize() const { return ArgumentStackSize; }
  void setArgumentStackSize(unsigned size) { ArgumentStackSize = size; }

  SmallVectorImpl<ForwardedRegister> &getForwardedMustTailRegParms() {
    return ForwardedMustTailRegParms;
  }

private:
  virtual void anchor();
};

} // end of namespace llvm

#endif // M68K_MACHINE_FUNCTION_INFO_H