2017-08-08 08:47:13 +08:00
|
|
|
//==- SIMachineFunctionInfo.h - SIMachineFunctionInfo interface --*- C++ -*-==//
|
2012-12-12 05:25:42 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2016-03-11 16:00:27 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
|
|
|
|
#define LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2017-08-04 07:00:29 +08:00
|
|
|
#include "AMDGPUArgumentUsageInfo.h"
|
2017-11-08 09:01:31 +08:00
|
|
|
#include "AMDGPUMachineFunction.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "SIRegisterInfo.h"
|
2017-08-08 08:47:13 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
|
|
#include "llvm/ADT/Optional.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2017-01-21 08:53:49 +08:00
|
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
2017-11-08 09:01:31 +08:00
|
|
|
#include "llvm/CodeGen/TargetInstrInfo.h"
|
2017-01-21 08:53:49 +08:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2016-06-27 18:26:43 +08:00
|
|
|
#include <array>
|
2017-01-21 08:53:49 +08:00
|
|
|
#include <cassert>
|
|
|
|
#include <utility>
|
2017-08-08 08:47:13 +08:00
|
|
|
#include <vector>
|
2012-12-12 05:25:42 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
class MachineFrameInfo;
|
|
|
|
class MachineFunction;
|
|
|
|
class TargetRegisterClass;
|
|
|
|
|
2016-12-20 23:52:17 +08:00
|
|
|
class AMDGPUImagePseudoSourceValue : public PseudoSourceValue {
|
|
|
|
public:
|
2017-09-15 04:53:51 +08:00
|
|
|
explicit AMDGPUImagePseudoSourceValue(const TargetInstrInfo &TII) :
|
|
|
|
PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { }
|
2016-12-20 23:52:17 +08:00
|
|
|
|
|
|
|
bool isConstant(const MachineFrameInfo *) const override {
|
|
|
|
// This should probably be true for most images, but we will start by being
|
|
|
|
// conservative.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAliased(const MachineFrameInfo *) const override {
|
|
|
|
// FIXME: If we ever change image intrinsics to accept fat pointers, then
|
|
|
|
// this could be true for some cases.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
bool mayAlias(const MachineFrameInfo *) const override {
|
2016-12-20 23:52:17 +08:00
|
|
|
// FIXME: If we ever change image intrinsics to accept fat pointers, then
|
|
|
|
// this could be true for some cases.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-12-21 01:19:44 +08:00
|
|
|
class AMDGPUBufferPseudoSourceValue : public PseudoSourceValue {
|
|
|
|
public:
|
2017-09-15 04:53:51 +08:00
|
|
|
explicit AMDGPUBufferPseudoSourceValue(const TargetInstrInfo &TII) :
|
|
|
|
PseudoSourceValue(PseudoSourceValue::TargetCustom, TII) { }
|
2016-12-21 01:19:44 +08:00
|
|
|
|
|
|
|
bool isConstant(const MachineFrameInfo *) const override {
|
|
|
|
// This should probably be true for most images, but we will start by being
|
|
|
|
// conservative.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAliased(const MachineFrameInfo *) const override {
|
|
|
|
// FIXME: If we ever change image intrinsics to accept fat pointers, then
|
|
|
|
// this could be true for some cases.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
bool mayAlias(const MachineFrameInfo *) const override {
|
2016-12-21 01:19:44 +08:00
|
|
|
// FIXME: If we ever change image intrinsics to accept fat pointers, then
|
|
|
|
// this could be true for some cases.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2016-12-20 23:52:17 +08:00
|
|
|
|
2012-12-12 05:25:42 +08:00
|
|
|
/// This class keeps track of the SPI_SP_INPUT_ADDR config register, which
|
|
|
|
/// tells the hardware which interpolation parameters to load.
|
2016-03-11 16:00:27 +08:00
|
|
|
class SIMachineFunctionInfo final : public AMDGPUMachineFunction {
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned TIDReg = AMDGPU::NoRegister;
|
2015-12-01 05:16:03 +08:00
|
|
|
|
|
|
|
// Registers that may be reserved for spilling purposes. These may be the same
|
|
|
|
// as the input registers.
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned ScratchRSrcReg = AMDGPU::PRIVATE_RSRC_REG;
|
|
|
|
unsigned ScratchWaveOffsetReg = AMDGPU::SCRATCH_WAVE_OFFSET_REG;
|
2015-12-01 05:16:03 +08:00
|
|
|
|
2017-04-25 02:05:16 +08:00
|
|
|
// This is the current function's incremented size from the kernel's scratch
|
|
|
|
// wave offset register. For an entry function, this is exactly the same as
|
|
|
|
// the ScratchWaveOffsetReg.
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned FrameOffsetReg = AMDGPU::FP_REG;
|
2017-04-25 02:05:16 +08:00
|
|
|
|
|
|
|
// Top of the stack SGPR offset derived from the ScratchWaveOffsetReg.
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned StackPtrOffsetReg = AMDGPU::SP_REG;
|
2017-04-25 02:05:16 +08:00
|
|
|
|
2017-08-04 07:00:29 +08:00
|
|
|
AMDGPUFunctionArgInfo ArgInfo;
|
2017-07-18 06:35:50 +08:00
|
|
|
|
2016-01-13 19:45:36 +08:00
|
|
|
// Graphics info.
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned PSInputAddr = 0;
|
|
|
|
unsigned PSInputEnable = 0;
|
2017-04-12 06:29:24 +08:00
|
|
|
|
2017-08-12 04:42:08 +08:00
|
|
|
/// Number of bytes of arguments this function has on the stack. If the callee
|
|
|
|
/// is expected to restore the argument stack this should be a multiple of 16,
|
|
|
|
/// all usable during a tail call.
|
|
|
|
///
|
|
|
|
/// The alternative would forbid tail call optimisation in some cases: if we
|
|
|
|
/// want to transfer control from a function with 8-bytes of stack-argument
|
|
|
|
/// space to a function with 16-bytes then misalignment of this value would
|
|
|
|
/// make a stack adjustment necessary, which could not be undone by the
|
|
|
|
/// callee.
|
|
|
|
unsigned BytesInStackArgArea = 0;
|
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
bool ReturnsVoid = true;
|
2016-01-13 19:45:36 +08:00
|
|
|
|
2016-09-07 04:22:28 +08:00
|
|
|
// A pair of default/requested minimum/maximum flat work group sizes.
|
|
|
|
// Minimum - first, maximum - second.
|
2017-08-08 08:47:13 +08:00
|
|
|
std::pair<unsigned, unsigned> FlatWorkGroupSizes = {0, 0};
|
2016-09-07 04:22:28 +08:00
|
|
|
|
|
|
|
// A pair of default/requested minimum/maximum number of waves per execution
|
|
|
|
// unit. Minimum - first, maximum - second.
|
2017-08-08 08:47:13 +08:00
|
|
|
std::pair<unsigned, unsigned> WavesPerEU = {0, 0};
|
AMDGPU: allow specifying a workgroup size that needs to fit in a compute unit
Summary:
For GL_ARB_compute_shader we need to support workgroup sizes of at least 1024. However, if we want to allow large workgroup sizes, we may need to use less registers, as we have to run more waves per SIMD.
This patch adds an attribute to specify the maximum work group size the compiled program needs to support. It defaults, to 256, as that has no wave restrictions.
Reducing the number of registers available is done similarly to how the registers were reserved for chips with the sgpr init bug.
Reviewers: mareko, arsenm, tstellarAMD, nhaehnle
Subscribers: FireBurn, kerberizer, llvm-commits, arsenm
Differential Revision: http://reviews.llvm.org/D18340
Patch By: Bas Nieuwenhuizen
llvm-svn: 266337
2016-04-15 00:27:07 +08:00
|
|
|
|
2016-06-25 11:11:28 +08:00
|
|
|
// Stack object indices for work group IDs.
|
2017-08-08 08:47:13 +08:00
|
|
|
std::array<int, 3> DebuggerWorkGroupIDStackObjectIndices = {{0, 0, 0}};
|
|
|
|
|
2016-06-25 11:11:28 +08:00
|
|
|
// Stack object indices for work item IDs.
|
2017-08-08 08:47:13 +08:00
|
|
|
std::array<int, 3> DebuggerWorkItemIDStackObjectIndices = {{0, 0, 0}};
|
2016-04-27 01:24:40 +08:00
|
|
|
|
2016-12-21 01:19:44 +08:00
|
|
|
AMDGPUBufferPseudoSourceValue BufferPSV;
|
2016-12-21 01:26:34 +08:00
|
|
|
AMDGPUImagePseudoSourceValue ImagePSV;
|
2016-12-20 23:52:17 +08:00
|
|
|
|
2017-04-19 04:59:40 +08:00
|
|
|
private:
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned LDSWaveSpillSize = 0;
|
|
|
|
unsigned NumUserSGPRs = 0;
|
|
|
|
unsigned NumSystemSGPRs = 0;
|
2015-11-26 04:55:12 +08:00
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
bool HasSpilledSGPRs = false;
|
|
|
|
bool HasSpilledVGPRs = false;
|
|
|
|
bool HasNonSpillStackObjects = false;
|
2014-09-24 09:33:17 +08:00
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
unsigned NumSpilledSGPRs = 0;
|
|
|
|
unsigned NumSpilledVGPRs = 0;
|
2016-07-14 01:35:15 +08:00
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
// Feature bits required for inputs passed in user SGPRs.
|
|
|
|
bool PrivateSegmentBuffer : 1;
|
2015-11-26 04:55:12 +08:00
|
|
|
bool DispatchPtr : 1;
|
|
|
|
bool QueuePtr : 1;
|
|
|
|
bool KernargSegmentPtr : 1;
|
2016-07-23 01:01:30 +08:00
|
|
|
bool DispatchID : 1;
|
2015-11-26 04:55:12 +08:00
|
|
|
bool FlatScratchInit : 1;
|
|
|
|
bool GridWorkgroupCountX : 1;
|
|
|
|
bool GridWorkgroupCountY : 1;
|
|
|
|
bool GridWorkgroupCountZ : 1;
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
// Feature bits required for inputs passed in system SGPRs.
|
2015-11-26 04:55:12 +08:00
|
|
|
bool WorkGroupIDX : 1; // Always initialized.
|
|
|
|
bool WorkGroupIDY : 1;
|
|
|
|
bool WorkGroupIDZ : 1;
|
|
|
|
bool WorkGroupInfo : 1;
|
2015-12-01 05:16:03 +08:00
|
|
|
bool PrivateSegmentWaveByteOffset : 1;
|
2015-11-26 04:55:12 +08:00
|
|
|
|
|
|
|
bool WorkItemIDX : 1; // Always initialized.
|
|
|
|
bool WorkItemIDY : 1;
|
|
|
|
bool WorkItemIDZ : 1;
|
2013-11-28 05:23:35 +08:00
|
|
|
|
2017-01-25 09:25:13 +08:00
|
|
|
// Private memory buffer
|
|
|
|
// Compute directly in sgpr[0:1]
|
|
|
|
// Other shaders indirect 64-bits at sgpr[0:1]
|
2017-06-26 11:01:31 +08:00
|
|
|
bool ImplicitBufferPtr : 1;
|
2017-01-25 09:25:13 +08:00
|
|
|
|
2017-07-28 23:52:08 +08:00
|
|
|
// Pointer to where the ABI inserts special kernel arguments separate from the
|
|
|
|
// user arguments. This is an offset from the KernargSegmentPtr.
|
|
|
|
bool ImplicitArgPtr : 1;
|
|
|
|
|
2017-09-29 17:49:35 +08:00
|
|
|
// The hard-wired high half of the address of the global information table
|
|
|
|
// for AMDPAL OS type. 0xffffffff represents no hard-wired high half, since
|
|
|
|
// current hardware only allows a 16 bit value.
|
|
|
|
unsigned GITPtrHigh;
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
MCPhysReg getNextUserSGPR() const {
|
|
|
|
assert(NumSystemSGPRs == 0 && "System SGPRs must be added after user SGPRs");
|
|
|
|
return AMDGPU::SGPR0 + NumUserSGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
MCPhysReg getNextSystemSGPR() const {
|
|
|
|
return AMDGPU::SGPR0 + NumUserSGPRs + NumSystemSGPRs;
|
|
|
|
}
|
|
|
|
|
2015-11-26 04:55:12 +08:00
|
|
|
public:
|
2013-11-28 05:23:35 +08:00
|
|
|
struct SpilledReg {
|
2017-01-21 08:53:49 +08:00
|
|
|
unsigned VGPR = AMDGPU::NoRegister;
|
|
|
|
int Lane = -1;
|
|
|
|
|
|
|
|
SpilledReg() = default;
|
2017-08-08 08:47:13 +08:00
|
|
|
SpilledReg(unsigned R, int L) : VGPR (R), Lane (L) {}
|
2017-01-21 08:53:49 +08:00
|
|
|
|
2013-11-28 05:23:35 +08:00
|
|
|
bool hasLane() { return Lane != -1;}
|
2016-03-05 02:31:18 +08:00
|
|
|
bool hasReg() { return VGPR != AMDGPU::NoRegister;}
|
2013-11-28 05:23:35 +08:00
|
|
|
};
|
|
|
|
|
2017-08-02 09:52:45 +08:00
|
|
|
struct SGPRSpillVGPRCSR {
|
|
|
|
// VGPR used for SGPR spills
|
|
|
|
unsigned VGPR;
|
|
|
|
|
|
|
|
// If the VGPR is a CSR, the stack slot used to save/restore it in the
|
|
|
|
// prolog/epilog.
|
|
|
|
Optional<int> FI;
|
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
SGPRSpillVGPRCSR(unsigned V, Optional<int> F) : VGPR(V), FI(F) {}
|
2017-08-02 09:52:45 +08:00
|
|
|
};
|
|
|
|
|
2017-02-22 03:12:08 +08:00
|
|
|
private:
|
|
|
|
// SGPR->VGPR spilling support.
|
2017-08-08 08:47:13 +08:00
|
|
|
using SpillRegMask = std::pair<unsigned, unsigned>;
|
2017-02-22 03:12:08 +08:00
|
|
|
|
|
|
|
// Track VGPR + wave index for each subregister of the SGPR spilled to
|
|
|
|
// frameindex key.
|
|
|
|
DenseMap<int, std::vector<SpilledReg>> SGPRToVGPRSpills;
|
|
|
|
unsigned NumVGPRSpillLanes = 0;
|
2017-08-02 09:52:45 +08:00
|
|
|
SmallVector<SGPRSpillVGPRCSR, 2> SpillVGPRs;
|
2017-02-22 03:12:08 +08:00
|
|
|
|
|
|
|
public:
|
2012-12-12 05:25:42 +08:00
|
|
|
SIMachineFunctionInfo(const MachineFunction &MF);
|
2017-01-21 08:53:49 +08:00
|
|
|
|
2017-02-22 03:12:08 +08:00
|
|
|
ArrayRef<SpilledReg> getSGPRToVGPRSpills(int FrameIndex) const {
|
|
|
|
auto I = SGPRToVGPRSpills.find(FrameIndex);
|
|
|
|
return (I == SGPRToVGPRSpills.end()) ?
|
|
|
|
ArrayRef<SpilledReg>() : makeArrayRef(I->second);
|
|
|
|
}
|
|
|
|
|
2017-08-02 09:52:45 +08:00
|
|
|
ArrayRef<SGPRSpillVGPRCSR> getSGPRSpillVGPRs() const {
|
|
|
|
return SpillVGPRs;
|
|
|
|
}
|
|
|
|
|
2017-02-22 03:12:08 +08:00
|
|
|
bool allocateSGPRSpillToVGPR(MachineFunction &MF, int FI);
|
|
|
|
void removeSGPRToVGPRFrameIndices(MachineFrameInfo &MFI);
|
|
|
|
|
2017-08-08 08:47:13 +08:00
|
|
|
bool hasCalculatedTID() const { return TIDReg != AMDGPU::NoRegister; }
|
|
|
|
unsigned getTIDReg() const { return TIDReg; }
|
2014-09-24 09:33:17 +08:00
|
|
|
void setTIDReg(unsigned Reg) { TIDReg = Reg; }
|
2015-11-05 13:27:10 +08:00
|
|
|
|
2017-08-12 04:42:08 +08:00
|
|
|
unsigned getBytesInStackArgArea() const {
|
|
|
|
return BytesInStackArgArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBytesInStackArgArea(unsigned Bytes) {
|
|
|
|
BytesInStackArgArea = Bytes;
|
|
|
|
}
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
// Add user SGPRs.
|
|
|
|
unsigned addPrivateSegmentBuffer(const SIRegisterInfo &TRI);
|
|
|
|
unsigned addDispatchPtr(const SIRegisterInfo &TRI);
|
|
|
|
unsigned addQueuePtr(const SIRegisterInfo &TRI);
|
|
|
|
unsigned addKernargSegmentPtr(const SIRegisterInfo &TRI);
|
2016-07-23 01:01:30 +08:00
|
|
|
unsigned addDispatchID(const SIRegisterInfo &TRI);
|
2016-02-12 14:31:30 +08:00
|
|
|
unsigned addFlatScratchInit(const SIRegisterInfo &TRI);
|
2017-06-26 11:01:31 +08:00
|
|
|
unsigned addImplicitBufferPtr(const SIRegisterInfo &TRI);
|
2015-12-01 05:16:03 +08:00
|
|
|
|
|
|
|
// Add system SGPRs.
|
|
|
|
unsigned addWorkGroupIDX() {
|
2017-08-04 07:00:29 +08:00
|
|
|
ArgInfo.WorkGroupIDX = ArgDescriptor::createRegister(getNextSystemSGPR());
|
2015-12-01 05:16:03 +08:00
|
|
|
NumSystemSGPRs += 1;
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupIDX.getRegister();
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned addWorkGroupIDY() {
|
2017-08-04 07:00:29 +08:00
|
|
|
ArgInfo.WorkGroupIDY = ArgDescriptor::createRegister(getNextSystemSGPR());
|
2015-12-01 05:16:03 +08:00
|
|
|
NumSystemSGPRs += 1;
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupIDY.getRegister();
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned addWorkGroupIDZ() {
|
2017-08-04 07:00:29 +08:00
|
|
|
ArgInfo.WorkGroupIDZ = ArgDescriptor::createRegister(getNextSystemSGPR());
|
2015-12-01 05:16:03 +08:00
|
|
|
NumSystemSGPRs += 1;
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupIDZ.getRegister();
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned addWorkGroupInfo() {
|
2017-08-04 07:00:29 +08:00
|
|
|
ArgInfo.WorkGroupInfo = ArgDescriptor::createRegister(getNextSystemSGPR());
|
2015-12-01 05:16:03 +08:00
|
|
|
NumSystemSGPRs += 1;
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupInfo.getRegister();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add special VGPR inputs
|
|
|
|
void setWorkItemIDX(ArgDescriptor Arg) {
|
|
|
|
ArgInfo.WorkItemIDX = Arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWorkItemIDY(ArgDescriptor Arg) {
|
|
|
|
ArgInfo.WorkItemIDY = Arg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setWorkItemIDZ(ArgDescriptor Arg) {
|
|
|
|
ArgInfo.WorkItemIDZ = Arg;
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned addPrivateSegmentWaveByteOffset() {
|
2017-08-04 07:00:29 +08:00
|
|
|
ArgInfo.PrivateSegmentWaveByteOffset
|
|
|
|
= ArgDescriptor::createRegister(getNextSystemSGPR());
|
2015-12-01 05:16:03 +08:00
|
|
|
NumSystemSGPRs += 1;
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.PrivateSegmentWaveByteOffset.getRegister();
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
|
|
|
|
2016-04-15 00:27:03 +08:00
|
|
|
void setPrivateSegmentWaveByteOffset(unsigned Reg) {
|
2017-08-04 07:00:29 +08:00
|
|
|
ArgInfo.PrivateSegmentWaveByteOffset = ArgDescriptor::createRegister(Reg);
|
2016-04-15 00:27:03 +08:00
|
|
|
}
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
bool hasPrivateSegmentBuffer() const {
|
|
|
|
return PrivateSegmentBuffer;
|
|
|
|
}
|
|
|
|
|
2015-11-26 04:55:12 +08:00
|
|
|
bool hasDispatchPtr() const {
|
|
|
|
return DispatchPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasQueuePtr() const {
|
|
|
|
return QueuePtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasKernargSegmentPtr() const {
|
|
|
|
return KernargSegmentPtr;
|
|
|
|
}
|
|
|
|
|
2016-07-23 01:01:30 +08:00
|
|
|
bool hasDispatchID() const {
|
|
|
|
return DispatchID;
|
|
|
|
}
|
|
|
|
|
2015-11-26 04:55:12 +08:00
|
|
|
bool hasFlatScratchInit() const {
|
|
|
|
return FlatScratchInit;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasGridWorkgroupCountX() const {
|
|
|
|
return GridWorkgroupCountX;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasGridWorkgroupCountY() const {
|
|
|
|
return GridWorkgroupCountY;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasGridWorkgroupCountZ() const {
|
|
|
|
return GridWorkgroupCountZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasWorkGroupIDX() const {
|
|
|
|
return WorkGroupIDX;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasWorkGroupIDY() const {
|
|
|
|
return WorkGroupIDY;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasWorkGroupIDZ() const {
|
|
|
|
return WorkGroupIDZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasWorkGroupInfo() const {
|
|
|
|
return WorkGroupInfo;
|
|
|
|
}
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
bool hasPrivateSegmentWaveByteOffset() const {
|
|
|
|
return PrivateSegmentWaveByteOffset;
|
|
|
|
}
|
|
|
|
|
2015-11-26 04:55:12 +08:00
|
|
|
bool hasWorkItemIDX() const {
|
|
|
|
return WorkItemIDX;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasWorkItemIDY() const {
|
|
|
|
return WorkItemIDY;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasWorkItemIDZ() const {
|
|
|
|
return WorkItemIDZ;
|
|
|
|
}
|
|
|
|
|
2017-07-28 23:52:08 +08:00
|
|
|
bool hasImplicitArgPtr() const {
|
|
|
|
return ImplicitArgPtr;
|
|
|
|
}
|
|
|
|
|
2017-06-26 11:01:31 +08:00
|
|
|
bool hasImplicitBufferPtr() const {
|
|
|
|
return ImplicitBufferPtr;
|
2017-01-25 09:25:13 +08:00
|
|
|
}
|
|
|
|
|
2017-08-04 07:00:29 +08:00
|
|
|
AMDGPUFunctionArgInfo &getArgInfo() {
|
|
|
|
return ArgInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
const AMDGPUFunctionArgInfo &getArgInfo() const {
|
|
|
|
return ArgInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<const ArgDescriptor *, const TargetRegisterClass *>
|
|
|
|
getPreloadedValue(AMDGPUFunctionArgInfo::PreloadedValue Value) const {
|
|
|
|
return ArgInfo.getPreloadedValue(Value);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const {
|
|
|
|
return ArgInfo.getPreloadedValue(Value).first->getRegister();
|
|
|
|
}
|
|
|
|
|
2017-09-29 17:49:35 +08:00
|
|
|
unsigned getGITPtrHigh() const {
|
|
|
|
return GITPtrHigh;
|
|
|
|
}
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
unsigned getNumUserSGPRs() const {
|
|
|
|
return NumUserSGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getNumPreloadedSGPRs() const {
|
|
|
|
return NumUserSGPRs + NumSystemSGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getPrivateSegmentWaveByteOffsetSystemSGPR() const {
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.PrivateSegmentWaveByteOffset.getRegister();
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
|
|
|
|
2015-11-26 04:55:12 +08:00
|
|
|
/// \brief Returns the physical register reserved for use as the resource
|
|
|
|
/// descriptor for scratch accesses.
|
|
|
|
unsigned getScratchRSrcReg() const {
|
|
|
|
return ScratchRSrcReg;
|
|
|
|
}
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
void setScratchRSrcReg(unsigned Reg) {
|
|
|
|
assert(Reg != AMDGPU::NoRegister && "Should never be unset");
|
|
|
|
ScratchRSrcReg = Reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getScratchWaveOffsetReg() const {
|
|
|
|
return ScratchWaveOffsetReg;
|
|
|
|
}
|
|
|
|
|
2017-04-25 02:05:16 +08:00
|
|
|
unsigned getFrameOffsetReg() const {
|
|
|
|
return FrameOffsetReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setStackPtrOffsetReg(unsigned Reg) {
|
|
|
|
StackPtrOffsetReg = Reg;
|
|
|
|
}
|
|
|
|
|
2017-07-19 00:44:56 +08:00
|
|
|
// Note the unset value for this is AMDGPU::SP_REG rather than
|
|
|
|
// NoRegister. This is mostly a workaround for MIR tests where state that
|
|
|
|
// can't be directly computed from the function is not preserved in serialized
|
|
|
|
// MIR.
|
2017-04-25 02:05:16 +08:00
|
|
|
unsigned getStackPtrOffsetReg() const {
|
|
|
|
return StackPtrOffsetReg;
|
|
|
|
}
|
|
|
|
|
2015-12-01 05:16:03 +08:00
|
|
|
void setScratchWaveOffsetReg(unsigned Reg) {
|
|
|
|
assert(Reg != AMDGPU::NoRegister && "Should never be unset");
|
|
|
|
ScratchWaveOffsetReg = Reg;
|
2017-05-18 05:56:25 +08:00
|
|
|
if (isEntryFunction())
|
|
|
|
FrameOffsetReg = ScratchWaveOffsetReg;
|
2015-12-01 05:16:03 +08:00
|
|
|
}
|
2015-11-26 04:55:12 +08:00
|
|
|
|
2016-04-26 03:27:24 +08:00
|
|
|
unsigned getQueuePtrUserSGPR() const {
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.QueuePtr.getRegister();
|
2016-04-26 03:27:24 +08:00
|
|
|
}
|
|
|
|
|
2017-06-26 11:01:31 +08:00
|
|
|
unsigned getImplicitBufferPtrUserSGPR() const {
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.ImplicitBufferPtr.getRegister();
|
2017-01-25 09:25:13 +08:00
|
|
|
}
|
|
|
|
|
2015-11-05 13:27:10 +08:00
|
|
|
bool hasSpilledSGPRs() const {
|
|
|
|
return HasSpilledSGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setHasSpilledSGPRs(bool Spill = true) {
|
|
|
|
HasSpilledSGPRs = Spill;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasSpilledVGPRs() const {
|
|
|
|
return HasSpilledVGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setHasSpilledVGPRs(bool Spill = true) {
|
|
|
|
HasSpilledVGPRs = Spill;
|
|
|
|
}
|
2014-09-24 09:33:17 +08:00
|
|
|
|
2016-02-12 14:31:30 +08:00
|
|
|
bool hasNonSpillStackObjects() const {
|
|
|
|
return HasNonSpillStackObjects;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setHasNonSpillStackObjects(bool StackObject = true) {
|
|
|
|
HasNonSpillStackObjects = StackObject;
|
|
|
|
}
|
|
|
|
|
2016-07-14 01:35:15 +08:00
|
|
|
unsigned getNumSpilledSGPRs() const {
|
|
|
|
return NumSpilledSGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getNumSpilledVGPRs() const {
|
|
|
|
return NumSpilledVGPRs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addToSpilledSGPRs(unsigned num) {
|
|
|
|
NumSpilledSGPRs += num;
|
|
|
|
}
|
|
|
|
|
|
|
|
void addToSpilledVGPRs(unsigned num) {
|
|
|
|
NumSpilledVGPRs += num;
|
|
|
|
}
|
|
|
|
|
2016-01-13 19:45:36 +08:00
|
|
|
unsigned getPSInputAddr() const {
|
|
|
|
return PSInputAddr;
|
|
|
|
}
|
|
|
|
|
2017-04-12 06:29:24 +08:00
|
|
|
unsigned getPSInputEnable() const {
|
|
|
|
return PSInputEnable;
|
|
|
|
}
|
|
|
|
|
2016-01-13 19:45:36 +08:00
|
|
|
bool isPSInputAllocated(unsigned Index) const {
|
|
|
|
return PSInputAddr & (1 << Index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void markPSInputAllocated(unsigned Index) {
|
|
|
|
PSInputAddr |= 1 << Index;
|
|
|
|
}
|
|
|
|
|
2017-04-12 06:29:24 +08:00
|
|
|
void markPSInputEnabled(unsigned Index) {
|
|
|
|
PSInputEnable |= 1 << Index;
|
|
|
|
}
|
|
|
|
|
2016-01-14 01:23:09 +08:00
|
|
|
bool returnsVoid() const {
|
|
|
|
return ReturnsVoid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setIfReturnsVoid(bool Value) {
|
|
|
|
ReturnsVoid = Value;
|
|
|
|
}
|
|
|
|
|
2016-09-07 04:22:28 +08:00
|
|
|
/// \returns A pair of default/requested minimum/maximum flat work group sizes
|
|
|
|
/// for this function.
|
|
|
|
std::pair<unsigned, unsigned> getFlatWorkGroupSizes() const {
|
|
|
|
return FlatWorkGroupSizes;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Default/requested minimum flat work group size for this function.
|
|
|
|
unsigned getMinFlatWorkGroupSize() const {
|
|
|
|
return FlatWorkGroupSizes.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Default/requested maximum flat work group size for this function.
|
|
|
|
unsigned getMaxFlatWorkGroupSize() const {
|
|
|
|
return FlatWorkGroupSizes.second;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns A pair of default/requested minimum/maximum number of waves per
|
|
|
|
/// execution unit.
|
|
|
|
std::pair<unsigned, unsigned> getWavesPerEU() const {
|
|
|
|
return WavesPerEU;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Default/requested minimum number of waves per execution unit.
|
|
|
|
unsigned getMinWavesPerEU() const {
|
|
|
|
return WavesPerEU.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Default/requested maximum number of waves per execution unit.
|
|
|
|
unsigned getMaxWavesPerEU() const {
|
|
|
|
return WavesPerEU.second;
|
2016-04-27 01:24:40 +08:00
|
|
|
}
|
|
|
|
|
2016-06-25 11:11:28 +08:00
|
|
|
/// \returns Stack object index for \p Dim's work group ID.
|
|
|
|
int getDebuggerWorkGroupIDStackObjectIndex(unsigned Dim) const {
|
|
|
|
assert(Dim < 3);
|
|
|
|
return DebuggerWorkGroupIDStackObjectIndices[Dim];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Sets stack object index for \p Dim's work group ID to \p ObjectIdx.
|
|
|
|
void setDebuggerWorkGroupIDStackObjectIndex(unsigned Dim, int ObjectIdx) {
|
|
|
|
assert(Dim < 3);
|
|
|
|
DebuggerWorkGroupIDStackObjectIndices[Dim] = ObjectIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns Stack object index for \p Dim's work item ID.
|
|
|
|
int getDebuggerWorkItemIDStackObjectIndex(unsigned Dim) const {
|
|
|
|
assert(Dim < 3);
|
|
|
|
return DebuggerWorkItemIDStackObjectIndices[Dim];
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Sets stack object index for \p Dim's work item ID to \p ObjectIdx.
|
|
|
|
void setDebuggerWorkItemIDStackObjectIndex(unsigned Dim, int ObjectIdx) {
|
|
|
|
assert(Dim < 3);
|
|
|
|
DebuggerWorkItemIDStackObjectIndices[Dim] = ObjectIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns SGPR used for \p Dim's work group ID.
|
|
|
|
unsigned getWorkGroupIDSGPR(unsigned Dim) const {
|
|
|
|
switch (Dim) {
|
|
|
|
case 0:
|
|
|
|
assert(hasWorkGroupIDX());
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupIDX.getRegister();
|
2016-06-25 11:11:28 +08:00
|
|
|
case 1:
|
|
|
|
assert(hasWorkGroupIDY());
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupIDY.getRegister();
|
2016-06-25 11:11:28 +08:00
|
|
|
case 2:
|
|
|
|
assert(hasWorkGroupIDZ());
|
2017-08-04 07:00:29 +08:00
|
|
|
return ArgInfo.WorkGroupIDZ.getRegister();
|
2016-06-25 11:11:28 +08:00
|
|
|
}
|
|
|
|
llvm_unreachable("unexpected dimension");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \returns VGPR used for \p Dim' work item ID.
|
|
|
|
unsigned getWorkItemIDVGPR(unsigned Dim) const {
|
|
|
|
switch (Dim) {
|
|
|
|
case 0:
|
|
|
|
assert(hasWorkItemIDX());
|
|
|
|
return AMDGPU::VGPR0;
|
|
|
|
case 1:
|
|
|
|
assert(hasWorkItemIDY());
|
|
|
|
return AMDGPU::VGPR1;
|
|
|
|
case 2:
|
|
|
|
assert(hasWorkItemIDZ());
|
|
|
|
return AMDGPU::VGPR2;
|
|
|
|
}
|
|
|
|
llvm_unreachable("unexpected dimension");
|
|
|
|
}
|
2016-12-20 23:52:17 +08:00
|
|
|
|
2017-04-19 04:59:40 +08:00
|
|
|
unsigned getLDSWaveSpillSize() const {
|
|
|
|
return LDSWaveSpillSize;
|
|
|
|
}
|
|
|
|
|
2016-12-21 01:19:44 +08:00
|
|
|
const AMDGPUBufferPseudoSourceValue *getBufferPSV() const {
|
|
|
|
return &BufferPSV;
|
|
|
|
}
|
|
|
|
|
2016-12-21 01:26:34 +08:00
|
|
|
const AMDGPUImagePseudoSourceValue *getImagePSV() const {
|
|
|
|
return &ImagePSV;
|
2016-12-20 23:52:17 +08:00
|
|
|
}
|
2012-12-12 05:25:42 +08:00
|
|
|
};
|
|
|
|
|
2017-01-21 08:53:49 +08:00
|
|
|
} // end namespace llvm
|
2012-12-12 05:25:42 +08:00
|
|
|
|
2017-01-21 08:53:49 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_AMDGPU_SIMACHINEFUNCTIONINFO_H
|