LLVM  14.0.0git
R600FrameLowering.cpp
Go to the documentation of this file.
1 //===----------------------- R600FrameLowering.cpp ------------------------===//
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 #include "R600FrameLowering.h"
10 #include "R600Subtarget.h"
11 
12 using namespace llvm;
13 
15 
16 /// \returns The number of registers allocated for \p FI.
19  Register &FrameReg) const {
20  const MachineFrameInfo &MFI = MF.getFrameInfo();
21  const R600RegisterInfo *RI
22  = MF.getSubtarget<R600Subtarget>().getRegisterInfo();
23 
24  // Fill in FrameReg output argument.
25  FrameReg = RI->getFrameRegister(MF);
26 
27  // Start the offset at 2 so we don't overwrite work group information.
28  // FIXME: We should only do this when the shader actually uses this
29  // information.
30  unsigned OffsetBytes = 2 * (getStackWidth(MF) * 4);
31  int UpperBound = FI == -1 ? MFI.getNumObjects() : FI;
32 
33  for (int i = MFI.getObjectIndexBegin(); i < UpperBound; ++i) {
34  OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlign(i));
35  OffsetBytes += MFI.getObjectSize(i);
36  // Each register holds 4 bytes, so we must always align the offset to at
37  // least 4 bytes, so that 2 frame objects won't share the same register.
38  OffsetBytes = alignTo(OffsetBytes, Align(4));
39  }
40 
41  if (FI != -1)
42  OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlign(FI));
43 
44  return StackOffset::getFixed(OffsetBytes / (getStackWidth(MF) * 4));
45 }
i
i
Definition: README.txt:29
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::StackOffset::getFixed
ScalarTy getFixed() const
Definition: TypeSize.h:149
R600FrameLowering.h
llvm::R600RegisterInfo
Definition: R600RegisterInfo.h:22
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::R600RegisterInfo::getFrameRegister
Register getFrameRegister(const MachineFunction &MF) const override
Definition: R600RegisterInfo.cpp:75
llvm::MachineFrameInfo::getObjectIndexBegin
int getObjectIndexBegin() const
Return the minimum frame object index.
Definition: MachineFrameInfo.h:390
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:626
llvm::R600Subtarget
Definition: R600Subtarget.h:35
llvm::R600FrameLowering::~R600FrameLowering
~R600FrameLowering() override
llvm::MachineFrameInfo::getObjectSize
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Definition: MachineFrameInfo.h:453
llvm::R600FrameLowering::getFrameIndexReference
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
Definition: R600FrameLowering.cpp:18
llvm::MachineFrameInfo::getObjectAlign
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
Definition: MachineFrameInfo.h:467
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:642
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::StackOffset
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
Definition: TypeSize.h:134
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
R600Subtarget.h
llvm::MachineFrameInfo::getNumObjects
unsigned getNumObjects() const
Return the number of objects.
Definition: MachineFrameInfo.h:399
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
llvm::AMDGPUFrameLowering::getStackWidth
unsigned getStackWidth(const MachineFunction &MF) const
Definition: AMDGPUFrameLowering.cpp:22