2016-12-22 03:06:24 +08:00
|
|
|
//===-- llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp - Call lowering -----===//
|
2016-04-15 03:09:28 +08:00
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2016-04-15 03:09:28 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// This file implements the lowering of LLVM calls to machine code calls for
|
|
|
|
/// GlobalISel.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "AMDGPUCallLowering.h"
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
#include "AMDGPU.h"
|
2016-04-15 03:09:28 +08:00
|
|
|
#include "AMDGPUISelLowering.h"
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
#include "AMDGPUSubtarget.h"
|
|
|
|
#include "SIISelLowering.h"
|
|
|
|
#include "SIMachineFunctionInfo.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "SIRegisterInfo.h"
|
AMDGPU: Remove #include "MCTargetDesc/AMDGPUMCTargetDesc.h" from common headers
Summary:
MCTargetDesc/AMDGPUMCTargetDesc.h contains enums for all the instuction
and register defintions, which are huge so we only want to include
them where needed.
This will also make it easier if we want to split the R600 and GCN
definitions into separate tablegenerated files.
I was unable to remove AMDGPUMCTargetDesc.h from SIMachineFunctionInfo.h
because it uses some enums from the header to initialize default values
for the SIMachineFunction class, so I ended up having to remove includes of
SIMachineFunctionInfo.h from headers too.
Reviewers: arsenm, nhaehnle
Reviewed By: nhaehnle
Subscribers: MatzeB, kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D46272
llvm-svn: 332930
2018-05-22 10:03:23 +08:00
|
|
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
#include "llvm/CodeGen/Analysis.h"
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
#include "llvm/CodeGen/CallingConvLower.h"
|
2016-04-15 03:09:28 +08:00
|
|
|
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
#include "llvm/Support/LowLevelTypeImpl.h"
|
2016-04-15 03:09:28 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
namespace {
|
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
struct OutgoingValueHandler : public CallLowering::ValueHandler {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
OutgoingValueHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI,
|
2019-07-26 10:36:05 +08:00
|
|
|
MachineInstrBuilder MIB, CCAssignFn *AssignFn)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
: ValueHandler(B, MRI, AssignFn), MIB(MIB) {}
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
|
|
|
|
MachineInstrBuilder MIB;
|
|
|
|
|
2019-10-19 04:13:42 +08:00
|
|
|
bool isIncomingArgumentHandler() const override { return false; }
|
|
|
|
|
2019-06-25 00:16:12 +08:00
|
|
|
Register getStackAddress(uint64_t Size, int64_t Offset,
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
MachinePointerInfo &MPO) override {
|
|
|
|
llvm_unreachable("not implemented");
|
|
|
|
}
|
|
|
|
|
2019-06-25 00:16:12 +08:00
|
|
|
void assignValueToAddress(Register ValVReg, Register Addr, uint64_t Size,
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
MachinePointerInfo &MPO, CCValAssign &VA) override {
|
|
|
|
llvm_unreachable("not implemented");
|
|
|
|
}
|
|
|
|
|
2019-06-25 00:16:12 +08:00
|
|
|
void assignValueToReg(Register ValVReg, Register PhysReg,
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
CCValAssign &VA) override {
|
2019-07-26 10:36:05 +08:00
|
|
|
Register ExtReg;
|
|
|
|
if (VA.getLocVT().getSizeInBits() < 32) {
|
|
|
|
// 16-bit types are reported as legal for 32-bit registers. We need to
|
|
|
|
// extend and do a 32-bit copy to avoid the verifier complaining about it.
|
|
|
|
ExtReg = MIRBuilder.buildAnyExt(LLT::scalar(32), ValVReg).getReg(0);
|
|
|
|
} else
|
|
|
|
ExtReg = extendRegister(ValVReg, VA);
|
|
|
|
|
|
|
|
MIRBuilder.buildCopy(PhysReg, ExtReg);
|
|
|
|
MIB.addUse(PhysReg, RegState::Implicit);
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool assignArg(unsigned ValNo, MVT ValVT, MVT LocVT,
|
|
|
|
CCValAssign::LocInfo LocInfo,
|
|
|
|
const CallLowering::ArgInfo &Info,
|
2019-09-04 05:42:28 +08:00
|
|
|
ISD::ArgFlagsTy Flags,
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
CCState &State) override {
|
2019-09-04 05:42:28 +08:00
|
|
|
return AssignFn(ValNo, ValVT, LocVT, LocInfo, Flags, State);
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
struct IncomingArgHandler : public CallLowering::ValueHandler {
|
|
|
|
uint64_t StackUsed = 0;
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
IncomingArgHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI,
|
2019-07-19 22:15:18 +08:00
|
|
|
CCAssignFn *AssignFn)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
: ValueHandler(B, MRI, AssignFn) {}
|
2019-07-19 22:15:18 +08:00
|
|
|
|
|
|
|
Register getStackAddress(uint64_t Size, int64_t Offset,
|
|
|
|
MachinePointerInfo &MPO) override {
|
|
|
|
auto &MFI = MIRBuilder.getMF().getFrameInfo();
|
|
|
|
int FI = MFI.CreateFixedObject(Size, Offset, true);
|
|
|
|
MPO = MachinePointerInfo::getFixedStack(MIRBuilder.getMF(), FI);
|
[GlobalISel] Tidy up unnecessary calls to createGenericVirtualRegister
Summary:
As a side effect some redundant copies of constant values are removed by
CSEMIRBuilder.
Reviewers: aemerson, arsenm, dsanders, aditya_nandakumar
Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, hiraditya, jrtc27, atanasyan, volkan, Petar.Avramovic, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73789
2020-01-31 20:40:31 +08:00
|
|
|
auto AddrReg = MIRBuilder.buildFrameIndex(
|
|
|
|
LLT::pointer(AMDGPUAS::PRIVATE_ADDRESS, 32), FI);
|
2019-07-19 22:15:18 +08:00
|
|
|
StackUsed = std::max(StackUsed, Size + Offset);
|
[GlobalISel] Tidy up unnecessary calls to createGenericVirtualRegister
Summary:
As a side effect some redundant copies of constant values are removed by
CSEMIRBuilder.
Reviewers: aemerson, arsenm, dsanders, aditya_nandakumar
Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, hiraditya, jrtc27, atanasyan, volkan, Petar.Avramovic, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73789
2020-01-31 20:40:31 +08:00
|
|
|
return AddrReg.getReg(0);
|
2019-07-19 22:15:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void assignValueToReg(Register ValVReg, Register PhysReg,
|
|
|
|
CCValAssign &VA) override {
|
|
|
|
markPhysRegUsed(PhysReg);
|
|
|
|
|
|
|
|
if (VA.getLocVT().getSizeInBits() < 32) {
|
|
|
|
// 16-bit types are reported as legal for 32-bit registers. We need to do
|
|
|
|
// a 32-bit copy, and truncate to avoid the verifier complaining about it.
|
|
|
|
auto Copy = MIRBuilder.buildCopy(LLT::scalar(32), PhysReg);
|
|
|
|
MIRBuilder.buildTrunc(ValVReg, Copy);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (VA.getLocInfo()) {
|
|
|
|
case CCValAssign::LocInfo::SExt:
|
|
|
|
case CCValAssign::LocInfo::ZExt:
|
|
|
|
case CCValAssign::LocInfo::AExt: {
|
|
|
|
auto Copy = MIRBuilder.buildCopy(LLT{VA.getLocVT()}, PhysReg);
|
|
|
|
MIRBuilder.buildTrunc(ValVReg, Copy);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
MIRBuilder.buildCopy(ValVReg, PhysReg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void assignValueToAddress(Register ValVReg, Register Addr, uint64_t Size,
|
|
|
|
MachinePointerInfo &MPO, CCValAssign &VA) override {
|
2019-08-28 12:01:46 +08:00
|
|
|
MachineFunction &MF = MIRBuilder.getMF();
|
|
|
|
unsigned Align = inferAlignmentFromPtrInfo(MF, MPO);
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
// FIXME: Get alignment
|
2019-08-28 12:01:46 +08:00
|
|
|
auto MMO = MF.getMachineMemOperand(
|
|
|
|
MPO, MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant, Size,
|
|
|
|
Align);
|
2019-07-19 22:15:18 +08:00
|
|
|
MIRBuilder.buildLoad(ValVReg, Addr, *MMO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// How the physical register gets marked varies between formal
|
|
|
|
/// parameters (it's a basic-block live-in), and a call instruction
|
|
|
|
/// (it's an implicit-def of the BL).
|
|
|
|
virtual void markPhysRegUsed(unsigned PhysReg) = 0;
|
|
|
|
|
|
|
|
// FIXME: What is the point of this being a callback?
|
2019-08-06 07:05:28 +08:00
|
|
|
bool isIncomingArgumentHandler() const override { return true; }
|
2019-07-19 22:15:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FormalArgHandler : public IncomingArgHandler {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
FormalArgHandler(MachineIRBuilder &B, MachineRegisterInfo &MRI,
|
2019-07-19 22:15:18 +08:00
|
|
|
CCAssignFn *AssignFn)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
: IncomingArgHandler(B, MRI, AssignFn) {}
|
2019-07-19 22:15:18 +08:00
|
|
|
|
|
|
|
void markPhysRegUsed(unsigned PhysReg) override {
|
|
|
|
MIRBuilder.getMBB().addLiveIn(PhysReg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
}
|
|
|
|
|
2016-04-15 03:09:28 +08:00
|
|
|
AMDGPUCallLowering::AMDGPUCallLowering(const AMDGPUTargetLowering &TLI)
|
2018-08-31 13:49:54 +08:00
|
|
|
: CallLowering(&TLI) {
|
2016-04-15 03:09:28 +08:00
|
|
|
}
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
void AMDGPUCallLowering::splitToValueTypes(
|
|
|
|
const ArgInfo &OrigArg, SmallVectorImpl<ArgInfo> &SplitArgs,
|
|
|
|
const DataLayout &DL, MachineRegisterInfo &MRI, CallingConv::ID CallConv,
|
|
|
|
SplitArgTy PerformArgSplit) const {
|
|
|
|
const SITargetLowering &TLI = *getTLI<SITargetLowering>();
|
|
|
|
LLVMContext &Ctx = OrigArg.Ty->getContext();
|
|
|
|
|
|
|
|
if (OrigArg.Ty->isVoidTy())
|
|
|
|
return;
|
|
|
|
|
|
|
|
SmallVector<EVT, 4> SplitVTs;
|
|
|
|
ComputeValueVTs(TLI, DL, OrigArg.Ty, SplitVTs);
|
|
|
|
|
2019-07-19 22:29:30 +08:00
|
|
|
assert(OrigArg.Regs.size() == SplitVTs.size());
|
2019-07-19 22:15:18 +08:00
|
|
|
|
2019-07-19 22:29:30 +08:00
|
|
|
int SplitIdx = 0;
|
|
|
|
for (EVT VT : SplitVTs) {
|
|
|
|
unsigned NumParts = TLI.getNumRegistersForCallingConv(Ctx, CallConv, VT);
|
|
|
|
Type *Ty = VT.getTypeForEVT(Ctx);
|
2019-07-19 22:15:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-07-19 22:29:30 +08:00
|
|
|
if (NumParts == 1) {
|
|
|
|
// No splitting to do, but we want to replace the original type (e.g. [1 x
|
|
|
|
// double] -> double).
|
|
|
|
SplitArgs.emplace_back(OrigArg.Regs[SplitIdx], Ty,
|
|
|
|
OrigArg.Flags, OrigArg.IsFixed);
|
|
|
|
|
|
|
|
++SplitIdx;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
LLT LLTy = getLLTForType(*Ty, DL);
|
|
|
|
|
|
|
|
SmallVector<Register, 8> SplitRegs;
|
|
|
|
|
|
|
|
EVT PartVT = TLI.getRegisterTypeForCallingConv(Ctx, CallConv, VT);
|
|
|
|
Type *PartTy = PartVT.getTypeForEVT(Ctx);
|
|
|
|
LLT PartLLT = getLLTForType(*PartTy, DL);
|
|
|
|
|
|
|
|
// FIXME: Should we be reporting all of the part registers for a single
|
|
|
|
// argument, and let handleAssignments take care of the repacking?
|
|
|
|
for (unsigned i = 0; i < NumParts; ++i) {
|
|
|
|
Register PartReg = MRI.createGenericVirtualRegister(PartLLT);
|
|
|
|
SplitRegs.push_back(PartReg);
|
|
|
|
SplitArgs.emplace_back(ArrayRef<Register>(PartReg), PartTy, OrigArg.Flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
PerformArgSplit(SplitRegs, LLTy, PartLLT, SplitIdx);
|
|
|
|
|
|
|
|
++SplitIdx;
|
|
|
|
}
|
2019-07-19 22:15:18 +08:00
|
|
|
}
|
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
// Get the appropriate type to make \p OrigTy \p Factor times bigger.
|
|
|
|
static LLT getMultipleType(LLT OrigTy, int Factor) {
|
|
|
|
if (OrigTy.isVector()) {
|
|
|
|
return LLT::vector(OrigTy.getNumElements() * Factor,
|
|
|
|
OrigTy.getElementType());
|
|
|
|
}
|
|
|
|
|
|
|
|
return LLT::scalar(OrigTy.getSizeInBits() * Factor);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Move to generic code
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
static void unpackRegsToOrigType(MachineIRBuilder &B,
|
2019-07-26 10:36:05 +08:00
|
|
|
ArrayRef<Register> DstRegs,
|
|
|
|
Register SrcReg,
|
|
|
|
LLT SrcTy,
|
|
|
|
LLT PartTy) {
|
|
|
|
assert(DstRegs.size() > 1 && "Nothing to unpack");
|
|
|
|
|
|
|
|
const unsigned SrcSize = SrcTy.getSizeInBits();
|
|
|
|
const unsigned PartSize = PartTy.getSizeInBits();
|
|
|
|
|
|
|
|
if (SrcTy.isVector() && !PartTy.isVector() &&
|
|
|
|
PartSize > SrcTy.getElementType().getSizeInBits()) {
|
|
|
|
// Vector was scalarized, and the elements extended.
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
auto UnmergeToEltTy = B.buildUnmerge(SrcTy.getElementType(),
|
2019-07-26 10:36:05 +08:00
|
|
|
SrcReg);
|
|
|
|
for (int i = 0, e = DstRegs.size(); i != e; ++i)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildAnyExt(DstRegs[i], UnmergeToEltTy.getReg(i));
|
2019-07-26 10:36:05 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SrcSize % PartSize == 0) {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildUnmerge(DstRegs, SrcReg);
|
2019-07-26 10:36:05 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int NumRoundedParts = (SrcSize + PartSize - 1) / PartSize;
|
|
|
|
|
|
|
|
LLT BigTy = getMultipleType(PartTy, NumRoundedParts);
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
auto ImpDef = B.buildUndef(BigTy);
|
2019-07-26 10:36:05 +08:00
|
|
|
|
[GlobalISel] Tidy up unnecessary calls to createGenericVirtualRegister
Summary:
As a side effect some redundant copies of constant values are removed by
CSEMIRBuilder.
Reviewers: aemerson, arsenm, dsanders, aditya_nandakumar
Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, hiraditya, jrtc27, atanasyan, volkan, Petar.Avramovic, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73789
2020-01-31 20:40:31 +08:00
|
|
|
auto Big = B.buildInsert(BigTy, ImpDef.getReg(0), SrcReg, 0).getReg(0);
|
2019-07-26 10:36:05 +08:00
|
|
|
|
|
|
|
int64_t Offset = 0;
|
|
|
|
for (unsigned i = 0, e = DstRegs.size(); i != e; ++i, Offset += PartSize)
|
[GlobalISel] Tidy up unnecessary calls to createGenericVirtualRegister
Summary:
As a side effect some redundant copies of constant values are removed by
CSEMIRBuilder.
Reviewers: aemerson, arsenm, dsanders, aditya_nandakumar
Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, hiraditya, jrtc27, atanasyan, volkan, Petar.Avramovic, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73789
2020-01-31 20:40:31 +08:00
|
|
|
B.buildExtract(DstRegs[i], Big, Offset);
|
2019-07-26 10:36:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Lower the return value for the already existing \p Ret. This assumes that
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
/// \p B's insertion point is correct.
|
|
|
|
bool AMDGPUCallLowering::lowerReturnVal(MachineIRBuilder &B,
|
2019-07-26 10:36:05 +08:00
|
|
|
const Value *Val, ArrayRef<Register> VRegs,
|
|
|
|
MachineInstrBuilder &Ret) const {
|
|
|
|
if (!Val)
|
|
|
|
return true;
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
auto &MF = B.getMF();
|
2019-07-26 10:36:05 +08:00
|
|
|
const auto &F = MF.getFunction();
|
|
|
|
const DataLayout &DL = MF.getDataLayout();
|
|
|
|
|
|
|
|
CallingConv::ID CC = F.getCallingConv();
|
|
|
|
const SITargetLowering &TLI = *getTLI<SITargetLowering>();
|
|
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
|
|
|
|
ArgInfo OrigRetInfo(VRegs, Val->getType());
|
|
|
|
setArgFlags(OrigRetInfo, AttributeList::ReturnIndex, DL, F);
|
|
|
|
SmallVector<ArgInfo, 4> SplitRetInfos;
|
|
|
|
|
|
|
|
splitToValueTypes(
|
|
|
|
OrigRetInfo, SplitRetInfos, DL, MRI, CC,
|
|
|
|
[&](ArrayRef<Register> Regs, LLT LLTy, LLT PartLLT, int VTSplitIdx) {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
unpackRegsToOrigType(B, Regs, VRegs[VTSplitIdx], LLTy, PartLLT);
|
2019-07-26 10:36:05 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
CCAssignFn *AssignFn = TLI.CCAssignFnForReturn(CC, F.isVarArg());
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
OutgoingValueHandler RetHandler(B, MF.getRegInfo(), Ret, AssignFn);
|
|
|
|
return handleAssignments(B, SplitRetInfos, RetHandler);
|
2019-07-26 10:36:05 +08:00
|
|
|
}
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
bool AMDGPUCallLowering::lowerReturn(MachineIRBuilder &B,
|
2018-08-02 16:33:31 +08:00
|
|
|
const Value *Val,
|
2019-06-24 23:50:29 +08:00
|
|
|
ArrayRef<Register> VRegs) const {
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineFunction &MF = B.getMF();
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
|
|
|
|
MFI->setIfReturnsVoid(!Val);
|
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
assert(!Val == VRegs.empty() && "Return value without a vreg");
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
CallingConv::ID CC = B.getMF().getFunction().getCallingConv();
|
2019-07-26 10:36:05 +08:00
|
|
|
const bool IsShader = AMDGPU::isShader(CC);
|
|
|
|
const bool IsWaveEnd = (IsShader && MFI->returnsVoid()) ||
|
|
|
|
AMDGPU::isKernel(CC);
|
|
|
|
if (IsWaveEnd) {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildInstr(AMDGPU::S_ENDPGM)
|
2019-07-26 10:36:05 +08:00
|
|
|
.addImm(0);
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
auto const &ST = B.getMF().getSubtarget<GCNSubtarget>();
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
|
2019-07-27 01:13:59 +08:00
|
|
|
unsigned ReturnOpc =
|
|
|
|
IsShader ? AMDGPU::SI_RETURN_TO_EPILOG : AMDGPU::S_SETPC_B64_return;
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
auto Ret = B.buildInstrNoInsert(ReturnOpc);
|
2019-07-26 10:36:05 +08:00
|
|
|
Register ReturnAddrVReg;
|
|
|
|
if (ReturnOpc == AMDGPU::S_SETPC_B64_return) {
|
|
|
|
ReturnAddrVReg = MRI.createVirtualRegister(&AMDGPU::CCR_SGPR_64RegClass);
|
|
|
|
Ret.addUse(ReturnAddrVReg);
|
AMDGPU/GlobalISel: Implement call lowering for shaders returning values
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, volkan, llvm-commits
Differential Revision: https://reviews.llvm.org/D57166
llvm-svn: 357964
2019-04-09 10:26:03 +08:00
|
|
|
}
|
2019-07-26 10:36:05 +08:00
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
if (!lowerReturnVal(B, Val, VRegs, Ret))
|
AMDGPU/GlobalISel: Fall-back to SelectionDAG for non-void functions
Reviewers: arsenm, nhaehnle
Reviewed By: nhaehnle
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D45843
llvm-svn: 330774
2018-04-25 05:29:36 +08:00
|
|
|
return false;
|
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
if (ReturnOpc == AMDGPU::S_SETPC_B64_return) {
|
|
|
|
const SIRegisterInfo *TRI = ST.getRegisterInfo();
|
|
|
|
Register LiveInReturn = MF.addLiveIn(TRI->getReturnAddressReg(MF),
|
|
|
|
&AMDGPU::SGPR_64RegClass);
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildCopy(ReturnAddrVReg, LiveInReturn);
|
2019-07-26 10:36:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Handle CalleeSavedRegsViaCopy.
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.insertInstr(Ret);
|
2016-04-15 03:09:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
Register AMDGPUCallLowering::lowerParameterPtr(MachineIRBuilder &B,
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
Type *ParamTy,
|
2018-07-06 01:01:20 +08:00
|
|
|
uint64_t Offset) const {
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineFunction &MF = B.getMF();
|
2017-08-04 07:00:29 +08:00
|
|
|
const SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
2017-12-16 06:22:58 +08:00
|
|
|
const Function &F = MF.getFunction();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
const DataLayout &DL = F.getParent()->getDataLayout();
|
2018-08-31 13:49:54 +08:00
|
|
|
PointerType *PtrTy = PointerType::get(ParamTy, AMDGPUAS::CONSTANT_ADDRESS);
|
Recommit: [globalisel] Change LLT constructor string into an LLT-based object that knows how to generate it.
Summary:
This will allow future patches to inspect the details of the LLT. The implementation is now split between
the Support and CodeGen libraries to allow TableGen to use this class without introducing layering concerns.
Thanks to Ahmed Bougacha for finding a reasonable way to avoid the layering issue and providing the version of this patch without that problem.
The problem with the previous commit appears to have been that TableGen was including CodeGen/LowLevelType.h instead of Support/LowLevelTypeImpl.h.
Reviewers: t.p.northover, qcolombet, rovka, aditya_nandakumar, ab, javed.absar
Subscribers: arsenm, nhaehnle, mgorny, dberris, llvm-commits, kristof.beyls
Differential Revision: https://reviews.llvm.org/D30046
llvm-svn: 297241
2017-03-08 07:20:35 +08:00
|
|
|
LLT PtrType = getLLTForType(*PtrTy, DL);
|
2019-06-25 00:16:12 +08:00
|
|
|
Register KernArgSegmentPtr =
|
2017-08-04 07:00:29 +08:00
|
|
|
MFI->getPreloadedReg(AMDGPUFunctionArgInfo::KERNARG_SEGMENT_PTR);
|
2019-06-25 00:16:12 +08:00
|
|
|
Register KernArgSegmentVReg = MRI.getLiveInVirtReg(KernArgSegmentPtr);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
|
[GlobalISel] Tidy up unnecessary calls to createGenericVirtualRegister
Summary:
As a side effect some redundant copies of constant values are removed by
CSEMIRBuilder.
Reviewers: aemerson, arsenm, dsanders, aditya_nandakumar
Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, hiraditya, jrtc27, atanasyan, volkan, Petar.Avramovic, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73789
2020-01-31 20:40:31 +08:00
|
|
|
auto OffsetReg = B.buildConstant(LLT::scalar(64), Offset);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
|
[GlobalISel] Tidy up unnecessary calls to createGenericVirtualRegister
Summary:
As a side effect some redundant copies of constant values are removed by
CSEMIRBuilder.
Reviewers: aemerson, arsenm, dsanders, aditya_nandakumar
Subscribers: sdardis, jvesely, wdng, nhaehnle, rovka, hiraditya, jrtc27, atanasyan, volkan, Petar.Avramovic, kerbowa, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73789
2020-01-31 20:40:31 +08:00
|
|
|
return B.buildPtrAdd(PtrType, KernArgSegmentVReg, OffsetReg).getReg(0);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
}
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
void AMDGPUCallLowering::lowerParameter(MachineIRBuilder &B,
|
2018-07-06 01:01:20 +08:00
|
|
|
Type *ParamTy, uint64_t Offset,
|
|
|
|
unsigned Align,
|
2019-06-24 23:50:29 +08:00
|
|
|
Register DstReg) const {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineFunction &MF = B.getMF();
|
2017-12-16 06:22:58 +08:00
|
|
|
const Function &F = MF.getFunction();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
const DataLayout &DL = F.getParent()->getDataLayout();
|
[AMDGPU] Don't create MachinePointerInfos with an UndefValue pointer
Summary:
The only useful information the UndefValue conveys is the address space,
which MachinePointerInfo can represent directly without referring to an
IR value.
Reviewers: arsenm, rampitec
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71838
2019-12-23 21:42:12 +08:00
|
|
|
MachinePointerInfo PtrInfo(AMDGPUAS::CONSTANT_ADDRESS);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
unsigned TypeSize = DL.getTypeStoreSize(ParamTy);
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
Register PtrReg = lowerParameterPtr(B, ParamTy, Offset);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
|
|
|
|
MachineMemOperand *MMO =
|
|
|
|
MF.getMachineMemOperand(PtrInfo, MachineMemOperand::MOLoad |
|
2019-07-20 01:52:56 +08:00
|
|
|
MachineMemOperand::MODereferenceable |
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
MachineMemOperand::MOInvariant,
|
|
|
|
TypeSize, Align);
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildLoad(DstReg, PtrReg, *MMO);
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
}
|
|
|
|
|
2019-07-02 02:50:50 +08:00
|
|
|
// Allocate special inputs passed in user SGPRs.
|
|
|
|
static void allocateHSAUserSGPRs(CCState &CCInfo,
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineIRBuilder &B,
|
2019-07-02 02:50:50 +08:00
|
|
|
MachineFunction &MF,
|
|
|
|
const SIRegisterInfo &TRI,
|
|
|
|
SIMachineFunctionInfo &Info) {
|
|
|
|
// FIXME: How should these inputs interact with inreg / custom SGPR inputs?
|
|
|
|
if (Info.hasPrivateSegmentBuffer()) {
|
|
|
|
unsigned PrivateSegmentBufferReg = Info.addPrivateSegmentBuffer(TRI);
|
|
|
|
MF.addLiveIn(PrivateSegmentBufferReg, &AMDGPU::SGPR_128RegClass);
|
|
|
|
CCInfo.AllocateReg(PrivateSegmentBufferReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info.hasDispatchPtr()) {
|
|
|
|
unsigned DispatchPtrReg = Info.addDispatchPtr(TRI);
|
|
|
|
MF.addLiveIn(DispatchPtrReg, &AMDGPU::SGPR_64RegClass);
|
|
|
|
CCInfo.AllocateReg(DispatchPtrReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info.hasQueuePtr()) {
|
|
|
|
unsigned QueuePtrReg = Info.addQueuePtr(TRI);
|
|
|
|
MF.addLiveIn(QueuePtrReg, &AMDGPU::SGPR_64RegClass);
|
|
|
|
CCInfo.AllocateReg(QueuePtrReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info.hasKernargSegmentPtr()) {
|
|
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
Register InputPtrReg = Info.addKernargSegmentPtr(TRI);
|
|
|
|
const LLT P4 = LLT::pointer(AMDGPUAS::CONSTANT_ADDRESS, 64);
|
|
|
|
Register VReg = MRI.createGenericVirtualRegister(P4);
|
|
|
|
MRI.addLiveIn(InputPtrReg, VReg);
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.getMBB().addLiveIn(InputPtrReg);
|
|
|
|
B.buildCopy(VReg, InputPtrReg);
|
2019-07-02 02:50:50 +08:00
|
|
|
CCInfo.AllocateReg(InputPtrReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info.hasDispatchID()) {
|
|
|
|
unsigned DispatchIDReg = Info.addDispatchID(TRI);
|
|
|
|
MF.addLiveIn(DispatchIDReg, &AMDGPU::SGPR_64RegClass);
|
|
|
|
CCInfo.AllocateReg(DispatchIDReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info.hasFlatScratchInit()) {
|
|
|
|
unsigned FlatScratchInitReg = Info.addFlatScratchInit(TRI);
|
|
|
|
MF.addLiveIn(FlatScratchInitReg, &AMDGPU::SGPR_64RegClass);
|
|
|
|
CCInfo.AllocateReg(FlatScratchInitReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Add GridWorkGroupCount user SGPRs when used. For now with HSA we read
|
|
|
|
// these from the dispatch pointer.
|
|
|
|
}
|
|
|
|
|
2019-07-11 22:18:25 +08:00
|
|
|
bool AMDGPUCallLowering::lowerFormalArgumentsKernel(
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineIRBuilder &B, const Function &F,
|
2019-07-11 22:18:25 +08:00
|
|
|
ArrayRef<ArrayRef<Register>> VRegs) const {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineFunction &MF = B.getMF();
|
2019-07-11 22:18:25 +08:00
|
|
|
const GCNSubtarget *Subtarget = &MF.getSubtarget<GCNSubtarget>();
|
|
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
SIMachineFunctionInfo *Info = MF.getInfo<SIMachineFunctionInfo>();
|
2019-07-19 22:15:18 +08:00
|
|
|
const SIRegisterInfo *TRI = Subtarget->getRegisterInfo();
|
|
|
|
const SITargetLowering &TLI = *getTLI<SITargetLowering>();
|
|
|
|
|
2019-07-11 22:18:25 +08:00
|
|
|
const DataLayout &DL = F.getParent()->getDataLayout();
|
|
|
|
|
|
|
|
SmallVector<CCValAssign, 16> ArgLocs;
|
|
|
|
CCState CCInfo(F.getCallingConv(), F.isVarArg(), MF, ArgLocs, F.getContext());
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
allocateHSAUserSGPRs(CCInfo, B, MF, *TRI, *Info);
|
2019-07-11 22:18:25 +08:00
|
|
|
|
|
|
|
unsigned i = 0;
|
|
|
|
const unsigned KernArgBaseAlign = 16;
|
|
|
|
const unsigned BaseOffset = Subtarget->getExplicitKernelArgOffset(F);
|
|
|
|
uint64_t ExplicitArgOffset = 0;
|
|
|
|
|
|
|
|
// TODO: Align down to dword alignment and extract bits for extending loads.
|
|
|
|
for (auto &Arg : F.args()) {
|
|
|
|
Type *ArgTy = Arg.getType();
|
|
|
|
unsigned AllocSize = DL.getTypeAllocSize(ArgTy);
|
|
|
|
if (AllocSize == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
unsigned ABIAlign = DL.getABITypeAlignment(ArgTy);
|
|
|
|
|
|
|
|
uint64_t ArgOffset = alignTo(ExplicitArgOffset, ABIAlign) + BaseOffset;
|
|
|
|
ExplicitArgOffset = alignTo(ExplicitArgOffset, ABIAlign) + AllocSize;
|
|
|
|
|
|
|
|
ArrayRef<Register> OrigArgRegs = VRegs[i];
|
|
|
|
Register ArgReg =
|
|
|
|
OrigArgRegs.size() == 1
|
|
|
|
? OrigArgRegs[0]
|
|
|
|
: MRI.createGenericVirtualRegister(getLLTForType(*ArgTy, DL));
|
|
|
|
unsigned Align = MinAlign(KernArgBaseAlign, ArgOffset);
|
|
|
|
ArgOffset = alignTo(ArgOffset, DL.getABITypeAlignment(ArgTy));
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
lowerParameter(B, ArgTy, ArgOffset, Align, ArgReg);
|
2019-07-11 22:18:25 +08:00
|
|
|
if (OrigArgRegs.size() > 1)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
unpackRegs(OrigArgRegs, ArgReg, ArgTy, B);
|
2019-07-11 22:18:25 +08:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
TLI.allocateSpecialEntryInputVGPRs(CCInfo, MF, *TRI, *Info);
|
|
|
|
TLI.allocateSystemSGPRs(CCInfo, MF, *Info, F.getCallingConv(), false);
|
2019-07-11 22:18:25 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-26 03:45:07 +08:00
|
|
|
/// Pack values \p SrcRegs to cover the vector type result \p DstRegs.
|
|
|
|
static MachineInstrBuilder mergeVectorRegsToResultRegs(
|
|
|
|
MachineIRBuilder &B, ArrayRef<Register> DstRegs, ArrayRef<Register> SrcRegs) {
|
|
|
|
MachineRegisterInfo &MRI = *B.getMRI();
|
|
|
|
LLT LLTy = MRI.getType(DstRegs[0]);
|
|
|
|
LLT PartLLT = MRI.getType(SrcRegs[0]);
|
|
|
|
|
|
|
|
// Deal with v3s16 split into v2s16
|
|
|
|
LLT LCMTy = getLCMType(LLTy, PartLLT);
|
|
|
|
if (LCMTy == LLTy) {
|
|
|
|
// Common case where no padding is needed.
|
|
|
|
assert(DstRegs.size() == 1);
|
|
|
|
return B.buildConcatVectors(DstRegs[0], SrcRegs);
|
|
|
|
}
|
|
|
|
|
|
|
|
const int NumWide = LCMTy.getSizeInBits() / PartLLT.getSizeInBits();
|
|
|
|
Register Undef = B.buildUndef(PartLLT).getReg(0);
|
|
|
|
|
|
|
|
// Build vector of undefs.
|
|
|
|
SmallVector<Register, 8> WidenedSrcs(NumWide, Undef);
|
|
|
|
|
|
|
|
// Replace the first sources with the real registers.
|
|
|
|
std::copy(SrcRegs.begin(), SrcRegs.end(), WidenedSrcs.begin());
|
|
|
|
|
|
|
|
auto Widened = B.buildConcatVectors(LCMTy, WidenedSrcs);
|
|
|
|
int NumDst = LCMTy.getSizeInBits() / LLTy.getSizeInBits();
|
|
|
|
|
|
|
|
SmallVector<Register, 8> PadDstRegs(NumDst);
|
|
|
|
std::copy(DstRegs.begin(), DstRegs.end(), PadDstRegs.begin());
|
|
|
|
|
|
|
|
// Create the excess dead defs for the unmerge.
|
|
|
|
for (int I = DstRegs.size(); I != NumDst; ++I)
|
|
|
|
PadDstRegs[I] = MRI.createGenericVirtualRegister(LLTy);
|
|
|
|
|
|
|
|
return B.buildUnmerge(PadDstRegs, Widened);
|
|
|
|
}
|
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
// TODO: Move this to generic code
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
static void packSplitRegsToOrigType(MachineIRBuilder &B,
|
2019-07-19 22:15:18 +08:00
|
|
|
ArrayRef<Register> OrigRegs,
|
|
|
|
ArrayRef<Register> Regs,
|
|
|
|
LLT LLTy,
|
|
|
|
LLT PartLLT) {
|
|
|
|
if (!LLTy.isVector() && !PartLLT.isVector()) {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildMerge(OrigRegs[0], Regs);
|
2019-07-19 22:15:18 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LLTy.isVector() && PartLLT.isVector()) {
|
2020-02-26 03:45:07 +08:00
|
|
|
assert(OrigRegs.size() == 1);
|
2019-07-19 22:15:18 +08:00
|
|
|
assert(LLTy.getElementType() == PartLLT.getElementType());
|
2020-02-26 03:45:07 +08:00
|
|
|
mergeVectorRegsToResultRegs(B, OrigRegs, Regs);
|
2019-07-19 22:15:18 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-04 02:33:36 +08:00
|
|
|
MachineRegisterInfo &MRI = *B.getMRI();
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
assert(LLTy.isVector() && !PartLLT.isVector());
|
|
|
|
|
|
|
|
LLT DstEltTy = LLTy.getElementType();
|
2020-01-04 02:33:36 +08:00
|
|
|
|
|
|
|
// Pointer information was discarded. We'll need to coerce some register types
|
|
|
|
// to avoid violating type constraints.
|
|
|
|
LLT RealDstEltTy = MRI.getType(OrigRegs[0]).getElementType();
|
|
|
|
|
|
|
|
assert(DstEltTy.getSizeInBits() == RealDstEltTy.getSizeInBits());
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
if (DstEltTy == PartLLT) {
|
|
|
|
// Vector was trivially scalarized.
|
2020-01-04 02:33:36 +08:00
|
|
|
|
|
|
|
if (RealDstEltTy.isPointer()) {
|
|
|
|
for (Register Reg : Regs)
|
|
|
|
MRI.setType(Reg, RealDstEltTy);
|
|
|
|
}
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildBuildVector(OrigRegs[0], Regs);
|
2019-07-19 22:15:18 +08:00
|
|
|
} else if (DstEltTy.getSizeInBits() > PartLLT.getSizeInBits()) {
|
|
|
|
// Deal with vector with 64-bit elements decomposed to 32-bit
|
|
|
|
// registers. Need to create intermediate 64-bit elements.
|
|
|
|
SmallVector<Register, 8> EltMerges;
|
|
|
|
int PartsPerElt = DstEltTy.getSizeInBits() / PartLLT.getSizeInBits();
|
|
|
|
|
|
|
|
assert(DstEltTy.getSizeInBits() % PartLLT.getSizeInBits() == 0);
|
|
|
|
|
|
|
|
for (int I = 0, NumElts = LLTy.getNumElements(); I != NumElts; ++I) {
|
2020-01-04 02:33:36 +08:00
|
|
|
auto Merge = B.buildMerge(RealDstEltTy, Regs.take_front(PartsPerElt));
|
|
|
|
// Fix the type in case this is really a vector of pointers.
|
|
|
|
MRI.setType(Merge.getReg(0), RealDstEltTy);
|
2019-07-19 22:15:18 +08:00
|
|
|
EltMerges.push_back(Merge.getReg(0));
|
|
|
|
Regs = Regs.drop_front(PartsPerElt);
|
|
|
|
}
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildBuildVector(OrigRegs[0], EltMerges);
|
2019-07-19 22:15:18 +08:00
|
|
|
} else {
|
|
|
|
// Vector was split, and elements promoted to a wider type.
|
|
|
|
LLT BVType = LLT::vector(LLTy.getNumElements(), PartLLT);
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
auto BV = B.buildBuildVector(BVType, Regs);
|
|
|
|
B.buildTrunc(OrigRegs[0], BV);
|
2019-07-19 22:15:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-27 16:54:17 +08:00
|
|
|
bool AMDGPUCallLowering::lowerFormalArguments(
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineIRBuilder &B, const Function &F,
|
2019-06-27 16:54:17 +08:00
|
|
|
ArrayRef<ArrayRef<Register>> VRegs) const {
|
2019-07-19 22:15:18 +08:00
|
|
|
CallingConv::ID CC = F.getCallingConv();
|
|
|
|
|
2019-07-11 22:18:25 +08:00
|
|
|
// The infrastructure for normal calling convention lowering is essentially
|
|
|
|
// useless for kernels. We want to avoid any kind of legalization or argument
|
|
|
|
// splitting.
|
2019-07-19 22:15:18 +08:00
|
|
|
if (CC == CallingConv::AMDGPU_KERNEL)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
return lowerFormalArgumentsKernel(B, F, VRegs);
|
2019-07-11 22:18:25 +08:00
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
const bool IsShader = AMDGPU::isShader(CC);
|
|
|
|
const bool IsEntryFunc = AMDGPU::isEntryFunctionCC(CC);
|
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
MachineFunction &MF = B.getMF();
|
|
|
|
MachineBasicBlock &MBB = B.getMBB();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
MachineRegisterInfo &MRI = MF.getRegInfo();
|
|
|
|
SIMachineFunctionInfo *Info = MF.getInfo<SIMachineFunctionInfo>();
|
2019-07-19 22:15:18 +08:00
|
|
|
const GCNSubtarget &Subtarget = MF.getSubtarget<GCNSubtarget>();
|
|
|
|
const SIRegisterInfo *TRI = Subtarget.getRegisterInfo();
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
const DataLayout &DL = F.getParent()->getDataLayout();
|
|
|
|
|
2019-05-31 03:33:18 +08:00
|
|
|
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
SmallVector<CCValAssign, 16> ArgLocs;
|
2019-07-19 22:15:18 +08:00
|
|
|
CCState CCInfo(CC, F.isVarArg(), MF, ArgLocs, F.getContext());
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
if (!IsEntryFunc) {
|
|
|
|
Register ReturnAddrReg = TRI->getReturnAddressReg(MF);
|
|
|
|
Register LiveInReturn = MF.addLiveIn(ReturnAddrReg,
|
|
|
|
&AMDGPU::SGPR_64RegClass);
|
|
|
|
MBB.addLiveIn(ReturnAddrReg);
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildCopy(LiveInReturn, ReturnAddrReg);
|
2019-07-26 10:36:05 +08:00
|
|
|
}
|
|
|
|
|
2019-07-02 02:50:50 +08:00
|
|
|
if (Info->hasImplicitBufferPtr()) {
|
2019-07-19 22:15:18 +08:00
|
|
|
Register ImplicitBufferPtrReg = Info->addImplicitBufferPtr(*TRI);
|
2019-07-02 02:50:50 +08:00
|
|
|
MF.addLiveIn(ImplicitBufferPtrReg, &AMDGPU::SGPR_64RegClass);
|
|
|
|
CCInfo.AllocateReg(ImplicitBufferPtrReg);
|
|
|
|
}
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
|
|
|
|
SmallVector<ArgInfo, 32> SplitArgs;
|
|
|
|
unsigned Idx = 0;
|
2018-04-25 04:51:28 +08:00
|
|
|
unsigned PSInputNum = 0;
|
2019-07-19 22:15:18 +08:00
|
|
|
|
|
|
|
for (auto &Arg : F.args()) {
|
|
|
|
if (DL.getTypeStoreSize(Arg.getType()) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const bool InReg = Arg.hasAttribute(Attribute::InReg);
|
|
|
|
|
|
|
|
// SGPR arguments to functions not implemented.
|
|
|
|
if (!IsShader && InReg)
|
|
|
|
return false;
|
|
|
|
|
2019-07-26 10:36:05 +08:00
|
|
|
if (Arg.hasAttribute(Attribute::SwiftSelf) ||
|
2019-07-19 22:15:18 +08:00
|
|
|
Arg.hasAttribute(Attribute::SwiftError) ||
|
2019-07-19 22:29:30 +08:00
|
|
|
Arg.hasAttribute(Attribute::Nest))
|
2019-07-19 22:15:18 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (CC == CallingConv::AMDGPU_PS && !InReg && PSInputNum <= 15) {
|
|
|
|
const bool ArgUsed = !Arg.use_empty();
|
|
|
|
bool SkipArg = !ArgUsed && !Info->isPSInputAllocated(PSInputNum);
|
|
|
|
|
|
|
|
if (!SkipArg) {
|
|
|
|
Info->markPSInputAllocated(PSInputNum);
|
|
|
|
if (ArgUsed)
|
|
|
|
Info->markPSInputEnabled(PSInputNum);
|
|
|
|
}
|
|
|
|
|
|
|
|
++PSInputNum;
|
|
|
|
|
|
|
|
if (SkipArg) {
|
2019-07-19 22:29:30 +08:00
|
|
|
for (int I = 0, E = VRegs[Idx].size(); I != E; ++I)
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.buildUndef(VRegs[Idx][I]);
|
2019-07-19 22:29:30 +08:00
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
++Idx;
|
2018-04-25 04:51:28 +08:00
|
|
|
continue;
|
|
|
|
}
|
2019-07-19 22:15:18 +08:00
|
|
|
}
|
2018-04-25 04:51:28 +08:00
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
ArgInfo OrigArg(VRegs[Idx], Arg.getType());
|
|
|
|
setArgFlags(OrigArg, Idx + AttributeList::FirstArgIndex, DL, F);
|
2019-07-19 22:29:30 +08:00
|
|
|
|
|
|
|
splitToValueTypes(
|
|
|
|
OrigArg, SplitArgs, DL, MRI, CC,
|
2019-07-19 22:15:18 +08:00
|
|
|
// FIXME: We should probably be passing multiple registers to
|
|
|
|
// handleAssignments to do this
|
2019-07-19 22:29:30 +08:00
|
|
|
[&](ArrayRef<Register> Regs, LLT LLTy, LLT PartLLT, int VTSplitIdx) {
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
packSplitRegsToOrigType(B, VRegs[Idx][VTSplitIdx], Regs,
|
2019-07-19 22:29:30 +08:00
|
|
|
LLTy, PartLLT);
|
2019-07-19 22:15:18 +08:00
|
|
|
});
|
2018-04-25 04:51:28 +08:00
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
++Idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
// At least one interpolation mode must be enabled or else the GPU will
|
|
|
|
// hang.
|
|
|
|
//
|
|
|
|
// Check PSInputAddr instead of PSInputEnable. The idea is that if the user
|
|
|
|
// set PSInputAddr, the user wants to enable some bits after the compilation
|
|
|
|
// based on run-time states. Since we can't know what the final PSInputEna
|
|
|
|
// will look like, so we shouldn't do anything here and the user should take
|
|
|
|
// responsibility for the correct programming.
|
|
|
|
//
|
|
|
|
// Otherwise, the following restrictions apply:
|
|
|
|
// - At least one of PERSP_* (0xF) or LINEAR_* (0x70) must be enabled.
|
|
|
|
// - If POS_W_FLOAT (11) is enabled, at least one of PERSP_* must be
|
|
|
|
// enabled too.
|
|
|
|
if (CC == CallingConv::AMDGPU_PS) {
|
|
|
|
if ((Info->getPSInputAddr() & 0x7F) == 0 ||
|
|
|
|
((Info->getPSInputAddr() & 0xF) == 0 &&
|
|
|
|
Info->isPSInputAllocated(11))) {
|
|
|
|
CCInfo.AllocateReg(AMDGPU::VGPR0);
|
|
|
|
CCInfo.AllocateReg(AMDGPU::VGPR1);
|
|
|
|
Info->markPSInputAllocated(0);
|
|
|
|
Info->markPSInputEnabled(0);
|
2018-04-25 04:51:28 +08:00
|
|
|
}
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
if (Subtarget.isAmdPalOS()) {
|
|
|
|
// For isAmdPalOS, the user does not enable some bits after compilation
|
|
|
|
// based on run-time states; the register values being generated here are
|
|
|
|
// the final ones set in hardware. Therefore we need to apply the
|
|
|
|
// workaround to PSInputAddr and PSInputEnable together. (The case where
|
|
|
|
// a bit is set in PSInputAddr but not PSInputEnable is where the frontend
|
|
|
|
// set up an input arg for a particular interpolation mode, but nothing
|
|
|
|
// uses that input arg. Really we should have an earlier pass that removes
|
|
|
|
// such an arg.)
|
|
|
|
unsigned PsInputBits = Info->getPSInputAddr() & Info->getPSInputEnable();
|
|
|
|
if ((PsInputBits & 0x7F) == 0 ||
|
|
|
|
((PsInputBits & 0xF) == 0 &&
|
|
|
|
(PsInputBits >> 11 & 1)))
|
|
|
|
Info->markPSInputEnabled(
|
|
|
|
countTrailingZeros(Info->getPSInputAddr(), ZB_Undefined));
|
2018-04-25 04:51:28 +08:00
|
|
|
}
|
Re-commit AMDGPU/GlobalISel: Add support for simple shaders
Fix build when global-isel is disabled and fix a warning.
Summary: We can select constant/global G_LOAD, global G_STORE, and G_GEP.
Reviewers: qcolombet, MatzeB, t.p.northover, ab, arsenm
Subscribers: mehdi_amini, vkalintiris, kzhuravl, wdng, nhaehnle, mgorny, yaxunl, tony-tye, modocache, llvm-commits, dberris
Differential Revision: https://reviews.llvm.org/D26730
llvm-svn: 293551
2017-01-31 05:56:46 +08:00
|
|
|
}
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
const SITargetLowering &TLI = *getTLI<SITargetLowering>();
|
|
|
|
CCAssignFn *AssignFn = TLI.CCAssignFnForCall(CC, F.isVarArg());
|
2019-05-31 03:33:18 +08:00
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
if (!MBB.empty())
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.setInstr(*MBB.begin());
|
2019-07-19 22:15:18 +08:00
|
|
|
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
FormalArgHandler Handler(B, MRI, AssignFn);
|
|
|
|
if (!handleAssignments(CCInfo, ArgLocs, B, SplitArgs, Handler))
|
2019-07-19 22:15:18 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!IsEntryFunc) {
|
|
|
|
// Special inputs come after user arguments.
|
|
|
|
TLI.allocateSpecialInputVGPRs(CCInfo, MF, *TRI, *Info);
|
AMDGPU/GlobalISel: Add support for amdgpu_vs calling convention
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, rovka, kristof.beyls, igorb, dstuttard, tpr, llvm-commits, t-tye
Differential Revision: https://reviews.llvm.org/D35916
llvm-svn: 309675
2017-08-01 20:38:33 +08:00
|
|
|
}
|
|
|
|
|
2019-07-19 22:15:18 +08:00
|
|
|
// Start adding system SGPRs.
|
|
|
|
if (IsEntryFunc) {
|
|
|
|
TLI.allocateSystemSGPRs(CCInfo, MF, *Info, CC, IsShader);
|
|
|
|
} else {
|
|
|
|
CCInfo.AllocateReg(Info->getScratchRSrcReg());
|
|
|
|
CCInfo.AllocateReg(Info->getScratchWaveOffsetReg());
|
|
|
|
CCInfo.AllocateReg(Info->getFrameOffsetReg());
|
|
|
|
TLI.allocateSpecialInputSGPRs(CCInfo, MF, *TRI, *Info);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Move back to the end of the basic block.
|
AMDGPU/GlobalISel: Rename MIRBuilder to B. NFC
Reviewers: arsenm
Reviewed By: arsenm
Subscribers: kzhuravl, jvesely, wdng, nhaehnle, yaxunl, rovka, dstuttard, tpr, t-tye, hiraditya, Petar.Avramovic, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67374
llvm-svn: 371467
2019-09-10 07:06:13 +08:00
|
|
|
B.setMBB(MBB);
|
2019-07-19 22:15:18 +08:00
|
|
|
|
|
|
|
return true;
|
2016-04-15 03:09:28 +08:00
|
|
|
}
|