blob: 377c5ce948465039b0bc59393167e5c6f2f9ba34 [file] [log] [blame]
Tom Stellard75aadc22012-12-11 21:25:42 +00001//===- SIMachineFunctionInfo.h - SIMachineFunctionInfo interface -*- C++ -*-==//
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//
10/// \file
11//
12//===----------------------------------------------------------------------===//
13
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_TARGET_R600_SIMACHINEFUNCTIONINFO_H
16#define LLVM_LIB_TARGET_R600_SIMACHINEFUNCTIONINFO_H
Tom Stellard75aadc22012-12-11 21:25:42 +000017
Vincent Lejeuneace6f732013-04-01 21:47:53 +000018#include "AMDGPUMachineFunction.h"
Tom Stellard96468902014-09-24 01:33:17 +000019#include "SIRegisterInfo.h"
Tom Stellardc149dc02013-11-27 21:23:35 +000020#include <map>
Tom Stellard75aadc22012-12-11 21:25:42 +000021
22namespace llvm {
23
Tom Stellardc149dc02013-11-27 21:23:35 +000024class MachineRegisterInfo;
25
Tom Stellard75aadc22012-12-11 21:25:42 +000026/// This class keeps track of the SPI_SP_INPUT_ADDR config register, which
27/// tells the hardware which interpolation parameters to load.
Vincent Lejeuneace6f732013-04-01 21:47:53 +000028class SIMachineFunctionInfo : public AMDGPUMachineFunction {
Craig Topper5656db42014-04-29 07:57:24 +000029 void anchor() override;
Tom Stellard96468902014-09-24 01:33:17 +000030
31 unsigned TIDReg;
Matt Arsenault49affb82015-11-25 20:55:12 +000032 unsigned ScratchRSrcReg;
33
34public:
35 // FIXME: Make private
36 unsigned LDSWaveSpillSize;
37 unsigned PSInputAddr;
38 std::map<unsigned, unsigned> LaneVGPRs;
39 unsigned ScratchOffsetReg;
40 unsigned NumUserSGPRs;
41
42private:
Matt Arsenault5b22dfa2015-11-05 05:27:10 +000043 bool HasSpilledSGPRs;
Tom Stellard42fb60e2015-01-14 15:42:31 +000044 bool HasSpilledVGPRs;
Tom Stellard96468902014-09-24 01:33:17 +000045
Matt Arsenault49affb82015-11-25 20:55:12 +000046 // Feature bits required for inputs passed in user / system SGPRs.
47 bool DispatchPtr : 1;
48 bool QueuePtr : 1;
49 bool DispatchID : 1;
50 bool KernargSegmentPtr : 1;
51 bool FlatScratchInit : 1;
52 bool GridWorkgroupCountX : 1;
53 bool GridWorkgroupCountY : 1;
54 bool GridWorkgroupCountZ : 1;
Tom Stellardc149dc02013-11-27 21:23:35 +000055
Matt Arsenault49affb82015-11-25 20:55:12 +000056 bool WorkGroupIDX : 1; // Always initialized.
57 bool WorkGroupIDY : 1;
58 bool WorkGroupIDZ : 1;
59 bool WorkGroupInfo : 1;
60
61 bool WorkItemIDX : 1; // Always initialized.
62 bool WorkItemIDY : 1;
63 bool WorkItemIDZ : 1;
64
65public:
Tom Stellardc149dc02013-11-27 21:23:35 +000066 struct SpilledReg {
67 unsigned VGPR;
68 int Lane;
69 SpilledReg(unsigned R, int L) : VGPR (R), Lane (L) { }
70 SpilledReg() : VGPR(0), Lane(-1) { }
71 bool hasLane() { return Lane != -1;}
72 };
73
Tom Stellardc149dc02013-11-27 21:23:35 +000074 // SIMachineFunctionInfo definition
75
Tom Stellard75aadc22012-12-11 21:25:42 +000076 SIMachineFunctionInfo(const MachineFunction &MF);
Tom Stellardc5cf2f02014-08-21 20:40:54 +000077 SpilledReg getSpilledReg(MachineFunction *MF, unsigned FrameIndex,
78 unsigned SubIdx);
Tom Stellard96468902014-09-24 01:33:17 +000079 bool hasCalculatedTID() const { return TIDReg != AMDGPU::NoRegister; };
80 unsigned getTIDReg() const { return TIDReg; };
81 void setTIDReg(unsigned Reg) { TIDReg = Reg; }
Matt Arsenault5b22dfa2015-11-05 05:27:10 +000082
Matt Arsenault49affb82015-11-25 20:55:12 +000083 bool hasDispatchPtr() const {
84 return DispatchPtr;
85 }
86
87 bool hasQueuePtr() const {
88 return QueuePtr;
89 }
90
91 bool hasDispatchID() const {
92 return DispatchID;
93 }
94
95 bool hasKernargSegmentPtr() const {
96 return KernargSegmentPtr;
97 }
98
99 bool hasFlatScratchInit() const {
100 return FlatScratchInit;
101 }
102
103 bool hasGridWorkgroupCountX() const {
104 return GridWorkgroupCountX;
105 }
106
107 bool hasGridWorkgroupCountY() const {
108 return GridWorkgroupCountY;
109 }
110
111 bool hasGridWorkgroupCountZ() const {
112 return GridWorkgroupCountZ;
113 }
114
115 bool hasWorkGroupIDX() const {
116 return WorkGroupIDX;
117 }
118
119 bool hasWorkGroupIDY() const {
120 return WorkGroupIDY;
121 }
122
123 bool hasWorkGroupIDZ() const {
124 return WorkGroupIDZ;
125 }
126
127 bool hasWorkGroupInfo() const {
128 return WorkGroupInfo;
129 }
130
131 bool hasWorkItemIDX() const {
132 return WorkItemIDX;
133 }
134
135 bool hasWorkItemIDY() const {
136 return WorkItemIDY;
137 }
138
139 bool hasWorkItemIDZ() const {
140 return WorkItemIDZ;
141 }
142
143 /// \brief Returns the physical register reserved for use as the resource
144 /// descriptor for scratch accesses.
145 unsigned getScratchRSrcReg() const {
146 return ScratchRSrcReg;
147 }
148
149 void setScratchRSrcReg(const SIRegisterInfo *TRI);
150
Matt Arsenault5b22dfa2015-11-05 05:27:10 +0000151 bool hasSpilledSGPRs() const {
152 return HasSpilledSGPRs;
153 }
154
155 void setHasSpilledSGPRs(bool Spill = true) {
156 HasSpilledSGPRs = Spill;
157 }
158
159 bool hasSpilledVGPRs() const {
160 return HasSpilledVGPRs;
161 }
162
163 void setHasSpilledVGPRs(bool Spill = true) {
164 HasSpilledVGPRs = Spill;
165 }
Tom Stellard96468902014-09-24 01:33:17 +0000166
167 unsigned getMaximumWorkGroupSize(const MachineFunction &MF) const;
Tom Stellard75aadc22012-12-11 21:25:42 +0000168};
169
170} // End namespace llvm
171
172
Benjamin Kramera7c40ef2014-08-13 16:26:38 +0000173#endif