10b57cec5SDimitry Andric //===----------------------- AMDGPUFrameLowering.cpp ----------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //==-----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // Interface to describe a layout of a stack frame on a AMDGPU target machine.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric #include "AMDGPUFrameLowering.h"
140b57cec5SDimitry Andric
150b57cec5SDimitry Andric using namespace llvm;
AMDGPUFrameLowering(StackDirection D,Align StackAl,int LAO,Align TransAl)168bcb0991SDimitry Andric AMDGPUFrameLowering::AMDGPUFrameLowering(StackDirection D, Align StackAl,
178bcb0991SDimitry Andric int LAO, Align TransAl)
180b57cec5SDimitry Andric : TargetFrameLowering(D, StackAl, LAO, TransAl) {}
190b57cec5SDimitry Andric
200b57cec5SDimitry Andric AMDGPUFrameLowering::~AMDGPUFrameLowering() = default;
210b57cec5SDimitry Andric
getStackWidth(const MachineFunction & MF) const220b57cec5SDimitry Andric unsigned AMDGPUFrameLowering::getStackWidth(const MachineFunction &MF) const {
230b57cec5SDimitry Andric // XXX: Hardcoding to 1 for now.
240b57cec5SDimitry Andric //
25*bdd1243dSDimitry Andric // I think the StackWidth should be stored as metadata associated with the
260b57cec5SDimitry Andric // MachineFunction. This metadata can either be added by a frontend, or
270b57cec5SDimitry Andric // calculated by a R600 specific LLVM IR pass.
280b57cec5SDimitry Andric //
290b57cec5SDimitry Andric // The StackWidth determines how stack objects are laid out in memory.
300b57cec5SDimitry Andric // For a vector stack variable, like: int4 stack[2], the data will be stored
310b57cec5SDimitry Andric // in the following ways depending on the StackWidth.
320b57cec5SDimitry Andric //
330b57cec5SDimitry Andric // StackWidth = 1:
340b57cec5SDimitry Andric //
350b57cec5SDimitry Andric // T0.X = stack[0].x
360b57cec5SDimitry Andric // T1.X = stack[0].y
370b57cec5SDimitry Andric // T2.X = stack[0].z
380b57cec5SDimitry Andric // T3.X = stack[0].w
390b57cec5SDimitry Andric // T4.X = stack[1].x
400b57cec5SDimitry Andric // T5.X = stack[1].y
410b57cec5SDimitry Andric // T6.X = stack[1].z
420b57cec5SDimitry Andric // T7.X = stack[1].w
430b57cec5SDimitry Andric //
440b57cec5SDimitry Andric // StackWidth = 2:
450b57cec5SDimitry Andric //
460b57cec5SDimitry Andric // T0.X = stack[0].x
470b57cec5SDimitry Andric // T0.Y = stack[0].y
480b57cec5SDimitry Andric // T1.X = stack[0].z
490b57cec5SDimitry Andric // T1.Y = stack[0].w
500b57cec5SDimitry Andric // T2.X = stack[1].x
510b57cec5SDimitry Andric // T2.Y = stack[1].y
520b57cec5SDimitry Andric // T3.X = stack[1].z
530b57cec5SDimitry Andric // T3.Y = stack[1].w
540b57cec5SDimitry Andric //
550b57cec5SDimitry Andric // StackWidth = 4:
560b57cec5SDimitry Andric // T0.X = stack[0].x
570b57cec5SDimitry Andric // T0.Y = stack[0].y
580b57cec5SDimitry Andric // T0.Z = stack[0].z
590b57cec5SDimitry Andric // T0.W = stack[0].w
600b57cec5SDimitry Andric // T1.X = stack[1].x
610b57cec5SDimitry Andric // T1.Y = stack[1].y
620b57cec5SDimitry Andric // T1.Z = stack[1].z
630b57cec5SDimitry Andric // T1.W = stack[1].w
640b57cec5SDimitry Andric return 1;
650b57cec5SDimitry Andric }
66