66 lines · cpp
1//===----------------------- AMDGPUFrameLowering.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-exception6//7//==-----------------------------------------------------------------------===//8//9// Interface to describe a layout of a stack frame on a AMDGPU target machine.10//11//===----------------------------------------------------------------------===//12 13#include "AMDGPUFrameLowering.h"14 15using namespace llvm;16AMDGPUFrameLowering::AMDGPUFrameLowering(StackDirection D, Align StackAl,17 int LAO, Align TransAl)18 : TargetFrameLowering(D, StackAl, LAO, TransAl) {}19 20AMDGPUFrameLowering::~AMDGPUFrameLowering() = default;21 22unsigned AMDGPUFrameLowering::getStackWidth(const MachineFunction &MF) const {23 // XXX: Hardcoding to 1 for now.24 //25 // I think the StackWidth should be stored as metadata associated with the26 // MachineFunction. This metadata can either be added by a frontend, or27 // calculated by a R600 specific LLVM IR pass.28 //29 // The StackWidth determines how stack objects are laid out in memory.30 // For a vector stack variable, like: int4 stack[2], the data will be stored31 // in the following ways depending on the StackWidth.32 //33 // StackWidth = 1:34 //35 // T0.X = stack[0].x36 // T1.X = stack[0].y37 // T2.X = stack[0].z38 // T3.X = stack[0].w39 // T4.X = stack[1].x40 // T5.X = stack[1].y41 // T6.X = stack[1].z42 // T7.X = stack[1].w43 //44 // StackWidth = 2:45 //46 // T0.X = stack[0].x47 // T0.Y = stack[0].y48 // T1.X = stack[0].z49 // T1.Y = stack[0].w50 // T2.X = stack[1].x51 // T2.Y = stack[1].y52 // T3.X = stack[1].z53 // T3.Y = stack[1].w54 //55 // StackWidth = 4:56 // T0.X = stack[0].x57 // T0.Y = stack[0].y58 // T0.Z = stack[0].z59 // T0.W = stack[0].w60 // T1.X = stack[1].x61 // T1.Y = stack[1].y62 // T1.Z = stack[1].z63 // T1.W = stack[1].w64 return 1;65}66