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"
|
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"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
AMDGPUCallLowering::AMDGPUCallLowering(const AMDGPUTargetLowering &TLI)
|
2018-08-31 13:49:54 +08:00
|
|
|
: CallLowering(&TLI) {
|
2016-04-15 03:09:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AMDGPUCallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
|
2018-08-02 16:33:31 +08:00
|
|
|
const Value *Val,
|
|
|
|
ArrayRef<unsigned> VRegs) const {
|
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
|
|
|
// FIXME: Add support for non-void returns.
|
|
|
|
if (Val)
|
|
|
|
return false;
|
|
|
|
|
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
|
|
|
MIRBuilder.buildInstr(AMDGPU::S_ENDPGM);
|
2016-04-15 03:09:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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 AMDGPUCallLowering::lowerParameterPtr(MachineIRBuilder &MIRBuilder,
|
|
|
|
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
|
|
|
|
|
|
|
MachineFunction &MF = MIRBuilder.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);
|
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 DstReg = MRI.createGenericVirtualRegister(PtrType);
|
|
|
|
unsigned KernArgSegmentPtr =
|
2017-08-04 07:00:29 +08:00
|
|
|
MFI->getPreloadedReg(AMDGPUFunctionArgInfo::KERNARG_SEGMENT_PTR);
|
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 KernArgSegmentVReg = MRI.getLiveInVirtReg(KernArgSegmentPtr);
|
|
|
|
|
|
|
|
unsigned OffsetReg = MRI.createGenericVirtualRegister(LLT::scalar(64));
|
|
|
|
MIRBuilder.buildConstant(OffsetReg, Offset);
|
|
|
|
|
|
|
|
MIRBuilder.buildGEP(DstReg, KernArgSegmentVReg, OffsetReg);
|
|
|
|
|
|
|
|
return DstReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMDGPUCallLowering::lowerParameter(MachineIRBuilder &MIRBuilder,
|
2018-07-06 01:01:20 +08:00
|
|
|
Type *ParamTy, uint64_t Offset,
|
|
|
|
unsigned Align,
|
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 DstReg) const {
|
|
|
|
MachineFunction &MF = MIRBuilder.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();
|
2018-08-31 13:49:54 +08:00
|
|
|
PointerType *PtrTy = PointerType::get(ParamTy, 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
|
|
|
MachinePointerInfo PtrInfo(UndefValue::get(PtrTy));
|
|
|
|
unsigned TypeSize = DL.getTypeStoreSize(ParamTy);
|
|
|
|
unsigned PtrReg = lowerParameterPtr(MIRBuilder, ParamTy, Offset);
|
|
|
|
|
|
|
|
MachineMemOperand *MMO =
|
|
|
|
MF.getMachineMemOperand(PtrInfo, MachineMemOperand::MOLoad |
|
|
|
|
MachineMemOperand::MONonTemporal |
|
|
|
|
MachineMemOperand::MOInvariant,
|
|
|
|
TypeSize, Align);
|
|
|
|
|
|
|
|
MIRBuilder.buildLoad(DstReg, PtrReg, *MMO);
|
|
|
|
}
|
|
|
|
|
2016-09-21 20:57:35 +08:00
|
|
|
bool AMDGPUCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
|
|
|
|
const Function &F,
|
|
|
|
ArrayRef<unsigned> VRegs) const {
|
2018-05-08 06:17:54 +08:00
|
|
|
// AMDGPU_GS and AMDGP_HS are not supported yet.
|
|
|
|
if (F.getCallingConv() == CallingConv::AMDGPU_GS ||
|
|
|
|
F.getCallingConv() == CallingConv::AMDGPU_HS)
|
2018-04-30 23:15:23 +08:00
|
|
|
return false;
|
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
|
|
|
|
|
|
|
MachineFunction &MF = MIRBuilder.getMF();
|
2018-07-12 04:59:01 +08:00
|
|
|
const GCNSubtarget *Subtarget = &MF.getSubtarget<GCNSubtarget>();
|
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>();
|
2018-07-12 04:59:01 +08:00
|
|
|
const SIRegisterInfo *TRI = MF.getSubtarget<GCNSubtarget>().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();
|
|
|
|
|
|
|
|
SmallVector<CCValAssign, 16> ArgLocs;
|
|
|
|
CCState CCInfo(F.getCallingConv(), F.isVarArg(), MF, ArgLocs, F.getContext());
|
|
|
|
|
|
|
|
// FIXME: How should these inputs interact with inreg / custom SGPR inputs?
|
|
|
|
if (Info->hasPrivateSegmentBuffer()) {
|
|
|
|
unsigned PrivateSegmentBufferReg = Info->addPrivateSegmentBuffer(*TRI);
|
|
|
|
MF.addLiveIn(PrivateSegmentBufferReg, &AMDGPU::SReg_128RegClass);
|
|
|
|
CCInfo.AllocateReg(PrivateSegmentBufferReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info->hasDispatchPtr()) {
|
|
|
|
unsigned DispatchPtrReg = Info->addDispatchPtr(*TRI);
|
|
|
|
// FIXME: Need to add reg as live-in
|
|
|
|
CCInfo.AllocateReg(DispatchPtrReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info->hasQueuePtr()) {
|
|
|
|
unsigned QueuePtrReg = Info->addQueuePtr(*TRI);
|
|
|
|
// FIXME: Need to add reg as live-in
|
|
|
|
CCInfo.AllocateReg(QueuePtrReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info->hasKernargSegmentPtr()) {
|
|
|
|
unsigned InputPtrReg = Info->addKernargSegmentPtr(*TRI);
|
2018-02-14 02:00:25 +08:00
|
|
|
const LLT P2 = LLT::pointer(AMDGPUAS::CONSTANT_ADDRESS, 64);
|
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 VReg = MRI.createGenericVirtualRegister(P2);
|
|
|
|
MRI.addLiveIn(InputPtrReg, VReg);
|
|
|
|
MIRBuilder.getMBB().addLiveIn(InputPtrReg);
|
|
|
|
MIRBuilder.buildCopy(VReg, InputPtrReg);
|
|
|
|
CCInfo.AllocateReg(InputPtrReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info->hasDispatchID()) {
|
|
|
|
unsigned DispatchIDReg = Info->addDispatchID(*TRI);
|
|
|
|
// FIXME: Need to add reg as live-in
|
|
|
|
CCInfo.AllocateReg(DispatchIDReg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Info->hasFlatScratchInit()) {
|
|
|
|
unsigned FlatScratchInitReg = Info->addFlatScratchInit(*TRI);
|
|
|
|
// FIXME: Need to add reg as live-in
|
|
|
|
CCInfo.AllocateReg(FlatScratchInitReg);
|
|
|
|
}
|
|
|
|
|
2018-07-06 01:01:20 +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.
|
|
|
|
if (F.getCallingConv() == CallingConv::AMDGPU_KERNEL) {
|
|
|
|
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;
|
|
|
|
|
|
|
|
unsigned Align = MinAlign(KernArgBaseAlign, ArgOffset);
|
|
|
|
ArgOffset = alignTo(ArgOffset, DL.getABITypeAlignment(ArgTy));
|
|
|
|
lowerParameter(MIRBuilder, ArgTy, ArgOffset, Align, VRegs[i]);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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 NumArgs = F.arg_size();
|
|
|
|
Function::const_arg_iterator CurOrigArg = F.arg_begin();
|
|
|
|
const AMDGPUTargetLowering &TLI = *getTLI<AMDGPUTargetLowering>();
|
2018-04-25 04:51:28 +08:00
|
|
|
unsigned PSInputNum = 0;
|
|
|
|
BitVector Skipped(NumArgs);
|
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
|
|
|
for (unsigned i = 0; i != NumArgs; ++i, ++CurOrigArg) {
|
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
|
|
|
EVT ValEVT = TLI.getValueType(DL, CurOrigArg->getType());
|
|
|
|
|
|
|
|
// We can only hanlde simple value types at the moment.
|
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
|
|
|
ISD::ArgFlagsTy Flags;
|
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
|
|
|
ArgInfo OrigArg{VRegs[i], CurOrigArg->getType()};
|
|
|
|
setArgFlags(OrigArg, i + 1, DL, F);
|
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
|
|
|
Flags.setOrigAlign(DL.getABITypeAlignment(CurOrigArg->getType()));
|
2018-04-25 04:51:28 +08:00
|
|
|
|
|
|
|
if (F.getCallingConv() == CallingConv::AMDGPU_PS &&
|
|
|
|
!OrigArg.Flags.isInReg() && !OrigArg.Flags.isByVal() &&
|
|
|
|
PSInputNum <= 15) {
|
|
|
|
if (CurOrigArg->use_empty() && !Info->isPSInputAllocated(PSInputNum)) {
|
|
|
|
Skipped.set(i);
|
|
|
|
++PSInputNum;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Info->markPSInputAllocated(PSInputNum);
|
|
|
|
if (!CurOrigArg->use_empty())
|
|
|
|
Info->markPSInputEnabled(PSInputNum);
|
|
|
|
|
|
|
|
++PSInputNum;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
CCAssignFn *AssignFn = CCAssignFnForCall(F.getCallingConv(),
|
|
|
|
/*IsVarArg=*/false);
|
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
|
|
|
|
2018-04-25 04:51:28 +08:00
|
|
|
if (ValEVT.isVector()) {
|
|
|
|
EVT ElemVT = ValEVT.getVectorElementType();
|
|
|
|
if (!ValEVT.isSimple())
|
|
|
|
return false;
|
|
|
|
MVT ValVT = ElemVT.getSimpleVT();
|
|
|
|
bool Res = AssignFn(i, ValVT, ValVT, CCValAssign::Full,
|
|
|
|
OrigArg.Flags, CCInfo);
|
|
|
|
if (!Res)
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
MVT ValVT = ValEVT.getSimpleVT();
|
|
|
|
if (!ValEVT.isSimple())
|
|
|
|
return false;
|
|
|
|
bool Res =
|
|
|
|
AssignFn(i, ValVT, ValVT, CCValAssign::Full, OrigArg.Flags, CCInfo);
|
|
|
|
|
|
|
|
// Fail if we don't know how to handle this type.
|
|
|
|
if (Res)
|
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
Function::const_arg_iterator Arg = F.arg_begin();
|
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
|
|
|
|
2018-04-25 04:51:28 +08:00
|
|
|
if (F.getCallingConv() == CallingConv::AMDGPU_VS ||
|
|
|
|
F.getCallingConv() == CallingConv::AMDGPU_PS) {
|
|
|
|
for (unsigned i = 0, OrigArgIdx = 0;
|
|
|
|
OrigArgIdx != NumArgs && i != ArgLocs.size(); ++Arg, ++OrigArgIdx) {
|
|
|
|
if (Skipped.test(OrigArgIdx))
|
|
|
|
continue;
|
|
|
|
CCValAssign &VA = ArgLocs[i++];
|
|
|
|
MRI.addLiveIn(VA.getLocReg(), VRegs[OrigArgIdx]);
|
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
|
|
|
MIRBuilder.getMBB().addLiveIn(VA.getLocReg());
|
2018-04-25 04:51:28 +08:00
|
|
|
MIRBuilder.buildCopy(VRegs[OrigArgIdx], VA.getLocReg());
|
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
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-06 01:01:20 +08:00
|
|
|
return false;
|
2016-04-15 03:09:28 +08:00
|
|
|
}
|