]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.cpp
Merge r357222 from the clang1000-import branch:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / AMDGPU / AMDGPUInstrInfo.cpp
1 //===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// \brief Implementation of the TargetInstrInfo class that is common to all
11 /// AMD GPUs.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include "AMDGPUInstrInfo.h"
16 #include "AMDGPURegisterInfo.h"
17 #include "AMDGPUTargetMachine.h"
18 #include "MCTargetDesc/AMDGPUMCTargetDesc.h"
19 #include "llvm/CodeGen/MachineFrameInfo.h"
20 #include "llvm/CodeGen/MachineInstrBuilder.h"
21 #include "llvm/CodeGen/MachineRegisterInfo.h"
22
23 using namespace llvm;
24
25 // Pin the vtable to this file.
26 //void AMDGPUInstrInfo::anchor() {}
27
28 AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { }
29
30
31 // TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
32 bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {
33   const Value *Ptr = MMO->getValue();
34   // UndefValue means this is a load of a kernel input.  These are uniform.
35   // Sometimes LDS instructions have constant pointers.
36   // If Ptr is null, then that means this mem operand contains a
37   // PseudoSourceValue like GOT.
38   if (!Ptr || isa<UndefValue>(Ptr) ||
39       isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
40     return true;
41
42   if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)
43     return true;
44
45   if (const Argument *Arg = dyn_cast<Argument>(Ptr))
46     return AMDGPU::isArgPassedInSGPR(Arg);
47
48   const Instruction *I = dyn_cast<Instruction>(Ptr);
49   return I && I->getMetadata("amdgpu.uniform");
50 }