145bb48eaSTom Stellard //===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===//
245bb48eaSTom Stellard //
32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
645bb48eaSTom Stellard //
745bb48eaSTom Stellard //===----------------------------------------------------------------------===//
845bb48eaSTom Stellard //
945bb48eaSTom Stellard /// \file
10c5a154dbSTom Stellard /// \brief Implementation of the TargetInstrInfo class that is common to all
1145bb48eaSTom Stellard /// AMD GPUs.
1245bb48eaSTom Stellard //
1345bb48eaSTom Stellard //===----------------------------------------------------------------------===//
1445bb48eaSTom Stellard 
1545bb48eaSTom Stellard #include "AMDGPUInstrInfo.h"
16*6a87e9b0Sdfukalov #include "AMDGPU.h"
17*6a87e9b0Sdfukalov #include "llvm/CodeGen/MachineMemOperand.h"
18*6a87e9b0Sdfukalov #include "llvm/IR/Constants.h"
19*6a87e9b0Sdfukalov #include "llvm/IR/Instruction.h"
20*6a87e9b0Sdfukalov #include "llvm/IR/Value.h"
2145bb48eaSTom Stellard 
2245bb48eaSTom Stellard using namespace llvm;
2345bb48eaSTom Stellard 
2445bb48eaSTom Stellard // Pin the vtable to this file.
25c5a154dbSTom Stellard //void AMDGPUInstrInfo::anchor() {}
2645bb48eaSTom Stellard 
AMDGPUInstrInfo(const GCNSubtarget & ST)275bfbae5cSTom Stellard AMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { }
2845bb48eaSTom Stellard 
29bcf7bec4SMatt Arsenault 
30bcf7bec4SMatt Arsenault // TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence.
isUniformMMO(const MachineMemOperand * MMO)31bcf7bec4SMatt Arsenault bool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) {
32bcf7bec4SMatt Arsenault   const Value *Ptr = MMO->getValue();
33bcf7bec4SMatt Arsenault   // UndefValue means this is a load of a kernel input.  These are uniform.
34bcf7bec4SMatt Arsenault   // Sometimes LDS instructions have constant pointers.
35bcf7bec4SMatt Arsenault   // If Ptr is null, then that means this mem operand contains a
36bcf7bec4SMatt Arsenault   // PseudoSourceValue like GOT.
37bcf7bec4SMatt Arsenault   if (!Ptr || isa<UndefValue>(Ptr) ||
38bcf7bec4SMatt Arsenault       isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
39bcf7bec4SMatt Arsenault     return true;
40bcf7bec4SMatt Arsenault 
41923712b6SMatt Arsenault   if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)
42923712b6SMatt Arsenault     return true;
43923712b6SMatt Arsenault 
44bcf7bec4SMatt Arsenault   if (const Argument *Arg = dyn_cast<Argument>(Ptr))
45bcf7bec4SMatt Arsenault     return AMDGPU::isArgPassedInSGPR(Arg);
46bcf7bec4SMatt Arsenault 
47bcf7bec4SMatt Arsenault   const Instruction *I = dyn_cast<Instruction>(Ptr);
48bcf7bec4SMatt Arsenault   return I && I->getMetadata("amdgpu.uniform");
49bcf7bec4SMatt Arsenault }
50