blob: e807977363639ce1f169d101407f69760080725a [file] [log] [blame]
Tom Stellardf3b2a1e2013-02-06 17:32:29 +00001//===----------------------- AMDGPUFrameLowering.cpp ----------------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Tom Stellardf3b2a1e2013-02-06 17:32:29 +00006//
7//==-----------------------------------------------------------------------===//
8//
Matt Arsenault7836f892016-01-20 21:22:21 +00009// Interface to describe a layout of a stack frame on a AMDGPU target machine.
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000010//
11//===----------------------------------------------------------------------===//
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000012
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000013#include "AMDGPUFrameLowering.h"
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000014
15using namespace llvm;
16AMDGPUFrameLowering::AMDGPUFrameLowering(StackDirection D, unsigned StackAl,
17 int LAO, unsigned TransAl)
18 : TargetFrameLowering(D, StackAl, LAO, TransAl) { }
19
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000020AMDGPUFrameLowering::~AMDGPUFrameLowering() = default;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000021
22unsigned AMDGPUFrameLowering::getStackWidth(const MachineFunction &MF) const {
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000023 // XXX: Hardcoding to 1 for now.
24 //
25 // I think the StackWidth should stored as metadata associated with the
26 // MachineFunction. This metadata can either be added by a frontend, or
27 // 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 stored
31 // in the following ways depending on the StackWidth.
32 //
33 // StackWidth = 1:
34 //
35 // T0.X = stack[0].x
36 // T1.X = stack[0].y
37 // T2.X = stack[0].z
38 // T3.X = stack[0].w
39 // T4.X = stack[1].x
40 // T5.X = stack[1].y
41 // T6.X = stack[1].z
42 // T7.X = stack[1].w
43 //
44 // StackWidth = 2:
45 //
46 // T0.X = stack[0].x
47 // T0.Y = stack[0].y
48 // T1.X = stack[0].z
49 // T1.Y = stack[0].w
50 // T2.X = stack[1].x
51 // T2.Y = stack[1].y
52 // T3.X = stack[1].z
53 // T3.Y = stack[1].w
Matt Arsenault7836f892016-01-20 21:22:21 +000054 //
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000055 // StackWidth = 4:
56 // T0.X = stack[0].x
57 // T0.Y = stack[0].y
58 // T0.Z = stack[0].z
59 // T0.W = stack[0].w
60 // T1.X = stack[1].x
61 // T1.Y = stack[1].y
62 // T1.Z = stack[1].z
63 // T1.W = stack[1].w
64 return 1;
65}