[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Target / AMDGPU / R600FrameLowering.cpp
blobabd4086db62c96d361b29c286579396918ec1c4f
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 //==-----------------------------------------------------------------------===//
9 #include "R600FrameLowering.h"
10 #include "R600Subtarget.h"
12 using namespace llvm;
14 R600FrameLowering::~R600FrameLowering() = default;
16 /// \returns The number of registers allocated for \p FI.
17 StackOffset
18 R600FrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
19 Register &FrameReg) const {
20 const MachineFrameInfo &MFI = MF.getFrameInfo();
21 const R600RegisterInfo *RI
22 = MF.getSubtarget<R600Subtarget>().getRegisterInfo();
24 // Fill in FrameReg output argument.
25 FrameReg = RI->getFrameRegister(MF);
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;
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));
41 if (FI != -1)
42 OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlign(FI));
44 return StackOffset::getFixed(OffsetBytes / (getStackWidth(MF) * 4));