LLVM  14.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);
65  if (!AI ||
67  return None;
68 
69  // Otherwise, allocate this object in the named value stack, outside of linear
70  // memory.
71  SmallVector<EVT, 4> ValueVTs;
72  const WebAssemblyTargetLowering &TLI =
73  *MF.getSubtarget<WebAssemblySubtarget>().getTargetLowering();
75  ComputeValueVTs(TLI, MF.getDataLayout(), AI->getAllocatedType(), ValueVTs);
77  // Abuse SP offset to record the index of the first local in the object.
78  unsigned Local = FuncInfo->getParams().size() + FuncInfo->getLocals().size();
79  MFI.setObjectOffset(FrameIndex, Local);
80  // Allocate WebAssembly locals for each non-aggregate component of the
81  // allocation.
82  for (EVT ValueVT : ValueVTs)
83  FuncInfo->addLocal(ValueVT.getSimpleVT());
84  // Abuse object size to record number of WebAssembly locals allocated to
85  // this object.
86  MFI.setObjectSize(FrameIndex, ValueVTs.size());
87  return static_cast<unsigned>(Local);
88 }
89 
90 /// We need a base pointer in the case of having items on the stack that
91 /// require stricter alignment than the stack pointer itself. Because we need
92 /// to shift the stack pointer by some unknown amount to force the alignment,
93 /// we need to record the value of the stack pointer on entry to the function.
94 bool WebAssemblyFrameLowering::hasBP(const MachineFunction &MF) const {
95  const auto *RegInfo =
96  MF.getSubtarget<WebAssemblySubtarget>().getRegisterInfo();
97  return RegInfo->hasStackRealignment(MF);
98 }
99 
100 /// Return true if the specified function should have a dedicated frame pointer
101 /// register.
103  const MachineFrameInfo &MFI = MF.getFrameInfo();
104 
105  // When we have var-sized objects, we move the stack pointer by an unknown
106  // amount, and need to emit a frame pointer to restore the stack to where we
107  // were on function entry.
108  // If we already need a base pointer, we use that to fix up the stack pointer.
109  // If there are no fixed-size objects, we would have no use of a frame
110  // pointer, and thus should not emit one.
111  bool HasFixedSizedObjects = MFI.getStackSize() > 0;
112  bool NeedsFixedReference = !hasBP(MF) || HasFixedSizedObjects;
113 
114  return MFI.isFrameAddressTaken() ||
115  (MFI.hasVarSizedObjects() && NeedsFixedReference) ||
116  MFI.hasStackMap() || MFI.hasPatchPoint();
117 }
118 
119 /// Under normal circumstances, when a frame pointer is not required, we reserve
120 /// argument space for call sites in the function immediately on entry to the
121 /// current function. This eliminates the need for add/sub sp brackets around
122 /// call sites. Returns true if the call frame is included as part of the stack
123 /// frame.
125  const MachineFunction &MF) const {
126  return !MF.getFrameInfo().hasVarSizedObjects();
127 }
128 
129 // Returns true if this function needs a local user-space stack pointer for its
130 // local frame (not for exception handling).
131 bool WebAssemblyFrameLowering::needsSPForLocalFrame(
132  const MachineFunction &MF) const {
133  auto &MFI = MF.getFrameInfo();
134  return MFI.getStackSize() || MFI.adjustsStack() || hasFP(MF);
135 }
136 
137 // In function with EH pads, we need to make a copy of the value of
138 // __stack_pointer global in SP32/64 register, in order to use it when
139 // restoring __stack_pointer after an exception is caught.
141  const MachineFunction &MF) const {
142  auto EHType = MF.getTarget().getMCAsmInfo()->getExceptionHandlingType();
143  return EHType == ExceptionHandling::Wasm &&
145 }
146 
147 /// Returns true if this function needs a local user-space stack pointer.
148 /// Unlike a machine stack pointer, the wasm user stack pointer is a global
149 /// variable, so it is loaded into a register in the prolog.
150 bool WebAssemblyFrameLowering::needsSP(const MachineFunction &MF) const {
151  return needsSPForLocalFrame(MF) || needsPrologForEH(MF);
152 }
153 
154 /// Returns true if the local user-space stack pointer needs to be written back
155 /// to __stack_pointer global by this function (this is not meaningful if
156 /// needsSP is false). If false, the stack red zone can be used and only a local
157 /// SP is needed.
158 bool WebAssemblyFrameLowering::needsSPWriteback(
159  const MachineFunction &MF) const {
160  auto &MFI = MF.getFrameInfo();
161  assert(needsSP(MF));
162  // When we don't need a local stack pointer for its local frame but only to
163  // support EH, we don't need to write SP back in the epilog, because we don't
164  // bump down the stack pointer in the prolog. We need to write SP back in the
165  // epilog only if
166  // 1. We need SP not only for EH support but also because we actually use
167  // stack or we have a frame address taken.
168  // 2. We cannot use the red zone.
169  bool CanUseRedZone = MFI.getStackSize() <= RedZoneSize && !MFI.hasCalls() &&
170  !MF.getFunction().hasFnAttribute(Attribute::NoRedZone);
171  return needsSPForLocalFrame(MF) && !CanUseRedZone;
172 }
173 
175  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
176  ? WebAssembly::SP64
177  : WebAssembly::SP32;
178 }
179 
181  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
182  ? WebAssembly::FP64
183  : WebAssembly::FP32;
184 }
185 
186 unsigned
188  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
189  ? WebAssembly::CONST_I64
190  : WebAssembly::CONST_I32;
191 }
192 
194  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
195  ? WebAssembly::ADD_I64
196  : WebAssembly::ADD_I32;
197 }
198 
200  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
201  ? WebAssembly::SUB_I64
202  : WebAssembly::SUB_I32;
203 }
204 
206  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
207  ? WebAssembly::AND_I64
208  : WebAssembly::AND_I32;
209 }
210 
211 unsigned
213  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
214  ? WebAssembly::GLOBAL_GET_I64
215  : WebAssembly::GLOBAL_GET_I32;
216 }
217 
218 unsigned
220  return MF.getSubtarget<WebAssemblySubtarget>().hasAddr64()
221  ? WebAssembly::GLOBAL_SET_I64
222  : WebAssembly::GLOBAL_SET_I32;
223 }
224 
226  unsigned SrcReg, MachineFunction &MF, MachineBasicBlock &MBB,
227  MachineBasicBlock::iterator &InsertStore, const DebugLoc &DL) const {
228  const auto *TII = MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
229 
230  const char *ES = "__stack_pointer";
231  auto *SPSymbol = MF.createExternalSymbolName(ES);
232 
233  BuildMI(MBB, InsertStore, DL, TII->get(getOpcGlobSet(MF)))
234  .addExternalSymbol(SPSymbol)
235  .addReg(SrcReg);
236 }
237 
242  assert(!I->getOperand(0).getImm() && (hasFP(MF) || hasBP(MF)) &&
243  "Call frame pseudos should only be used for dynamic stack adjustment");
244  auto &ST = MF.getSubtarget<WebAssemblySubtarget>();
245  const auto *TII = ST.getInstrInfo();
246  if (I->getOpcode() == TII->getCallFrameDestroyOpcode() &&
247  needsSPWriteback(MF)) {
248  DebugLoc DL = I->getDebugLoc();
249  writeSPToGlobal(getSPReg(MF), MF, MBB, I, DL);
250  }
251  return MBB.erase(I);
252 }
253 
255  MachineBasicBlock &MBB) const {
256  // TODO: Do ".setMIFlag(MachineInstr::FrameSetup)" on emitted instructions
257  auto &MFI = MF.getFrameInfo();
258  assert(MFI.getCalleeSavedInfo().empty() &&
259  "WebAssembly should not have callee-saved registers");
260 
261  if (!needsSP(MF))
262  return;
263  uint64_t StackSize = MFI.getStackSize();
264 
265  auto &ST = MF.getSubtarget<WebAssemblySubtarget>();
266  const auto *TII = ST.getInstrInfo();
267  auto &MRI = MF.getRegInfo();
268 
269  auto InsertPt = MBB.begin();
270  while (InsertPt != MBB.end() &&
271  WebAssembly::isArgument(InsertPt->getOpcode()))
272  ++InsertPt;
273  DebugLoc DL;
274 
275  const TargetRegisterClass *PtrRC =
277  unsigned SPReg = getSPReg(MF);
278  if (StackSize)
279  SPReg = MRI.createVirtualRegister(PtrRC);
280 
281  const char *ES = "__stack_pointer";
282  auto *SPSymbol = MF.createExternalSymbolName(ES);
283  BuildMI(MBB, InsertPt, DL, TII->get(getOpcGlobGet(MF)), SPReg)
284  .addExternalSymbol(SPSymbol);
285 
286  bool HasBP = hasBP(MF);
287  if (HasBP) {
288  auto FI = MF.getInfo<WebAssemblyFunctionInfo>();
289  Register BasePtr = MRI.createVirtualRegister(PtrRC);
290  FI->setBasePointerVreg(BasePtr);
291  BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::COPY), BasePtr)
292  .addReg(SPReg);
293  }
294  if (StackSize) {
295  // Subtract the frame size
296  Register OffsetReg = MRI.createVirtualRegister(PtrRC);
297  BuildMI(MBB, InsertPt, DL, TII->get(getOpcConst(MF)), OffsetReg)
298  .addImm(StackSize);
299  BuildMI(MBB, InsertPt, DL, TII->get(getOpcSub(MF)), getSPReg(MF))
300  .addReg(SPReg)
301  .addReg(OffsetReg);
302  }
303  if (HasBP) {
304  Register BitmaskReg = MRI.createVirtualRegister(PtrRC);
305  Align Alignment = MFI.getMaxAlign();
306  BuildMI(MBB, InsertPt, DL, TII->get(getOpcConst(MF)), BitmaskReg)
307  .addImm((int64_t) ~(Alignment.value() - 1));
308  BuildMI(MBB, InsertPt, DL, TII->get(getOpcAnd(MF)), getSPReg(MF))
309  .addReg(getSPReg(MF))
310  .addReg(BitmaskReg);
311  }
312  if (hasFP(MF)) {
313  // Unlike most conventional targets (where FP points to the saved FP),
314  // FP points to the bottom of the fixed-size locals, so we can use positive
315  // offsets in load/store instructions.
316  BuildMI(MBB, InsertPt, DL, TII->get(WebAssembly::COPY), getFPReg(MF))
317  .addReg(getSPReg(MF));
318  }
319  if (StackSize && needsSPWriteback(MF)) {
320  writeSPToGlobal(getSPReg(MF), MF, MBB, InsertPt, DL);
321  }
322 }
323 
325  MachineBasicBlock &MBB) const {
326  uint64_t StackSize = MF.getFrameInfo().getStackSize();
327  if (!needsSP(MF) || !needsSPWriteback(MF))
328  return;
329  auto &ST = MF.getSubtarget<WebAssemblySubtarget>();
330  const auto *TII = ST.getInstrInfo();
331  auto &MRI = MF.getRegInfo();
332  auto InsertPt = MBB.getFirstTerminator();
333  DebugLoc DL;
334 
335  if (InsertPt != MBB.end())
336  DL = InsertPt->getDebugLoc();
337 
338  // Restore the stack pointer. If we had fixed-size locals, add the offset
339  // subtracted in the prolog.
340  unsigned SPReg = 0;
341  unsigned SPFPReg = hasFP(MF) ? getFPReg(MF) : getSPReg(MF);
342  if (hasBP(MF)) {
343  auto FI = MF.getInfo<WebAssemblyFunctionInfo>();
344  SPReg = FI->getBasePointerVreg();
345  } else if (StackSize) {
346  const TargetRegisterClass *PtrRC =
348  Register OffsetReg = MRI.createVirtualRegister(PtrRC);
349  BuildMI(MBB, InsertPt, DL, TII->get(getOpcConst(MF)), OffsetReg)
350  .addImm(StackSize);
351  // In the epilog we don't need to write the result back to the SP32/64
352  // physreg because it won't be used again. We can use a stackified register
353  // instead.
354  SPReg = MRI.createVirtualRegister(PtrRC);
355  BuildMI(MBB, InsertPt, DL, TII->get(getOpcAdd(MF)), SPReg)
356  .addReg(SPFPReg)
357  .addReg(OffsetReg);
358  } else {
359  SPReg = SPFPReg;
360  }
361 
362  writeSPToGlobal(SPReg, MF, MBB, InsertPt, DL);
363 }
364 
366  TargetStackID::Value ID) const {
367  // Use the Object stack for WebAssembly locals which can only be accessed
368  // by name, not via an address in linear memory.
370  return true;
371 
373 }
374 
377  DwarfFrameBase Loc;
380  if (needsSP(MF) && MFI.isFrameBaseVirtual()) {
381  unsigned LocalNum = MFI.getFrameBaseLocal();
383  } else {
384  // TODO: This should work on a breakpoint at a function with no frame,
385  // but probably won't work for traversing up the stack.
387  }
388  return Loc;
389 }
llvm::WebAssemblyFrameLowering::getOpcAdd
static unsigned getOpcAdd(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:193
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:353
MachineModuleInfoImpls.h
llvm::WebAssembly::isArgument
bool isArgument(unsigned Opc)
Definition: WebAssemblyMCTargetDesc.h:277
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: AllocatorList.h:23
llvm::WebAssemblyFrameLowering::getSPReg
static unsigned getSPReg(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:174
llvm::TargetStackID::WasmLocal
@ WasmLocal
Definition: TargetFrameLowering.h:31
WebAssembly.h
llvm::WebAssemblyFunctionInfo::getLocals
const std::vector< MVT > & getLocals() const
Definition: WebAssemblyMachineFunctionInfo.h:95
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:158
llvm::WebAssemblyFrameLowering::isSupportedStackID
bool isSupportedStackID(TargetStackID::Value ID) const override
Definition: WebAssemblyFrameLowering.cpp:365
llvm::WebAssemblyFrameLowering::getOpcSub
static unsigned getOpcSub(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:199
llvm::LocalNum
LocalNum
Definition: PredicateInfo.cpp:89
llvm::AllocaInst::getType
PointerType * getType() const
Overload to return most specific pointer type.
Definition: Instructions.h:104
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::MachineRegisterInfo::getTargetRegisterInfo
const TargetRegisterInfo * getTargetRegisterInfo() const
Definition: MachineRegisterInfo.h:153
llvm::PointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:687
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:460
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:225
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:239
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:124
llvm::MachineBasicBlock::erase
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
Definition: MachineBasicBlock.cpp:1301
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:644
llvm::WebAssemblyFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
These methods insert prolog and epilog code into the function.
Definition: WebAssemblyFrameLowering.cpp:254
llvm::WebAssemblyFunctionInfo::getBasePointerVreg
unsigned getBasePointerVreg() const
Definition: WebAssemblyMachineFunctionInfo.h:103
llvm::AllocaInst::getAllocatedType
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
Definition: Instructions.h:113
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:732
llvm::EVT
Extended Value Type.
Definition: ValueTypes.h:35
llvm::TargetRegisterClass
Definition: TargetRegisterInfo.h:46
llvm::WebAssemblyFrameLowering::getOpcConst
static unsigned getOpcConst(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:187
WebAssemblyInstrInfo.h
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:129
llvm::ExceptionHandling::Wasm
@ Wasm
WebAssembly Exception Handling.
llvm::MachineFrameInfo::getStackID
uint8_t getStackID(int ObjectIdx) const
Definition: MachineFrameInfo.h:699
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition: Function.h:775
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:553
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:494
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::None
const NoneType None
Definition: None.h:23
llvm::WebAssembly::TI_GLOBAL_RELOC
@ TI_GLOBAL_RELOC
Definition: WebAssembly.h:100
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
WebAssemblyUtilities.h
llvm::WebAssemblyFrameLowering::getOpcGlobSet
static unsigned getOpcGlobSet(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:219
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:759
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:376
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:634
llvm::Function::hasFnAttribute
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition: Function.cpp:626
llvm::TargetFrameLowering::isSupportedStackID
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition: TargetFrameLowering.h:424
uint64_t
WebAssemblyFrameLowering.h
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
I
#define I(x, y, z)
Definition: MD5.cpp:59
Analysis.h
llvm::MachineFrameInfo::setObjectOffset
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
Definition: MachineFrameInfo.h:528
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:650
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:234
llvm::MachineBasicBlock::getFirstTerminator
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Definition: MachineBasicBlock.cpp:241
llvm::TargetMachine::getMCAsmInfo
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
Definition: TargetMachine.h:208
llvm::MachineFrameInfo::setStackID
void setStackID(int ObjectIdx, uint8_t ID)
Definition: MachineFrameInfo.h:704
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:386
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:324
llvm::WebAssemblySubtarget
Definition: WebAssemblySubtarget.h:35
llvm::WebAssemblyFrameLowering::getOpcAnd
static unsigned getOpcAnd(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:205
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:368
llvm::MachineFrameInfo::hasCalls
bool hasCalls() const
Return true if the current function has any function calls.
Definition: MachineFrameInfo.h:581
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:124
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:180
llvm::TargetFrameLowering::DwarfFrameBase::Location
union llvm::TargetFrameLowering::DwarfFrameBase::@222 Location
llvm::WebAssembly::TI_LOCAL
@ TI_LOCAL
Definition: WebAssembly.h:93
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:600
llvm::MachineFunction::getTarget
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Definition: MachineFunction.h:630
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:102
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::WebAssemblyFunctionInfo::isFrameBaseVirtual
bool isFrameBaseVirtual() const
Definition: WebAssemblyMachineFunctionInfo.h:114
llvm::WebAssemblyFrameLowering::needsPrologForEH
bool needsPrologForEH(const MachineFunction &MF) const
Definition: WebAssemblyFrameLowering.cpp:140
llvm::MCAsmInfo::getExceptionHandlingType
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:762
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
Instructions.h
llvm::MachineBasicBlock::begin
iterator begin()
Definition: MachineBasicBlock.h:268
MachineInstrBuilder.h
llvm::WebAssembly::isWasmVarAddressSpace
bool isWasmVarAddressSpace(unsigned AS)
Definition: WebAssemblyUtilities.h:50
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition: MachineInstrBuilder.h:328
llvm::WebAssemblyFunctionInfo::getParams
const std::vector< MVT > & getParams() const
Definition: WebAssemblyMachineFunctionInfo.h:82
llvm::MachineFunction::getDataLayout
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Definition: MachineFunction.cpp:261
llvm::WebAssemblyFrameLowering::getOpcGlobGet
static unsigned getOpcGlobGet(const MachineFunction &MF)
Definition: WebAssemblyFrameLowering.cpp:212
llvm::MachineFunction::createExternalSymbolName
const char * createExternalSymbolName(StringRef Name)
Allocate a string and populate it with the given external symbol name.
Definition: MachineFunction.cpp:515
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:380
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition: Instructions.h:62
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:94
llvm::WebAssemblyFunctionInfo::getFrameBaseLocal
unsigned getFrameBaseLocal() const
Definition: WebAssemblyMachineFunctionInfo.h:116
Debug.h
llvm::MachineBasicBlock::end
iterator end()
Definition: MachineBasicBlock.h:270
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::MachineFrameInfo::getObjectAllocation
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
Definition: MachineFrameInfo.h:486