LLVM  16.0.0git
WebAssemblyFrameLowering.cpp
Go to the documentation of this file.
1 //===-- WebAssemblyFrameLowering.cpp - WebAssembly Frame Lowering ----------==//
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 file contains the WebAssembly implementation of
11 /// TargetFrameLowering class.
12 ///
13 /// On WebAssembly, there aren't a lot of things to do here. There are no
14 /// callee-saved registers to save, and no spill slots.
15 ///
16 /// The stack grows downward.
17 ///
18 //===----------------------------------------------------------------------===//
19 
23 #include "WebAssembly.h"
24 #include "WebAssemblyInstrInfo.h"
26 #include "WebAssemblySubtarget.h"
28 #include "llvm/CodeGen/Analysis.h"
34 #include "llvm/IR/Instructions.h"
35 #include "llvm/MC/MCAsmInfo.h"
36 #include "llvm/Support/Debug.h"
37 using namespace llvm;
38 
39 #define DEBUG_TYPE "wasm-frame-info"
40 
41 // TODO: wasm64
42 // TODO: Emit TargetOpcode::CFI_INSTRUCTION instructions
43 
44 // In an ideal world, when objects are added to the MachineFrameInfo by
45 // FunctionLoweringInfo::set, we could somehow hook into target-specific code to
46 // ensure they are assigned the right stack ID. However there isn't a hook that
47 // runs between then and DAG building time, though, so instead we hoist stack
48 // objects lazily when they are first used, and comprehensively after the DAG is
49 // built via the PreprocessISelDAG hook, called by the
50 // SelectionDAGISel::runOnMachineFunction. We have to do it in two places
51 // because we want to do it while building the selection DAG for uses of alloca,
52 // but not all alloca instructions are used so we have to follow up afterwards.
55  int FrameIndex) {
56  MachineFrameInfo &MFI = MF.getFrameInfo();
57 
58  // If already hoisted to a local, done.
60  return static_cast<unsigned>(MFI.getObjectOffset(FrameIndex));
61 
62  // If not allocated in the object address space, this object will be in
63  // linear memory.
64  const AllocaInst *AI = MFI.getObjectAllocation(FrameIndex);
66  return None;
67 
68  // Otherwise, allocate this object in the named value stack, outside of linear
69  // memory.
70  SmallVector<EVT, 4> ValueVTs;
71  const WebAssemblyTargetLowering &TLI =
72  *MF.getSubtarget<WebAssemblySubtarget>().getTargetLowering();
74  ComputeValueVTs(TLI, MF.getDataLayout(), AI->getAllocatedType(), ValueVTs);
76  // Abuse SP offset to record the index of the first local in the object.
77  unsigned Local = FuncInfo->getParams().size() + FuncInfo->getLocals().size();
78  MFI.setObjectOffset(FrameIndex, Local);
79  // Allocate WebAssembly locals for each non-aggregate component of the
80  // allocation.
81  for (EVT ValueVT : ValueVTs)
82  FuncInfo->addLocal(ValueVT.getSimpleVT());
83  // Abuse object size to record number of WebAssembly locals allocated to
84  // this object.
85  MFI.setObjectSize(FrameIndex, ValueVTs.size());
86  return static_cast<unsigned>(Local);
87 }
88 
89 /// We need a base pointer in the case of having items on the stack that
90 /// require stricter alignment than the stack pointer itself. Because we need
91 /// to shift the stack pointer by some unknown amount to force the alignment,
92 /// we need to record the value of the stack pointer on entry to the function.
93 bool WebAssemblyFrameLowering::hasBP(const MachineFunction &MF) const {
94  const auto *RegInfo =
95  MF.getSubtarget<WebAssemblySubtarget>().getRegisterInfo();
96  return RegInfo->hasStackRealignment(MF);
97 }
98 
99 /// Return true if the specified function should have a dedicated frame pointer
100 /// register.
102  const MachineFrameInfo &MFI = MF.getFrameInfo();
103 
104  // When we have var-sized objects, we move the stack pointer by an unknown
105  // amount, and need to emit a frame pointer to restore the stack to where we
106  // were on function entry.
107  // If we already need a base pointer, we use that to fix up the stack pointer.
108  // If there are no fixed-size objects, we would have no use of a frame
109  // pointer, and thus should not emit one.
110  bool HasFixedSizedObjects = MFI.getStackSize() > 0;
111  bool NeedsFixedReference = !hasBP(MF) || HasFixedSizedObjects;
112 
113  return MFI.isFrameAddressTaken() ||
114  (MFI.hasVarSizedObjects() && NeedsFixedReference) ||
115  MFI.hasStackMap() || MFI.hasPatchPoint();
116 }
117 
118 /// Under normal circumstances, when a frame pointer is not required, we reserve
119 /// argument space for call sites in the function immediately on entry to the
120 /// current function. This eliminates the need for add/sub sp brackets around
121 /// call sites. Returns true if the call frame is included as part of the stack
122 /// frame.
124  const MachineFunction &MF) const {
125  return !MF.getFrameInfo().hasVarSizedObjects();
126 }
127 
128 // Returns true if this function needs a local user-space stack pointer for its
129 // local frame (not for exception handling).
130 bool WebAssemblyFrameLowering::needsSPForLocalFrame(
131  const MachineFunction &MF) const {
132  auto &MFI = MF.getFrameInfo();
133  return MFI.getStackSize() || MFI.adjustsStack() || hasFP(MF);
134 }
135 
136 // In function with EH pads, we need to make a copy of the value of
137 // __stack_pointer global in SP32/64 register, in order to use it when
138 // restoring __stack_pointer after an exception is caught.
140  const MachineFunction &MF) const {
141  auto EHType = MF.getTarget().getMCAsmInfo()->getExceptionHandlingType();
142  return EHType == ExceptionHandling::Wasm &&
144 }
145 
146 /// Returns true if this function needs a local user-space stack pointer.
147 /// Unlike a machine stack pointer, the wasm user stack pointer is a global
148 /// variable, so it is loaded into a register in the prolog.
149 bool WebAssemblyFrameLowering::needsSP(const MachineFunction &MF) const {
150  return needsSPForLocalFrame(MF) || needsPrologForEH(MF);
151 }
152 
153 /// Returns true if the local user-space stack pointer needs to be written back
154 /// to __stack_pointer global by this function (this is not meaningful if
155 /// needsSP is false). If false, the stack red zone can be used and only a local
156 /// SP is needed.
157 bool WebAssemblyFrameLowering::needsSPWriteback(
158  const MachineFunction &MF) const {
159  auto &MFI = MF.getFrameInfo();
160  assert(needsSP(MF));
161  // When we don't need a local stack pointer for its local frame but only to
162  // support EH, we don't need to write SP back in the epilog, because we don't
163  // bump down the stack pointer in the prolog. We need to write SP back in the
164  // epilog only if
165  // 1. We need SP not only for EH support but also because we actually use
166  // stack or we have a frame address taken.
167  // 2. We cannot use the red zone.
168  bool CanUseRedZone = MFI.getStackSize() <= RedZoneSize && !MFI.hasCalls() &&
169  !MF.getFunction().hasFnAttribute(Attribute::NoRedZone);
170  return needsSPForLocalFrame(MF) && !CanUseRedZone;
171 }
172 
174  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
175  ? WebAssembly::SP64
176  : WebAssembly::SP32;
177 }
178 
180  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
181  ? WebAssembly::FP64
182  : WebAssembly::FP32;
183 }
184 
185 unsigned
187  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
188  ? WebAssembly::CONST_I64
189  : WebAssembly::CONST_I32;
190 }
191 
193  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
194  ? WebAssembly::ADD_I64
195  : WebAssembly::ADD_I32;
196 }
197 
199  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
200  ? WebAssembly::SUB_I64
201  : WebAssembly::SUB_I32;
202 }
203 
205  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
206  ? WebAssembly::AND_I64
207  : WebAssembly::AND_I32;
208 }
209 
210 unsigned
212  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
213  ? WebAssembly::GLOBAL_GET_I64
214  : WebAssembly::GLOBAL_GET_I32;
215 }
216 
217 unsigned
219  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
220  ? WebAssembly::GLOBAL_SET_I64
221  : WebAssembly::GLOBAL_SET_I32;
222 }
223 
225  unsigned SrcReg, MachineFunction &MF, MachineBasicBlock &MBB,
226  MachineBasicBlock::iterator &InsertStore, const DebugLoc &DL) const {
227  const auto *TII = MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
228 
229  const char *ES = "__stack_pointer";
230  auto *SPSymbol = MF.createExternalSymbolName(ES);
231 
232  BuildMI(MBB, InsertStore, DL, TII->get(getOpcGlobSet(MF)))
233  .addExternalSymbol(SPSymbol)
234  .addReg(SrcReg);
235 }
236 
241  assert(!I->getOperand(0).getImm() && (hasFP(MF) || hasBP(MF)) &&
242  "Call frame pseudos should only be used for dynamic stack adjustment");
243  auto &ST = MF.getSubtarget<WebAssemblySubtarget>();
244  const auto *TII = ST.getInstrInfo();
245  if (I->getOpcode() == TII->getCallFrameDestroyOpcode() &&
246  needsSPWriteback(MF)) {
247  DebugLoc DL = I->getDebugLoc();
248  writeSPToGlobal(getSPReg(MF), MF, MBB, I, DL);
249  }
250  return MBB.erase(I);
251 }
252 
254  MachineBasicBlock &MBB) const {
255  // TODO: Do ".setMIFlag(MachineInstr::FrameSetup)" on emitted instructions
256  auto &MFI = MF.getFrameInfo();
257  assert(MFI.getCalleeSavedInfo().empty() &&
258  "WebAssembly should not have callee-saved registers");
259 
260  if (!needsSP(MF))
261  return;
262  uint64_t StackSize = MFI.getStackSize();
263 
264  auto &ST = MF.getSubtarget<WebAssemblySubtarget>();
265  const auto *TII = ST.getInstrInfo();
266  auto &MRI = MF.getRegInfo();
267 
268  auto InsertPt = MBB.begin();
269  while (InsertPt != MBB.end() &&
270  WebAssembly::isArgument(InsertPt->getOpcode()))
271  ++InsertPt;
272  DebugLoc DL;
273 
274  const TargetRegisterClass *PtrRC =
276  unsigned SPReg = getSPReg(MF);
277  if (StackSize)
278  SPReg = MRI.createVirtualRegister(PtrRC);
279 
280  const char *ES = "__stack_pointer";
281  auto *SPSymbol = MF.createExternalSymbolName(ES);
282  BuildMI(MBB, InsertPt, DL, TII->get(getOpcGlobGet(MF)), SPReg)
283  .addExternalSymbol(SPSymbol);
284 
285  bool HasBP = hasBP(MF);
286  if (HasBP) {
287  auto FI = MF.getInfo<WebAssemblyFunctionInfo>();
288  Register BasePtr = MRI.createVirtualRegister(PtrRC);
289  FI->setBasePointerVreg(BasePtr);
290  BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::COPY), BasePtr)
291  .addReg(SPReg);
292  }
293  if (StackSize) {
294  // Subtract the frame size
295  Register OffsetReg = MRI.createVirtualRegister(PtrRC);
296  BuildMI(MBB, InsertPt, DL, TII->get(getOpcConst(MF)), OffsetReg)
297  .addImm(StackSize);
298  BuildMI(MBB, InsertPt, DL, TII->get(getOpcSub(MF)), getSPReg(MF))
299  .addReg(SPReg)
300  .addReg(OffsetReg);
301  }
302  if (HasBP) {
303  Register BitmaskReg = MRI.createVirtualRegister(PtrRC);
304  Align Alignment = MFI.getMaxAlign();
305  BuildMI(MBB, InsertPt, DL, TII->get(getOpcConst(MF)), BitmaskReg)
306  .addImm((int64_t) ~(Alignment.value() - 1));
307  BuildMI(MBB, InsertPt, DL, TII->get(getOpcAnd(MF)), getSPReg(MF))
308  .addReg(getSPReg(MF))
309  .addReg(BitmaskReg);
310  }
311  if (hasFP(MF)) {
312  // Unlike most conventional targets (where FP points to the saved FP),
313  // FP points to the bottom of the fixed-size locals, so we can use positive
314  // offsets in load/store instructions.
315  BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::COPY), getFPReg(MF))
316  .addReg(getSPReg(MF));
317  }
318  if (StackSize && needsSPWriteback(MF)) {
319  writeSPToGlobal(getSPReg(MF), MF, MBB, InsertPt, DL);
320  }
321 }
322 
324  MachineBasicBlock &MBB) const {
325  uint64_t StackSize = MF.getFrameInfo().getStackSize();
326  if (!needsSP(MF) || !needsSPWriteback(MF))
327  return;
328  auto &ST = MF.getSubtarget<WebAssemblySubtarget>();
329  const auto *TII = ST.getInstrInfo();
330  auto &MRI = MF.getRegInfo();
331  auto InsertPt = MBB.getFirstTerminator();
332  DebugLoc DL;
333 
334  if (InsertPt != MBB.end())
335  DL = InsertPt->getDebugLoc();
336 
337  // Restore the stack pointer. If we had fixed-size locals, add the offset
338  // subtracted in the prolog.
339  unsigned SPReg = 0;
340  unsigned SPFPReg = hasFP(MF) ? getFPReg(MF) : getSPReg(MF);
341  if (hasBP(MF)) {
342  auto FI = MF.getInfo<WebAssemblyFunctionInfo>();
343  SPReg = FI->getBasePointerVreg();
344  } else if (StackSize) {
345  const TargetRegisterClass *PtrRC =
347  Register OffsetReg = MRI.createVirtualRegister(PtrRC);
348  BuildMI(MBB, InsertPt, DL, TII->get(getOpcConst(MF)), OffsetReg)
349  .addImm(StackSize);
350  // In the epilog we don't need to write the result back to the SP32/64
351  // physreg because it won't be used again. We can use a stackified register
352  // instead.
353  SPReg = MRI.createVirtualRegister(PtrRC);
354  BuildMI(MBB, InsertPt, DL, TII->get(getOpcAdd(MF)), SPReg)
355  .addReg(SPFPReg)
356  .addReg(OffsetReg);
357  } else {
358  SPReg = SPFPReg;
359  }
360 
361  writeSPToGlobal(SPReg, MF, MBB, InsertPt, DL);
362 }
363 
365  TargetStackID::Value ID) const {
366  // Use the Object stack for WebAssembly locals which can only be accessed
367  // by name, not via an address in linear memory.
369  return true;
370 
372 }
373 
376  DwarfFrameBase Loc;
379  if (needsSP(MF) && MFI.isFrameBaseVirtual()) {
380  unsigned LocalNum = MFI.getFrameBaseLocal();
382  } else {
383  // TODO: This should work on a breakpoint at a function with no frame,
384  // but probably won't work for traversing up the stack.
386  }
387  return Loc;
388 }
llvm::WebAssemblyFrameLowering::getOpcAdd
static unsigned getOpcAdd(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:192
llvm::MachineFrameInfo::hasVarSizedObjects
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
Definition: MachineFrameInfo.h:355
MachineModuleInfoImpls.h
llvm::WebAssembly::isArgument
bool isArgument(unsigned Opc)
Definition: WebAssemblyMCTargetDesc.h:275
llvm::MachineInstrBuilder::addImm
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Definition: MachineInstrBuilder.h:131
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::WebAssemblyFrameLowering::getSPReg
static unsigned getSPReg(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:173
llvm::TargetStackID::WasmLocal
@ WasmLocal
Definition: TargetFrameLowering.h:31
WebAssembly.h
llvm::WebAssemblyFunctionInfo::getLocals
const std::vector< MVT > & getLocals() const
Definition: WebAssemblyMachineFunctionInfo.h:93
llvm::MachineRegisterInfo::createVirtualRegister
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Definition: MachineRegisterInfo.cpp:156
llvm::WebAssemblyFrameLowering::isSupportedStackID
bool isSupportedStackID(TargetStackID::Value ID) const override
Definition: WebAssemblyFrameLowering.cpp:364
llvm::WebAssemblyFrameLowering::getOpcSub
static unsigned getOpcSub(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:198
llvm::LocalNum
LocalNum
Definition: PredicateInfo.cpp:81
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::MachineRegisterInfo::getTargetRegisterInfo
const TargetRegisterInfo * getTargetRegisterInfo() const
Definition: MachineRegisterInfo.h:151
llvm::Optional< unsigned >
llvm::TargetFrameLowering::DwarfFrameBase
Definition: TargetFrameLowering.h:56
WebAssemblyTargetMachine.h
llvm::MachineFrameInfo::setObjectSize
void setObjectSize(int ObjectIdx, int64_t Size)
Change the size of the specified stack object.
Definition: MachineFrameInfo.h:477
llvm::AllocaInst::getAddressSpace
unsigned getAddressSpace() const
Return the address space for the allocation.
Definition: Instructions.h:106
llvm::WebAssemblyFrameLowering::writeSPToGlobal
void writeSPToGlobal(unsigned SrcReg, MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator &InsertStore, const DebugLoc &DL) const
Write SP back to __stack_pointer global.
Definition: WebAssemblyFrameLowering.cpp:224
llvm::WebAssemblyFrameLowering::eliminateCallFramePseudoInstr
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
Definition: WebAssemblyFrameLowering.cpp:238
MachineRegisterInfo.h
llvm::ComputeValueVTs
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
Definition: Analysis.cpp:121
llvm::MachineBasicBlock::erase
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Definition: MachineBasicBlock.cpp:1314
llvm::WebAssemblyTargetLowering
Definition: WebAssemblyISelLowering.h:43
llvm::TargetFrameLowering::DwarfFrameBase::WasmLoc
struct WasmFrameBase WasmLoc
Definition: TargetFrameLowering.h:66
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:667
llvm::WebAssemblyFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
These methods insert prolog and epilog code into the function.
Definition: WebAssemblyFrameLowering.cpp:253
llvm::WebAssemblyFunctionInfo::getBasePointerVreg
unsigned getBasePointerVreg() const
Definition: WebAssemblyMachineFunctionInfo.h:101
llvm::AllocaInst::getAllocatedType
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Definition: Instructions.h:115
llvm::MachineFunction::getInfo
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Definition: MachineFunction.h:755
llvm::EVT
Extended Value Type.
Definition: ValueTypes.h:34
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
llvm::WebAssemblyFrameLowering::getOpcConst
static unsigned getOpcConst(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:186
WebAssemblyInstrInfo.h
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:125
WebAssemblyTypeUtilities.h
llvm::ExceptionHandling::Wasm
@ Wasm
WebAssembly Exception Handling.
llvm::MachineFrameInfo::getStackID
uint8_t getStackID(int ObjectIdx) const
Definition: MachineFrameInfo.h:731
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:759
llvm::MachineFrameInfo::getStackSize
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
Definition: MachineFrameInfo.h:585
llvm::TargetFrameLowering::DwarfFrameBase::WasmFrameBase
@ WasmFrameBase
Definition: TargetFrameLowering.h:59
llvm::MachineFrameInfo::getObjectOffset
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
Definition: MachineFrameInfo.h:526
llvm::TargetFrameLowering::DwarfFrameBase::Kind
enum llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind Kind
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::MachineInstrBuilder::addExternalSymbol
const MachineInstrBuilder & addExternalSymbol(const char *FnName, unsigned TargetFlags=0) const
Definition: MachineInstrBuilder.h:184
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::WebAssembly::TI_GLOBAL_RELOC
@ TI_GLOBAL_RELOC
Definition: WebAssembly.h:96
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::WebAssemblyFrameLowering::getOpcGlobSet
static unsigned getOpcGlobSet(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:218
WebAssemblyMCTargetDesc.h
llvm::TargetRegisterInfo::getPointerRegClass
virtual const TargetRegisterClass * getPointerRegClass(const MachineFunction &MF, unsigned Kind=0) const
Returns a TargetRegisterClass used for pointer values.
Definition: TargetRegisterInfo.h:791
llvm::WebAssemblyFrameLowering::getDwarfFrameBase
DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const override
Return the frame base information to be encoded in the DWARF subprogram debug info.
Definition: WebAssemblyFrameLowering.cpp:375
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:657
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:629
llvm::TargetFrameLowering::isSupportedStackID
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition: TargetFrameLowering.h:436
uint64_t
WebAssemblyFrameLowering.h
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
I
#define I(x, y, z)
Definition: MD5.cpp:58
Analysis.h
llvm::MachineFrameInfo::setObjectOffset
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
Definition: MachineFrameInfo.h:560
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:673
llvm::WebAssemblyFunctionInfo
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
Definition: WebAssemblyMachineFunctionInfo.h:33
llvm::MachineInstrBuilder::addReg
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Definition: MachineInstrBuilder.h:97
WebAssemblyMachineFunctionInfo.h
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::MachineBasicBlock::getFirstTerminator
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Definition: MachineBasicBlock.cpp:239
llvm::TargetMachine::getMCAsmInfo
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
Definition: TargetMachine.h:204
llvm::MachineFrameInfo::setStackID
void setStackID(int ObjectIdx, uint8_t ID)
Definition: MachineFrameInfo.h:736
llvm::MachineFrameInfo::hasPatchPoint
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:389
MCAsmInfo.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::WebAssemblyFrameLowering::emitEpilogue
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition: WebAssemblyFrameLowering.cpp:323
llvm::WebAssemblySubtarget
Definition: WebAssemblySubtarget.h:35
llvm::WebAssemblyFrameLowering::getOpcAnd
static unsigned getOpcAnd(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:204
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::MachineFrameInfo::isFrameAddressTaken
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:371
llvm::MachineFrameInfo::hasCalls
bool hasCalls() const
Return true if the current function has any function calls.
Definition: MachineFrameInfo.h:613
llvm::WebAssemblyFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
Under normal circumstances, when a frame pointer is not required, we reserve argument space for call ...
Definition: WebAssemblyFrameLowering.cpp:123
llvm::ISD::FrameIndex
@ FrameIndex
Definition: ISDOpcodes.h:80
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::WebAssemblyFrameLowering::getFPReg
static unsigned getFPReg(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:179
llvm::WebAssembly::TI_LOCAL
@ TI_LOCAL
Definition: WebAssembly.h:89
llvm::WebAssemblyFrameLowering::RedZoneSize
static const size_t RedZoneSize
Size of the red zone for the user stack (leaf functions can use this much space below the stack point...
Definition: WebAssemblyFrameLowering.h:28
llvm::MachineFunction::getFunction
Function & getFunction()
Return the LLVM function that this machine code represents.
Definition: MachineFunction.h:623
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:653
MachineFrameInfo.h
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
WebAssemblySubtarget.h
llvm::WebAssemblyFrameLowering::hasFP
bool hasFP(const MachineFunction &MF) const override
Return true if the specified function should have a dedicated frame pointer register.
Definition: WebAssemblyFrameLowering.cpp:101
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::WebAssemblyFunctionInfo::isFrameBaseVirtual
bool isFrameBaseVirtual() const
Definition: WebAssemblyMachineFunctionInfo.h:112
llvm::WebAssemblyFrameLowering::needsPrologForEH
bool needsPrologForEH(const MachineFunction &MF) const
Definition: WebAssemblyFrameLowering.cpp:139
llvm::MCAsmInfo::getExceptionHandlingType
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:777
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:106
Instructions.h
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition: MachineInstrBuilder.h:357
llvm::MachineBasicBlock::begin
iterator begin()
Definition: MachineBasicBlock.h:305
MachineInstrBuilder.h
llvm::WebAssembly::isWasmVarAddressSpace
bool isWasmVarAddressSpace(unsigned AS)
Definition: WebAssemblyTypeUtilities.h:66
llvm::WebAssemblyFunctionInfo::getParams
const std::vector< MVT > & getParams() const
Definition: WebAssemblyMachineFunctionInfo.h:80
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:285
llvm::WebAssemblyFrameLowering::getOpcGlobGet
static unsigned getOpcGlobGet(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:211
llvm::MachineFunction::createExternalSymbolName
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
Definition: MachineFunction.cpp:540
llvm::MachineFrameInfo::hasStackMap
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
Definition: MachineFrameInfo.h:383
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:59
llvm::TargetFrameLowering::DwarfFrameBase::Location
union llvm::TargetFrameLowering::DwarfFrameBase::@232 Location
MachineFunction.h
llvm::WebAssemblyFrameLowering::getLocalForStackObject
static Optional< unsigned > getLocalForStackObject(MachineFunction &MF, int FrameIndex)
Definition: WebAssemblyFrameLowering.cpp:54
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::WebAssemblyFunctionInfo::addLocal
void addLocal(MVT VT)
Definition: WebAssemblyMachineFunctionInfo.h:92
llvm::WebAssemblyFunctionInfo::getFrameBaseLocal
unsigned getFrameBaseLocal() const
Definition: WebAssemblyMachineFunctionInfo.h:114
Debug.h
llvm::MachineBasicBlock::end
iterator end()
Definition: MachineBasicBlock.h:307
llvm::MachineFrameInfo::getObjectAllocation
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
Definition: MachineFrameInfo.h:510