blob: e32ca9653b3a1f314d2b0cbba9dcbd98bcd9a638 [file] [log] [blame]
Tom Stellardf3b2a1e2013-02-06 17:32:29 +00001//===----------------------- AMDGPUFrameLowering.cpp ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//==-----------------------------------------------------------------------===//
9//
Matt Arsenault7836f892016-01-20 21:22:21 +000010// Interface to describe a layout of a stack frame on a AMDGPU target machine.
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000011//
12//===----------------------------------------------------------------------===//
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000013
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000014#include "AMDGPUFrameLowering.h"
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000015
16using namespace llvm;
17AMDGPUFrameLowering::AMDGPUFrameLowering(StackDirection D, unsigned StackAl,
18 int LAO, unsigned TransAl)
19 : TargetFrameLowering(D, StackAl, LAO, TransAl) { }
20
Eugene Zelenko2bc2f332016-12-09 22:06:55 +000021AMDGPUFrameLowering::~AMDGPUFrameLowering() = default;
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000022
23unsigned AMDGPUFrameLowering::getStackWidth(const MachineFunction &MF) const {
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000024 // XXX: Hardcoding to 1 for now.
25 //
26 // I think the StackWidth should stored as metadata associated with the
27 // MachineFunction. This metadata can either be added by a frontend, or
28 // calculated by a R600 specific LLVM IR pass.
29 //
30 // The StackWidth determines how stack objects are laid out in memory.
31 // For a vector stack variable, like: int4 stack[2], the data will be stored
32 // in the following ways depending on the StackWidth.
33 //
34 // StackWidth = 1:
35 //
36 // T0.X = stack[0].x
37 // T1.X = stack[0].y
38 // T2.X = stack[0].z
39 // T3.X = stack[0].w
40 // T4.X = stack[1].x
41 // T5.X = stack[1].y
42 // T6.X = stack[1].z
43 // T7.X = stack[1].w
44 //
45 // StackWidth = 2:
46 //
47 // T0.X = stack[0].x
48 // T0.Y = stack[0].y
49 // T1.X = stack[0].z
50 // T1.Y = stack[0].w
51 // T2.X = stack[1].x
52 // T2.Y = stack[1].y
53 // T3.X = stack[1].z
54 // T3.Y = stack[1].w
Matt Arsenault7836f892016-01-20 21:22:21 +000055 //
Tom Stellardf3b2a1e2013-02-06 17:32:29 +000056 // StackWidth = 4:
57 // T0.X = stack[0].x
58 // T0.Y = stack[0].y
59 // T0.Z = stack[0].z
60 // T0.W = stack[0].w
61 // T1.X = stack[1].x
62 // T1.Y = stack[1].y
63 // T1.Z = stack[1].z
64 // T1.W = stack[1].w
65 return 1;
66}