Movatterモバイル変換


[0]ホーム

URL:


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

Generated on Fri Jul 18 2025 14:44:36 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp