1*af732203SDimitry Andric //===- AMDGPUMIRFormatter.cpp ---------------------------------------------===//
2*af732203SDimitry Andric //
3*af732203SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*af732203SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*af732203SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*af732203SDimitry Andric //
7*af732203SDimitry Andric //===----------------------------------------------------------------------===//
8*af732203SDimitry Andric //
9*af732203SDimitry Andric /// \file
10*af732203SDimitry Andric /// Implementation of AMDGPU overrides of MIRFormatter.
11*af732203SDimitry Andric //
12*af732203SDimitry Andric //===----------------------------------------------------------------------===//
13*af732203SDimitry Andric 
14*af732203SDimitry Andric #include "AMDGPUMIRFormatter.h"
15*af732203SDimitry Andric #include "GCNSubtarget.h"
16*af732203SDimitry Andric #include "SIMachineFunctionInfo.h"
17*af732203SDimitry Andric 
18*af732203SDimitry Andric using namespace llvm;
19*af732203SDimitry Andric 
parseCustomPseudoSourceValue(StringRef Src,MachineFunction & MF,PerFunctionMIParsingState & PFS,const PseudoSourceValue * & PSV,ErrorCallbackType ErrorCallback) const20*af732203SDimitry Andric bool AMDGPUMIRFormatter::parseCustomPseudoSourceValue(
21*af732203SDimitry Andric     StringRef Src, MachineFunction &MF, PerFunctionMIParsingState &PFS,
22*af732203SDimitry Andric     const PseudoSourceValue *&PSV, ErrorCallbackType ErrorCallback) const {
23*af732203SDimitry Andric   SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
24*af732203SDimitry Andric   const SIInstrInfo &TII = *MF.getSubtarget<GCNSubtarget>().getInstrInfo();
25*af732203SDimitry Andric   if (Src == "BufferResource") {
26*af732203SDimitry Andric     PSV = MFI->getBufferPSV(TII);
27*af732203SDimitry Andric     return false;
28*af732203SDimitry Andric   }
29*af732203SDimitry Andric   if (Src == "ImageResource") {
30*af732203SDimitry Andric     PSV = MFI->getImagePSV(TII);
31*af732203SDimitry Andric     return false;
32*af732203SDimitry Andric   }
33*af732203SDimitry Andric   if (Src == "GWSResource") {
34*af732203SDimitry Andric     PSV = MFI->getGWSPSV(TII);
35*af732203SDimitry Andric     return false;
36*af732203SDimitry Andric   }
37*af732203SDimitry Andric   llvm_unreachable("unknown MIR custom pseudo source value");
38*af732203SDimitry Andric }
39