1112158Sdas//===-- AMDGPUInstrInfo.cpp - Base class for AMD GPU InstrInfo ------------===// 2112158Sdas// 3112158Sdas// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4112158Sdas// See https://llvm.org/LICENSE.txt for license information. 5112158Sdas// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6112158Sdas// 7112158Sdas//===----------------------------------------------------------------------===// 8112158Sdas// 9112158Sdas/// \file 10112158Sdas/// \brief Implementation of the TargetInstrInfo class that is common to all 11112158Sdas/// AMD GPUs. 12112158Sdas// 13112158Sdas//===----------------------------------------------------------------------===// 14112158Sdas 15112158Sdas#include "AMDGPUInstrInfo.h" 16112158Sdas#include "AMDGPURegisterInfo.h" 17112158Sdas#include "AMDGPUTargetMachine.h" 18112158Sdas#include "MCTargetDesc/AMDGPUMCTargetDesc.h" 19112158Sdas#include "llvm/CodeGen/MachineFrameInfo.h" 20112158Sdas#include "llvm/CodeGen/MachineInstrBuilder.h" 21112158Sdas#include "llvm/CodeGen/MachineRegisterInfo.h" 22112158Sdas 23112158Sdasusing namespace llvm; 24112158Sdas 25112158Sdas// Pin the vtable to this file. 26112158Sdas//void AMDGPUInstrInfo::anchor() {} 27112158Sdas 28112158SdasAMDGPUInstrInfo::AMDGPUInstrInfo(const GCNSubtarget &ST) { } 29165743Sdas 30165743Sdas 31112158Sdas// TODO: Should largely merge with AMDGPUTTIImpl::isSourceOfDivergence. 32174679Sdasbool AMDGPUInstrInfo::isUniformMMO(const MachineMemOperand *MMO) { 33174679Sdas const Value *Ptr = MMO->getValue(); 34112158Sdas // UndefValue means this is a load of a kernel input. These are uniform. 35165743Sdas // Sometimes LDS instructions have constant pointers. 36165743Sdas // If Ptr is null, then that means this mem operand contains a 37165743Sdas // PseudoSourceValue like GOT. 38112158Sdas if (!Ptr || isa<UndefValue>(Ptr) || 39112158Sdas isa<Constant>(Ptr) || isa<GlobalValue>(Ptr)) 40112158Sdas return true; 41112158Sdas 42112158Sdas if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT) 43112158Sdas return true; 44112158Sdas 45112158Sdas if (const Argument *Arg = dyn_cast<Argument>(Ptr)) 46112158Sdas return AMDGPU::isArgPassedInSGPR(Arg); 47112158Sdas 48112158Sdas const Instruction *I = dyn_cast<Instruction>(Ptr); 49112158Sdas return I && I->getMetadata("amdgpu.uniform"); 50112158Sdas} 51112158Sdas