LLVM 19.0.0git
Go to the documentation of this file.
1//===----------------------- R600FrameLowering.cpp ------------------------===//
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
9#include "R600FrameLowering.h"
10#include "R600Subtarget.h"
13using namespace llvm;
17/// \returns The number of registers allocated for \p FI.
20 Register &FrameReg) const {
21 const MachineFrameInfo &MFI = MF.getFrameInfo();
22 const R600RegisterInfo *RI
23 = MF.getSubtarget<R600Subtarget>().getRegisterInfo();
25 // Fill in FrameReg output argument.
26 FrameReg = RI->getFrameRegister(MF);
28 // Start the offset at 2 so we don't overwrite work group information.
29 // FIXME: We should only do this when the shader actually uses this
30 // information.
31 unsigned OffsetBytes = 2 * (getStackWidth(MF) * 4);
32 int UpperBound = FI == -1 ? MFI.getNumObjects() : FI;
34 for (int i = MFI.getObjectIndexBegin(); i < UpperBound; ++i) {
35 OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlign(i));
36 OffsetBytes += MFI.getObjectSize(i);
37 // Each register holds 4 bytes, so we must always align the offset to at
38 // least 4 bytes, so that 2 frame objects won't share the same register.
39 OffsetBytes = alignTo(OffsetBytes, Align(4));
40 }
42 if (FI != -1)
43 OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlign(FI));
45 return StackOffset::getFixed(OffsetBytes / (getStackWidth(MF) * 4));
AMDGPU R600 specific subclass of TargetSubtarget.
unsigned getStackWidth(const MachineFunction &MF) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getNumObjects() const
Return the number of objects.
int getObjectIndexBegin() const
Return the minimum frame object index.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
~R600FrameLowering() override
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:33
int64_t getFixed() const
Returns the fixed component of the stack.
Definition: TypeSize.h:49
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Register getFrameRegister(const MachineFunction &MF) const override